babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @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
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. 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);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * 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".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Normalize the current Vector3 with the given input length.
  2082. * Please note that this is an in place operation.
  2083. * @param len the length of the vector
  2084. * @returns the current updated Vector3
  2085. */
  2086. normalizeFromLength(len: number): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to a new vector
  2089. * @returns the new Vector3
  2090. */
  2091. normalizeToNew(): Vector3;
  2092. /**
  2093. * Normalize the current Vector3 to the reference
  2094. * @param reference define the Vector3 to update
  2095. * @returns the updated Vector3
  2096. */
  2097. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2098. /**
  2099. * Creates a new Vector3 copied from the current Vector3
  2100. * @returns the new Vector3
  2101. */
  2102. clone(): Vector3;
  2103. /**
  2104. * Copies the given vector coordinates to the current Vector3 ones
  2105. * @param source defines the source Vector3
  2106. * @returns the current updated Vector3
  2107. */
  2108. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2109. /**
  2110. * Copies the given floats to the current Vector3 coordinates
  2111. * @param x defines the x coordinate of the operand
  2112. * @param y defines the y coordinate of the operand
  2113. * @param z defines the z coordinate of the operand
  2114. * @returns the current updated Vector3
  2115. */
  2116. copyFromFloats(x: number, y: number, z: number): Vector3;
  2117. /**
  2118. * Copies the given floats to the current Vector3 coordinates
  2119. * @param x defines the x coordinate of the operand
  2120. * @param y defines the y coordinate of the operand
  2121. * @param z defines the z coordinate of the operand
  2122. * @returns the current updated Vector3
  2123. */
  2124. set(x: number, y: number, z: number): Vector3;
  2125. /**
  2126. * Copies the given float to the current Vector3 coordinates
  2127. * @param v defines the x, y and z coordinates of the operand
  2128. * @returns the current updated Vector3
  2129. */
  2130. setAll(v: number): Vector3;
  2131. /**
  2132. * Get the clip factor between two vectors
  2133. * @param vector0 defines the first operand
  2134. * @param vector1 defines the second operand
  2135. * @param axis defines the axis to use
  2136. * @param size defines the size along the axis
  2137. * @returns the clip factor
  2138. */
  2139. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2140. /**
  2141. * Get angle between two vectors
  2142. * @param vector0 angle between vector0 and vector1
  2143. * @param vector1 angle between vector0 and vector1
  2144. * @param normal direction of the normal
  2145. * @return the angle between vector0 and vector1
  2146. */
  2147. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2148. /**
  2149. * Returns a new Vector3 set from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @returns the new Vector3
  2153. */
  2154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArray instead
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @returns the new Vector3
  2161. */
  2162. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2163. /**
  2164. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @param result defines the Vector3 where to store the result
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2172. * This function is deprecated. Use FromArrayToRef instead.
  2173. * @param array defines the source array
  2174. * @param offset defines the offset in the source array
  2175. * @param result defines the Vector3 where to store the result
  2176. */
  2177. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2178. /**
  2179. * Sets the given vector "result" with the given floats.
  2180. * @param x defines the x coordinate of the source
  2181. * @param y defines the y coordinate of the source
  2182. * @param z defines the z coordinate of the source
  2183. * @param result defines the Vector3 where to store the result
  2184. */
  2185. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2186. /**
  2187. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2188. * @returns a new empty Vector3
  2189. */
  2190. static Zero(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2193. * @returns a new unit Vector3
  2194. */
  2195. static One(): Vector3;
  2196. /**
  2197. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2198. * @returns a new up Vector3
  2199. */
  2200. static Up(): Vector3;
  2201. /**
  2202. * Gets a up Vector3 that must not be updated
  2203. */
  2204. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2205. /**
  2206. * Gets a zero Vector3 that must not be updated
  2207. */
  2208. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2211. * @returns a new down Vector3
  2212. */
  2213. static Down(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Forward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2221. * @returns a new forward Vector3
  2222. */
  2223. static Backward(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2226. * @returns a new right Vector3
  2227. */
  2228. static Right(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2231. * @returns a new left Vector3
  2232. */
  2233. static Left(): Vector3;
  2234. /**
  2235. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2236. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2237. * @param vector defines the Vector3 to transform
  2238. * @param transformation defines the transformation matrix
  2239. * @returns the transformed Vector3
  2240. */
  2241. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2242. /**
  2243. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2244. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2245. * @param vector defines the Vector3 to transform
  2246. * @param transformation defines the transformation matrix
  2247. * @param result defines the Vector3 where to store the result
  2248. */
  2249. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2250. /**
  2251. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2252. * This method computes tranformed coordinates only, not transformed direction vectors
  2253. * @param x define the x coordinate of the source vector
  2254. * @param y define the y coordinate of the source vector
  2255. * @param z define the z coordinate of the source vector
  2256. * @param transformation defines the transformation matrix
  2257. * @param result defines the Vector3 where to store the result
  2258. */
  2259. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2260. /**
  2261. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2262. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2263. * @param vector defines the Vector3 to transform
  2264. * @param transformation defines the transformation matrix
  2265. * @returns the new Vector3
  2266. */
  2267. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2268. /**
  2269. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2270. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2271. * @param vector defines the Vector3 to transform
  2272. * @param transformation defines the transformation matrix
  2273. * @param result defines the Vector3 where to store the result
  2274. */
  2275. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2276. /**
  2277. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2278. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2279. * @param x define the x coordinate of the source vector
  2280. * @param y define the y coordinate of the source vector
  2281. * @param z define the z coordinate of the source vector
  2282. * @param transformation defines the transformation matrix
  2283. * @param result defines the Vector3 where to store the result
  2284. */
  2285. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2286. /**
  2287. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2288. * @param value1 defines the first control point
  2289. * @param value2 defines the second control point
  2290. * @param value3 defines the third control point
  2291. * @param value4 defines the fourth control point
  2292. * @param amount defines the amount on the spline to use
  2293. * @returns the new Vector3
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2296. /**
  2297. * 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"
  2298. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2299. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2300. * @param value defines the current value
  2301. * @param min defines the lower range value
  2302. * @param max defines the upper range value
  2303. * @returns the new Vector3
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2306. /**
  2307. * 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"
  2308. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2309. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2310. * @param value defines the current value
  2311. * @param min defines the lower range value
  2312. * @param max defines the upper range value
  2313. * @param result defines the Vector3 where to store the result
  2314. */
  2315. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2316. /**
  2317. * Checks if a given vector is inside a specific range
  2318. * @param v defines the vector to test
  2319. * @param min defines the minimum range
  2320. * @param max defines the maximum range
  2321. */
  2322. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2323. /**
  2324. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2325. * @param value1 defines the first control point
  2326. * @param tangent1 defines the first tangent vector
  2327. * @param value2 defines the second control point
  2328. * @param tangent2 defines the second tangent vector
  2329. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2330. * @returns the new Vector3
  2331. */
  2332. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2333. /**
  2334. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2335. * @param start defines the start value
  2336. * @param end defines the end value
  2337. * @param amount max defines amount between both (between 0 and 1)
  2338. * @returns the new Vector3
  2339. */
  2340. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2341. /**
  2342. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2343. * @param start defines the start value
  2344. * @param end defines the end value
  2345. * @param amount max defines amount between both (between 0 and 1)
  2346. * @param result defines the Vector3 where to store the result
  2347. */
  2348. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2349. /**
  2350. * Returns the dot product (float) between the vectors "left" and "right"
  2351. * @param left defines the left operand
  2352. * @param right defines the right operand
  2353. * @returns the dot product
  2354. */
  2355. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2356. /**
  2357. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2358. * The cross product is then orthogonal to both "left" and "right"
  2359. * @param left defines the left operand
  2360. * @param right defines the right operand
  2361. * @returns the cross product
  2362. */
  2363. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Sets the given vector "result" with the cross product of "left" and "right"
  2366. * The cross product is then orthogonal to both "left" and "right"
  2367. * @param left defines the left operand
  2368. * @param right defines the right operand
  2369. * @param result defines the Vector3 where to store the result
  2370. */
  2371. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2372. /**
  2373. * Returns a new Vector3 as the normalization of the given vector
  2374. * @param vector defines the Vector3 to normalize
  2375. * @returns the new Vector3
  2376. */
  2377. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Sets the given vector "result" with the normalization of the given first vector
  2380. * @param vector defines the Vector3 to normalize
  2381. * @param result defines the Vector3 where to store the result
  2382. */
  2383. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2384. /**
  2385. * Project a Vector3 onto screen space
  2386. * @param vector defines the Vector3 to project
  2387. * @param world defines the world matrix to use
  2388. * @param transform defines the transform (view x projection) matrix to use
  2389. * @param viewport defines the screen viewport to use
  2390. * @returns the new Vector3
  2391. */
  2392. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2393. /** @hidden */
  2394. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param transform defines the transform (view x projection) matrix to use
  2402. * @returns the new Vector3
  2403. */
  2404. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2405. /**
  2406. * Unproject from screen space to object space
  2407. * @param source defines the screen space Vector3 to use
  2408. * @param viewportWidth defines the current width of the viewport
  2409. * @param viewportHeight defines the current height of the viewport
  2410. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2411. * @param view defines the view matrix to use
  2412. * @param projection defines the projection matrix to use
  2413. * @returns the new Vector3
  2414. */
  2415. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2416. /**
  2417. * Unproject from screen space to object space
  2418. * @param source defines the screen space Vector3 to use
  2419. * @param viewportWidth defines the current width of the viewport
  2420. * @param viewportHeight defines the current height of the viewport
  2421. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2422. * @param view defines the view matrix to use
  2423. * @param projection defines the projection matrix to use
  2424. * @param result defines the Vector3 where to store the result
  2425. */
  2426. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2427. /**
  2428. * Unproject from screen space to object space
  2429. * @param sourceX defines the screen space x coordinate to use
  2430. * @param sourceY defines the screen space y coordinate to use
  2431. * @param sourceZ defines the screen space z coordinate to use
  2432. * @param viewportWidth defines the current width of the viewport
  2433. * @param viewportHeight defines the current height of the viewport
  2434. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2435. * @param view defines the view matrix to use
  2436. * @param projection defines the projection matrix to use
  2437. * @param result defines the Vector3 where to store the result
  2438. */
  2439. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2440. /**
  2441. * Gets the minimal coordinate values between two Vector3
  2442. * @param left defines the first operand
  2443. * @param right defines the second operand
  2444. * @returns the new Vector3
  2445. */
  2446. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2447. /**
  2448. * Gets the maximal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Returns the distance between the vectors "value1" and "value2"
  2456. * @param value1 defines the first operand
  2457. * @param value2 defines the second operand
  2458. * @returns the distance
  2459. */
  2460. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2461. /**
  2462. * Returns the squared distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the squared distance
  2466. */
  2467. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns a new Vector3 located at the center between "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the new Vector3
  2473. */
  2474. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2475. /**
  2476. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2477. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2478. * to something in order to rotate it from its local system to the given target system
  2479. * Note: axis1, axis2 and axis3 are normalized during this operation
  2480. * @param axis1 defines the first axis
  2481. * @param axis2 defines the second axis
  2482. * @param axis3 defines the third axis
  2483. * @returns a new Vector3
  2484. */
  2485. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2486. /**
  2487. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2488. * @param axis1 defines the first axis
  2489. * @param axis2 defines the second axis
  2490. * @param axis3 defines the third axis
  2491. * @param ref defines the Vector3 where to store the result
  2492. */
  2493. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2494. }
  2495. /**
  2496. * Vector4 class created for EulerAngle class conversion to Quaternion
  2497. */
  2498. export class Vector4 {
  2499. /** x value of the vector */
  2500. x: number;
  2501. /** y value of the vector */
  2502. y: number;
  2503. /** z value of the vector */
  2504. z: number;
  2505. /** w value of the vector */
  2506. w: number;
  2507. /**
  2508. * Creates a Vector4 object from the given floats.
  2509. * @param x x value of the vector
  2510. * @param y y value of the vector
  2511. * @param z z value of the vector
  2512. * @param w w value of the vector
  2513. */
  2514. constructor(
  2515. /** x value of the vector */
  2516. x: number,
  2517. /** y value of the vector */
  2518. y: number,
  2519. /** z value of the vector */
  2520. z: number,
  2521. /** w value of the vector */
  2522. w: number);
  2523. /**
  2524. * Returns the string with the Vector4 coordinates.
  2525. * @returns a string containing all the vector values
  2526. */
  2527. toString(): string;
  2528. /**
  2529. * Returns the string "Vector4".
  2530. * @returns "Vector4"
  2531. */
  2532. getClassName(): string;
  2533. /**
  2534. * Returns the Vector4 hash code.
  2535. * @returns a unique hash code
  2536. */
  2537. getHashCode(): number;
  2538. /**
  2539. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2540. * @returns the resulting array
  2541. */
  2542. asArray(): number[];
  2543. /**
  2544. * Populates the given array from the given index with the Vector4 coordinates.
  2545. * @param array array to populate
  2546. * @param index index of the array to start at (default: 0)
  2547. * @returns the Vector4.
  2548. */
  2549. toArray(array: FloatArray, index?: number): Vector4;
  2550. /**
  2551. * Adds the given vector to the current Vector4.
  2552. * @param otherVector the vector to add
  2553. * @returns the updated Vector4.
  2554. */
  2555. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2556. /**
  2557. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2558. * @param otherVector the vector to add
  2559. * @returns the resulting vector
  2560. */
  2561. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2562. /**
  2563. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2564. * @param otherVector the vector to add
  2565. * @param result the vector to store the result
  2566. * @returns the current Vector4.
  2567. */
  2568. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2569. /**
  2570. * Subtract in place the given vector from the current Vector4.
  2571. * @param otherVector the vector to subtract
  2572. * @returns the updated Vector4.
  2573. */
  2574. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2575. /**
  2576. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2577. * @param otherVector the vector to add
  2578. * @returns the new vector with the result
  2579. */
  2580. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2581. /**
  2582. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2583. * @param otherVector the vector to subtract
  2584. * @param result the vector to store the result
  2585. * @returns the current Vector4.
  2586. */
  2587. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2588. /**
  2589. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2590. */
  2591. /**
  2592. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2593. * @param x value to subtract
  2594. * @param y value to subtract
  2595. * @param z value to subtract
  2596. * @param w value to subtract
  2597. * @returns new vector containing the result
  2598. */
  2599. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2600. /**
  2601. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2602. * @param x value to subtract
  2603. * @param y value to subtract
  2604. * @param z value to subtract
  2605. * @param w value to subtract
  2606. * @param result the vector to store the result in
  2607. * @returns the current Vector4.
  2608. */
  2609. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2610. /**
  2611. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2612. * @returns a new vector with the negated values
  2613. */
  2614. negate(): Vector4;
  2615. /**
  2616. * Multiplies the current Vector4 coordinates by scale (float).
  2617. * @param scale the number to scale with
  2618. * @returns the updated Vector4.
  2619. */
  2620. scaleInPlace(scale: number): Vector4;
  2621. /**
  2622. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2623. * @param scale the number to scale with
  2624. * @returns a new vector with the result
  2625. */
  2626. scale(scale: number): Vector4;
  2627. /**
  2628. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2629. * @param scale the number to scale with
  2630. * @param result a vector to store the result in
  2631. * @returns the current Vector4.
  2632. */
  2633. scaleToRef(scale: number, result: Vector4): Vector4;
  2634. /**
  2635. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2636. * @param scale defines the scale factor
  2637. * @param result defines the Vector4 object where to store the result
  2638. * @returns the unmodified current Vector4
  2639. */
  2640. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2643. * @param otherVector the vector to compare against
  2644. * @returns true if they are equal
  2645. */
  2646. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2647. /**
  2648. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2649. * @param otherVector vector to compare against
  2650. * @param epsilon (Default: very small number)
  2651. * @returns true if they are equal
  2652. */
  2653. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2654. /**
  2655. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2656. * @param x x value to compare against
  2657. * @param y y value to compare against
  2658. * @param z z value to compare against
  2659. * @param w w value to compare against
  2660. * @returns true if equal
  2661. */
  2662. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2663. /**
  2664. * Multiplies in place the current Vector4 by the given one.
  2665. * @param otherVector vector to multiple with
  2666. * @returns the updated Vector4.
  2667. */
  2668. multiplyInPlace(otherVector: Vector4): Vector4;
  2669. /**
  2670. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2671. * @param otherVector vector to multiple with
  2672. * @returns resulting new vector
  2673. */
  2674. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2675. /**
  2676. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2677. * @param otherVector vector to multiple with
  2678. * @param result vector to store the result
  2679. * @returns the current Vector4.
  2680. */
  2681. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2682. /**
  2683. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2684. * @param x x value multiply with
  2685. * @param y y value multiply with
  2686. * @param z z value multiply with
  2687. * @param w w value multiply with
  2688. * @returns resulting new vector
  2689. */
  2690. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2691. /**
  2692. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2693. * @param otherVector vector to devide with
  2694. * @returns resulting new vector
  2695. */
  2696. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2697. /**
  2698. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2699. * @param otherVector vector to devide with
  2700. * @param result vector to store the result
  2701. * @returns the current Vector4.
  2702. */
  2703. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2704. /**
  2705. * Divides the current Vector3 coordinates by the given ones.
  2706. * @param otherVector vector to devide with
  2707. * @returns the updated Vector3.
  2708. */
  2709. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2710. /**
  2711. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2712. * @param other defines the second operand
  2713. * @returns the current updated Vector4
  2714. */
  2715. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2716. /**
  2717. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2718. * @param other defines the second operand
  2719. * @returns the current updated Vector4
  2720. */
  2721. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector4 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. floor(): Vector4;
  2727. /**
  2728. * Gets a new Vector4 from current Vector3 floored values
  2729. * @returns a new Vector4
  2730. */
  2731. fract(): Vector4;
  2732. /**
  2733. * Returns the Vector4 length (float).
  2734. * @returns the length
  2735. */
  2736. length(): number;
  2737. /**
  2738. * Returns the Vector4 squared length (float).
  2739. * @returns the length squared
  2740. */
  2741. lengthSquared(): number;
  2742. /**
  2743. * Normalizes in place the Vector4.
  2744. * @returns the updated Vector4.
  2745. */
  2746. normalize(): Vector4;
  2747. /**
  2748. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2749. * @returns this converted to a new vector3
  2750. */
  2751. toVector3(): Vector3;
  2752. /**
  2753. * Returns a new Vector4 copied from the current one.
  2754. * @returns the new cloned vector
  2755. */
  2756. clone(): Vector4;
  2757. /**
  2758. * Updates the current Vector4 with the given one coordinates.
  2759. * @param source the source vector to copy from
  2760. * @returns the updated Vector4.
  2761. */
  2762. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2763. /**
  2764. * Updates the current Vector4 coordinates with the given floats.
  2765. * @param x float to copy from
  2766. * @param y float to copy from
  2767. * @param z float to copy from
  2768. * @param w float to copy from
  2769. * @returns the updated Vector4.
  2770. */
  2771. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2772. /**
  2773. * Updates the current Vector4 coordinates with the given floats.
  2774. * @param x float to set from
  2775. * @param y float to set from
  2776. * @param z float to set from
  2777. * @param w float to set from
  2778. * @returns the updated Vector4.
  2779. */
  2780. set(x: number, y: number, z: number, w: number): Vector4;
  2781. /**
  2782. * Copies the given float to the current Vector3 coordinates
  2783. * @param v defines the x, y, z and w coordinates of the operand
  2784. * @returns the current updated Vector3
  2785. */
  2786. setAll(v: number): Vector4;
  2787. /**
  2788. * Returns a new Vector4 set from the starting index of the given array.
  2789. * @param array the array to pull values from
  2790. * @param offset the offset into the array to start at
  2791. * @returns the new vector
  2792. */
  2793. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2794. /**
  2795. * Updates the given vector "result" from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @param result the vector to store the result in
  2799. */
  2800. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given Float32Array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" coordinates from the given floats.
  2810. * @param x float to set from
  2811. * @param y float to set from
  2812. * @param z float to set from
  2813. * @param w float to set from
  2814. * @param result the vector to the floats in
  2815. */
  2816. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2817. /**
  2818. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2819. * @returns the new vector
  2820. */
  2821. static Zero(): Vector4;
  2822. /**
  2823. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2824. * @returns the new vector
  2825. */
  2826. static One(): Vector4;
  2827. /**
  2828. * Returns a new normalized Vector4 from the given one.
  2829. * @param vector the vector to normalize
  2830. * @returns the vector
  2831. */
  2832. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2833. /**
  2834. * Updates the given vector "result" from the normalization of the given one.
  2835. * @param vector the vector to normalize
  2836. * @param result the vector to store the result in
  2837. */
  2838. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2839. /**
  2840. * Returns a vector with the minimum values from the left and right vectors
  2841. * @param left left vector to minimize
  2842. * @param right right vector to minimize
  2843. * @returns a new vector with the minimum of the left and right vector values
  2844. */
  2845. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2846. /**
  2847. * Returns a vector with the maximum values from the left and right vectors
  2848. * @param left left vector to maximize
  2849. * @param right right vector to maximize
  2850. * @returns a new vector with the maximum of the left and right vector values
  2851. */
  2852. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns the distance (float) between the vectors "value1" and "value2".
  2855. * @param value1 value to calulate the distance between
  2856. * @param value2 value to calulate the distance between
  2857. * @return the distance between the two vectors
  2858. */
  2859. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2860. /**
  2861. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors squared
  2865. */
  2866. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the center between
  2870. * @param value2 value to calulate the center between
  2871. * @return the center between the two vectors
  2872. */
  2873. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2874. /**
  2875. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2876. * This methods computes transformed normalized direction vectors only.
  2877. * @param vector the vector to transform
  2878. * @param transformation the transformation matrix to apply
  2879. * @returns the new vector
  2880. */
  2881. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2882. /**
  2883. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2884. * This methods computes transformed normalized direction vectors only.
  2885. * @param vector the vector to transform
  2886. * @param transformation the transformation matrix to apply
  2887. * @param result the vector to store the result in
  2888. */
  2889. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2890. /**
  2891. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2892. * This methods computes transformed normalized direction vectors only.
  2893. * @param x value to transform
  2894. * @param y value to transform
  2895. * @param z value to transform
  2896. * @param w value to transform
  2897. * @param transformation the transformation matrix to apply
  2898. * @param result the vector to store the results in
  2899. */
  2900. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2901. /**
  2902. * Creates a new Vector4 from a Vector3
  2903. * @param source defines the source data
  2904. * @param w defines the 4th component (default is 0)
  2905. * @returns a new Vector4
  2906. */
  2907. static FromVector3(source: Vector3, w?: number): Vector4;
  2908. }
  2909. /**
  2910. * Class used to store quaternion data
  2911. * @see https://en.wikipedia.org/wiki/Quaternion
  2912. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2913. */
  2914. export class Quaternion {
  2915. /** defines the first component (0 by default) */
  2916. x: number;
  2917. /** defines the second component (0 by default) */
  2918. y: number;
  2919. /** defines the third component (0 by default) */
  2920. z: number;
  2921. /** defines the fourth component (1.0 by default) */
  2922. w: number;
  2923. /**
  2924. * Creates a new Quaternion from the given floats
  2925. * @param x defines the first component (0 by default)
  2926. * @param y defines the second component (0 by default)
  2927. * @param z defines the third component (0 by default)
  2928. * @param w defines the fourth component (1.0 by default)
  2929. */
  2930. constructor(
  2931. /** defines the first component (0 by default) */
  2932. x?: number,
  2933. /** defines the second component (0 by default) */
  2934. y?: number,
  2935. /** defines the third component (0 by default) */
  2936. z?: number,
  2937. /** defines the fourth component (1.0 by default) */
  2938. w?: number);
  2939. /**
  2940. * Gets a string representation for the current quaternion
  2941. * @returns a string with the Quaternion coordinates
  2942. */
  2943. toString(): string;
  2944. /**
  2945. * Gets the class name of the quaternion
  2946. * @returns the string "Quaternion"
  2947. */
  2948. getClassName(): string;
  2949. /**
  2950. * Gets a hash code for this quaternion
  2951. * @returns the quaternion hash code
  2952. */
  2953. getHashCode(): number;
  2954. /**
  2955. * Copy the quaternion to an array
  2956. * @returns a new array populated with 4 elements from the quaternion coordinates
  2957. */
  2958. asArray(): number[];
  2959. /**
  2960. * Check if two quaternions are equals
  2961. * @param otherQuaternion defines the second operand
  2962. * @return true if the current quaternion and the given one coordinates are strictly equals
  2963. */
  2964. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2965. /**
  2966. * Clone the current quaternion
  2967. * @returns a new quaternion copied from the current one
  2968. */
  2969. clone(): Quaternion;
  2970. /**
  2971. * Copy a quaternion to the current one
  2972. * @param other defines the other quaternion
  2973. * @returns the updated current quaternion
  2974. */
  2975. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2976. /**
  2977. * Updates the current quaternion with the given float coordinates
  2978. * @param x defines the x coordinate
  2979. * @param y defines the y coordinate
  2980. * @param z defines the z coordinate
  2981. * @param w defines the w coordinate
  2982. * @returns the updated current quaternion
  2983. */
  2984. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2985. /**
  2986. * Updates the current quaternion from the given float coordinates
  2987. * @param x defines the x coordinate
  2988. * @param y defines the y coordinate
  2989. * @param z defines the z coordinate
  2990. * @param w defines the w coordinate
  2991. * @returns the updated current quaternion
  2992. */
  2993. set(x: number, y: number, z: number, w: number): Quaternion;
  2994. /**
  2995. * Adds two quaternions
  2996. * @param other defines the second operand
  2997. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2998. */
  2999. add(other: DeepImmutable<Quaternion>): Quaternion;
  3000. /**
  3001. * Add a quaternion to the current one
  3002. * @param other defines the quaternion to add
  3003. * @returns the current quaternion
  3004. */
  3005. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3006. /**
  3007. * Subtract two quaternions
  3008. * @param other defines the second operand
  3009. * @returns a new quaternion as the subtraction result of the given one from the current one
  3010. */
  3011. subtract(other: Quaternion): Quaternion;
  3012. /**
  3013. * Multiplies the current quaternion by a scale factor
  3014. * @param value defines the scale factor
  3015. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3016. */
  3017. scale(value: number): Quaternion;
  3018. /**
  3019. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3020. * @param scale defines the scale factor
  3021. * @param result defines the Quaternion object where to store the result
  3022. * @returns the unmodified current quaternion
  3023. */
  3024. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3025. /**
  3026. * Multiplies in place the current quaternion by a scale factor
  3027. * @param value defines the scale factor
  3028. * @returns the current modified quaternion
  3029. */
  3030. scaleInPlace(value: number): Quaternion;
  3031. /**
  3032. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3033. * @param scale defines the scale factor
  3034. * @param result defines the Quaternion object where to store the result
  3035. * @returns the unmodified current quaternion
  3036. */
  3037. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3038. /**
  3039. * Multiplies two quaternions
  3040. * @param q1 defines the second operand
  3041. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3042. */
  3043. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3044. /**
  3045. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3046. * @param q1 defines the second operand
  3047. * @param result defines the target quaternion
  3048. * @returns the current quaternion
  3049. */
  3050. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3051. /**
  3052. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @returns the currentupdated quaternion
  3055. */
  3056. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3057. /**
  3058. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3059. * @param ref defines the target quaternion
  3060. * @returns the current quaternion
  3061. */
  3062. conjugateToRef(ref: Quaternion): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns the current updated quaternion
  3066. */
  3067. conjugateInPlace(): Quaternion;
  3068. /**
  3069. * Conjugates in place (1-q) the current quaternion
  3070. * @returns a new quaternion
  3071. */
  3072. conjugate(): Quaternion;
  3073. /**
  3074. * Gets length of current quaternion
  3075. * @returns the quaternion length (float)
  3076. */
  3077. length(): number;
  3078. /**
  3079. * Normalize in place the current quaternion
  3080. * @returns the current updated quaternion
  3081. */
  3082. normalize(): Quaternion;
  3083. /**
  3084. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3085. * @param order is a reserved parameter and is ignore for now
  3086. * @returns a new Vector3 containing the Euler angles
  3087. */
  3088. toEulerAngles(order?: string): Vector3;
  3089. /**
  3090. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3091. * @param result defines the vector which will be filled with the Euler angles
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns the current unchanged quaternion
  3094. */
  3095. toEulerAnglesToRef(result: Vector3): Quaternion;
  3096. /**
  3097. * Updates the given rotation matrix with the current quaternion values
  3098. * @param result defines the target matrix
  3099. * @returns the current unchanged quaternion
  3100. */
  3101. toRotationMatrix(result: Matrix): Quaternion;
  3102. /**
  3103. * Updates the current quaternion from the given rotation matrix values
  3104. * @param matrix defines the source matrix
  3105. * @returns the current updated quaternion
  3106. */
  3107. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3108. /**
  3109. * Creates a new quaternion from a rotation matrix
  3110. * @param matrix defines the source matrix
  3111. * @returns a new quaternion created from the given rotation matrix values
  3112. */
  3113. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3114. /**
  3115. * Updates the given quaternion with the given rotation matrix values
  3116. * @param matrix defines the source matrix
  3117. * @param result defines the target quaternion
  3118. */
  3119. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3120. /**
  3121. * Returns the dot product (float) between the quaternions "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3127. /**
  3128. * Checks if the two quaternions are close to each other
  3129. * @param quat0 defines the first quaternion to check
  3130. * @param quat1 defines the second quaternion to check
  3131. * @returns true if the two quaternions are close to each other
  3132. */
  3133. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3134. /**
  3135. * Creates an empty quaternion
  3136. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3137. */
  3138. static Zero(): Quaternion;
  3139. /**
  3140. * Inverse a given quaternion
  3141. * @param q defines the source quaternion
  3142. * @returns a new quaternion as the inverted current quaternion
  3143. */
  3144. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3145. /**
  3146. * Inverse a given quaternion
  3147. * @param q defines the source quaternion
  3148. * @param result the quaternion the result will be stored in
  3149. * @returns the result quaternion
  3150. */
  3151. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3152. /**
  3153. * Creates an identity quaternion
  3154. * @returns the identity quaternion
  3155. */
  3156. static Identity(): Quaternion;
  3157. /**
  3158. * Gets a boolean indicating if the given quaternion is identity
  3159. * @param quaternion defines the quaternion to check
  3160. * @returns true if the quaternion is identity
  3161. */
  3162. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3163. /**
  3164. * Creates a quaternion from a rotation around an axis
  3165. * @param axis defines the axis to use
  3166. * @param angle defines the angle to use
  3167. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3168. */
  3169. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3170. /**
  3171. * Creates a rotation around an axis and stores it into the given quaternion
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @param result defines the target quaternion
  3175. * @returns the target quaternion
  3176. */
  3177. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3178. /**
  3179. * Creates a new quaternion from data stored into an array
  3180. * @param array defines the data source
  3181. * @param offset defines the offset in the source array where the data starts
  3182. * @returns a new quaternion
  3183. */
  3184. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3185. /**
  3186. * Create a quaternion from Euler rotation angles
  3187. * @param x Pitch
  3188. * @param y Yaw
  3189. * @param z Roll
  3190. * @returns the new Quaternion
  3191. */
  3192. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3193. /**
  3194. * Updates a quaternion from Euler rotation angles
  3195. * @param x Pitch
  3196. * @param y Yaw
  3197. * @param z Roll
  3198. * @param result the quaternion to store the result
  3199. * @returns the updated quaternion
  3200. */
  3201. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3202. /**
  3203. * Create a quaternion from Euler rotation vector
  3204. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3205. * @returns the new Quaternion
  3206. */
  3207. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3208. /**
  3209. * Updates a quaternion from Euler rotation vector
  3210. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3211. * @param result the quaternion to store the result
  3212. * @returns the updated quaternion
  3213. */
  3214. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3215. /**
  3216. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3217. * @param yaw defines the rotation around Y axis
  3218. * @param pitch defines the rotation around X axis
  3219. * @param roll defines the rotation around Z axis
  3220. * @returns the new quaternion
  3221. */
  3222. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3223. /**
  3224. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3225. * @param yaw defines the rotation around Y axis
  3226. * @param pitch defines the rotation around X axis
  3227. * @param roll defines the rotation around Z axis
  3228. * @param result defines the target quaternion
  3229. */
  3230. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3231. /**
  3232. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3233. * @param alpha defines the rotation around first axis
  3234. * @param beta defines the rotation around second axis
  3235. * @param gamma defines the rotation around third axis
  3236. * @returns the new quaternion
  3237. */
  3238. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3239. /**
  3240. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3241. * @param alpha defines the rotation around first axis
  3242. * @param beta defines the rotation around second axis
  3243. * @param gamma defines the rotation around third axis
  3244. * @param result defines the target quaternion
  3245. */
  3246. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3247. /**
  3248. * 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)
  3249. * @param axis1 defines the first axis
  3250. * @param axis2 defines the second axis
  3251. * @param axis3 defines the third axis
  3252. * @returns the new quaternion
  3253. */
  3254. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3255. /**
  3256. * 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
  3257. * @param axis1 defines the first axis
  3258. * @param axis2 defines the second axis
  3259. * @param axis3 defines the third axis
  3260. * @param ref defines the target quaternion
  3261. */
  3262. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3263. /**
  3264. * Interpolates between two quaternions
  3265. * @param left defines first quaternion
  3266. * @param right defines second quaternion
  3267. * @param amount defines the gradient to use
  3268. * @returns the new interpolated quaternion
  3269. */
  3270. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3271. /**
  3272. * Interpolates between two quaternions and stores it into a target quaternion
  3273. * @param left defines first quaternion
  3274. * @param right defines second quaternion
  3275. * @param amount defines the gradient to use
  3276. * @param result defines the target quaternion
  3277. */
  3278. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3279. /**
  3280. * Interpolate between two quaternions using Hermite interpolation
  3281. * @param value1 defines first quaternion
  3282. * @param tangent1 defines the incoming tangent
  3283. * @param value2 defines second quaternion
  3284. * @param tangent2 defines the outgoing tangent
  3285. * @param amount defines the target quaternion
  3286. * @returns the new interpolated quaternion
  3287. */
  3288. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3289. }
  3290. /**
  3291. * Class used to store matrix data (4x4)
  3292. */
  3293. export class Matrix {
  3294. private static _updateFlagSeed;
  3295. private static _identityReadOnly;
  3296. private _isIdentity;
  3297. private _isIdentityDirty;
  3298. private _isIdentity3x2;
  3299. private _isIdentity3x2Dirty;
  3300. /**
  3301. * Gets the update flag of the matrix which is an unique number for the matrix.
  3302. * It will be incremented every time the matrix data change.
  3303. * You can use it to speed the comparison between two versions of the same matrix.
  3304. */
  3305. updateFlag: number;
  3306. private readonly _m;
  3307. /**
  3308. * Gets the internal data of the matrix
  3309. */
  3310. readonly m: DeepImmutable<Float32Array>;
  3311. /** @hidden */
  3312. _markAsUpdated(): void;
  3313. /** @hidden */
  3314. private _updateIdentityStatus;
  3315. /**
  3316. * Creates an empty matrix (filled with zeros)
  3317. */
  3318. constructor();
  3319. /**
  3320. * Check if the current matrix is identity
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentity(): boolean;
  3324. /**
  3325. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3326. * @returns true is the matrix is the identity matrix
  3327. */
  3328. isIdentityAs3x2(): boolean;
  3329. /**
  3330. * Gets the determinant of the matrix
  3331. * @returns the matrix determinant
  3332. */
  3333. determinant(): number;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array
  3337. */
  3338. toArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Returns the matrix as a Float32Array
  3341. * @returns the matrix underlying array.
  3342. */
  3343. asArray(): DeepImmutable<Float32Array>;
  3344. /**
  3345. * Inverts the current matrix in place
  3346. * @returns the current inverted matrix
  3347. */
  3348. invert(): Matrix;
  3349. /**
  3350. * Sets all the matrix elements to zero
  3351. * @returns the current matrix
  3352. */
  3353. reset(): Matrix;
  3354. /**
  3355. * Adds the current matrix with a second one
  3356. * @param other defines the matrix to add
  3357. * @returns a new matrix as the addition of the current matrix and the given one
  3358. */
  3359. add(other: DeepImmutable<Matrix>): Matrix;
  3360. /**
  3361. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3362. * @param other defines the matrix to add
  3363. * @param result defines the target matrix
  3364. * @returns the current matrix
  3365. */
  3366. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3367. /**
  3368. * Adds in place the given matrix to the current matrix
  3369. * @param other defines the second operand
  3370. * @returns the current updated matrix
  3371. */
  3372. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3373. /**
  3374. * Sets the given matrix to the current inverted Matrix
  3375. * @param other defines the target matrix
  3376. * @returns the unmodified current matrix
  3377. */
  3378. invertToRef(other: Matrix): Matrix;
  3379. /**
  3380. * add a value at the specified position in the current Matrix
  3381. * @param index the index of the value within the matrix. between 0 and 15.
  3382. * @param value the value to be added
  3383. * @returns the current updated matrix
  3384. */
  3385. addAtIndex(index: number, value: number): Matrix;
  3386. /**
  3387. * mutiply the specified position in the current Matrix by a value
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. multiplyAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * Inserts the translation vector (using 3 floats) in the current matrix
  3395. * @param x defines the 1st component of the translation
  3396. * @param y defines the 2nd component of the translation
  3397. * @param z defines the 3rd component of the translation
  3398. * @returns the current updated matrix
  3399. */
  3400. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3401. /**
  3402. * Adds the translation vector (using 3 floats) in the current matrix
  3403. * @param x defines the 1st component of the translation
  3404. * @param y defines the 2nd component of the translation
  3405. * @param z defines the 3rd component of the translation
  3406. * @returns the current updated matrix
  3407. */
  3408. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3409. /**
  3410. * Inserts the translation vector in the current matrix
  3411. * @param vector3 defines the translation to insert
  3412. * @returns the current updated matrix
  3413. */
  3414. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3415. /**
  3416. * Gets the translation value of the current matrix
  3417. * @returns a new Vector3 as the extracted translation from the matrix
  3418. */
  3419. getTranslation(): Vector3;
  3420. /**
  3421. * Fill a Vector3 with the extracted translation from the matrix
  3422. * @param result defines the Vector3 where to store the translation
  3423. * @returns the current matrix
  3424. */
  3425. getTranslationToRef(result: Vector3): Matrix;
  3426. /**
  3427. * Remove rotation and scaling part from the matrix
  3428. * @returns the updated matrix
  3429. */
  3430. removeRotationAndScaling(): Matrix;
  3431. /**
  3432. * Multiply two matrices
  3433. * @param other defines the second operand
  3434. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3435. */
  3436. multiply(other: DeepImmutable<Matrix>): Matrix;
  3437. /**
  3438. * Copy the current matrix from the given one
  3439. * @param other defines the source matrix
  3440. * @returns the current updated matrix
  3441. */
  3442. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3443. /**
  3444. * Populates the given array from the starting index with the current matrix values
  3445. * @param array defines the target array
  3446. * @param offset defines the offset in the target array where to start storing values
  3447. * @returns the current matrix
  3448. */
  3449. copyToArray(array: Float32Array, offset?: number): Matrix;
  3450. /**
  3451. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3452. * @param other defines the second operand
  3453. * @param result defines the matrix where to store the multiplication
  3454. * @returns the current matrix
  3455. */
  3456. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3457. /**
  3458. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the array where to store the multiplication
  3461. * @param offset defines the offset in the target array where to start storing values
  3462. * @returns the current matrix
  3463. */
  3464. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3465. /**
  3466. * Check equality between this matrix and a second one
  3467. * @param value defines the second matrix to compare
  3468. * @returns true is the current matrix and the given one values are strictly equal
  3469. */
  3470. equals(value: DeepImmutable<Matrix>): boolean;
  3471. /**
  3472. * Clone the current matrix
  3473. * @returns a new matrix from the current matrix
  3474. */
  3475. clone(): Matrix;
  3476. /**
  3477. * Returns the name of the current matrix class
  3478. * @returns the string "Matrix"
  3479. */
  3480. getClassName(): string;
  3481. /**
  3482. * Gets the hash code of the current matrix
  3483. * @returns the hash code
  3484. */
  3485. getHashCode(): number;
  3486. /**
  3487. * Decomposes the current Matrix into a translation, rotation and scaling components
  3488. * @param scale defines the scale vector3 given as a reference to update
  3489. * @param rotation defines the rotation quaternion given as a reference to update
  3490. * @param translation defines the translation vector3 given as a reference to update
  3491. * @returns true if operation was successful
  3492. */
  3493. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3494. /**
  3495. * Gets specific row of the matrix
  3496. * @param index defines the number of the row to get
  3497. * @returns the index-th row of the current matrix as a new Vector4
  3498. */
  3499. getRow(index: number): Nullable<Vector4>;
  3500. /**
  3501. * Sets the index-th row of the current matrix to the vector4 values
  3502. * @param index defines the number of the row to set
  3503. * @param row defines the target vector4
  3504. * @returns the updated current matrix
  3505. */
  3506. setRow(index: number, row: Vector4): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix
  3509. * @returns the new transposed matrix
  3510. */
  3511. transpose(): Matrix;
  3512. /**
  3513. * Compute the transpose of the matrix and store it in a given matrix
  3514. * @param result defines the target matrix
  3515. * @returns the current matrix
  3516. */
  3517. transposeToRef(result: Matrix): Matrix;
  3518. /**
  3519. * Sets the index-th row of the current matrix with the given 4 x float values
  3520. * @param index defines the row index
  3521. * @param x defines the x component to set
  3522. * @param y defines the y component to set
  3523. * @param z defines the z component to set
  3524. * @param w defines the w component to set
  3525. * @returns the updated current matrix
  3526. */
  3527. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3528. /**
  3529. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3530. * @param scale defines the scale factor
  3531. * @returns a new matrix
  3532. */
  3533. scale(scale: number): Matrix;
  3534. /**
  3535. * Scale the current matrix values by a factor to a given result matrix
  3536. * @param scale defines the scale factor
  3537. * @param result defines the matrix to store the result
  3538. * @returns the current matrix
  3539. */
  3540. scaleToRef(scale: number, result: Matrix): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor and add the result to a given matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the Matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3550. * @param ref matrix to store the result
  3551. */
  3552. toNormalMatrix(ref: Matrix): void;
  3553. /**
  3554. * Gets only rotation part of the current matrix
  3555. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3556. */
  3557. getRotationMatrix(): Matrix;
  3558. /**
  3559. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3560. * @param result defines the target matrix to store data to
  3561. * @returns the current matrix
  3562. */
  3563. getRotationMatrixToRef(result: Matrix): Matrix;
  3564. /**
  3565. * Toggles model matrix from being right handed to left handed in place and vice versa
  3566. */
  3567. toggleModelMatrixHandInPlace(): void;
  3568. /**
  3569. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3570. */
  3571. toggleProjectionMatrixHandInPlace(): void;
  3572. /**
  3573. * Creates a matrix from an array
  3574. * @param array defines the source array
  3575. * @param offset defines an offset in the source array
  3576. * @returns a new Matrix set from the starting index of the given array
  3577. */
  3578. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3579. /**
  3580. * Copy the content of an array into a given matrix
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @param result defines the target matrix
  3584. */
  3585. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3586. /**
  3587. * Stores an array into a matrix after having multiplied each component by a given factor
  3588. * @param array defines the source array
  3589. * @param offset defines the offset in the source array
  3590. * @param scale defines the scaling factor
  3591. * @param result defines the target matrix
  3592. */
  3593. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3594. /**
  3595. * Gets an identity matrix that must not be updated
  3596. */
  3597. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3598. /**
  3599. * Stores a list of values (16) inside a given matrix
  3600. * @param initialM11 defines 1st value of 1st row
  3601. * @param initialM12 defines 2nd value of 1st row
  3602. * @param initialM13 defines 3rd value of 1st row
  3603. * @param initialM14 defines 4th value of 1st row
  3604. * @param initialM21 defines 1st value of 2nd row
  3605. * @param initialM22 defines 2nd value of 2nd row
  3606. * @param initialM23 defines 3rd value of 2nd row
  3607. * @param initialM24 defines 4th value of 2nd row
  3608. * @param initialM31 defines 1st value of 3rd row
  3609. * @param initialM32 defines 2nd value of 3rd row
  3610. * @param initialM33 defines 3rd value of 3rd row
  3611. * @param initialM34 defines 4th value of 3rd row
  3612. * @param initialM41 defines 1st value of 4th row
  3613. * @param initialM42 defines 2nd value of 4th row
  3614. * @param initialM43 defines 3rd value of 4th row
  3615. * @param initialM44 defines 4th value of 4th row
  3616. * @param result defines the target matrix
  3617. */
  3618. 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;
  3619. /**
  3620. * Creates new matrix from a list of values (16)
  3621. * @param initialM11 defines 1st value of 1st row
  3622. * @param initialM12 defines 2nd value of 1st row
  3623. * @param initialM13 defines 3rd value of 1st row
  3624. * @param initialM14 defines 4th value of 1st row
  3625. * @param initialM21 defines 1st value of 2nd row
  3626. * @param initialM22 defines 2nd value of 2nd row
  3627. * @param initialM23 defines 3rd value of 2nd row
  3628. * @param initialM24 defines 4th value of 2nd row
  3629. * @param initialM31 defines 1st value of 3rd row
  3630. * @param initialM32 defines 2nd value of 3rd row
  3631. * @param initialM33 defines 3rd value of 3rd row
  3632. * @param initialM34 defines 4th value of 3rd row
  3633. * @param initialM41 defines 1st value of 4th row
  3634. * @param initialM42 defines 2nd value of 4th row
  3635. * @param initialM43 defines 3rd value of 4th row
  3636. * @param initialM44 defines 4th value of 4th row
  3637. * @returns the new matrix
  3638. */
  3639. 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;
  3640. /**
  3641. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3642. * @param scale defines the scale vector3
  3643. * @param rotation defines the rotation quaternion
  3644. * @param translation defines the translation vector3
  3645. * @returns a new matrix
  3646. */
  3647. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3648. /**
  3649. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3650. * @param scale defines the scale vector3
  3651. * @param rotation defines the rotation quaternion
  3652. * @param translation defines the translation vector3
  3653. * @param result defines the target matrix
  3654. */
  3655. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3656. /**
  3657. * Creates a new identity matrix
  3658. * @returns a new identity matrix
  3659. */
  3660. static Identity(): Matrix;
  3661. /**
  3662. * Creates a new identity matrix and stores the result in a given matrix
  3663. * @param result defines the target matrix
  3664. */
  3665. static IdentityToRef(result: Matrix): void;
  3666. /**
  3667. * Creates a new zero matrix
  3668. * @returns a new zero matrix
  3669. */
  3670. static Zero(): Matrix;
  3671. /**
  3672. * Creates a new rotation matrix for "angle" radians around the X axis
  3673. * @param angle defines the angle (in radians) to use
  3674. * @return the new matrix
  3675. */
  3676. static RotationX(angle: number): Matrix;
  3677. /**
  3678. * Creates a new matrix as the invert of a given matrix
  3679. * @param source defines the source matrix
  3680. * @returns the new matrix
  3681. */
  3682. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3683. /**
  3684. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3685. * @param angle defines the angle (in radians) to use
  3686. * @param result defines the target matrix
  3687. */
  3688. static RotationXToRef(angle: number, result: Matrix): void;
  3689. /**
  3690. * Creates a new rotation matrix for "angle" radians around the Y axis
  3691. * @param angle defines the angle (in radians) to use
  3692. * @return the new matrix
  3693. */
  3694. static RotationY(angle: number): Matrix;
  3695. /**
  3696. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3697. * @param angle defines the angle (in radians) to use
  3698. * @param result defines the target matrix
  3699. */
  3700. static RotationYToRef(angle: number, result: Matrix): void;
  3701. /**
  3702. * Creates a new rotation matrix for "angle" radians around the Z axis
  3703. * @param angle defines the angle (in radians) to use
  3704. * @return the new matrix
  3705. */
  3706. static RotationZ(angle: number): Matrix;
  3707. /**
  3708. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3709. * @param angle defines the angle (in radians) to use
  3710. * @param result defines the target matrix
  3711. */
  3712. static RotationZToRef(angle: number, result: Matrix): void;
  3713. /**
  3714. * Creates a new rotation matrix for "angle" radians around the given axis
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle (in radians) to use
  3717. * @return the new matrix
  3718. */
  3719. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @param result defines the target matrix
  3725. */
  3726. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3727. /**
  3728. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3729. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3730. * @param from defines the vector to align
  3731. * @param to defines the vector to align to
  3732. * @param result defines the target matrix
  3733. */
  3734. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3735. /**
  3736. * Creates a rotation matrix
  3737. * @param yaw defines the yaw angle in radians (Y axis)
  3738. * @param pitch defines the pitch angle in radians (X axis)
  3739. * @param roll defines the roll angle in radians (X axis)
  3740. * @returns the new rotation matrix
  3741. */
  3742. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3743. /**
  3744. * Creates a rotation matrix and stores it in a given matrix
  3745. * @param yaw defines the yaw angle in radians (Y axis)
  3746. * @param pitch defines the pitch angle in radians (X axis)
  3747. * @param roll defines the roll angle in radians (X axis)
  3748. * @param result defines the target matrix
  3749. */
  3750. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3751. /**
  3752. * Creates a scaling matrix
  3753. * @param x defines the scale factor on X axis
  3754. * @param y defines the scale factor on Y axis
  3755. * @param z defines the scale factor on Z axis
  3756. * @returns the new matrix
  3757. */
  3758. static Scaling(x: number, y: number, z: number): Matrix;
  3759. /**
  3760. * Creates a scaling matrix and stores it in a given matrix
  3761. * @param x defines the scale factor on X axis
  3762. * @param y defines the scale factor on Y axis
  3763. * @param z defines the scale factor on Z axis
  3764. * @param result defines the target matrix
  3765. */
  3766. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3767. /**
  3768. * Creates a translation matrix
  3769. * @param x defines the translation on X axis
  3770. * @param y defines the translation on Y axis
  3771. * @param z defines the translationon Z axis
  3772. * @returns the new matrix
  3773. */
  3774. static Translation(x: number, y: number, z: number): Matrix;
  3775. /**
  3776. * Creates a translation matrix and stores it in a given matrix
  3777. * @param x defines the translation on X axis
  3778. * @param y defines the translation on Y axis
  3779. * @param z defines the translationon Z axis
  3780. * @param result defines the target matrix
  3781. */
  3782. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3783. /**
  3784. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3785. * @param startValue defines the start value
  3786. * @param endValue defines the end value
  3787. * @param gradient defines the gradient factor
  3788. * @returns the new matrix
  3789. */
  3790. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3791. /**
  3792. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3793. * @param startValue defines the start value
  3794. * @param endValue defines the end value
  3795. * @param gradient defines the gradient factor
  3796. * @param result defines the Matrix object where to store data
  3797. */
  3798. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3799. /**
  3800. * Builds a new matrix whose values are computed by:
  3801. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3802. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3803. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3804. * @param startValue defines the first matrix
  3805. * @param endValue defines the second matrix
  3806. * @param gradient defines the gradient between the two matrices
  3807. * @returns the new matrix
  3808. */
  3809. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3810. /**
  3811. * Update a matrix to values which are computed by:
  3812. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3813. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3814. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3815. * @param startValue defines the first matrix
  3816. * @param endValue defines the second matrix
  3817. * @param gradient defines the gradient between the two matrices
  3818. * @param result defines the target matrix
  3819. */
  3820. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3821. /**
  3822. * 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"
  3823. * This function works in left handed mode
  3824. * @param eye defines the final position of the entity
  3825. * @param target defines where the entity should look at
  3826. * @param up defines the up vector for the entity
  3827. * @returns the new matrix
  3828. */
  3829. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3830. /**
  3831. * 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".
  3832. * This function works in left handed mode
  3833. * @param eye defines the final position of the entity
  3834. * @param target defines where the entity should look at
  3835. * @param up defines the up vector for the entity
  3836. * @param result defines the target matrix
  3837. */
  3838. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3839. /**
  3840. * 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"
  3841. * This function works in right handed mode
  3842. * @param eye defines the final position of the entity
  3843. * @param target defines where the entity should look at
  3844. * @param up defines the up vector for the entity
  3845. * @returns the new matrix
  3846. */
  3847. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3848. /**
  3849. * 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".
  3850. * This function works in right handed mode
  3851. * @param eye defines the final position of the entity
  3852. * @param target defines where the entity should look at
  3853. * @param up defines the up vector for the entity
  3854. * @param result defines the target matrix
  3855. */
  3856. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3857. /**
  3858. * Create a left-handed orthographic projection matrix
  3859. * @param width defines the viewport width
  3860. * @param height defines the viewport height
  3861. * @param znear defines the near clip plane
  3862. * @param zfar defines the far clip plane
  3863. * @returns a new matrix as a left-handed orthographic projection matrix
  3864. */
  3865. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3866. /**
  3867. * Store a left-handed orthographic projection to a given matrix
  3868. * @param width defines the viewport width
  3869. * @param height defines the viewport height
  3870. * @param znear defines the near clip plane
  3871. * @param zfar defines the far clip plane
  3872. * @param result defines the target matrix
  3873. */
  3874. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3875. /**
  3876. * Create a left-handed orthographic projection matrix
  3877. * @param left defines the viewport left coordinate
  3878. * @param right defines the viewport right coordinate
  3879. * @param bottom defines the viewport bottom coordinate
  3880. * @param top defines the viewport top coordinate
  3881. * @param znear defines the near clip plane
  3882. * @param zfar defines the far clip plane
  3883. * @returns a new matrix as a left-handed orthographic projection matrix
  3884. */
  3885. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3886. /**
  3887. * Stores a left-handed orthographic projection into a given matrix
  3888. * @param left defines the viewport left coordinate
  3889. * @param right defines the viewport right coordinate
  3890. * @param bottom defines the viewport bottom coordinate
  3891. * @param top defines the viewport top coordinate
  3892. * @param znear defines the near clip plane
  3893. * @param zfar defines the far clip plane
  3894. * @param result defines the target matrix
  3895. */
  3896. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3897. /**
  3898. * Creates a right-handed orthographic projection matrix
  3899. * @param left defines the viewport left coordinate
  3900. * @param right defines the viewport right coordinate
  3901. * @param bottom defines the viewport bottom coordinate
  3902. * @param top defines the viewport top coordinate
  3903. * @param znear defines the near clip plane
  3904. * @param zfar defines the far clip plane
  3905. * @returns a new matrix as a right-handed orthographic projection matrix
  3906. */
  3907. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3908. /**
  3909. * Stores a right-handed orthographic projection into a given matrix
  3910. * @param left defines the viewport left coordinate
  3911. * @param right defines the viewport right coordinate
  3912. * @param bottom defines the viewport bottom coordinate
  3913. * @param top defines the viewport top coordinate
  3914. * @param znear defines the near clip plane
  3915. * @param zfar defines the far clip plane
  3916. * @param result defines the target matrix
  3917. */
  3918. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3919. /**
  3920. * Creates a left-handed perspective projection matrix
  3921. * @param width defines the viewport width
  3922. * @param height defines the viewport height
  3923. * @param znear defines the near clip plane
  3924. * @param zfar defines the far clip plane
  3925. * @returns a new matrix as a left-handed perspective projection matrix
  3926. */
  3927. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3928. /**
  3929. * Creates a left-handed perspective projection matrix
  3930. * @param fov defines the horizontal field of view
  3931. * @param aspect defines the aspect ratio
  3932. * @param znear defines the near clip plane
  3933. * @param zfar defines the far clip plane
  3934. * @returns a new matrix as a left-handed perspective projection matrix
  3935. */
  3936. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3937. /**
  3938. * Stores a left-handed perspective projection into a given matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @param result defines the target matrix
  3944. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3945. */
  3946. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3947. /**
  3948. * Creates a right-handed perspective projection matrix
  3949. * @param fov defines the horizontal field of view
  3950. * @param aspect defines the aspect ratio
  3951. * @param znear defines the near clip plane
  3952. * @param zfar defines the far clip plane
  3953. * @returns a new matrix as a right-handed perspective projection matrix
  3954. */
  3955. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3956. /**
  3957. * Stores a right-handed perspective projection into a given matrix
  3958. * @param fov defines the horizontal field of view
  3959. * @param aspect defines the aspect ratio
  3960. * @param znear defines the near clip plane
  3961. * @param zfar defines the far clip plane
  3962. * @param result defines the target matrix
  3963. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3964. */
  3965. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3966. /**
  3967. * Stores a perspective projection for WebVR info a given matrix
  3968. * @param fov defines the field of view
  3969. * @param znear defines the near clip plane
  3970. * @param zfar defines the far clip plane
  3971. * @param result defines the target matrix
  3972. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3973. */
  3974. static PerspectiveFovWebVRToRef(fov: {
  3975. upDegrees: number;
  3976. downDegrees: number;
  3977. leftDegrees: number;
  3978. rightDegrees: number;
  3979. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3980. /**
  3981. * Computes a complete transformation matrix
  3982. * @param viewport defines the viewport to use
  3983. * @param world defines the world matrix
  3984. * @param view defines the view matrix
  3985. * @param projection defines the projection matrix
  3986. * @param zmin defines the near clip plane
  3987. * @param zmax defines the far clip plane
  3988. * @returns the transformation matrix
  3989. */
  3990. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3991. /**
  3992. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3993. * @param matrix defines the matrix to use
  3994. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3995. */
  3996. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3997. /**
  3998. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3999. * @param matrix defines the matrix to use
  4000. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4001. */
  4002. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4003. /**
  4004. * Compute the transpose of a given matrix
  4005. * @param matrix defines the matrix to transpose
  4006. * @returns the new matrix
  4007. */
  4008. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Compute the transpose of a matrix and store it in a target matrix
  4011. * @param matrix defines the matrix to transpose
  4012. * @param result defines the target matrix
  4013. */
  4014. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4015. /**
  4016. * Computes a reflection matrix from a plane
  4017. * @param plane defines the reflection plane
  4018. * @returns a new matrix
  4019. */
  4020. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4021. /**
  4022. * Computes a reflection matrix from a plane
  4023. * @param plane defines the reflection plane
  4024. * @param result defines the target matrix
  4025. */
  4026. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4027. /**
  4028. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4029. * @param xaxis defines the value of the 1st axis
  4030. * @param yaxis defines the value of the 2nd axis
  4031. * @param zaxis defines the value of the 3rd axis
  4032. * @param result defines the target matrix
  4033. */
  4034. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4035. /**
  4036. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4037. * @param quat defines the quaternion to use
  4038. * @param result defines the target matrix
  4039. */
  4040. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4041. }
  4042. /**
  4043. * @hidden
  4044. */
  4045. export class TmpVectors {
  4046. static Vector2: Vector2[];
  4047. static Vector3: Vector3[];
  4048. static Vector4: Vector4[];
  4049. static Quaternion: Quaternion[];
  4050. static Matrix: Matrix[];
  4051. }
  4052. }
  4053. declare module "babylonjs/Engines/constants" {
  4054. /** Defines the cross module used constants to avoid circular dependncies */
  4055. export class Constants {
  4056. /** Defines that alpha blending is disabled */
  4057. static readonly ALPHA_DISABLE: number;
  4058. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4059. static readonly ALPHA_ADD: number;
  4060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_COMBINE: number;
  4062. /** Defines that alpha blending to DEST - SRC * DEST */
  4063. static readonly ALPHA_SUBTRACT: number;
  4064. /** Defines that alpha blending to SRC * DEST */
  4065. static readonly ALPHA_MULTIPLY: number;
  4066. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4067. static readonly ALPHA_MAXIMIZED: number;
  4068. /** Defines that alpha blending to SRC + DEST */
  4069. static readonly ALPHA_ONEONE: number;
  4070. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4071. static readonly ALPHA_PREMULTIPLIED: number;
  4072. /**
  4073. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4074. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4075. */
  4076. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4077. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4078. static readonly ALPHA_INTERPOLATE: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4081. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_SCREENMODE: number;
  4084. /** Defines that the ressource is not delayed*/
  4085. static readonly DELAYLOADSTATE_NONE: number;
  4086. /** Defines that the ressource was successfully delay loaded */
  4087. static readonly DELAYLOADSTATE_LOADED: number;
  4088. /** Defines that the ressource is currently delay loading */
  4089. static readonly DELAYLOADSTATE_LOADING: number;
  4090. /** Defines that the ressource is delayed and has not started loading */
  4091. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4093. static readonly NEVER: number;
  4094. /** 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 */
  4095. static readonly ALWAYS: number;
  4096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4097. static readonly LESS: number;
  4098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4099. static readonly EQUAL: number;
  4100. /** 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 */
  4101. static readonly LEQUAL: number;
  4102. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4103. static readonly GREATER: number;
  4104. /** 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 */
  4105. static readonly GEQUAL: number;
  4106. /** 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 */
  4107. static readonly NOTEQUAL: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be kept */
  4109. static readonly KEEP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4111. static readonly REPLACE: number;
  4112. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4113. static readonly INCR: number;
  4114. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4115. static readonly DECR: number;
  4116. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4117. static readonly INVERT: number;
  4118. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4119. static readonly INCR_WRAP: number;
  4120. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4121. static readonly DECR_WRAP: number;
  4122. /** Texture is not repeating outside of 0..1 UVs */
  4123. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4124. /** Texture is repeating outside of 0..1 UVs */
  4125. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4126. /** Texture is repeating and mirrored */
  4127. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4128. /** ALPHA */
  4129. static readonly TEXTUREFORMAT_ALPHA: number;
  4130. /** LUMINANCE */
  4131. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4132. /** LUMINANCE_ALPHA */
  4133. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4134. /** RGB */
  4135. static readonly TEXTUREFORMAT_RGB: number;
  4136. /** RGBA */
  4137. static readonly TEXTUREFORMAT_RGBA: number;
  4138. /** RED */
  4139. static readonly TEXTUREFORMAT_RED: number;
  4140. /** RED (2nd reference) */
  4141. static readonly TEXTUREFORMAT_R: number;
  4142. /** RG */
  4143. static readonly TEXTUREFORMAT_RG: number;
  4144. /** RED_INTEGER */
  4145. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4146. /** RED_INTEGER (2nd reference) */
  4147. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4148. /** RG_INTEGER */
  4149. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4150. /** RGB_INTEGER */
  4151. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4152. /** RGBA_INTEGER */
  4153. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4154. /** UNSIGNED_BYTE */
  4155. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4156. /** UNSIGNED_BYTE (2nd reference) */
  4157. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4158. /** FLOAT */
  4159. static readonly TEXTURETYPE_FLOAT: number;
  4160. /** HALF_FLOAT */
  4161. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4162. /** BYTE */
  4163. static readonly TEXTURETYPE_BYTE: number;
  4164. /** SHORT */
  4165. static readonly TEXTURETYPE_SHORT: number;
  4166. /** UNSIGNED_SHORT */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4168. /** INT */
  4169. static readonly TEXTURETYPE_INT: number;
  4170. /** UNSIGNED_INT */
  4171. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4172. /** UNSIGNED_SHORT_4_4_4_4 */
  4173. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4174. /** UNSIGNED_SHORT_5_5_5_1 */
  4175. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4176. /** UNSIGNED_SHORT_5_6_5 */
  4177. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4178. /** UNSIGNED_INT_2_10_10_10_REV */
  4179. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4180. /** UNSIGNED_INT_24_8 */
  4181. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4182. /** UNSIGNED_INT_10F_11F_11F_REV */
  4183. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4184. /** UNSIGNED_INT_5_9_9_9_REV */
  4185. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4186. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4187. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4188. /** nearest is mag = nearest and min = nearest and mip = linear */
  4189. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4191. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4192. /** Trilinear is mag = linear and min = linear and mip = linear */
  4193. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4194. /** nearest is mag = nearest and min = nearest and mip = linear */
  4195. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4196. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4197. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4198. /** Trilinear is mag = linear and min = linear and mip = linear */
  4199. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4200. /** mag = nearest and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4202. /** mag = nearest and min = linear and mip = nearest */
  4203. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4204. /** mag = nearest and min = linear and mip = linear */
  4205. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4206. /** mag = nearest and min = linear and mip = none */
  4207. static readonly TEXTURE_NEAREST_LINEAR: number;
  4208. /** mag = nearest and min = nearest and mip = none */
  4209. static readonly TEXTURE_NEAREST_NEAREST: number;
  4210. /** mag = linear and min = nearest and mip = nearest */
  4211. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4212. /** mag = linear and min = nearest and mip = linear */
  4213. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4214. /** mag = linear and min = linear and mip = none */
  4215. static readonly TEXTURE_LINEAR_LINEAR: number;
  4216. /** mag = linear and min = nearest and mip = none */
  4217. static readonly TEXTURE_LINEAR_NEAREST: number;
  4218. /** Explicit coordinates mode */
  4219. static readonly TEXTURE_EXPLICIT_MODE: number;
  4220. /** Spherical coordinates mode */
  4221. static readonly TEXTURE_SPHERICAL_MODE: number;
  4222. /** Planar coordinates mode */
  4223. static readonly TEXTURE_PLANAR_MODE: number;
  4224. /** Cubic coordinates mode */
  4225. static readonly TEXTURE_CUBIC_MODE: number;
  4226. /** Projection coordinates mode */
  4227. static readonly TEXTURE_PROJECTION_MODE: number;
  4228. /** Skybox coordinates mode */
  4229. static readonly TEXTURE_SKYBOX_MODE: number;
  4230. /** Inverse Cubic coordinates mode */
  4231. static readonly TEXTURE_INVCUBIC_MODE: number;
  4232. /** Equirectangular coordinates mode */
  4233. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4234. /** Equirectangular Fixed coordinates mode */
  4235. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4236. /** Equirectangular Fixed Mirrored coordinates mode */
  4237. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4238. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4239. static readonly SCALEMODE_FLOOR: number;
  4240. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4241. static readonly SCALEMODE_NEAREST: number;
  4242. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4243. static readonly SCALEMODE_CEILING: number;
  4244. /**
  4245. * The dirty texture flag value
  4246. */
  4247. static readonly MATERIAL_TextureDirtyFlag: number;
  4248. /**
  4249. * The dirty light flag value
  4250. */
  4251. static readonly MATERIAL_LightDirtyFlag: number;
  4252. /**
  4253. * The dirty fresnel flag value
  4254. */
  4255. static readonly MATERIAL_FresnelDirtyFlag: number;
  4256. /**
  4257. * The dirty attribute flag value
  4258. */
  4259. static readonly MATERIAL_AttributesDirtyFlag: number;
  4260. /**
  4261. * The dirty misc flag value
  4262. */
  4263. static readonly MATERIAL_MiscDirtyFlag: number;
  4264. /**
  4265. * The all dirty flag value
  4266. */
  4267. static readonly MATERIAL_AllDirtyFlag: number;
  4268. /**
  4269. * Returns the triangle fill mode
  4270. */
  4271. static readonly MATERIAL_TriangleFillMode: number;
  4272. /**
  4273. * Returns the wireframe mode
  4274. */
  4275. static readonly MATERIAL_WireFrameFillMode: number;
  4276. /**
  4277. * Returns the point fill mode
  4278. */
  4279. static readonly MATERIAL_PointFillMode: number;
  4280. /**
  4281. * Returns the point list draw mode
  4282. */
  4283. static readonly MATERIAL_PointListDrawMode: number;
  4284. /**
  4285. * Returns the line list draw mode
  4286. */
  4287. static readonly MATERIAL_LineListDrawMode: number;
  4288. /**
  4289. * Returns the line loop draw mode
  4290. */
  4291. static readonly MATERIAL_LineLoopDrawMode: number;
  4292. /**
  4293. * Returns the line strip draw mode
  4294. */
  4295. static readonly MATERIAL_LineStripDrawMode: number;
  4296. /**
  4297. * Returns the triangle strip draw mode
  4298. */
  4299. static readonly MATERIAL_TriangleStripDrawMode: number;
  4300. /**
  4301. * Returns the triangle fan draw mode
  4302. */
  4303. static readonly MATERIAL_TriangleFanDrawMode: number;
  4304. /**
  4305. * Stores the clock-wise side orientation
  4306. */
  4307. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4308. /**
  4309. * Stores the counter clock-wise side orientation
  4310. */
  4311. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4312. /**
  4313. * Nothing
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_NothingTrigger: number;
  4317. /**
  4318. * On pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnPickTrigger: number;
  4322. /**
  4323. * On left pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnLeftPickTrigger: number;
  4327. /**
  4328. * On right pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnRightPickTrigger: number;
  4332. /**
  4333. * On center pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnCenterPickTrigger: number;
  4337. /**
  4338. * On pick down
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickDownTrigger: number;
  4342. /**
  4343. * On double pick
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnDoublePickTrigger: number;
  4347. /**
  4348. * On pick up
  4349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4350. */
  4351. static readonly ACTION_OnPickUpTrigger: number;
  4352. /**
  4353. * On pick out.
  4354. * This trigger will only be raised if you also declared a OnPickDown
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPickOutTrigger: number;
  4358. /**
  4359. * On long press
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnLongPressTrigger: number;
  4363. /**
  4364. * On pointer over
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOverTrigger: number;
  4368. /**
  4369. * On pointer out
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnPointerOutTrigger: number;
  4373. /**
  4374. * On every frame
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnEveryFrameTrigger: number;
  4378. /**
  4379. * On intersection enter
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4383. /**
  4384. * On intersection exit
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnIntersectionExitTrigger: number;
  4388. /**
  4389. * On key down
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyDownTrigger: number;
  4393. /**
  4394. * On key up
  4395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4396. */
  4397. static readonly ACTION_OnKeyUpTrigger: number;
  4398. /**
  4399. * Billboard mode will only apply to Y axis
  4400. */
  4401. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4402. /**
  4403. * Billboard mode will apply to all axes
  4404. */
  4405. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4406. /**
  4407. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4408. */
  4409. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4410. /**
  4411. * Gets or sets base Assets URL
  4412. */
  4413. static PARTICLES_BaseAssetsUrl: string;
  4414. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4415. * Test order :
  4416. * Is the bounding sphere outside the frustum ?
  4417. * If not, are the bounding box vertices outside the frustum ?
  4418. * It not, then the cullable object is in the frustum.
  4419. */
  4420. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4421. /** Culling strategy : Bounding Sphere Only.
  4422. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4423. * It's also less accurate than the standard because some not visible objects can still be selected.
  4424. * Test : is the bounding sphere outside the frustum ?
  4425. * If not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4428. /** Culling strategy : Optimistic Inclusion.
  4429. * This in an inclusion test first, then the standard exclusion test.
  4430. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4431. * 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.
  4432. * Anyway, it's as accurate as the standard strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the default culling strategy.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4438. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4439. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4440. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4441. * 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.
  4442. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4443. * Test :
  4444. * Is the cullable object bounding sphere center in the frustum ?
  4445. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4446. */
  4447. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4448. /**
  4449. * No logging while loading
  4450. */
  4451. static readonly SCENELOADER_NO_LOGGING: number;
  4452. /**
  4453. * Minimal logging while loading
  4454. */
  4455. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4456. /**
  4457. * Summary logging while loading
  4458. */
  4459. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4460. /**
  4461. * Detailled logging while loading
  4462. */
  4463. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4464. }
  4465. }
  4466. declare module "babylonjs/Engines/IPipelineContext" {
  4467. /**
  4468. * Class used to store and describe the pipeline context associated with an effect
  4469. */
  4470. export interface IPipelineContext {
  4471. /**
  4472. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4473. */
  4474. isAsync: boolean;
  4475. /**
  4476. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4477. */
  4478. isReady: boolean;
  4479. /** @hidden */
  4480. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4481. }
  4482. }
  4483. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4484. /** @hidden */
  4485. export interface IShaderProcessor {
  4486. attributeProcessor?: (attribute: string) => string;
  4487. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4488. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4489. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4490. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4491. lineProcessor?: (line: string, isFragment: boolean) => string;
  4492. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4493. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4494. }
  4495. }
  4496. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4497. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4498. /** @hidden */
  4499. export interface ProcessingOptions {
  4500. defines: string[];
  4501. indexParameters: any;
  4502. isFragment: boolean;
  4503. shouldUseHighPrecisionShader: boolean;
  4504. supportsUniformBuffers: boolean;
  4505. shadersRepository: string;
  4506. includesShadersStore: {
  4507. [key: string]: string;
  4508. };
  4509. processor?: IShaderProcessor;
  4510. version: string;
  4511. platformName: string;
  4512. lookForClosingBracketForUniformBuffer?: boolean;
  4513. }
  4514. }
  4515. declare module "babylonjs/Misc/stringTools" {
  4516. /**
  4517. * Helper to manipulate strings
  4518. */
  4519. export class StringTools {
  4520. /**
  4521. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4522. * @param str Source string
  4523. * @param suffix Suffix to search for in the source string
  4524. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4525. */
  4526. static EndsWith(str: string, suffix: string): boolean;
  4527. /**
  4528. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static StartsWith(str: string, suffix: string): boolean;
  4534. }
  4535. }
  4536. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4537. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4538. /** @hidden */
  4539. export class ShaderCodeNode {
  4540. line: string;
  4541. children: ShaderCodeNode[];
  4542. additionalDefineKey?: string;
  4543. additionalDefineValue?: string;
  4544. isValid(preprocessors: {
  4545. [key: string]: string;
  4546. }): boolean;
  4547. process(preprocessors: {
  4548. [key: string]: string;
  4549. }, options: ProcessingOptions): string;
  4550. }
  4551. }
  4552. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4553. /** @hidden */
  4554. export class ShaderCodeCursor {
  4555. private _lines;
  4556. lineIndex: number;
  4557. readonly currentLine: string;
  4558. readonly canRead: boolean;
  4559. lines: string[];
  4560. }
  4561. }
  4562. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4563. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4564. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4565. /** @hidden */
  4566. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4567. process(preprocessors: {
  4568. [key: string]: string;
  4569. }, options: ProcessingOptions): string;
  4570. }
  4571. }
  4572. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4573. /** @hidden */
  4574. export class ShaderDefineExpression {
  4575. isTrue(preprocessors: {
  4576. [key: string]: string;
  4577. }): boolean;
  4578. }
  4579. }
  4580. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4581. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4582. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4583. /** @hidden */
  4584. export class ShaderCodeTestNode extends ShaderCodeNode {
  4585. testExpression: ShaderDefineExpression;
  4586. isValid(preprocessors: {
  4587. [key: string]: string;
  4588. }): boolean;
  4589. }
  4590. }
  4591. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4592. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4593. /** @hidden */
  4594. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4595. define: string;
  4596. not: boolean;
  4597. constructor(define: string, not?: boolean);
  4598. isTrue(preprocessors: {
  4599. [key: string]: string;
  4600. }): boolean;
  4601. }
  4602. }
  4603. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4604. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4605. /** @hidden */
  4606. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4607. leftOperand: ShaderDefineExpression;
  4608. rightOperand: ShaderDefineExpression;
  4609. isTrue(preprocessors: {
  4610. [key: string]: string;
  4611. }): boolean;
  4612. }
  4613. }
  4614. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4615. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4616. /** @hidden */
  4617. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4618. leftOperand: ShaderDefineExpression;
  4619. rightOperand: ShaderDefineExpression;
  4620. isTrue(preprocessors: {
  4621. [key: string]: string;
  4622. }): boolean;
  4623. }
  4624. }
  4625. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4626. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4627. /** @hidden */
  4628. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4629. define: string;
  4630. operand: string;
  4631. testValue: string;
  4632. constructor(define: string, operand: string, testValue: string);
  4633. isTrue(preprocessors: {
  4634. [key: string]: string;
  4635. }): boolean;
  4636. }
  4637. }
  4638. declare module "babylonjs/Misc/loadFileError" {
  4639. import { WebRequest } from "babylonjs/Misc/webRequest";
  4640. /**
  4641. * @ignore
  4642. * Application error to support additional information when loading a file
  4643. */
  4644. export class LoadFileError extends Error {
  4645. /** defines the optional web request */
  4646. request?: WebRequest | undefined;
  4647. private static _setPrototypeOf;
  4648. /**
  4649. * Creates a new LoadFileError
  4650. * @param message defines the message of the error
  4651. * @param request defines the optional web request
  4652. */
  4653. constructor(message: string,
  4654. /** defines the optional web request */
  4655. request?: WebRequest | undefined);
  4656. }
  4657. }
  4658. declare module "babylonjs/Offline/IOfflineProvider" {
  4659. /**
  4660. * Class used to enable access to offline support
  4661. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4662. */
  4663. export interface IOfflineProvider {
  4664. /**
  4665. * Gets a boolean indicating if scene must be saved in the database
  4666. */
  4667. enableSceneOffline: boolean;
  4668. /**
  4669. * Gets a boolean indicating if textures must be saved in the database
  4670. */
  4671. enableTexturesOffline: boolean;
  4672. /**
  4673. * Open the offline support and make it available
  4674. * @param successCallback defines the callback to call on success
  4675. * @param errorCallback defines the callback to call on error
  4676. */
  4677. open(successCallback: () => void, errorCallback: () => void): void;
  4678. /**
  4679. * Loads an image from the offline support
  4680. * @param url defines the url to load from
  4681. * @param image defines the target DOM image
  4682. */
  4683. loadImage(url: string, image: HTMLImageElement): void;
  4684. /**
  4685. * Loads a file from offline support
  4686. * @param url defines the URL to load from
  4687. * @param sceneLoaded defines a callback to call on success
  4688. * @param progressCallBack defines a callback to call when progress changed
  4689. * @param errorCallback defines a callback to call on error
  4690. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4691. */
  4692. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4693. }
  4694. }
  4695. declare module "babylonjs/Misc/filesInputStore" {
  4696. /**
  4697. * Class used to help managing file picking and drag'n'drop
  4698. * File Storage
  4699. */
  4700. export class FilesInputStore {
  4701. /**
  4702. * List of files ready to be loaded
  4703. */
  4704. static FilesToLoad: {
  4705. [key: string]: File;
  4706. };
  4707. }
  4708. }
  4709. declare module "babylonjs/Misc/retryStrategy" {
  4710. import { WebRequest } from "babylonjs/Misc/webRequest";
  4711. /**
  4712. * Class used to define a retry strategy when error happens while loading assets
  4713. */
  4714. export class RetryStrategy {
  4715. /**
  4716. * Function used to defines an exponential back off strategy
  4717. * @param maxRetries defines the maximum number of retries (3 by default)
  4718. * @param baseInterval defines the interval between retries
  4719. * @returns the strategy function to use
  4720. */
  4721. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4722. }
  4723. }
  4724. declare module "babylonjs/Misc/fileTools" {
  4725. import { WebRequest } from "babylonjs/Misc/webRequest";
  4726. import { Nullable } from "babylonjs/types";
  4727. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4728. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4729. /**
  4730. * @hidden
  4731. */
  4732. export class FileTools {
  4733. /**
  4734. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4735. */
  4736. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4737. /**
  4738. * Gets or sets the base URL to use to load assets
  4739. */
  4740. static BaseUrl: string;
  4741. /**
  4742. * Default behaviour for cors in the application.
  4743. * It can be a string if the expected behavior is identical in the entire app.
  4744. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4745. */
  4746. static CorsBehavior: string | ((url: string | string[]) => string);
  4747. /**
  4748. * Gets or sets a function used to pre-process url before using them to load assets
  4749. */
  4750. static PreprocessUrl: (url: string) => string;
  4751. /**
  4752. * Removes unwanted characters from an url
  4753. * @param url defines the url to clean
  4754. * @returns the cleaned url
  4755. */
  4756. private static _CleanUrl;
  4757. /**
  4758. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4759. * @param url define the url we are trying
  4760. * @param element define the dom element where to configure the cors policy
  4761. */
  4762. static SetCorsBehavior(url: string | string[], element: {
  4763. crossOrigin: string | null;
  4764. }): void;
  4765. /**
  4766. * Loads an image as an HTMLImageElement.
  4767. * @param input url string, ArrayBuffer, or Blob to load
  4768. * @param onLoad callback called when the image successfully loads
  4769. * @param onError callback called when the image fails to load
  4770. * @param offlineProvider offline provider for caching
  4771. * @returns the HTMLImageElement of the loaded image
  4772. */
  4773. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4774. /**
  4775. * Loads a file
  4776. * @param fileToLoad defines the file to load
  4777. * @param callback defines the callback to call when data is loaded
  4778. * @param progressCallBack defines the callback to call during loading process
  4779. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4780. * @returns a file request object
  4781. */
  4782. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4783. /**
  4784. * Loads a file
  4785. * @param url url string, ArrayBuffer, or Blob to load
  4786. * @param onSuccess callback called when the file successfully loads
  4787. * @param onProgress callback called while file is loading (if the server supports this mode)
  4788. * @param offlineProvider defines the offline provider for caching
  4789. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4790. * @param onError callback called when the file fails to load
  4791. * @returns a file request object
  4792. */
  4793. 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;
  4794. /**
  4795. * Checks if the loaded document was accessed via `file:`-Protocol.
  4796. * @returns boolean
  4797. */
  4798. static IsFileURL(): boolean;
  4799. }
  4800. }
  4801. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4802. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4803. /** @hidden */
  4804. export class ShaderProcessor {
  4805. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4806. private static _ProcessPrecision;
  4807. private static _ExtractOperation;
  4808. private static _BuildSubExpression;
  4809. private static _BuildExpression;
  4810. private static _MoveCursorWithinIf;
  4811. private static _MoveCursor;
  4812. private static _EvaluatePreProcessors;
  4813. private static _PreparePreProcessors;
  4814. private static _ProcessShaderConversion;
  4815. private static _ProcessIncludes;
  4816. }
  4817. }
  4818. declare module "babylonjs/Maths/math.color" {
  4819. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4820. /**
  4821. * Class used to hold a RBG color
  4822. */
  4823. export class Color3 {
  4824. /**
  4825. * Defines the red component (between 0 and 1, default is 0)
  4826. */
  4827. r: number;
  4828. /**
  4829. * Defines the green component (between 0 and 1, default is 0)
  4830. */
  4831. g: number;
  4832. /**
  4833. * Defines the blue component (between 0 and 1, default is 0)
  4834. */
  4835. b: number;
  4836. /**
  4837. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4838. * @param r defines the red component (between 0 and 1, default is 0)
  4839. * @param g defines the green component (between 0 and 1, default is 0)
  4840. * @param b defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. constructor(
  4843. /**
  4844. * Defines the red component (between 0 and 1, default is 0)
  4845. */
  4846. r?: number,
  4847. /**
  4848. * Defines the green component (between 0 and 1, default is 0)
  4849. */
  4850. g?: number,
  4851. /**
  4852. * Defines the blue component (between 0 and 1, default is 0)
  4853. */
  4854. b?: number);
  4855. /**
  4856. * Creates a string with the Color3 current values
  4857. * @returns the string representation of the Color3 object
  4858. */
  4859. toString(): string;
  4860. /**
  4861. * Returns the string "Color3"
  4862. * @returns "Color3"
  4863. */
  4864. getClassName(): string;
  4865. /**
  4866. * Compute the Color3 hash code
  4867. * @returns an unique number that can be used to hash Color3 objects
  4868. */
  4869. getHashCode(): number;
  4870. /**
  4871. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4872. * @param array defines the array where to store the r,g,b components
  4873. * @param index defines an optional index in the target array to define where to start storing values
  4874. * @returns the current Color3 object
  4875. */
  4876. toArray(array: FloatArray, index?: number): Color3;
  4877. /**
  4878. * Returns a new Color4 object from the current Color3 and the given alpha
  4879. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4880. * @returns a new Color4 object
  4881. */
  4882. toColor4(alpha?: number): Color4;
  4883. /**
  4884. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4885. * @returns the new array
  4886. */
  4887. asArray(): number[];
  4888. /**
  4889. * Returns the luminance value
  4890. * @returns a float value
  4891. */
  4892. toLuminance(): number;
  4893. /**
  4894. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4895. * @param otherColor defines the second operand
  4896. * @returns the new Color3 object
  4897. */
  4898. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4899. /**
  4900. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4901. * @param otherColor defines the second operand
  4902. * @param result defines the Color3 object where to store the result
  4903. * @returns the current Color3
  4904. */
  4905. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4906. /**
  4907. * Determines equality between Color3 objects
  4908. * @param otherColor defines the second operand
  4909. * @returns true if the rgb values are equal to the given ones
  4910. */
  4911. equals(otherColor: DeepImmutable<Color3>): boolean;
  4912. /**
  4913. * Determines equality between the current Color3 object and a set of r,b,g values
  4914. * @param r defines the red component to check
  4915. * @param g defines the green component to check
  4916. * @param b defines the blue component to check
  4917. * @returns true if the rgb values are equal to the given ones
  4918. */
  4919. equalsFloats(r: number, g: number, b: number): boolean;
  4920. /**
  4921. * Multiplies in place each rgb value by scale
  4922. * @param scale defines the scaling factor
  4923. * @returns the updated Color3
  4924. */
  4925. scale(scale: number): Color3;
  4926. /**
  4927. * Multiplies the rgb values by scale and stores the result into "result"
  4928. * @param scale defines the scaling factor
  4929. * @param result defines the Color3 object where to store the result
  4930. * @returns the unmodified current Color3
  4931. */
  4932. scaleToRef(scale: number, result: Color3): Color3;
  4933. /**
  4934. * Scale the current Color3 values by a factor and add the result to a given Color3
  4935. * @param scale defines the scale factor
  4936. * @param result defines color to store the result into
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Clamps the rgb values by the min and max values and stores the result into "result"
  4942. * @param min defines minimum clamping value (default is 0)
  4943. * @param max defines maximum clamping value (default is 1)
  4944. * @param result defines color to store the result into
  4945. * @returns the original Color3
  4946. */
  4947. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4948. /**
  4949. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4950. * @param otherColor defines the second operand
  4951. * @returns the new Color3
  4952. */
  4953. add(otherColor: DeepImmutable<Color3>): Color3;
  4954. /**
  4955. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4956. * @param otherColor defines the second operand
  4957. * @param result defines Color3 object to store the result into
  4958. * @returns the unmodified current Color3
  4959. */
  4960. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4961. /**
  4962. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4963. * @param otherColor defines the second operand
  4964. * @returns the new Color3
  4965. */
  4966. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4967. /**
  4968. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4969. * @param otherColor defines the second operand
  4970. * @param result defines Color3 object to store the result into
  4971. * @returns the unmodified current Color3
  4972. */
  4973. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4974. /**
  4975. * Copy the current object
  4976. * @returns a new Color3 copied the current one
  4977. */
  4978. clone(): Color3;
  4979. /**
  4980. * Copies the rgb values from the source in the current Color3
  4981. * @param source defines the source Color3 object
  4982. * @returns the updated Color3 object
  4983. */
  4984. copyFrom(source: DeepImmutable<Color3>): Color3;
  4985. /**
  4986. * Updates the Color3 rgb values from the given floats
  4987. * @param r defines the red component to read from
  4988. * @param g defines the green component to read from
  4989. * @param b defines the blue component to read from
  4990. * @returns the current Color3 object
  4991. */
  4992. copyFromFloats(r: number, g: number, b: number): Color3;
  4993. /**
  4994. * Updates the Color3 rgb values from the given floats
  4995. * @param r defines the red component to read from
  4996. * @param g defines the green component to read from
  4997. * @param b defines the blue component to read from
  4998. * @returns the current Color3 object
  4999. */
  5000. set(r: number, g: number, b: number): Color3;
  5001. /**
  5002. * Compute the Color3 hexadecimal code as a string
  5003. * @returns a string containing the hexadecimal representation of the Color3 object
  5004. */
  5005. toHexString(): string;
  5006. /**
  5007. * Computes a new Color3 converted from the current one to linear space
  5008. * @returns a new Color3 object
  5009. */
  5010. toLinearSpace(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @returns a new color3 representing the HSV values
  5014. */
  5015. toHSV(): Color3;
  5016. /**
  5017. * Converts current color in rgb space to HSV values
  5018. * @param result defines the Color3 where to store the HSV values
  5019. */
  5020. toHSVToRef(result: Color3): void;
  5021. /**
  5022. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5023. * @param convertedColor defines the Color3 object where to store the linear space version
  5024. * @returns the unmodified Color3
  5025. */
  5026. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5027. /**
  5028. * Computes a new Color3 converted from the current one to gamma space
  5029. * @returns a new Color3 object
  5030. */
  5031. toGammaSpace(): Color3;
  5032. /**
  5033. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5034. * @param convertedColor defines the Color3 object where to store the gamma space version
  5035. * @returns the unmodified Color3
  5036. */
  5037. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5038. private static _BlackReadOnly;
  5039. /**
  5040. * Convert Hue, saturation and value to a Color3 (RGB)
  5041. * @param hue defines the hue
  5042. * @param saturation defines the saturation
  5043. * @param value defines the value
  5044. * @param result defines the Color3 where to store the RGB values
  5045. */
  5046. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5047. /**
  5048. * Creates a new Color3 from the string containing valid hexadecimal values
  5049. * @param hex defines a string containing valid hexadecimal values
  5050. * @returns a new Color3 object
  5051. */
  5052. static FromHexString(hex: string): Color3;
  5053. /**
  5054. * Creates a new Color3 from the starting index of the given array
  5055. * @param array defines the source array
  5056. * @param offset defines an offset in the source array
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5060. /**
  5061. * Creates a new Color3 from integer values (< 256)
  5062. * @param r defines the red component to read from (value between 0 and 255)
  5063. * @param g defines the green component to read from (value between 0 and 255)
  5064. * @param b defines the blue component to read from (value between 0 and 255)
  5065. * @returns a new Color3 object
  5066. */
  5067. static FromInts(r: number, g: number, b: number): Color3;
  5068. /**
  5069. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5070. * @param start defines the start Color3 value
  5071. * @param end defines the end Color3 value
  5072. * @param amount defines the gradient value between start and end
  5073. * @returns a new Color3 object
  5074. */
  5075. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5076. /**
  5077. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5078. * @param left defines the start value
  5079. * @param right defines the end value
  5080. * @param amount defines the gradient factor
  5081. * @param result defines the Color3 object where to store the result
  5082. */
  5083. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5084. /**
  5085. * Returns a Color3 value containing a red color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Red(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a green color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Green(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a blue color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Blue(): Color3;
  5099. /**
  5100. * Returns a Color3 value containing a black color
  5101. * @returns a new Color3 object
  5102. */
  5103. static Black(): Color3;
  5104. /**
  5105. * Gets a Color3 value containing a black color that must not be updated
  5106. */
  5107. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5108. /**
  5109. * Returns a Color3 value containing a white color
  5110. * @returns a new Color3 object
  5111. */
  5112. static White(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a purple color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Purple(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a magenta color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Magenta(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a yellow color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Yellow(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a gray color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Gray(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a teal color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Teal(): Color3;
  5138. /**
  5139. * Returns a Color3 value containing a random color
  5140. * @returns a new Color3 object
  5141. */
  5142. static Random(): Color3;
  5143. }
  5144. /**
  5145. * Class used to hold a RBGA color
  5146. */
  5147. export class Color4 {
  5148. /**
  5149. * Defines the red component (between 0 and 1, default is 0)
  5150. */
  5151. r: number;
  5152. /**
  5153. * Defines the green component (between 0 and 1, default is 0)
  5154. */
  5155. g: number;
  5156. /**
  5157. * Defines the blue component (between 0 and 1, default is 0)
  5158. */
  5159. b: number;
  5160. /**
  5161. * Defines the alpha component (between 0 and 1, default is 1)
  5162. */
  5163. a: number;
  5164. /**
  5165. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5166. * @param r defines the red component (between 0 and 1, default is 0)
  5167. * @param g defines the green component (between 0 and 1, default is 0)
  5168. * @param b defines the blue component (between 0 and 1, default is 0)
  5169. * @param a defines the alpha component (between 0 and 1, default is 1)
  5170. */
  5171. constructor(
  5172. /**
  5173. * Defines the red component (between 0 and 1, default is 0)
  5174. */
  5175. r?: number,
  5176. /**
  5177. * Defines the green component (between 0 and 1, default is 0)
  5178. */
  5179. g?: number,
  5180. /**
  5181. * Defines the blue component (between 0 and 1, default is 0)
  5182. */
  5183. b?: number,
  5184. /**
  5185. * Defines the alpha component (between 0 and 1, default is 1)
  5186. */
  5187. a?: number);
  5188. /**
  5189. * Adds in place the given Color4 values to the current Color4 object
  5190. * @param right defines the second operand
  5191. * @returns the current updated Color4 object
  5192. */
  5193. addInPlace(right: DeepImmutable<Color4>): Color4;
  5194. /**
  5195. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5196. * @returns the new array
  5197. */
  5198. asArray(): number[];
  5199. /**
  5200. * Stores from the starting index in the given array the Color4 successive values
  5201. * @param array defines the array where to store the r,g,b components
  5202. * @param index defines an optional index in the target array to define where to start storing values
  5203. * @returns the current Color4 object
  5204. */
  5205. toArray(array: number[], index?: number): Color4;
  5206. /**
  5207. * Determines equality between Color4 objects
  5208. * @param otherColor defines the second operand
  5209. * @returns true if the rgba values are equal to the given ones
  5210. */
  5211. equals(otherColor: DeepImmutable<Color4>): boolean;
  5212. /**
  5213. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5214. * @param right defines the second operand
  5215. * @returns a new Color4 object
  5216. */
  5217. add(right: DeepImmutable<Color4>): Color4;
  5218. /**
  5219. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5220. * @param right defines the second operand
  5221. * @returns a new Color4 object
  5222. */
  5223. subtract(right: DeepImmutable<Color4>): Color4;
  5224. /**
  5225. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5226. * @param right defines the second operand
  5227. * @param result defines the Color4 object where to store the result
  5228. * @returns the current Color4 object
  5229. */
  5230. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5231. /**
  5232. * Creates a new Color4 with the current Color4 values multiplied by scale
  5233. * @param scale defines the scaling factor to apply
  5234. * @returns a new Color4 object
  5235. */
  5236. scale(scale: number): Color4;
  5237. /**
  5238. * Multiplies the current Color4 values by scale and stores the result in "result"
  5239. * @param scale defines the scaling factor to apply
  5240. * @param result defines the Color4 object where to store the result
  5241. * @returns the current unmodified Color4
  5242. */
  5243. scaleToRef(scale: number, result: Color4): Color4;
  5244. /**
  5245. * Scale the current Color4 values by a factor and add the result to a given Color4
  5246. * @param scale defines the scale factor
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the unmodified current Color4
  5249. */
  5250. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Clamps the rgb values by the min and max values and stores the result into "result"
  5253. * @param min defines minimum clamping value (default is 0)
  5254. * @param max defines maximum clamping value (default is 1)
  5255. * @param result defines color to store the result into.
  5256. * @returns the cuurent Color4
  5257. */
  5258. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5259. /**
  5260. * Multipy an Color4 value by another and return a new Color4 object
  5261. * @param color defines the Color4 value to multiply by
  5262. * @returns a new Color4 object
  5263. */
  5264. multiply(color: Color4): Color4;
  5265. /**
  5266. * Multipy a Color4 value by another and push the result in a reference value
  5267. * @param color defines the Color4 value to multiply by
  5268. * @param result defines the Color4 to fill the result in
  5269. * @returns the result Color4
  5270. */
  5271. multiplyToRef(color: Color4, result: Color4): Color4;
  5272. /**
  5273. * Creates a string with the Color4 current values
  5274. * @returns the string representation of the Color4 object
  5275. */
  5276. toString(): string;
  5277. /**
  5278. * Returns the string "Color4"
  5279. * @returns "Color4"
  5280. */
  5281. getClassName(): string;
  5282. /**
  5283. * Compute the Color4 hash code
  5284. * @returns an unique number that can be used to hash Color4 objects
  5285. */
  5286. getHashCode(): number;
  5287. /**
  5288. * Creates a new Color4 copied from the current one
  5289. * @returns a new Color4 object
  5290. */
  5291. clone(): Color4;
  5292. /**
  5293. * Copies the given Color4 values into the current one
  5294. * @param source defines the source Color4 object
  5295. * @returns the current updated Color4 object
  5296. */
  5297. copyFrom(source: Color4): Color4;
  5298. /**
  5299. * Copies the given float values into the current one
  5300. * @param r defines the red component to read from
  5301. * @param g defines the green component to read from
  5302. * @param b defines the blue component to read from
  5303. * @param a defines the alpha component to read from
  5304. * @returns the current updated Color4 object
  5305. */
  5306. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5307. /**
  5308. * Copies the given float values into the current one
  5309. * @param r defines the red component to read from
  5310. * @param g defines the green component to read from
  5311. * @param b defines the blue component to read from
  5312. * @param a defines the alpha component to read from
  5313. * @returns the current updated Color4 object
  5314. */
  5315. set(r: number, g: number, b: number, a: number): Color4;
  5316. /**
  5317. * Compute the Color4 hexadecimal code as a string
  5318. * @returns a string containing the hexadecimal representation of the Color4 object
  5319. */
  5320. toHexString(): string;
  5321. /**
  5322. * Computes a new Color4 converted from the current one to linear space
  5323. * @returns a new Color4 object
  5324. */
  5325. toLinearSpace(): Color4;
  5326. /**
  5327. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5328. * @param convertedColor defines the Color4 object where to store the linear space version
  5329. * @returns the unmodified Color4
  5330. */
  5331. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5332. /**
  5333. * Computes a new Color4 converted from the current one to gamma space
  5334. * @returns a new Color4 object
  5335. */
  5336. toGammaSpace(): Color4;
  5337. /**
  5338. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5339. * @param convertedColor defines the Color4 object where to store the gamma space version
  5340. * @returns the unmodified Color4
  5341. */
  5342. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5343. /**
  5344. * Creates a new Color4 from the string containing valid hexadecimal values
  5345. * @param hex defines a string containing valid hexadecimal values
  5346. * @returns a new Color4 object
  5347. */
  5348. static FromHexString(hex: string): Color4;
  5349. /**
  5350. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5351. * @param left defines the start value
  5352. * @param right defines the end value
  5353. * @param amount defines the gradient factor
  5354. * @returns a new Color4 object
  5355. */
  5356. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5357. /**
  5358. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  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 Color4 object where to store data
  5363. */
  5364. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5365. /**
  5366. * Creates a new Color4 from a Color3 and an alpha value
  5367. * @param color3 defines the source Color3 to read from
  5368. * @param alpha defines the alpha component (1.0 by default)
  5369. * @returns a new Color4 object
  5370. */
  5371. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5372. /**
  5373. * Creates a new Color4 from the starting index element of the given array
  5374. * @param array defines the source array to read from
  5375. * @param offset defines the offset in the source array
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5379. /**
  5380. * Creates a new Color3 from integer values (< 256)
  5381. * @param r defines the red component to read from (value between 0 and 255)
  5382. * @param g defines the green component to read from (value between 0 and 255)
  5383. * @param b defines the blue component to read from (value between 0 and 255)
  5384. * @param a defines the alpha component to read from (value between 0 and 255)
  5385. * @returns a new Color3 object
  5386. */
  5387. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5388. /**
  5389. * Check the content of a given array and convert it to an array containing RGBA data
  5390. * If the original array was already containing count * 4 values then it is returned directly
  5391. * @param colors defines the array to check
  5392. * @param count defines the number of RGBA data to expect
  5393. * @returns an array containing count * 4 values (RGBA)
  5394. */
  5395. static CheckColors4(colors: number[], count: number): number[];
  5396. }
  5397. /**
  5398. * @hidden
  5399. */
  5400. export class TmpColors {
  5401. static Color3: Color3[];
  5402. static Color4: Color4[];
  5403. }
  5404. }
  5405. declare module "babylonjs/Maths/sphericalPolynomial" {
  5406. import { Vector3 } from "babylonjs/Maths/math.vector";
  5407. import { Color3 } from "babylonjs/Maths/math.color";
  5408. /**
  5409. * Class representing spherical harmonics coefficients to the 3rd degree
  5410. */
  5411. export class SphericalHarmonics {
  5412. /**
  5413. * Defines whether or not the harmonics have been prescaled for rendering.
  5414. */
  5415. preScaled: boolean;
  5416. /**
  5417. * The l0,0 coefficients of the spherical harmonics
  5418. */
  5419. l00: Vector3;
  5420. /**
  5421. * The l1,-1 coefficients of the spherical harmonics
  5422. */
  5423. l1_1: Vector3;
  5424. /**
  5425. * The l1,0 coefficients of the spherical harmonics
  5426. */
  5427. l10: Vector3;
  5428. /**
  5429. * The l1,1 coefficients of the spherical harmonics
  5430. */
  5431. l11: Vector3;
  5432. /**
  5433. * The l2,-2 coefficients of the spherical harmonics
  5434. */
  5435. l2_2: Vector3;
  5436. /**
  5437. * The l2,-1 coefficients of the spherical harmonics
  5438. */
  5439. l2_1: Vector3;
  5440. /**
  5441. * The l2,0 coefficients of the spherical harmonics
  5442. */
  5443. l20: Vector3;
  5444. /**
  5445. * The l2,1 coefficients of the spherical harmonics
  5446. */
  5447. l21: Vector3;
  5448. /**
  5449. * The l2,2 coefficients of the spherical harmonics
  5450. */
  5451. l22: Vector3;
  5452. /**
  5453. * Adds a light to the spherical harmonics
  5454. * @param direction the direction of the light
  5455. * @param color the color of the light
  5456. * @param deltaSolidAngle the delta solid angle of the light
  5457. */
  5458. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5459. /**
  5460. * Scales the spherical harmonics by the given amount
  5461. * @param scale the amount to scale
  5462. */
  5463. scaleInPlace(scale: number): void;
  5464. /**
  5465. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5466. *
  5467. * ```
  5468. * E_lm = A_l * L_lm
  5469. * ```
  5470. *
  5471. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5472. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5473. * the scaling factors are given in equation 9.
  5474. */
  5475. convertIncidentRadianceToIrradiance(): void;
  5476. /**
  5477. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5478. *
  5479. * ```
  5480. * L = (1/pi) * E * rho
  5481. * ```
  5482. *
  5483. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5484. */
  5485. convertIrradianceToLambertianRadiance(): void;
  5486. /**
  5487. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5488. * required operations at run time.
  5489. *
  5490. * This is simply done by scaling back the SH with Ylm constants parameter.
  5491. * The trigonometric part being applied by the shader at run time.
  5492. */
  5493. preScaleForRendering(): void;
  5494. /**
  5495. * Constructs a spherical harmonics from an array.
  5496. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5497. * @returns the spherical harmonics
  5498. */
  5499. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5500. /**
  5501. * Gets the spherical harmonics from polynomial
  5502. * @param polynomial the spherical polynomial
  5503. * @returns the spherical harmonics
  5504. */
  5505. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5506. }
  5507. /**
  5508. * Class representing spherical polynomial coefficients to the 3rd degree
  5509. */
  5510. export class SphericalPolynomial {
  5511. private _harmonics;
  5512. /**
  5513. * The spherical harmonics used to create the polynomials.
  5514. */
  5515. readonly preScaledHarmonics: SphericalHarmonics;
  5516. /**
  5517. * The x coefficients of the spherical polynomial
  5518. */
  5519. x: Vector3;
  5520. /**
  5521. * The y coefficients of the spherical polynomial
  5522. */
  5523. y: Vector3;
  5524. /**
  5525. * The z coefficients of the spherical polynomial
  5526. */
  5527. z: Vector3;
  5528. /**
  5529. * The xx coefficients of the spherical polynomial
  5530. */
  5531. xx: Vector3;
  5532. /**
  5533. * The yy coefficients of the spherical polynomial
  5534. */
  5535. yy: Vector3;
  5536. /**
  5537. * The zz coefficients of the spherical polynomial
  5538. */
  5539. zz: Vector3;
  5540. /**
  5541. * The xy coefficients of the spherical polynomial
  5542. */
  5543. xy: Vector3;
  5544. /**
  5545. * The yz coefficients of the spherical polynomial
  5546. */
  5547. yz: Vector3;
  5548. /**
  5549. * The zx coefficients of the spherical polynomial
  5550. */
  5551. zx: Vector3;
  5552. /**
  5553. * Adds an ambient color to the spherical polynomial
  5554. * @param color the color to add
  5555. */
  5556. addAmbient(color: Color3): void;
  5557. /**
  5558. * Scales the spherical polynomial by the given amount
  5559. * @param scale the amount to scale
  5560. */
  5561. scaleInPlace(scale: number): void;
  5562. /**
  5563. * Gets the spherical polynomial from harmonics
  5564. * @param harmonics the spherical harmonics
  5565. * @returns the spherical polynomial
  5566. */
  5567. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5568. /**
  5569. * Constructs a spherical polynomial from an array.
  5570. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5571. * @returns the spherical polynomial
  5572. */
  5573. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5574. }
  5575. }
  5576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5577. /**
  5578. * Define options used to create a render target texture
  5579. */
  5580. export class RenderTargetCreationOptions {
  5581. /**
  5582. * Specifies is mipmaps must be generated
  5583. */
  5584. generateMipMaps?: boolean;
  5585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5586. generateDepthBuffer?: boolean;
  5587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5588. generateStencilBuffer?: boolean;
  5589. /** Defines texture type (int by default) */
  5590. type?: number;
  5591. /** Defines sampling mode (trilinear by default) */
  5592. samplingMode?: number;
  5593. /** Defines format (RGBA by default) */
  5594. format?: number;
  5595. }
  5596. }
  5597. declare module "babylonjs/States/alphaCullingState" {
  5598. /**
  5599. * @hidden
  5600. **/
  5601. export class _AlphaState {
  5602. private _isAlphaBlendDirty;
  5603. private _isBlendFunctionParametersDirty;
  5604. private _isBlendEquationParametersDirty;
  5605. private _isBlendConstantsDirty;
  5606. private _alphaBlend;
  5607. private _blendFunctionParameters;
  5608. private _blendEquationParameters;
  5609. private _blendConstants;
  5610. /**
  5611. * Initializes the state.
  5612. */
  5613. constructor();
  5614. readonly isDirty: boolean;
  5615. alphaBlend: boolean;
  5616. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5617. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5618. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5619. reset(): void;
  5620. apply(gl: WebGLRenderingContext): void;
  5621. }
  5622. }
  5623. declare module "babylonjs/States/depthCullingState" {
  5624. import { Nullable } from "babylonjs/types";
  5625. /**
  5626. * @hidden
  5627. **/
  5628. export class _DepthCullingState {
  5629. private _isDepthTestDirty;
  5630. private _isDepthMaskDirty;
  5631. private _isDepthFuncDirty;
  5632. private _isCullFaceDirty;
  5633. private _isCullDirty;
  5634. private _isZOffsetDirty;
  5635. private _isFrontFaceDirty;
  5636. private _depthTest;
  5637. private _depthMask;
  5638. private _depthFunc;
  5639. private _cull;
  5640. private _cullFace;
  5641. private _zOffset;
  5642. private _frontFace;
  5643. /**
  5644. * Initializes the state.
  5645. */
  5646. constructor();
  5647. readonly isDirty: boolean;
  5648. zOffset: number;
  5649. cullFace: Nullable<number>;
  5650. cull: Nullable<boolean>;
  5651. depthFunc: Nullable<number>;
  5652. depthMask: boolean;
  5653. depthTest: boolean;
  5654. frontFace: Nullable<number>;
  5655. reset(): void;
  5656. apply(gl: WebGLRenderingContext): void;
  5657. }
  5658. }
  5659. declare module "babylonjs/States/stencilState" {
  5660. /**
  5661. * @hidden
  5662. **/
  5663. export class _StencilState {
  5664. /** 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 */
  5665. static readonly ALWAYS: number;
  5666. /** Passed to stencilOperation to specify that stencil value must be kept */
  5667. static readonly KEEP: number;
  5668. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5669. static readonly REPLACE: number;
  5670. private _isStencilTestDirty;
  5671. private _isStencilMaskDirty;
  5672. private _isStencilFuncDirty;
  5673. private _isStencilOpDirty;
  5674. private _stencilTest;
  5675. private _stencilMask;
  5676. private _stencilFunc;
  5677. private _stencilFuncRef;
  5678. private _stencilFuncMask;
  5679. private _stencilOpStencilFail;
  5680. private _stencilOpDepthFail;
  5681. private _stencilOpStencilDepthPass;
  5682. readonly isDirty: boolean;
  5683. stencilFunc: number;
  5684. stencilFuncRef: number;
  5685. stencilFuncMask: number;
  5686. stencilOpStencilFail: number;
  5687. stencilOpDepthFail: number;
  5688. stencilOpStencilDepthPass: number;
  5689. stencilMask: number;
  5690. stencilTest: boolean;
  5691. constructor();
  5692. reset(): void;
  5693. apply(gl: WebGLRenderingContext): void;
  5694. }
  5695. }
  5696. declare module "babylonjs/States/index" {
  5697. export * from "babylonjs/States/alphaCullingState";
  5698. export * from "babylonjs/States/depthCullingState";
  5699. export * from "babylonjs/States/stencilState";
  5700. }
  5701. declare module "babylonjs/Instrumentation/timeToken" {
  5702. import { Nullable } from "babylonjs/types";
  5703. /**
  5704. * @hidden
  5705. **/
  5706. export class _TimeToken {
  5707. _startTimeQuery: Nullable<WebGLQuery>;
  5708. _endTimeQuery: Nullable<WebGLQuery>;
  5709. _timeElapsedQuery: Nullable<WebGLQuery>;
  5710. _timeElapsedQueryEnded: boolean;
  5711. }
  5712. }
  5713. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5714. /**
  5715. * Class used to evalaute queries containing `and` and `or` operators
  5716. */
  5717. export class AndOrNotEvaluator {
  5718. /**
  5719. * Evaluate a query
  5720. * @param query defines the query to evaluate
  5721. * @param evaluateCallback defines the callback used to filter result
  5722. * @returns true if the query matches
  5723. */
  5724. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5725. private static _HandleParenthesisContent;
  5726. private static _SimplifyNegation;
  5727. }
  5728. }
  5729. declare module "babylonjs/Misc/tags" {
  5730. /**
  5731. * Class used to store custom tags
  5732. */
  5733. export class Tags {
  5734. /**
  5735. * Adds support for tags on the given object
  5736. * @param obj defines the object to use
  5737. */
  5738. static EnableFor(obj: any): void;
  5739. /**
  5740. * Removes tags support
  5741. * @param obj defines the object to use
  5742. */
  5743. static DisableFor(obj: any): void;
  5744. /**
  5745. * Gets a boolean indicating if the given object has tags
  5746. * @param obj defines the object to use
  5747. * @returns a boolean
  5748. */
  5749. static HasTags(obj: any): boolean;
  5750. /**
  5751. * Gets the tags available on a given object
  5752. * @param obj defines the object to use
  5753. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5754. * @returns the tags
  5755. */
  5756. static GetTags(obj: any, asString?: boolean): any;
  5757. /**
  5758. * Adds tags to an object
  5759. * @param obj defines the object to use
  5760. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5761. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5762. */
  5763. static AddTagsTo(obj: any, tagsString: string): void;
  5764. /**
  5765. * @hidden
  5766. */
  5767. static _AddTagTo(obj: any, tag: string): void;
  5768. /**
  5769. * Removes specific tags from a specific object
  5770. * @param obj defines the object to use
  5771. * @param tagsString defines the tags to remove
  5772. */
  5773. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5774. /**
  5775. * @hidden
  5776. */
  5777. static _RemoveTagFrom(obj: any, tag: string): void;
  5778. /**
  5779. * Defines if tags hosted on an object match a given query
  5780. * @param obj defines the object to use
  5781. * @param tagsQuery defines the tag query
  5782. * @returns a boolean
  5783. */
  5784. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5785. }
  5786. }
  5787. declare module "babylonjs/Maths/math.path" {
  5788. import { DeepImmutable, Nullable } from "babylonjs/types";
  5789. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5790. /**
  5791. * Defines potential orientation for back face culling
  5792. */
  5793. export enum Orientation {
  5794. /**
  5795. * Clockwise
  5796. */
  5797. CW = 0,
  5798. /** Counter clockwise */
  5799. CCW = 1
  5800. }
  5801. /** Class used to represent a Bezier curve */
  5802. export class BezierCurve {
  5803. /**
  5804. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5805. * @param t defines the time
  5806. * @param x1 defines the left coordinate on X axis
  5807. * @param y1 defines the left coordinate on Y axis
  5808. * @param x2 defines the right coordinate on X axis
  5809. * @param y2 defines the right coordinate on Y axis
  5810. * @returns the interpolated value
  5811. */
  5812. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5813. }
  5814. /**
  5815. * Defines angle representation
  5816. */
  5817. export class Angle {
  5818. private _radians;
  5819. /**
  5820. * Creates an Angle object of "radians" radians (float).
  5821. * @param radians the angle in radians
  5822. */
  5823. constructor(radians: number);
  5824. /**
  5825. * Get value in degrees
  5826. * @returns the Angle value in degrees (float)
  5827. */
  5828. degrees(): number;
  5829. /**
  5830. * Get value in radians
  5831. * @returns the Angle value in radians (float)
  5832. */
  5833. radians(): number;
  5834. /**
  5835. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5836. * @param a defines first vector
  5837. * @param b defines second vector
  5838. * @returns a new Angle
  5839. */
  5840. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5841. /**
  5842. * Gets a new Angle object from the given float in radians
  5843. * @param radians defines the angle value in radians
  5844. * @returns a new Angle
  5845. */
  5846. static FromRadians(radians: number): Angle;
  5847. /**
  5848. * Gets a new Angle object from the given float in degrees
  5849. * @param degrees defines the angle value in degrees
  5850. * @returns a new Angle
  5851. */
  5852. static FromDegrees(degrees: number): Angle;
  5853. }
  5854. /**
  5855. * This represents an arc in a 2d space.
  5856. */
  5857. export class Arc2 {
  5858. /** Defines the start point of the arc */
  5859. startPoint: Vector2;
  5860. /** Defines the mid point of the arc */
  5861. midPoint: Vector2;
  5862. /** Defines the end point of the arc */
  5863. endPoint: Vector2;
  5864. /**
  5865. * Defines the center point of the arc.
  5866. */
  5867. centerPoint: Vector2;
  5868. /**
  5869. * Defines the radius of the arc.
  5870. */
  5871. radius: number;
  5872. /**
  5873. * Defines the angle of the arc (from mid point to end point).
  5874. */
  5875. angle: Angle;
  5876. /**
  5877. * Defines the start angle of the arc (from start point to middle point).
  5878. */
  5879. startAngle: Angle;
  5880. /**
  5881. * Defines the orientation of the arc (clock wise/counter clock wise).
  5882. */
  5883. orientation: Orientation;
  5884. /**
  5885. * Creates an Arc object from the three given points : start, middle and end.
  5886. * @param startPoint Defines the start point of the arc
  5887. * @param midPoint Defines the midlle point of the arc
  5888. * @param endPoint Defines the end point of the arc
  5889. */
  5890. constructor(
  5891. /** Defines the start point of the arc */
  5892. startPoint: Vector2,
  5893. /** Defines the mid point of the arc */
  5894. midPoint: Vector2,
  5895. /** Defines the end point of the arc */
  5896. endPoint: Vector2);
  5897. }
  5898. /**
  5899. * Represents a 2D path made up of multiple 2D points
  5900. */
  5901. export class Path2 {
  5902. private _points;
  5903. private _length;
  5904. /**
  5905. * If the path start and end point are the same
  5906. */
  5907. closed: boolean;
  5908. /**
  5909. * Creates a Path2 object from the starting 2D coordinates x and y.
  5910. * @param x the starting points x value
  5911. * @param y the starting points y value
  5912. */
  5913. constructor(x: number, y: number);
  5914. /**
  5915. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5916. * @param x the added points x value
  5917. * @param y the added points y value
  5918. * @returns the updated Path2.
  5919. */
  5920. addLineTo(x: number, y: number): Path2;
  5921. /**
  5922. * 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.
  5923. * @param midX middle point x value
  5924. * @param midY middle point y value
  5925. * @param endX end point x value
  5926. * @param endY end point y value
  5927. * @param numberOfSegments (default: 36)
  5928. * @returns the updated Path2.
  5929. */
  5930. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5931. /**
  5932. * Closes the Path2.
  5933. * @returns the Path2.
  5934. */
  5935. close(): Path2;
  5936. /**
  5937. * Gets the sum of the distance between each sequential point in the path
  5938. * @returns the Path2 total length (float).
  5939. */
  5940. length(): number;
  5941. /**
  5942. * Gets the points which construct the path
  5943. * @returns the Path2 internal array of points.
  5944. */
  5945. getPoints(): Vector2[];
  5946. /**
  5947. * Retreives the point at the distance aways from the starting point
  5948. * @param normalizedLengthPosition the length along the path to retreive the point from
  5949. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5950. */
  5951. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5952. /**
  5953. * Creates a new path starting from an x and y position
  5954. * @param x starting x value
  5955. * @param y starting y value
  5956. * @returns a new Path2 starting at the coordinates (x, y).
  5957. */
  5958. static StartingAt(x: number, y: number): Path2;
  5959. }
  5960. /**
  5961. * Represents a 3D path made up of multiple 3D points
  5962. */
  5963. export class Path3D {
  5964. /**
  5965. * an array of Vector3, the curve axis of the Path3D
  5966. */
  5967. path: Vector3[];
  5968. private _curve;
  5969. private _distances;
  5970. private _tangents;
  5971. private _normals;
  5972. private _binormals;
  5973. private _raw;
  5974. /**
  5975. * new Path3D(path, normal, raw)
  5976. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5977. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5978. * @param path an array of Vector3, the curve axis of the Path3D
  5979. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5980. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5981. */
  5982. constructor(
  5983. /**
  5984. * an array of Vector3, the curve axis of the Path3D
  5985. */
  5986. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5987. /**
  5988. * Returns the Path3D array of successive Vector3 designing its curve.
  5989. * @returns the Path3D array of successive Vector3 designing its curve.
  5990. */
  5991. getCurve(): Vector3[];
  5992. /**
  5993. * Returns an array populated with tangent vectors on each Path3D curve point.
  5994. * @returns an array populated with tangent vectors on each Path3D curve point.
  5995. */
  5996. getTangents(): Vector3[];
  5997. /**
  5998. * Returns an array populated with normal vectors on each Path3D curve point.
  5999. * @returns an array populated with normal vectors on each Path3D curve point.
  6000. */
  6001. getNormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with binormal vectors on each Path3D curve point.
  6004. * @returns an array populated with binormal vectors on each Path3D curve point.
  6005. */
  6006. getBinormals(): Vector3[];
  6007. /**
  6008. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6009. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6010. */
  6011. getDistances(): number[];
  6012. /**
  6013. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6014. * @param path path which all values are copied into the curves points
  6015. * @param firstNormal which should be projected onto the curve
  6016. * @returns the same object updated.
  6017. */
  6018. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6019. private _compute;
  6020. private _getFirstNonNullVector;
  6021. private _getLastNonNullVector;
  6022. private _normalVector;
  6023. }
  6024. /**
  6025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6026. * A Curve3 is designed from a series of successive Vector3.
  6027. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6028. */
  6029. export class Curve3 {
  6030. private _points;
  6031. private _length;
  6032. /**
  6033. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6034. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6035. * @param v1 (Vector3) the control point
  6036. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6037. * @param nbPoints (integer) the wanted number of points in the curve
  6038. * @returns the created Curve3
  6039. */
  6040. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6041. /**
  6042. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6043. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6044. * @param v1 (Vector3) the first control point
  6045. * @param v2 (Vector3) the second control point
  6046. * @param v3 (Vector3) the end point of the Cubic Bezier
  6047. * @param nbPoints (integer) the wanted number of points in the curve
  6048. * @returns the created Curve3
  6049. */
  6050. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6051. /**
  6052. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6053. * @param p1 (Vector3) the origin point of the Hermite Spline
  6054. * @param t1 (Vector3) the tangent vector at the origin point
  6055. * @param p2 (Vector3) the end point of the Hermite Spline
  6056. * @param t2 (Vector3) the tangent vector at the end point
  6057. * @param nbPoints (integer) the wanted number of points in the curve
  6058. * @returns the created Curve3
  6059. */
  6060. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6061. /**
  6062. * Returns a Curve3 object along a CatmullRom Spline curve :
  6063. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6064. * @param nbPoints (integer) the wanted number of points between each curve control points
  6065. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6066. * @returns the created Curve3
  6067. */
  6068. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6069. /**
  6070. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6071. * A Curve3 is designed from a series of successive Vector3.
  6072. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6073. * @param points points which make up the curve
  6074. */
  6075. constructor(points: Vector3[]);
  6076. /**
  6077. * @returns the Curve3 stored array of successive Vector3
  6078. */
  6079. getPoints(): Vector3[];
  6080. /**
  6081. * @returns the computed length (float) of the curve.
  6082. */
  6083. length(): number;
  6084. /**
  6085. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6086. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6087. * curveA and curveB keep unchanged.
  6088. * @param curve the curve to continue from this curve
  6089. * @returns the newly constructed curve
  6090. */
  6091. continue(curve: DeepImmutable<Curve3>): Curve3;
  6092. private _computeLength;
  6093. }
  6094. }
  6095. declare module "babylonjs/Animations/easing" {
  6096. /**
  6097. * This represents the main contract an easing function should follow.
  6098. * Easing functions are used throughout the animation system.
  6099. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6100. */
  6101. export interface IEasingFunction {
  6102. /**
  6103. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6104. * of the easing function.
  6105. * The link below provides some of the most common examples of easing functions.
  6106. * @see https://easings.net/
  6107. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6108. * @returns the corresponding value on the curve defined by the easing function
  6109. */
  6110. ease(gradient: number): number;
  6111. }
  6112. /**
  6113. * Base class used for every default easing function.
  6114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6115. */
  6116. export class EasingFunction implements IEasingFunction {
  6117. /**
  6118. * Interpolation follows the mathematical formula associated with the easing function.
  6119. */
  6120. static readonly EASINGMODE_EASEIN: number;
  6121. /**
  6122. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6123. */
  6124. static readonly EASINGMODE_EASEOUT: number;
  6125. /**
  6126. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6127. */
  6128. static readonly EASINGMODE_EASEINOUT: number;
  6129. private _easingMode;
  6130. /**
  6131. * Sets the easing mode of the current function.
  6132. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6133. */
  6134. setEasingMode(easingMode: number): void;
  6135. /**
  6136. * Gets the current easing mode.
  6137. * @returns the easing mode
  6138. */
  6139. getEasingMode(): number;
  6140. /**
  6141. * @hidden
  6142. */
  6143. easeInCore(gradient: number): number;
  6144. /**
  6145. * Given an input gradient between 0 and 1, this returns the corresponding value
  6146. * of the easing function.
  6147. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6148. * @returns the corresponding value on the curve defined by the easing function
  6149. */
  6150. ease(gradient: number): number;
  6151. }
  6152. /**
  6153. * Easing function with a circle shape (see link below).
  6154. * @see https://easings.net/#easeInCirc
  6155. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6156. */
  6157. export class CircleEase extends EasingFunction implements IEasingFunction {
  6158. /** @hidden */
  6159. easeInCore(gradient: number): number;
  6160. }
  6161. /**
  6162. * Easing function with a ease back shape (see link below).
  6163. * @see https://easings.net/#easeInBack
  6164. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6165. */
  6166. export class BackEase extends EasingFunction implements IEasingFunction {
  6167. /** Defines the amplitude of the function */
  6168. amplitude: number;
  6169. /**
  6170. * Instantiates a back ease easing
  6171. * @see https://easings.net/#easeInBack
  6172. * @param amplitude Defines the amplitude of the function
  6173. */
  6174. constructor(
  6175. /** Defines the amplitude of the function */
  6176. amplitude?: number);
  6177. /** @hidden */
  6178. easeInCore(gradient: number): number;
  6179. }
  6180. /**
  6181. * Easing function with a bouncing shape (see link below).
  6182. * @see https://easings.net/#easeInBounce
  6183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6184. */
  6185. export class BounceEase extends EasingFunction implements IEasingFunction {
  6186. /** Defines the number of bounces */
  6187. bounces: number;
  6188. /** Defines the amplitude of the bounce */
  6189. bounciness: number;
  6190. /**
  6191. * Instantiates a bounce easing
  6192. * @see https://easings.net/#easeInBounce
  6193. * @param bounces Defines the number of bounces
  6194. * @param bounciness Defines the amplitude of the bounce
  6195. */
  6196. constructor(
  6197. /** Defines the number of bounces */
  6198. bounces?: number,
  6199. /** Defines the amplitude of the bounce */
  6200. bounciness?: number);
  6201. /** @hidden */
  6202. easeInCore(gradient: number): number;
  6203. }
  6204. /**
  6205. * Easing function with a power of 3 shape (see link below).
  6206. * @see https://easings.net/#easeInCubic
  6207. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6208. */
  6209. export class CubicEase extends EasingFunction implements IEasingFunction {
  6210. /** @hidden */
  6211. easeInCore(gradient: number): number;
  6212. }
  6213. /**
  6214. * Easing function with an elastic shape (see link below).
  6215. * @see https://easings.net/#easeInElastic
  6216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6217. */
  6218. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6219. /** Defines the number of oscillations*/
  6220. oscillations: number;
  6221. /** Defines the amplitude of the oscillations*/
  6222. springiness: number;
  6223. /**
  6224. * Instantiates an elastic easing function
  6225. * @see https://easings.net/#easeInElastic
  6226. * @param oscillations Defines the number of oscillations
  6227. * @param springiness Defines the amplitude of the oscillations
  6228. */
  6229. constructor(
  6230. /** Defines the number of oscillations*/
  6231. oscillations?: number,
  6232. /** Defines the amplitude of the oscillations*/
  6233. springiness?: number);
  6234. /** @hidden */
  6235. easeInCore(gradient: number): number;
  6236. }
  6237. /**
  6238. * Easing function with an exponential shape (see link below).
  6239. * @see https://easings.net/#easeInExpo
  6240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6241. */
  6242. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6243. /** Defines the exponent of the function */
  6244. exponent: number;
  6245. /**
  6246. * Instantiates an exponential easing function
  6247. * @see https://easings.net/#easeInExpo
  6248. * @param exponent Defines the exponent of the function
  6249. */
  6250. constructor(
  6251. /** Defines the exponent of the function */
  6252. exponent?: number);
  6253. /** @hidden */
  6254. easeInCore(gradient: number): number;
  6255. }
  6256. /**
  6257. * Easing function with a power shape (see link below).
  6258. * @see https://easings.net/#easeInQuad
  6259. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6260. */
  6261. export class PowerEase extends EasingFunction implements IEasingFunction {
  6262. /** Defines the power of the function */
  6263. power: number;
  6264. /**
  6265. * Instantiates an power base easing function
  6266. * @see https://easings.net/#easeInQuad
  6267. * @param power Defines the power of the function
  6268. */
  6269. constructor(
  6270. /** Defines the power of the function */
  6271. power?: number);
  6272. /** @hidden */
  6273. easeInCore(gradient: number): number;
  6274. }
  6275. /**
  6276. * Easing function with a power of 2 shape (see link below).
  6277. * @see https://easings.net/#easeInQuad
  6278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6279. */
  6280. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6281. /** @hidden */
  6282. easeInCore(gradient: number): number;
  6283. }
  6284. /**
  6285. * Easing function with a power of 4 shape (see link below).
  6286. * @see https://easings.net/#easeInQuart
  6287. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6288. */
  6289. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6290. /** @hidden */
  6291. easeInCore(gradient: number): number;
  6292. }
  6293. /**
  6294. * Easing function with a power of 5 shape (see link below).
  6295. * @see https://easings.net/#easeInQuint
  6296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6297. */
  6298. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6299. /** @hidden */
  6300. easeInCore(gradient: number): number;
  6301. }
  6302. /**
  6303. * Easing function with a sin shape (see link below).
  6304. * @see https://easings.net/#easeInSine
  6305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6306. */
  6307. export class SineEase extends EasingFunction implements IEasingFunction {
  6308. /** @hidden */
  6309. easeInCore(gradient: number): number;
  6310. }
  6311. /**
  6312. * Easing function with a bezier shape (see link below).
  6313. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6315. */
  6316. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6317. /** Defines the x component of the start tangent in the bezier curve */
  6318. x1: number;
  6319. /** Defines the y component of the start tangent in the bezier curve */
  6320. y1: number;
  6321. /** Defines the x component of the end tangent in the bezier curve */
  6322. x2: number;
  6323. /** Defines the y component of the end tangent in the bezier curve */
  6324. y2: number;
  6325. /**
  6326. * Instantiates a bezier function
  6327. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6328. * @param x1 Defines the x component of the start tangent in the bezier curve
  6329. * @param y1 Defines the y component of the start tangent in the bezier curve
  6330. * @param x2 Defines the x component of the end tangent in the bezier curve
  6331. * @param y2 Defines the y component of the end tangent in the bezier curve
  6332. */
  6333. constructor(
  6334. /** Defines the x component of the start tangent in the bezier curve */
  6335. x1?: number,
  6336. /** Defines the y component of the start tangent in the bezier curve */
  6337. y1?: number,
  6338. /** Defines the x component of the end tangent in the bezier curve */
  6339. x2?: number,
  6340. /** Defines the y component of the end tangent in the bezier curve */
  6341. y2?: number);
  6342. /** @hidden */
  6343. easeInCore(gradient: number): number;
  6344. }
  6345. }
  6346. declare module "babylonjs/Animations/animationKey" {
  6347. /**
  6348. * Defines an interface which represents an animation key frame
  6349. */
  6350. export interface IAnimationKey {
  6351. /**
  6352. * Frame of the key frame
  6353. */
  6354. frame: number;
  6355. /**
  6356. * Value at the specifies key frame
  6357. */
  6358. value: any;
  6359. /**
  6360. * The input tangent for the cubic hermite spline
  6361. */
  6362. inTangent?: any;
  6363. /**
  6364. * The output tangent for the cubic hermite spline
  6365. */
  6366. outTangent?: any;
  6367. /**
  6368. * The animation interpolation type
  6369. */
  6370. interpolation?: AnimationKeyInterpolation;
  6371. }
  6372. /**
  6373. * Enum for the animation key frame interpolation type
  6374. */
  6375. export enum AnimationKeyInterpolation {
  6376. /**
  6377. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6378. */
  6379. STEP = 1
  6380. }
  6381. }
  6382. declare module "babylonjs/Animations/animationRange" {
  6383. /**
  6384. * Represents the range of an animation
  6385. */
  6386. export class AnimationRange {
  6387. /**The name of the animation range**/
  6388. name: string;
  6389. /**The starting frame of the animation */
  6390. from: number;
  6391. /**The ending frame of the animation*/
  6392. to: number;
  6393. /**
  6394. * Initializes the range of an animation
  6395. * @param name The name of the animation range
  6396. * @param from The starting frame of the animation
  6397. * @param to The ending frame of the animation
  6398. */
  6399. constructor(
  6400. /**The name of the animation range**/
  6401. name: string,
  6402. /**The starting frame of the animation */
  6403. from: number,
  6404. /**The ending frame of the animation*/
  6405. to: number);
  6406. /**
  6407. * Makes a copy of the animation range
  6408. * @returns A copy of the animation range
  6409. */
  6410. clone(): AnimationRange;
  6411. }
  6412. }
  6413. declare module "babylonjs/Animations/animationEvent" {
  6414. /**
  6415. * Composed of a frame, and an action function
  6416. */
  6417. export class AnimationEvent {
  6418. /** The frame for which the event is triggered **/
  6419. frame: number;
  6420. /** The event to perform when triggered **/
  6421. action: (currentFrame: number) => void;
  6422. /** Specifies if the event should be triggered only once**/
  6423. onlyOnce?: boolean | undefined;
  6424. /**
  6425. * Specifies if the animation event is done
  6426. */
  6427. isDone: boolean;
  6428. /**
  6429. * Initializes the animation event
  6430. * @param frame The frame for which the event is triggered
  6431. * @param action The event to perform when triggered
  6432. * @param onlyOnce Specifies if the event should be triggered only once
  6433. */
  6434. constructor(
  6435. /** The frame for which the event is triggered **/
  6436. frame: number,
  6437. /** The event to perform when triggered **/
  6438. action: (currentFrame: number) => void,
  6439. /** Specifies if the event should be triggered only once**/
  6440. onlyOnce?: boolean | undefined);
  6441. /** @hidden */
  6442. _clone(): AnimationEvent;
  6443. }
  6444. }
  6445. declare module "babylonjs/Behaviors/behavior" {
  6446. import { Nullable } from "babylonjs/types";
  6447. /**
  6448. * Interface used to define a behavior
  6449. */
  6450. export interface Behavior<T> {
  6451. /** gets or sets behavior's name */
  6452. name: string;
  6453. /**
  6454. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6455. */
  6456. init(): void;
  6457. /**
  6458. * Called when the behavior is attached to a target
  6459. * @param target defines the target where the behavior is attached to
  6460. */
  6461. attach(target: T): void;
  6462. /**
  6463. * Called when the behavior is detached from its target
  6464. */
  6465. detach(): void;
  6466. }
  6467. /**
  6468. * Interface implemented by classes supporting behaviors
  6469. */
  6470. export interface IBehaviorAware<T> {
  6471. /**
  6472. * Attach a behavior
  6473. * @param behavior defines the behavior to attach
  6474. * @returns the current host
  6475. */
  6476. addBehavior(behavior: Behavior<T>): T;
  6477. /**
  6478. * Remove a behavior from the current object
  6479. * @param behavior defines the behavior to detach
  6480. * @returns the current host
  6481. */
  6482. removeBehavior(behavior: Behavior<T>): T;
  6483. /**
  6484. * Gets a behavior using its name to search
  6485. * @param name defines the name to search
  6486. * @returns the behavior or null if not found
  6487. */
  6488. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6489. }
  6490. }
  6491. declare module "babylonjs/Misc/smartArray" {
  6492. /**
  6493. * Defines an array and its length.
  6494. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6495. */
  6496. export interface ISmartArrayLike<T> {
  6497. /**
  6498. * The data of the array.
  6499. */
  6500. data: Array<T>;
  6501. /**
  6502. * The active length of the array.
  6503. */
  6504. length: number;
  6505. }
  6506. /**
  6507. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6508. */
  6509. export class SmartArray<T> implements ISmartArrayLike<T> {
  6510. /**
  6511. * The full set of data from the array.
  6512. */
  6513. data: Array<T>;
  6514. /**
  6515. * The active length of the array.
  6516. */
  6517. length: number;
  6518. protected _id: number;
  6519. /**
  6520. * Instantiates a Smart Array.
  6521. * @param capacity defines the default capacity of the array.
  6522. */
  6523. constructor(capacity: number);
  6524. /**
  6525. * Pushes a value at the end of the active data.
  6526. * @param value defines the object to push in the array.
  6527. */
  6528. push(value: T): void;
  6529. /**
  6530. * Iterates over the active data and apply the lambda to them.
  6531. * @param func defines the action to apply on each value.
  6532. */
  6533. forEach(func: (content: T) => void): void;
  6534. /**
  6535. * Sorts the full sets of data.
  6536. * @param compareFn defines the comparison function to apply.
  6537. */
  6538. sort(compareFn: (a: T, b: T) => number): void;
  6539. /**
  6540. * Resets the active data to an empty array.
  6541. */
  6542. reset(): void;
  6543. /**
  6544. * Releases all the data from the array as well as the array.
  6545. */
  6546. dispose(): void;
  6547. /**
  6548. * Concats the active data with a given array.
  6549. * @param array defines the data to concatenate with.
  6550. */
  6551. concat(array: any): void;
  6552. /**
  6553. * Returns the position of a value in the active data.
  6554. * @param value defines the value to find the index for
  6555. * @returns the index if found in the active data otherwise -1
  6556. */
  6557. indexOf(value: T): number;
  6558. /**
  6559. * Returns whether an element is part of the active data.
  6560. * @param value defines the value to look for
  6561. * @returns true if found in the active data otherwise false
  6562. */
  6563. contains(value: T): boolean;
  6564. private static _GlobalId;
  6565. }
  6566. /**
  6567. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6568. * The data in this array can only be present once
  6569. */
  6570. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6571. private _duplicateId;
  6572. /**
  6573. * Pushes a value at the end of the active data.
  6574. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6575. * @param value defines the object to push in the array.
  6576. */
  6577. push(value: T): void;
  6578. /**
  6579. * Pushes a value at the end of the active data.
  6580. * If the data is already present, it won t be added again
  6581. * @param value defines the object to push in the array.
  6582. * @returns true if added false if it was already present
  6583. */
  6584. pushNoDuplicate(value: T): boolean;
  6585. /**
  6586. * Resets the active data to an empty array.
  6587. */
  6588. reset(): void;
  6589. /**
  6590. * Concats the active data with a given array.
  6591. * This ensures no dupplicate will be present in the result.
  6592. * @param array defines the data to concatenate with.
  6593. */
  6594. concatWithNoDuplicate(array: any): void;
  6595. }
  6596. }
  6597. declare module "babylonjs/Cameras/cameraInputsManager" {
  6598. import { Nullable } from "babylonjs/types";
  6599. import { Camera } from "babylonjs/Cameras/camera";
  6600. /**
  6601. * @ignore
  6602. * This is a list of all the different input types that are available in the application.
  6603. * Fo instance: ArcRotateCameraGamepadInput...
  6604. */
  6605. export var CameraInputTypes: {};
  6606. /**
  6607. * This is the contract to implement in order to create a new input class.
  6608. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6609. */
  6610. export interface ICameraInput<TCamera extends Camera> {
  6611. /**
  6612. * Defines the camera the input is attached to.
  6613. */
  6614. camera: Nullable<TCamera>;
  6615. /**
  6616. * Gets the class name of the current intput.
  6617. * @returns the class name
  6618. */
  6619. getClassName(): string;
  6620. /**
  6621. * Get the friendly name associated with the input class.
  6622. * @returns the input friendly name
  6623. */
  6624. getSimpleName(): string;
  6625. /**
  6626. * Attach the input controls to a specific dom element to get the input from.
  6627. * @param element Defines the element the controls should be listened from
  6628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6629. */
  6630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6631. /**
  6632. * Detach the current controls from the specified dom element.
  6633. * @param element Defines the element to stop listening the inputs from
  6634. */
  6635. detachControl(element: Nullable<HTMLElement>): void;
  6636. /**
  6637. * Update the current camera state depending on the inputs that have been used this frame.
  6638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6639. */
  6640. checkInputs?: () => void;
  6641. }
  6642. /**
  6643. * Represents a map of input types to input instance or input index to input instance.
  6644. */
  6645. export interface CameraInputsMap<TCamera extends Camera> {
  6646. /**
  6647. * Accessor to the input by input type.
  6648. */
  6649. [name: string]: ICameraInput<TCamera>;
  6650. /**
  6651. * Accessor to the input by input index.
  6652. */
  6653. [idx: number]: ICameraInput<TCamera>;
  6654. }
  6655. /**
  6656. * This represents the input manager used within a camera.
  6657. * It helps dealing with all the different kind of input attached to a camera.
  6658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6659. */
  6660. export class CameraInputsManager<TCamera extends Camera> {
  6661. /**
  6662. * Defines the list of inputs attahed to the camera.
  6663. */
  6664. attached: CameraInputsMap<TCamera>;
  6665. /**
  6666. * Defines the dom element the camera is collecting inputs from.
  6667. * This is null if the controls have not been attached.
  6668. */
  6669. attachedElement: Nullable<HTMLElement>;
  6670. /**
  6671. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6672. */
  6673. noPreventDefault: boolean;
  6674. /**
  6675. * Defined the camera the input manager belongs to.
  6676. */
  6677. camera: TCamera;
  6678. /**
  6679. * Update the current camera state depending on the inputs that have been used this frame.
  6680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6681. */
  6682. checkInputs: () => void;
  6683. /**
  6684. * Instantiate a new Camera Input Manager.
  6685. * @param camera Defines the camera the input manager blongs to
  6686. */
  6687. constructor(camera: TCamera);
  6688. /**
  6689. * Add an input method to a camera
  6690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6691. * @param input camera input method
  6692. */
  6693. add(input: ICameraInput<TCamera>): void;
  6694. /**
  6695. * Remove a specific input method from a camera
  6696. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6697. * @param inputToRemove camera input method
  6698. */
  6699. remove(inputToRemove: ICameraInput<TCamera>): void;
  6700. /**
  6701. * Remove a specific input type from a camera
  6702. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6703. * @param inputType the type of the input to remove
  6704. */
  6705. removeByType(inputType: string): void;
  6706. private _addCheckInputs;
  6707. /**
  6708. * Attach the input controls to the currently attached dom element to listen the events from.
  6709. * @param input Defines the input to attach
  6710. */
  6711. attachInput(input: ICameraInput<TCamera>): void;
  6712. /**
  6713. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6714. * @param element Defines the dom element to collect the events from
  6715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6716. */
  6717. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6718. /**
  6719. * Detach the current manager inputs controls from a specific dom element.
  6720. * @param element Defines the dom element to collect the events from
  6721. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6722. */
  6723. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6724. /**
  6725. * Rebuild the dynamic inputCheck function from the current list of
  6726. * defined inputs in the manager.
  6727. */
  6728. rebuildInputCheck(): void;
  6729. /**
  6730. * Remove all attached input methods from a camera
  6731. */
  6732. clear(): void;
  6733. /**
  6734. * Serialize the current input manager attached to a camera.
  6735. * This ensures than once parsed,
  6736. * the input associated to the camera will be identical to the current ones
  6737. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6738. */
  6739. serialize(serializedCamera: any): void;
  6740. /**
  6741. * Parses an input manager serialized JSON to restore the previous list of inputs
  6742. * and states associated to a camera.
  6743. * @param parsedCamera Defines the JSON to parse
  6744. */
  6745. parse(parsedCamera: any): void;
  6746. }
  6747. }
  6748. declare module "babylonjs/Collisions/intersectionInfo" {
  6749. import { Nullable } from "babylonjs/types";
  6750. /**
  6751. * @hidden
  6752. */
  6753. export class IntersectionInfo {
  6754. bu: Nullable<number>;
  6755. bv: Nullable<number>;
  6756. distance: number;
  6757. faceId: number;
  6758. subMeshId: number;
  6759. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6760. }
  6761. }
  6762. declare module "babylonjs/Maths/math.plane" {
  6763. import { DeepImmutable } from "babylonjs/types";
  6764. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6765. /**
  6766. * Represens a plane by the equation ax + by + cz + d = 0
  6767. */
  6768. export class Plane {
  6769. private static _TmpMatrix;
  6770. /**
  6771. * Normal of the plane (a,b,c)
  6772. */
  6773. normal: Vector3;
  6774. /**
  6775. * d component of the plane
  6776. */
  6777. d: number;
  6778. /**
  6779. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6780. * @param a a component of the plane
  6781. * @param b b component of the plane
  6782. * @param c c component of the plane
  6783. * @param d d component of the plane
  6784. */
  6785. constructor(a: number, b: number, c: number, d: number);
  6786. /**
  6787. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6788. */
  6789. asArray(): number[];
  6790. /**
  6791. * @returns a new plane copied from the current Plane.
  6792. */
  6793. clone(): Plane;
  6794. /**
  6795. * @returns the string "Plane".
  6796. */
  6797. getClassName(): string;
  6798. /**
  6799. * @returns the Plane hash code.
  6800. */
  6801. getHashCode(): number;
  6802. /**
  6803. * Normalize the current Plane in place.
  6804. * @returns the updated Plane.
  6805. */
  6806. normalize(): Plane;
  6807. /**
  6808. * Applies a transformation the plane and returns the result
  6809. * @param transformation the transformation matrix to be applied to the plane
  6810. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6811. */
  6812. transform(transformation: DeepImmutable<Matrix>): Plane;
  6813. /**
  6814. * Calcualtte the dot product between the point and the plane normal
  6815. * @param point point to calculate the dot product with
  6816. * @returns the dot product (float) of the point coordinates and the plane normal.
  6817. */
  6818. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6819. /**
  6820. * Updates the current Plane from the plane defined by the three given points.
  6821. * @param point1 one of the points used to contruct the plane
  6822. * @param point2 one of the points used to contruct the plane
  6823. * @param point3 one of the points used to contruct the plane
  6824. * @returns the updated Plane.
  6825. */
  6826. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6827. /**
  6828. * Checks if the plane is facing a given direction
  6829. * @param direction the direction to check if the plane is facing
  6830. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6831. * @returns True is the vector "direction" is the same side than the plane normal.
  6832. */
  6833. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6834. /**
  6835. * Calculates the distance to a point
  6836. * @param point point to calculate distance to
  6837. * @returns the signed distance (float) from the given point to the Plane.
  6838. */
  6839. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6840. /**
  6841. * Creates a plane from an array
  6842. * @param array the array to create a plane from
  6843. * @returns a new Plane from the given array.
  6844. */
  6845. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6846. /**
  6847. * Creates a plane from three points
  6848. * @param point1 point used to create the plane
  6849. * @param point2 point used to create the plane
  6850. * @param point3 point used to create the plane
  6851. * @returns a new Plane defined by the three given points.
  6852. */
  6853. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6854. /**
  6855. * Creates a plane from an origin point and a normal
  6856. * @param origin origin of the plane to be constructed
  6857. * @param normal normal of the plane to be constructed
  6858. * @returns a new Plane the normal vector to this plane at the given origin point.
  6859. * Note : the vector "normal" is updated because normalized.
  6860. */
  6861. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6862. /**
  6863. * Calculates the distance from a plane and a point
  6864. * @param origin origin of the plane to be constructed
  6865. * @param normal normal of the plane to be constructed
  6866. * @param point point to calculate distance to
  6867. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6868. */
  6869. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6870. }
  6871. }
  6872. declare module "babylonjs/Culling/boundingSphere" {
  6873. import { DeepImmutable } from "babylonjs/types";
  6874. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6875. import { Plane } from "babylonjs/Maths/math.plane";
  6876. /**
  6877. * Class used to store bounding sphere information
  6878. */
  6879. export class BoundingSphere {
  6880. /**
  6881. * Gets the center of the bounding sphere in local space
  6882. */
  6883. readonly center: Vector3;
  6884. /**
  6885. * Radius of the bounding sphere in local space
  6886. */
  6887. radius: number;
  6888. /**
  6889. * Gets the center of the bounding sphere in world space
  6890. */
  6891. readonly centerWorld: Vector3;
  6892. /**
  6893. * Radius of the bounding sphere in world space
  6894. */
  6895. radiusWorld: number;
  6896. /**
  6897. * Gets the minimum vector in local space
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * Gets the maximum vector in local space
  6902. */
  6903. readonly maximum: Vector3;
  6904. private _worldMatrix;
  6905. private static readonly TmpVector3;
  6906. /**
  6907. * Creates a new bounding sphere
  6908. * @param min defines the minimum vector (in local space)
  6909. * @param max defines the maximum vector (in local space)
  6910. * @param worldMatrix defines the new world matrix
  6911. */
  6912. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6913. /**
  6914. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6915. * @param min defines the new minimum vector (in local space)
  6916. * @param max defines the new maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6920. /**
  6921. * Scale the current bounding sphere by applying a scale factor
  6922. * @param factor defines the scale factor to apply
  6923. * @returns the current bounding box
  6924. */
  6925. scale(factor: number): BoundingSphere;
  6926. /**
  6927. * Gets the world matrix of the bounding box
  6928. * @returns a matrix
  6929. */
  6930. getWorldMatrix(): DeepImmutable<Matrix>;
  6931. /** @hidden */
  6932. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6933. /**
  6934. * Tests if the bounding sphere is intersecting the frustum planes
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @returns true if there is an intersection
  6937. */
  6938. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if the bounding sphere center is in between the frustum planes.
  6941. * Used for optimistic fast inclusion.
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if the sphere center is in between the frustum planes
  6944. */
  6945. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if a point is inside the bounding sphere
  6948. * @param point defines the point to test
  6949. * @returns true if the point is inside the bounding sphere
  6950. */
  6951. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6952. /**
  6953. * Checks if two sphere intersct
  6954. * @param sphere0 sphere 0
  6955. * @param sphere1 sphere 1
  6956. * @returns true if the speres intersect
  6957. */
  6958. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6959. }
  6960. }
  6961. declare module "babylonjs/Culling/boundingBox" {
  6962. import { DeepImmutable } from "babylonjs/types";
  6963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6964. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6965. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6966. import { Plane } from "babylonjs/Maths/math.plane";
  6967. /**
  6968. * Class used to store bounding box information
  6969. */
  6970. export class BoundingBox implements ICullable {
  6971. /**
  6972. * Gets the 8 vectors representing the bounding box in local space
  6973. */
  6974. readonly vectors: Vector3[];
  6975. /**
  6976. * Gets the center of the bounding box in local space
  6977. */
  6978. readonly center: Vector3;
  6979. /**
  6980. * Gets the center of the bounding box in world space
  6981. */
  6982. readonly centerWorld: Vector3;
  6983. /**
  6984. * Gets the extend size in local space
  6985. */
  6986. readonly extendSize: Vector3;
  6987. /**
  6988. * Gets the extend size in world space
  6989. */
  6990. readonly extendSizeWorld: Vector3;
  6991. /**
  6992. * Gets the OBB (object bounding box) directions
  6993. */
  6994. readonly directions: Vector3[];
  6995. /**
  6996. * Gets the 8 vectors representing the bounding box in world space
  6997. */
  6998. readonly vectorsWorld: Vector3[];
  6999. /**
  7000. * Gets the minimum vector in world space
  7001. */
  7002. readonly minimumWorld: Vector3;
  7003. /**
  7004. * Gets the maximum vector in world space
  7005. */
  7006. readonly maximumWorld: Vector3;
  7007. /**
  7008. * Gets the minimum vector in local space
  7009. */
  7010. readonly minimum: Vector3;
  7011. /**
  7012. * Gets the maximum vector in local space
  7013. */
  7014. readonly maximum: Vector3;
  7015. private _worldMatrix;
  7016. private static readonly TmpVector3;
  7017. /**
  7018. * @hidden
  7019. */
  7020. _tag: number;
  7021. /**
  7022. * Creates a new bounding box
  7023. * @param min defines the minimum vector (in local space)
  7024. * @param max defines the maximum vector (in local space)
  7025. * @param worldMatrix defines the new world matrix
  7026. */
  7027. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7028. /**
  7029. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7030. * @param min defines the new minimum vector (in local space)
  7031. * @param max defines the new maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Scale the current bounding box by applying a scale factor
  7037. * @param factor defines the scale factor to apply
  7038. * @returns the current bounding box
  7039. */
  7040. scale(factor: number): BoundingBox;
  7041. /**
  7042. * Gets the world matrix of the bounding box
  7043. * @returns a matrix
  7044. */
  7045. getWorldMatrix(): DeepImmutable<Matrix>;
  7046. /** @hidden */
  7047. _update(world: DeepImmutable<Matrix>): void;
  7048. /**
  7049. * Tests if the bounding box is intersecting the frustum planes
  7050. * @param frustumPlanes defines the frustum planes to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7054. /**
  7055. * Tests if the bounding box is entirely inside the frustum planes
  7056. * @param frustumPlanes defines the frustum planes to test
  7057. * @returns true if there is an inclusion
  7058. */
  7059. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7060. /**
  7061. * Tests if a point is inside the bounding box
  7062. * @param point defines the point to test
  7063. * @returns true if the point is inside the bounding box
  7064. */
  7065. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7066. /**
  7067. * Tests if the bounding box intersects with a bounding sphere
  7068. * @param sphere defines the sphere to test
  7069. * @returns true if there is an intersection
  7070. */
  7071. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7072. /**
  7073. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7074. * @param min defines the min vector to use
  7075. * @param max defines the max vector to use
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7079. /**
  7080. * Tests if two bounding boxes are intersections
  7081. * @param box0 defines the first box to test
  7082. * @param box1 defines the second box to test
  7083. * @returns true if there is an intersection
  7084. */
  7085. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7086. /**
  7087. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7088. * @param minPoint defines the minimum vector of the bounding box
  7089. * @param maxPoint defines the maximum vector of the bounding box
  7090. * @param sphereCenter defines the sphere center
  7091. * @param sphereRadius defines the sphere radius
  7092. * @returns true if there is an intersection
  7093. */
  7094. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7095. /**
  7096. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7097. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7098. * @param frustumPlanes defines the frustum planes to test
  7099. * @return true if there is an inclusion
  7100. */
  7101. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an intersection
  7107. */
  7108. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. }
  7110. }
  7111. declare module "babylonjs/Collisions/collider" {
  7112. import { Nullable, IndicesArray } from "babylonjs/types";
  7113. import { Vector3 } from "babylonjs/Maths/math.vector";
  7114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7115. import { Plane } from "babylonjs/Maths/math.plane";
  7116. /** @hidden */
  7117. export class Collider {
  7118. /** Define if a collision was found */
  7119. collisionFound: boolean;
  7120. /**
  7121. * Define last intersection point in local space
  7122. */
  7123. intersectionPoint: Vector3;
  7124. /**
  7125. * Define last collided mesh
  7126. */
  7127. collidedMesh: Nullable<AbstractMesh>;
  7128. private _collisionPoint;
  7129. private _planeIntersectionPoint;
  7130. private _tempVector;
  7131. private _tempVector2;
  7132. private _tempVector3;
  7133. private _tempVector4;
  7134. private _edge;
  7135. private _baseToVertex;
  7136. private _destinationPoint;
  7137. private _slidePlaneNormal;
  7138. private _displacementVector;
  7139. /** @hidden */
  7140. _radius: Vector3;
  7141. /** @hidden */
  7142. _retry: number;
  7143. private _velocity;
  7144. private _basePoint;
  7145. private _epsilon;
  7146. /** @hidden */
  7147. _velocityWorldLength: number;
  7148. /** @hidden */
  7149. _basePointWorld: Vector3;
  7150. private _velocityWorld;
  7151. private _normalizedVelocity;
  7152. /** @hidden */
  7153. _initialVelocity: Vector3;
  7154. /** @hidden */
  7155. _initialPosition: Vector3;
  7156. private _nearestDistance;
  7157. private _collisionMask;
  7158. collisionMask: number;
  7159. /**
  7160. * Gets the plane normal used to compute the sliding response (in local space)
  7161. */
  7162. readonly slidePlaneNormal: Vector3;
  7163. /** @hidden */
  7164. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7165. /** @hidden */
  7166. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7167. /** @hidden */
  7168. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7169. /** @hidden */
  7170. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7171. /** @hidden */
  7172. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7173. /** @hidden */
  7174. _getResponse(pos: Vector3, vel: Vector3): void;
  7175. }
  7176. }
  7177. declare module "babylonjs/Culling/boundingInfo" {
  7178. import { DeepImmutable } from "babylonjs/types";
  7179. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7180. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7181. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7182. import { Plane } from "babylonjs/Maths/math.plane";
  7183. import { Collider } from "babylonjs/Collisions/collider";
  7184. /**
  7185. * Interface for cullable objects
  7186. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7187. */
  7188. export interface ICullable {
  7189. /**
  7190. * Checks if the object or part of the object is in the frustum
  7191. * @param frustumPlanes Camera near/planes
  7192. * @returns true if the object is in frustum otherwise false
  7193. */
  7194. isInFrustum(frustumPlanes: Plane[]): boolean;
  7195. /**
  7196. * Checks if a cullable object (mesh...) is in the camera frustum
  7197. * Unlike isInFrustum this cheks the full bounding box
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7202. }
  7203. /**
  7204. * Info for a bounding data of a mesh
  7205. */
  7206. export class BoundingInfo implements ICullable {
  7207. /**
  7208. * Bounding box for the mesh
  7209. */
  7210. readonly boundingBox: BoundingBox;
  7211. /**
  7212. * Bounding sphere for the mesh
  7213. */
  7214. readonly boundingSphere: BoundingSphere;
  7215. private _isLocked;
  7216. private static readonly TmpVector3;
  7217. /**
  7218. * Constructs bounding info
  7219. * @param minimum min vector of the bounding box/sphere
  7220. * @param maximum max vector of the bounding box/sphere
  7221. * @param worldMatrix defines the new world matrix
  7222. */
  7223. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7224. /**
  7225. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7226. * @param min defines the new minimum vector (in local space)
  7227. * @param max defines the new maximum vector (in local space)
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7231. /**
  7232. * min vector of the bounding box/sphere
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * max vector of the bounding box/sphere
  7237. */
  7238. readonly maximum: Vector3;
  7239. /**
  7240. * If the info is locked and won't be updated to avoid perf overhead
  7241. */
  7242. isLocked: boolean;
  7243. /**
  7244. * Updates the bounding sphere and box
  7245. * @param world world matrix to be used to update
  7246. */
  7247. update(world: DeepImmutable<Matrix>): void;
  7248. /**
  7249. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7250. * @param center New center of the bounding info
  7251. * @param extend New extend of the bounding info
  7252. * @returns the current bounding info
  7253. */
  7254. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7255. /**
  7256. * Scale the current bounding info by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding info
  7259. */
  7260. scale(factor: number): BoundingInfo;
  7261. /**
  7262. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7263. * @param frustumPlanes defines the frustum to test
  7264. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7265. * @returns true if the bounding info is in the frustum planes
  7266. */
  7267. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7268. /**
  7269. * Gets the world distance between the min and max points of the bounding box
  7270. */
  7271. readonly diagonalLength: number;
  7272. /**
  7273. * Checks if a cullable object (mesh...) is in the camera frustum
  7274. * Unlike isInFrustum this cheks the full bounding box
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7279. /** @hidden */
  7280. _checkCollision(collider: Collider): boolean;
  7281. /**
  7282. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7283. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7284. * @param point the point to check intersection with
  7285. * @returns if the point intersects
  7286. */
  7287. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7288. /**
  7289. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param boundingInfo the bounding info to check intersection with
  7292. * @param precise if the intersection should be done using OBB
  7293. * @returns if the bounding info intersects
  7294. */
  7295. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7296. }
  7297. }
  7298. declare module "babylonjs/Maths/math.functions" {
  7299. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7300. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7301. /**
  7302. * Extracts minimum and maximum values from a list of indexed positions
  7303. * @param positions defines the positions to use
  7304. * @param indices defines the indices to the positions
  7305. * @param indexStart defines the start index
  7306. * @param indexCount defines the end index
  7307. * @param bias defines bias value to add to the result
  7308. * @return minimum and maximum values
  7309. */
  7310. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7311. minimum: Vector3;
  7312. maximum: Vector3;
  7313. };
  7314. /**
  7315. * Extracts minimum and maximum values from a list of positions
  7316. * @param positions defines the positions to use
  7317. * @param start defines the start index in the positions array
  7318. * @param count defines the number of positions to handle
  7319. * @param bias defines bias value to add to the result
  7320. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7321. * @return minimum and maximum values
  7322. */
  7323. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7324. minimum: Vector3;
  7325. maximum: Vector3;
  7326. };
  7327. }
  7328. declare module "babylonjs/Misc/iInspectable" {
  7329. /**
  7330. * Enum that determines the text-wrapping mode to use.
  7331. */
  7332. export enum InspectableType {
  7333. /**
  7334. * Checkbox for booleans
  7335. */
  7336. Checkbox = 0,
  7337. /**
  7338. * Sliders for numbers
  7339. */
  7340. Slider = 1,
  7341. /**
  7342. * Vector3
  7343. */
  7344. Vector3 = 2,
  7345. /**
  7346. * Quaternions
  7347. */
  7348. Quaternion = 3,
  7349. /**
  7350. * Color3
  7351. */
  7352. Color3 = 4,
  7353. /**
  7354. * String
  7355. */
  7356. String = 5
  7357. }
  7358. /**
  7359. * Interface used to define custom inspectable properties.
  7360. * This interface is used by the inspector to display custom property grids
  7361. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7362. */
  7363. export interface IInspectable {
  7364. /**
  7365. * Gets the label to display
  7366. */
  7367. label: string;
  7368. /**
  7369. * Gets the name of the property to edit
  7370. */
  7371. propertyName: string;
  7372. /**
  7373. * Gets the type of the editor to use
  7374. */
  7375. type: InspectableType;
  7376. /**
  7377. * Gets the minimum value of the property when using in "slider" mode
  7378. */
  7379. min?: number;
  7380. /**
  7381. * Gets the maximum value of the property when using in "slider" mode
  7382. */
  7383. max?: number;
  7384. /**
  7385. * Gets the setp to use when using in "slider" mode
  7386. */
  7387. step?: number;
  7388. }
  7389. }
  7390. declare module "babylonjs/Misc/timingTools" {
  7391. /**
  7392. * Class used to provide helper for timing
  7393. */
  7394. export class TimingTools {
  7395. /**
  7396. * Polyfill for setImmediate
  7397. * @param action defines the action to execute after the current execution block
  7398. */
  7399. static SetImmediate(action: () => void): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/instantiationTools" {
  7403. /**
  7404. * Class used to enable instatition of objects by class name
  7405. */
  7406. export class InstantiationTools {
  7407. /**
  7408. * Use this object to register external classes like custom textures or material
  7409. * to allow the laoders to instantiate them
  7410. */
  7411. static RegisteredExternalClasses: {
  7412. [key: string]: Object;
  7413. };
  7414. /**
  7415. * Tries to instantiate a new object from a given class name
  7416. * @param className defines the class name to instantiate
  7417. * @returns the new object or null if the system was not able to do the instantiation
  7418. */
  7419. static Instantiate(className: string): any;
  7420. }
  7421. }
  7422. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7423. import { Nullable } from "babylonjs/types";
  7424. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7425. /**
  7426. * This represents the required contract to create a new type of texture loader.
  7427. */
  7428. export interface IInternalTextureLoader {
  7429. /**
  7430. * Defines wether the loader supports cascade loading the different faces.
  7431. */
  7432. supportCascades: boolean;
  7433. /**
  7434. * This returns if the loader support the current file information.
  7435. * @param extension defines the file extension of the file being loaded
  7436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7437. * @param fallback defines the fallback internal texture if any
  7438. * @param isBase64 defines whether the texture is encoded as a base64
  7439. * @param isBuffer defines whether the texture data are stored as a buffer
  7440. * @returns true if the loader can load the specified file
  7441. */
  7442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7443. /**
  7444. * Transform the url before loading if required.
  7445. * @param rootUrl the url of the texture
  7446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7447. * @returns the transformed texture
  7448. */
  7449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7450. /**
  7451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the fallback texture
  7455. */
  7456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7457. /**
  7458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7459. * @param data contains the texture data
  7460. * @param texture defines the BabylonJS internal texture
  7461. * @param createPolynomials will be true if polynomials have been requested
  7462. * @param onLoad defines the callback to trigger once the texture is ready
  7463. * @param onError defines the callback to trigger in case of error
  7464. */
  7465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7466. /**
  7467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7468. * @param data contains the texture data
  7469. * @param texture defines the BabylonJS internal texture
  7470. * @param callback defines the method to call once ready to upload
  7471. */
  7472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7473. }
  7474. }
  7475. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7477. import { Nullable } from "babylonjs/types";
  7478. import { Scene } from "babylonjs/scene";
  7479. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7480. module "babylonjs/Engines/engine" {
  7481. interface Engine {
  7482. /**
  7483. * Creates a depth stencil cube texture.
  7484. * This is only available in WebGL 2.
  7485. * @param size The size of face edge in the cube texture.
  7486. * @param options The options defining the cube texture.
  7487. * @returns The cube texture
  7488. */
  7489. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7490. /**
  7491. * Creates a cube texture
  7492. * @param rootUrl defines the url where the files to load is located
  7493. * @param scene defines the current scene
  7494. * @param files defines the list of files to load (1 per face)
  7495. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7496. * @param onLoad defines an optional callback raised when the texture is loaded
  7497. * @param onError defines an optional callback raised if there is an issue to load the texture
  7498. * @param format defines the format of the data
  7499. * @param forcedExtension defines the extension to use to pick the right loader
  7500. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7503. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7504. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7505. * @returns the cube texture as an InternalTexture
  7506. */
  7507. 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;
  7508. /**
  7509. * Creates a cube texture
  7510. * @param rootUrl defines the url where the files to load is located
  7511. * @param scene defines the current scene
  7512. * @param files defines the list of files to load (1 per face)
  7513. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7514. * @param onLoad defines an optional callback raised when the texture is loaded
  7515. * @param onError defines an optional callback raised if there is an issue to load the texture
  7516. * @param format defines the format of the data
  7517. * @param forcedExtension defines the extension to use to pick the right loader
  7518. * @returns the cube texture as an InternalTexture
  7519. */
  7520. 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;
  7521. /**
  7522. * Creates a cube texture
  7523. * @param rootUrl defines the url where the files to load is located
  7524. * @param scene defines the current scene
  7525. * @param files defines the list of files to load (1 per face)
  7526. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7527. * @param onLoad defines an optional callback raised when the texture is loaded
  7528. * @param onError defines an optional callback raised if there is an issue to load the texture
  7529. * @param format defines the format of the data
  7530. * @param forcedExtension defines the extension to use to pick the right loader
  7531. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7532. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7533. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7534. * @returns the cube texture as an InternalTexture
  7535. */
  7536. 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;
  7537. /** @hidden */
  7538. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7539. /** @hidden */
  7540. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7541. /** @hidden */
  7542. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7543. /** @hidden */
  7544. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7545. }
  7546. }
  7547. }
  7548. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7549. import { Nullable } from "babylonjs/types";
  7550. import { Scene } from "babylonjs/scene";
  7551. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7552. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7553. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7554. /**
  7555. * Class for creating a cube texture
  7556. */
  7557. export class CubeTexture extends BaseTexture {
  7558. private _delayedOnLoad;
  7559. /**
  7560. * The url of the texture
  7561. */
  7562. url: string;
  7563. /**
  7564. * Gets or sets the center of the bounding box associated with the cube texture.
  7565. * It must define where the camera used to render the texture was set
  7566. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7567. */
  7568. boundingBoxPosition: Vector3;
  7569. private _boundingBoxSize;
  7570. /**
  7571. * Gets or sets the size of the bounding box associated with the cube texture
  7572. * When defined, the cubemap will switch to local mode
  7573. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7574. * @example https://www.babylonjs-playground.com/#RNASML
  7575. */
  7576. /**
  7577. * Returns the bounding box size
  7578. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7579. */
  7580. boundingBoxSize: Vector3;
  7581. protected _rotationY: number;
  7582. /**
  7583. * Sets texture matrix rotation angle around Y axis in radians.
  7584. */
  7585. /**
  7586. * Gets texture matrix rotation angle around Y axis radians.
  7587. */
  7588. rotationY: number;
  7589. /**
  7590. * Are mip maps generated for this texture or not.
  7591. */
  7592. readonly noMipmap: boolean;
  7593. private _noMipmap;
  7594. private _files;
  7595. private _extensions;
  7596. private _textureMatrix;
  7597. private _format;
  7598. private _createPolynomials;
  7599. /** @hidden */
  7600. _prefiltered: boolean;
  7601. /**
  7602. * Creates a cube texture from an array of image urls
  7603. * @param files defines an array of image urls
  7604. * @param scene defines the hosting scene
  7605. * @param noMipmap specifies if mip maps are not used
  7606. * @returns a cube texture
  7607. */
  7608. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7609. /**
  7610. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7611. * @param url defines the url of the prefiltered texture
  7612. * @param scene defines the scene the texture is attached to
  7613. * @param forcedExtension defines the extension of the file if different from the url
  7614. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7615. * @return the prefiltered texture
  7616. */
  7617. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7618. /**
  7619. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7620. * as prefiltered data.
  7621. * @param rootUrl defines the url of the texture or the root name of the six images
  7622. * @param scene defines the scene the texture is attached to
  7623. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7624. * @param noMipmap defines if mipmaps should be created or not
  7625. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7626. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7627. * @param onError defines a callback triggered in case of error during load
  7628. * @param format defines the internal format to use for the texture once loaded
  7629. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7630. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7631. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7634. * @return the cube texture
  7635. */
  7636. 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);
  7637. /**
  7638. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7639. */
  7640. readonly isPrefiltered: boolean;
  7641. /**
  7642. * Get the current class name of the texture useful for serialization or dynamic coding.
  7643. * @returns "CubeTexture"
  7644. */
  7645. getClassName(): string;
  7646. /**
  7647. * Update the url (and optional buffer) of this texture if url was null during construction.
  7648. * @param url the url of the texture
  7649. * @param forcedExtension defines the extension to use
  7650. * @param onLoad callback called when the texture is loaded (defaults to null)
  7651. */
  7652. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7653. /**
  7654. * Delays loading of the cube texture
  7655. * @param forcedExtension defines the extension to use
  7656. */
  7657. delayLoad(forcedExtension?: string): void;
  7658. /**
  7659. * Returns the reflection texture matrix
  7660. * @returns the reflection texture matrix
  7661. */
  7662. getReflectionTextureMatrix(): Matrix;
  7663. /**
  7664. * Sets the reflection texture matrix
  7665. * @param value Reflection texture matrix
  7666. */
  7667. setReflectionTextureMatrix(value: Matrix): void;
  7668. /**
  7669. * Parses text to create a cube texture
  7670. * @param parsedTexture define the serialized text to read from
  7671. * @param scene defines the hosting scene
  7672. * @param rootUrl defines the root url of the cube texture
  7673. * @returns a cube texture
  7674. */
  7675. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7676. /**
  7677. * Makes a clone, or deep copy, of the cube texture
  7678. * @returns a new cube texture
  7679. */
  7680. clone(): CubeTexture;
  7681. }
  7682. }
  7683. declare module "babylonjs/Materials/materialDefines" {
  7684. /**
  7685. * Manages the defines for the Material
  7686. */
  7687. export class MaterialDefines {
  7688. /** @hidden */
  7689. protected _keys: string[];
  7690. private _isDirty;
  7691. /** @hidden */
  7692. _renderId: number;
  7693. /** @hidden */
  7694. _areLightsDirty: boolean;
  7695. /** @hidden */
  7696. _areLightsDisposed: boolean;
  7697. /** @hidden */
  7698. _areAttributesDirty: boolean;
  7699. /** @hidden */
  7700. _areTexturesDirty: boolean;
  7701. /** @hidden */
  7702. _areFresnelDirty: boolean;
  7703. /** @hidden */
  7704. _areMiscDirty: boolean;
  7705. /** @hidden */
  7706. _areImageProcessingDirty: boolean;
  7707. /** @hidden */
  7708. _normals: boolean;
  7709. /** @hidden */
  7710. _uvs: boolean;
  7711. /** @hidden */
  7712. _needNormals: boolean;
  7713. /** @hidden */
  7714. _needUVs: boolean;
  7715. [id: string]: any;
  7716. /**
  7717. * Specifies if the material needs to be re-calculated
  7718. */
  7719. readonly isDirty: boolean;
  7720. /**
  7721. * Marks the material to indicate that it has been re-calculated
  7722. */
  7723. markAsProcessed(): void;
  7724. /**
  7725. * Marks the material to indicate that it needs to be re-calculated
  7726. */
  7727. markAsUnprocessed(): void;
  7728. /**
  7729. * Marks the material to indicate all of its defines need to be re-calculated
  7730. */
  7731. markAllAsDirty(): void;
  7732. /**
  7733. * Marks the material to indicate that image processing needs to be re-calculated
  7734. */
  7735. markAsImageProcessingDirty(): void;
  7736. /**
  7737. * Marks the material to indicate the lights need to be re-calculated
  7738. * @param disposed Defines whether the light is dirty due to dispose or not
  7739. */
  7740. markAsLightDirty(disposed?: boolean): void;
  7741. /**
  7742. * Marks the attribute state as changed
  7743. */
  7744. markAsAttributesDirty(): void;
  7745. /**
  7746. * Marks the texture state as changed
  7747. */
  7748. markAsTexturesDirty(): void;
  7749. /**
  7750. * Marks the fresnel state as changed
  7751. */
  7752. markAsFresnelDirty(): void;
  7753. /**
  7754. * Marks the misc state as changed
  7755. */
  7756. markAsMiscDirty(): void;
  7757. /**
  7758. * Rebuilds the material defines
  7759. */
  7760. rebuild(): void;
  7761. /**
  7762. * Specifies if two material defines are equal
  7763. * @param other - A material define instance to compare to
  7764. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7765. */
  7766. isEqual(other: MaterialDefines): boolean;
  7767. /**
  7768. * Clones this instance's defines to another instance
  7769. * @param other - material defines to clone values to
  7770. */
  7771. cloneTo(other: MaterialDefines): void;
  7772. /**
  7773. * Resets the material define values
  7774. */
  7775. reset(): void;
  7776. /**
  7777. * Converts the material define values to a string
  7778. * @returns - String of material define information
  7779. */
  7780. toString(): string;
  7781. }
  7782. }
  7783. declare module "babylonjs/Materials/colorCurves" {
  7784. import { Effect } from "babylonjs/Materials/effect";
  7785. /**
  7786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7788. * 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;
  7789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7790. */
  7791. export class ColorCurves {
  7792. private _dirty;
  7793. private _tempColor;
  7794. private _globalCurve;
  7795. private _highlightsCurve;
  7796. private _midtonesCurve;
  7797. private _shadowsCurve;
  7798. private _positiveCurve;
  7799. private _negativeCurve;
  7800. private _globalHue;
  7801. private _globalDensity;
  7802. private _globalSaturation;
  7803. private _globalExposure;
  7804. /**
  7805. * Gets the global Hue value.
  7806. * 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).
  7807. */
  7808. /**
  7809. * Sets the global Hue value.
  7810. * 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).
  7811. */
  7812. globalHue: number;
  7813. /**
  7814. * Gets the global Density value.
  7815. * 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.
  7816. * Values less than zero provide a filter of opposite hue.
  7817. */
  7818. /**
  7819. * Sets the global Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. globalDensity: number;
  7824. /**
  7825. * Gets the global Saturation value.
  7826. * 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.
  7827. */
  7828. /**
  7829. * Sets the global Saturation value.
  7830. * 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.
  7831. */
  7832. globalSaturation: number;
  7833. /**
  7834. * Gets the global Exposure value.
  7835. * 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.
  7836. */
  7837. /**
  7838. * Sets the global Exposure value.
  7839. * 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.
  7840. */
  7841. globalExposure: number;
  7842. private _highlightsHue;
  7843. private _highlightsDensity;
  7844. private _highlightsSaturation;
  7845. private _highlightsExposure;
  7846. /**
  7847. * Gets the highlights Hue value.
  7848. * 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).
  7849. */
  7850. /**
  7851. * Sets the highlights Hue value.
  7852. * 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).
  7853. */
  7854. highlightsHue: number;
  7855. /**
  7856. * Gets the highlights Density value.
  7857. * 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.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the highlights Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. highlightsDensity: number;
  7866. /**
  7867. * Gets the highlights Saturation value.
  7868. * 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.
  7869. */
  7870. /**
  7871. * Sets the highlights Saturation value.
  7872. * 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.
  7873. */
  7874. highlightsSaturation: number;
  7875. /**
  7876. * Gets the highlights Exposure value.
  7877. * 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.
  7878. */
  7879. /**
  7880. * Sets the highlights Exposure value.
  7881. * 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.
  7882. */
  7883. highlightsExposure: number;
  7884. private _midtonesHue;
  7885. private _midtonesDensity;
  7886. private _midtonesSaturation;
  7887. private _midtonesExposure;
  7888. /**
  7889. * Gets the midtones Hue value.
  7890. * 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).
  7891. */
  7892. /**
  7893. * Sets the midtones Hue value.
  7894. * 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).
  7895. */
  7896. midtonesHue: number;
  7897. /**
  7898. * Gets the midtones Density value.
  7899. * 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.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the midtones Density value.
  7904. * 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.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. midtonesDensity: number;
  7908. /**
  7909. * Gets the midtones Saturation value.
  7910. * 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.
  7911. */
  7912. /**
  7913. * Sets the midtones Saturation value.
  7914. * 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.
  7915. */
  7916. midtonesSaturation: number;
  7917. /**
  7918. * Gets the midtones Exposure value.
  7919. * 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.
  7920. */
  7921. /**
  7922. * Sets the midtones Exposure value.
  7923. * 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.
  7924. */
  7925. midtonesExposure: number;
  7926. private _shadowsHue;
  7927. private _shadowsDensity;
  7928. private _shadowsSaturation;
  7929. private _shadowsExposure;
  7930. /**
  7931. * Gets the shadows Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the shadows Hue value.
  7936. * 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).
  7937. */
  7938. shadowsHue: number;
  7939. /**
  7940. * Gets the shadows Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the shadows Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. shadowsDensity: number;
  7950. /**
  7951. * Gets the shadows Saturation value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the shadows Saturation value.
  7956. * 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.
  7957. */
  7958. shadowsSaturation: number;
  7959. /**
  7960. * Gets the shadows Exposure value.
  7961. * 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.
  7962. */
  7963. /**
  7964. * Sets the shadows Exposure value.
  7965. * 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.
  7966. */
  7967. shadowsExposure: number;
  7968. /**
  7969. * Returns the class name
  7970. * @returns The class name
  7971. */
  7972. getClassName(): string;
  7973. /**
  7974. * Binds the color curves to the shader.
  7975. * @param colorCurves The color curve to bind
  7976. * @param effect The effect to bind to
  7977. * @param positiveUniform The positive uniform shader parameter
  7978. * @param neutralUniform The neutral uniform shader parameter
  7979. * @param negativeUniform The negative uniform shader parameter
  7980. */
  7981. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7982. /**
  7983. * Prepare the list of uniforms associated with the ColorCurves effects.
  7984. * @param uniformsList The list of uniforms used in the effect
  7985. */
  7986. static PrepareUniforms(uniformsList: string[]): void;
  7987. /**
  7988. * Returns color grading data based on a hue, density, saturation and exposure value.
  7989. * @param filterHue The hue of the color filter.
  7990. * @param filterDensity The density of the color filter.
  7991. * @param saturation The saturation.
  7992. * @param exposure The exposure.
  7993. * @param result The result data container.
  7994. */
  7995. private getColorGradingDataToRef;
  7996. /**
  7997. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7998. * @param value The input slider value in range [-100,100].
  7999. * @returns Adjusted value.
  8000. */
  8001. private static applyColorGradingSliderNonlinear;
  8002. /**
  8003. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8004. * @param hue The hue (H) input.
  8005. * @param saturation The saturation (S) input.
  8006. * @param brightness The brightness (B) input.
  8007. * @result An RGBA color represented as Vector4.
  8008. */
  8009. private static fromHSBToRef;
  8010. /**
  8011. * Returns a value clamped between min and max
  8012. * @param value The value to clamp
  8013. * @param min The minimum of value
  8014. * @param max The maximum of value
  8015. * @returns The clamped value.
  8016. */
  8017. private static clamp;
  8018. /**
  8019. * Clones the current color curve instance.
  8020. * @return The cloned curves
  8021. */
  8022. clone(): ColorCurves;
  8023. /**
  8024. * Serializes the current color curve instance to a json representation.
  8025. * @return a JSON representation
  8026. */
  8027. serialize(): any;
  8028. /**
  8029. * Parses the color curve from a json representation.
  8030. * @param source the JSON source to parse
  8031. * @return The parsed curves
  8032. */
  8033. static Parse(source: any): ColorCurves;
  8034. }
  8035. }
  8036. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8037. import { Observable } from "babylonjs/Misc/observable";
  8038. import { Nullable } from "babylonjs/types";
  8039. import { Color4 } from "babylonjs/Maths/math.color";
  8040. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8041. import { Effect } from "babylonjs/Materials/effect";
  8042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8043. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8044. /**
  8045. * Interface to follow in your material defines to integrate easily the
  8046. * Image proccessing functions.
  8047. * @hidden
  8048. */
  8049. export interface IImageProcessingConfigurationDefines {
  8050. IMAGEPROCESSING: boolean;
  8051. VIGNETTE: boolean;
  8052. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8053. VIGNETTEBLENDMODEOPAQUE: boolean;
  8054. TONEMAPPING: boolean;
  8055. TONEMAPPING_ACES: boolean;
  8056. CONTRAST: boolean;
  8057. EXPOSURE: boolean;
  8058. COLORCURVES: boolean;
  8059. COLORGRADING: boolean;
  8060. COLORGRADING3D: boolean;
  8061. SAMPLER3DGREENDEPTH: boolean;
  8062. SAMPLER3DBGRMAP: boolean;
  8063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8064. }
  8065. /**
  8066. * @hidden
  8067. */
  8068. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8069. IMAGEPROCESSING: boolean;
  8070. VIGNETTE: boolean;
  8071. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8072. VIGNETTEBLENDMODEOPAQUE: boolean;
  8073. TONEMAPPING: boolean;
  8074. TONEMAPPING_ACES: boolean;
  8075. CONTRAST: boolean;
  8076. COLORCURVES: boolean;
  8077. COLORGRADING: boolean;
  8078. COLORGRADING3D: boolean;
  8079. SAMPLER3DGREENDEPTH: boolean;
  8080. SAMPLER3DBGRMAP: boolean;
  8081. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8082. EXPOSURE: boolean;
  8083. constructor();
  8084. }
  8085. /**
  8086. * This groups together the common properties used for image processing either in direct forward pass
  8087. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8088. * or not.
  8089. */
  8090. export class ImageProcessingConfiguration {
  8091. /**
  8092. * Default tone mapping applied in BabylonJS.
  8093. */
  8094. static readonly TONEMAPPING_STANDARD: number;
  8095. /**
  8096. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8097. * to other engines rendering to increase portability.
  8098. */
  8099. static readonly TONEMAPPING_ACES: number;
  8100. /**
  8101. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8102. */
  8103. colorCurves: Nullable<ColorCurves>;
  8104. private _colorCurvesEnabled;
  8105. /**
  8106. * Gets wether the color curves effect is enabled.
  8107. */
  8108. /**
  8109. * Sets wether the color curves effect is enabled.
  8110. */
  8111. colorCurvesEnabled: boolean;
  8112. private _colorGradingTexture;
  8113. /**
  8114. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8115. */
  8116. /**
  8117. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8118. */
  8119. colorGradingTexture: Nullable<BaseTexture>;
  8120. private _colorGradingEnabled;
  8121. /**
  8122. * Gets wether the color grading effect is enabled.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is enabled.
  8126. */
  8127. colorGradingEnabled: boolean;
  8128. private _colorGradingWithGreenDepth;
  8129. /**
  8130. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8131. */
  8132. /**
  8133. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8134. */
  8135. colorGradingWithGreenDepth: boolean;
  8136. private _colorGradingBGR;
  8137. /**
  8138. * Gets wether the color grading texture contains BGR values.
  8139. */
  8140. /**
  8141. * Sets wether the color grading texture contains BGR values.
  8142. */
  8143. colorGradingBGR: boolean;
  8144. /** @hidden */
  8145. _exposure: number;
  8146. /**
  8147. * Gets the Exposure used in the effect.
  8148. */
  8149. /**
  8150. * Sets the Exposure used in the effect.
  8151. */
  8152. exposure: number;
  8153. private _toneMappingEnabled;
  8154. /**
  8155. * Gets wether the tone mapping effect is enabled.
  8156. */
  8157. /**
  8158. * Sets wether the tone mapping effect is enabled.
  8159. */
  8160. toneMappingEnabled: boolean;
  8161. private _toneMappingType;
  8162. /**
  8163. * Gets the type of tone mapping effect.
  8164. */
  8165. /**
  8166. * Sets the type of tone mapping effect used in BabylonJS.
  8167. */
  8168. toneMappingType: number;
  8169. protected _contrast: number;
  8170. /**
  8171. * Gets the contrast used in the effect.
  8172. */
  8173. /**
  8174. * Sets the contrast used in the effect.
  8175. */
  8176. contrast: number;
  8177. /**
  8178. * Vignette stretch size.
  8179. */
  8180. vignetteStretch: number;
  8181. /**
  8182. * Vignette centre X Offset.
  8183. */
  8184. vignetteCentreX: number;
  8185. /**
  8186. * Vignette centre Y Offset.
  8187. */
  8188. vignetteCentreY: number;
  8189. /**
  8190. * Vignette weight or intensity of the vignette effect.
  8191. */
  8192. vignetteWeight: number;
  8193. /**
  8194. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8195. * if vignetteEnabled is set to true.
  8196. */
  8197. vignetteColor: Color4;
  8198. /**
  8199. * Camera field of view used by the Vignette effect.
  8200. */
  8201. vignetteCameraFov: number;
  8202. private _vignetteBlendMode;
  8203. /**
  8204. * Gets the vignette blend mode allowing different kind of effect.
  8205. */
  8206. /**
  8207. * Sets the vignette blend mode allowing different kind of effect.
  8208. */
  8209. vignetteBlendMode: number;
  8210. private _vignetteEnabled;
  8211. /**
  8212. * Gets wether the vignette effect is enabled.
  8213. */
  8214. /**
  8215. * Sets wether the vignette effect is enabled.
  8216. */
  8217. vignetteEnabled: boolean;
  8218. private _applyByPostProcess;
  8219. /**
  8220. * Gets wether the image processing is applied through a post process or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is applied through a post process or not.
  8224. */
  8225. applyByPostProcess: boolean;
  8226. private _isEnabled;
  8227. /**
  8228. * Gets wether the image processing is enabled or not.
  8229. */
  8230. /**
  8231. * Sets wether the image processing is enabled or not.
  8232. */
  8233. isEnabled: boolean;
  8234. /**
  8235. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8236. */
  8237. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8238. /**
  8239. * Method called each time the image processing information changes requires to recompile the effect.
  8240. */
  8241. protected _updateParameters(): void;
  8242. /**
  8243. * Gets the current class name.
  8244. * @return "ImageProcessingConfiguration"
  8245. */
  8246. getClassName(): string;
  8247. /**
  8248. * Prepare the list of uniforms associated with the Image Processing effects.
  8249. * @param uniforms The list of uniforms used in the effect
  8250. * @param defines the list of defines currently in use
  8251. */
  8252. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8253. /**
  8254. * Prepare the list of samplers associated with the Image Processing effects.
  8255. * @param samplersList The list of uniforms used in the effect
  8256. * @param defines the list of defines currently in use
  8257. */
  8258. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8259. /**
  8260. * Prepare the list of defines associated to the shader.
  8261. * @param defines the list of defines to complete
  8262. * @param forPostProcess Define if we are currently in post process mode or not
  8263. */
  8264. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8265. /**
  8266. * Returns true if all the image processing information are ready.
  8267. * @returns True if ready, otherwise, false
  8268. */
  8269. isReady(): boolean;
  8270. /**
  8271. * Binds the image processing to the shader.
  8272. * @param effect The effect to bind to
  8273. * @param aspectRatio Define the current aspect ratio of the effect
  8274. */
  8275. bind(effect: Effect, aspectRatio?: number): void;
  8276. /**
  8277. * Clones the current image processing instance.
  8278. * @return The cloned image processing
  8279. */
  8280. clone(): ImageProcessingConfiguration;
  8281. /**
  8282. * Serializes the current image processing instance to a json representation.
  8283. * @return a JSON representation
  8284. */
  8285. serialize(): any;
  8286. /**
  8287. * Parses the image processing from a json representation.
  8288. * @param source the JSON source to parse
  8289. * @return The parsed image processing
  8290. */
  8291. static Parse(source: any): ImageProcessingConfiguration;
  8292. private static _VIGNETTEMODE_MULTIPLY;
  8293. private static _VIGNETTEMODE_OPAQUE;
  8294. /**
  8295. * Used to apply the vignette as a mix with the pixel color.
  8296. */
  8297. static readonly VIGNETTEMODE_MULTIPLY: number;
  8298. /**
  8299. * Used to apply the vignette as a replacement of the pixel color.
  8300. */
  8301. static readonly VIGNETTEMODE_OPAQUE: number;
  8302. }
  8303. }
  8304. declare module "babylonjs/Shaders/postprocess.vertex" {
  8305. /** @hidden */
  8306. export var postprocessVertexShader: {
  8307. name: string;
  8308. shader: string;
  8309. };
  8310. }
  8311. declare module "babylonjs/Maths/math.axis" {
  8312. import { Vector3 } from "babylonjs/Maths/math.vector";
  8313. /** Defines supported spaces */
  8314. export enum Space {
  8315. /** Local (object) space */
  8316. LOCAL = 0,
  8317. /** World space */
  8318. WORLD = 1,
  8319. /** Bone space */
  8320. BONE = 2
  8321. }
  8322. /** Defines the 3 main axes */
  8323. export class Axis {
  8324. /** X axis */
  8325. static X: Vector3;
  8326. /** Y axis */
  8327. static Y: Vector3;
  8328. /** Z axis */
  8329. static Z: Vector3;
  8330. }
  8331. }
  8332. declare module "babylonjs/Cameras/targetCamera" {
  8333. import { Nullable } from "babylonjs/types";
  8334. import { Camera } from "babylonjs/Cameras/camera";
  8335. import { Scene } from "babylonjs/scene";
  8336. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8337. /**
  8338. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8339. * This is the base of the follow, arc rotate cameras and Free camera
  8340. * @see http://doc.babylonjs.com/features/cameras
  8341. */
  8342. export class TargetCamera extends Camera {
  8343. private static _RigCamTransformMatrix;
  8344. private static _TargetTransformMatrix;
  8345. private static _TargetFocalPoint;
  8346. /**
  8347. * Define the current direction the camera is moving to
  8348. */
  8349. cameraDirection: Vector3;
  8350. /**
  8351. * Define the current rotation the camera is rotating to
  8352. */
  8353. cameraRotation: Vector2;
  8354. /**
  8355. * When set, the up vector of the camera will be updated by the rotation of the camera
  8356. */
  8357. updateUpVectorFromRotation: boolean;
  8358. private _tmpQuaternion;
  8359. /**
  8360. * Define the current rotation of the camera
  8361. */
  8362. rotation: Vector3;
  8363. /**
  8364. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8365. */
  8366. rotationQuaternion: Quaternion;
  8367. /**
  8368. * Define the current speed of the camera
  8369. */
  8370. speed: number;
  8371. /**
  8372. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8373. * around all axis.
  8374. */
  8375. noRotationConstraint: boolean;
  8376. /**
  8377. * Define the current target of the camera as an object or a position.
  8378. */
  8379. lockedTarget: any;
  8380. /** @hidden */
  8381. _currentTarget: Vector3;
  8382. /** @hidden */
  8383. _initialFocalDistance: number;
  8384. /** @hidden */
  8385. _viewMatrix: Matrix;
  8386. /** @hidden */
  8387. _camMatrix: Matrix;
  8388. /** @hidden */
  8389. _cameraTransformMatrix: Matrix;
  8390. /** @hidden */
  8391. _cameraRotationMatrix: Matrix;
  8392. /** @hidden */
  8393. _referencePoint: Vector3;
  8394. /** @hidden */
  8395. _transformedReferencePoint: Vector3;
  8396. protected _globalCurrentTarget: Vector3;
  8397. protected _globalCurrentUpVector: Vector3;
  8398. /** @hidden */
  8399. _reset: () => void;
  8400. private _defaultUp;
  8401. /**
  8402. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8403. * This is the base of the follow, arc rotate cameras and Free camera
  8404. * @see http://doc.babylonjs.com/features/cameras
  8405. * @param name Defines the name of the camera in the scene
  8406. * @param position Defines the start position of the camera in the scene
  8407. * @param scene Defines the scene the camera belongs to
  8408. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8409. */
  8410. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8411. /**
  8412. * Gets the position in front of the camera at a given distance.
  8413. * @param distance The distance from the camera we want the position to be
  8414. * @returns the position
  8415. */
  8416. getFrontPosition(distance: number): Vector3;
  8417. /** @hidden */
  8418. _getLockedTargetPosition(): Nullable<Vector3>;
  8419. private _storedPosition;
  8420. private _storedRotation;
  8421. private _storedRotationQuaternion;
  8422. /**
  8423. * Store current camera state of the camera (fov, position, rotation, etc..)
  8424. * @returns the camera
  8425. */
  8426. storeState(): Camera;
  8427. /**
  8428. * Restored camera state. You must call storeState() first
  8429. * @returns whether it was successful or not
  8430. * @hidden
  8431. */
  8432. _restoreStateValues(): boolean;
  8433. /** @hidden */
  8434. _initCache(): void;
  8435. /** @hidden */
  8436. _updateCache(ignoreParentClass?: boolean): void;
  8437. /** @hidden */
  8438. _isSynchronizedViewMatrix(): boolean;
  8439. /** @hidden */
  8440. _computeLocalCameraSpeed(): number;
  8441. /**
  8442. * Defines the target the camera should look at.
  8443. * @param target Defines the new target as a Vector or a mesh
  8444. */
  8445. setTarget(target: Vector3): void;
  8446. /**
  8447. * Return the current target position of the camera. This value is expressed in local space.
  8448. * @returns the target position
  8449. */
  8450. getTarget(): Vector3;
  8451. /** @hidden */
  8452. _decideIfNeedsToMove(): boolean;
  8453. /** @hidden */
  8454. _updatePosition(): void;
  8455. /** @hidden */
  8456. _checkInputs(): void;
  8457. protected _updateCameraRotationMatrix(): void;
  8458. /**
  8459. * 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)
  8460. * @returns the current camera
  8461. */
  8462. private _rotateUpVectorWithCameraRotationMatrix;
  8463. private _cachedRotationZ;
  8464. private _cachedQuaternionRotationZ;
  8465. /** @hidden */
  8466. _getViewMatrix(): Matrix;
  8467. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8468. /**
  8469. * @hidden
  8470. */
  8471. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8472. /**
  8473. * @hidden
  8474. */
  8475. _updateRigCameras(): void;
  8476. private _getRigCamPositionAndTarget;
  8477. /**
  8478. * Gets the current object class name.
  8479. * @return the class name
  8480. */
  8481. getClassName(): string;
  8482. }
  8483. }
  8484. declare module "babylonjs/Events/keyboardEvents" {
  8485. /**
  8486. * Gather the list of keyboard event types as constants.
  8487. */
  8488. export class KeyboardEventTypes {
  8489. /**
  8490. * The keydown event is fired when a key becomes active (pressed).
  8491. */
  8492. static readonly KEYDOWN: number;
  8493. /**
  8494. * The keyup event is fired when a key has been released.
  8495. */
  8496. static readonly KEYUP: number;
  8497. }
  8498. /**
  8499. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8500. */
  8501. export class KeyboardInfo {
  8502. /**
  8503. * Defines the type of event (KeyboardEventTypes)
  8504. */
  8505. type: number;
  8506. /**
  8507. * Defines the related dom event
  8508. */
  8509. event: KeyboardEvent;
  8510. /**
  8511. * Instantiates a new keyboard info.
  8512. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8513. * @param type Defines the type of event (KeyboardEventTypes)
  8514. * @param event Defines the related dom event
  8515. */
  8516. constructor(
  8517. /**
  8518. * Defines the type of event (KeyboardEventTypes)
  8519. */
  8520. type: number,
  8521. /**
  8522. * Defines the related dom event
  8523. */
  8524. event: KeyboardEvent);
  8525. }
  8526. /**
  8527. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8528. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8529. */
  8530. export class KeyboardInfoPre extends KeyboardInfo {
  8531. /**
  8532. * Defines the type of event (KeyboardEventTypes)
  8533. */
  8534. type: number;
  8535. /**
  8536. * Defines the related dom event
  8537. */
  8538. event: KeyboardEvent;
  8539. /**
  8540. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8541. */
  8542. skipOnPointerObservable: boolean;
  8543. /**
  8544. * Instantiates a new keyboard pre info.
  8545. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8546. * @param type Defines the type of event (KeyboardEventTypes)
  8547. * @param event Defines the related dom event
  8548. */
  8549. constructor(
  8550. /**
  8551. * Defines the type of event (KeyboardEventTypes)
  8552. */
  8553. type: number,
  8554. /**
  8555. * Defines the related dom event
  8556. */
  8557. event: KeyboardEvent);
  8558. }
  8559. }
  8560. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8561. import { Nullable } from "babylonjs/types";
  8562. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8563. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8564. /**
  8565. * Manage the keyboard inputs to control the movement of a free camera.
  8566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8567. */
  8568. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8569. /**
  8570. * Defines the camera the input is attached to.
  8571. */
  8572. camera: FreeCamera;
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8575. */
  8576. keysUp: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8579. */
  8580. keysDown: number[];
  8581. /**
  8582. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8583. */
  8584. keysLeft: number[];
  8585. /**
  8586. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8587. */
  8588. keysRight: number[];
  8589. private _keys;
  8590. private _onCanvasBlurObserver;
  8591. private _onKeyboardObserver;
  8592. private _engine;
  8593. private _scene;
  8594. /**
  8595. * Attach the input controls to a specific dom element to get the input from.
  8596. * @param element Defines the element the controls should be listened from
  8597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8598. */
  8599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8600. /**
  8601. * Detach the current controls from the specified dom element.
  8602. * @param element Defines the element to stop listening the inputs from
  8603. */
  8604. detachControl(element: Nullable<HTMLElement>): void;
  8605. /**
  8606. * Update the current camera state depending on the inputs that have been used this frame.
  8607. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8608. */
  8609. checkInputs(): void;
  8610. /**
  8611. * Gets the class name of the current intput.
  8612. * @returns the class name
  8613. */
  8614. getClassName(): string;
  8615. /** @hidden */
  8616. _onLostFocus(): void;
  8617. /**
  8618. * Get the friendly name associated with the input class.
  8619. * @returns the input friendly name
  8620. */
  8621. getSimpleName(): string;
  8622. }
  8623. }
  8624. declare module "babylonjs/Lights/shadowLight" {
  8625. import { Camera } from "babylonjs/Cameras/camera";
  8626. import { Scene } from "babylonjs/scene";
  8627. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8629. import { Light } from "babylonjs/Lights/light";
  8630. /**
  8631. * Interface describing all the common properties and methods a shadow light needs to implement.
  8632. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8633. * as well as binding the different shadow properties to the effects.
  8634. */
  8635. export interface IShadowLight extends Light {
  8636. /**
  8637. * The light id in the scene (used in scene.findLighById for instance)
  8638. */
  8639. id: string;
  8640. /**
  8641. * The position the shdow will be casted from.
  8642. */
  8643. position: Vector3;
  8644. /**
  8645. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8646. */
  8647. direction: Vector3;
  8648. /**
  8649. * The transformed position. Position of the light in world space taking parenting in account.
  8650. */
  8651. transformedPosition: Vector3;
  8652. /**
  8653. * The transformed direction. Direction of the light in world space taking parenting in account.
  8654. */
  8655. transformedDirection: Vector3;
  8656. /**
  8657. * The friendly name of the light in the scene.
  8658. */
  8659. name: string;
  8660. /**
  8661. * Defines the shadow projection clipping minimum z value.
  8662. */
  8663. shadowMinZ: number;
  8664. /**
  8665. * Defines the shadow projection clipping maximum z value.
  8666. */
  8667. shadowMaxZ: number;
  8668. /**
  8669. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8670. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8671. */
  8672. computeTransformedInformation(): boolean;
  8673. /**
  8674. * Gets the scene the light belongs to.
  8675. * @returns The scene
  8676. */
  8677. getScene(): Scene;
  8678. /**
  8679. * Callback defining a custom Projection Matrix Builder.
  8680. * This can be used to override the default projection matrix computation.
  8681. */
  8682. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8683. /**
  8684. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8685. * @param matrix The materix to updated with the projection information
  8686. * @param viewMatrix The transform matrix of the light
  8687. * @param renderList The list of mesh to render in the map
  8688. * @returns The current light
  8689. */
  8690. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8691. /**
  8692. * Gets the current depth scale used in ESM.
  8693. * @returns The scale
  8694. */
  8695. getDepthScale(): number;
  8696. /**
  8697. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8698. * @returns true if a cube texture needs to be use
  8699. */
  8700. needCube(): boolean;
  8701. /**
  8702. * Detects if the projection matrix requires to be recomputed this frame.
  8703. * @returns true if it requires to be recomputed otherwise, false.
  8704. */
  8705. needProjectionMatrixCompute(): boolean;
  8706. /**
  8707. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8708. */
  8709. forceProjectionMatrixCompute(): void;
  8710. /**
  8711. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8712. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8713. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8714. */
  8715. getShadowDirection(faceIndex?: number): Vector3;
  8716. /**
  8717. * Gets the minZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the min for
  8719. * @returns the depth min z
  8720. */
  8721. getDepthMinZ(activeCamera: Camera): number;
  8722. /**
  8723. * Gets the maxZ used for shadow according to both the scene and the light.
  8724. * @param activeCamera The camera we are returning the max for
  8725. * @returns the depth max z
  8726. */
  8727. getDepthMaxZ(activeCamera: Camera): number;
  8728. }
  8729. /**
  8730. * Base implementation IShadowLight
  8731. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8732. */
  8733. export abstract class ShadowLight extends Light implements IShadowLight {
  8734. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8735. protected _position: Vector3;
  8736. protected _setPosition(value: Vector3): void;
  8737. /**
  8738. * Sets the position the shadow will be casted from. Also use as the light position for both
  8739. * point and spot lights.
  8740. */
  8741. /**
  8742. * Sets the position the shadow will be casted from. Also use as the light position for both
  8743. * point and spot lights.
  8744. */
  8745. position: Vector3;
  8746. protected _direction: Vector3;
  8747. protected _setDirection(value: Vector3): void;
  8748. /**
  8749. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8750. * Also use as the light direction on spot and directional lights.
  8751. */
  8752. /**
  8753. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8754. * Also use as the light direction on spot and directional lights.
  8755. */
  8756. direction: Vector3;
  8757. private _shadowMinZ;
  8758. /**
  8759. * Gets the shadow projection clipping minimum z value.
  8760. */
  8761. /**
  8762. * Sets the shadow projection clipping minimum z value.
  8763. */
  8764. shadowMinZ: number;
  8765. private _shadowMaxZ;
  8766. /**
  8767. * Sets the shadow projection clipping maximum z value.
  8768. */
  8769. /**
  8770. * Gets the shadow projection clipping maximum z value.
  8771. */
  8772. shadowMaxZ: number;
  8773. /**
  8774. * Callback defining a custom Projection Matrix Builder.
  8775. * This can be used to override the default projection matrix computation.
  8776. */
  8777. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8778. /**
  8779. * The transformed position. Position of the light in world space taking parenting in account.
  8780. */
  8781. transformedPosition: Vector3;
  8782. /**
  8783. * The transformed direction. Direction of the light in world space taking parenting in account.
  8784. */
  8785. transformedDirection: Vector3;
  8786. private _needProjectionMatrixCompute;
  8787. /**
  8788. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8789. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8790. */
  8791. computeTransformedInformation(): boolean;
  8792. /**
  8793. * Return the depth scale used for the shadow map.
  8794. * @returns the depth scale.
  8795. */
  8796. getDepthScale(): number;
  8797. /**
  8798. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8799. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8800. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8801. */
  8802. getShadowDirection(faceIndex?: number): Vector3;
  8803. /**
  8804. * Returns the ShadowLight absolute position in the World.
  8805. * @returns the position vector in world space
  8806. */
  8807. getAbsolutePosition(): Vector3;
  8808. /**
  8809. * Sets the ShadowLight direction toward the passed target.
  8810. * @param target The point to target in local space
  8811. * @returns the updated ShadowLight direction
  8812. */
  8813. setDirectionToTarget(target: Vector3): Vector3;
  8814. /**
  8815. * Returns the light rotation in euler definition.
  8816. * @returns the x y z rotation in local space.
  8817. */
  8818. getRotation(): Vector3;
  8819. /**
  8820. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8821. * @returns true if a cube texture needs to be use
  8822. */
  8823. needCube(): boolean;
  8824. /**
  8825. * Detects if the projection matrix requires to be recomputed this frame.
  8826. * @returns true if it requires to be recomputed otherwise, false.
  8827. */
  8828. needProjectionMatrixCompute(): boolean;
  8829. /**
  8830. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8831. */
  8832. forceProjectionMatrixCompute(): void;
  8833. /** @hidden */
  8834. _initCache(): void;
  8835. /** @hidden */
  8836. _isSynchronized(): boolean;
  8837. /**
  8838. * Computes the world matrix of the node
  8839. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8840. * @returns the world matrix
  8841. */
  8842. computeWorldMatrix(force?: boolean): Matrix;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. /**
  8856. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8857. * @param matrix The materix to updated with the projection information
  8858. * @param viewMatrix The transform matrix of the light
  8859. * @param renderList The list of mesh to render in the map
  8860. * @returns The current light
  8861. */
  8862. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8863. }
  8864. }
  8865. declare module "babylonjs/Materials/materialHelper" {
  8866. import { Nullable } from "babylonjs/types";
  8867. import { Scene } from "babylonjs/scene";
  8868. import { Engine } from "babylonjs/Engines/engine";
  8869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8870. import { Light } from "babylonjs/Lights/light";
  8871. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8872. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8874. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8875. /**
  8876. * "Static Class" containing the most commonly used helper while dealing with material for
  8877. * rendering purpose.
  8878. *
  8879. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8880. *
  8881. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8882. */
  8883. export class MaterialHelper {
  8884. /**
  8885. * Bind the current view position to an effect.
  8886. * @param effect The effect to be bound
  8887. * @param scene The scene the eyes position is used from
  8888. */
  8889. static BindEyePosition(effect: Effect, scene: Scene): void;
  8890. /**
  8891. * Helps preparing the defines values about the UVs in used in the effect.
  8892. * UVs are shared as much as we can accross channels in the shaders.
  8893. * @param texture The texture we are preparing the UVs for
  8894. * @param defines The defines to update
  8895. * @param key The channel key "diffuse", "specular"... used in the shader
  8896. */
  8897. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8898. /**
  8899. * Binds a texture matrix value to its corrsponding uniform
  8900. * @param texture The texture to bind the matrix for
  8901. * @param uniformBuffer The uniform buffer receivin the data
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8905. /**
  8906. * Gets the current status of the fog (should it be enabled?)
  8907. * @param mesh defines the mesh to evaluate for fog support
  8908. * @param scene defines the hosting scene
  8909. * @returns true if fog must be enabled
  8910. */
  8911. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8912. /**
  8913. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8914. * @param mesh defines the current mesh
  8915. * @param scene defines the current scene
  8916. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8917. * @param pointsCloud defines if point cloud rendering has to be turned on
  8918. * @param fogEnabled defines if fog has to be turned on
  8919. * @param alphaTest defines if alpha testing has to be turned on
  8920. * @param defines defines the current list of defines
  8921. */
  8922. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8923. /**
  8924. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8925. * @param scene defines the current scene
  8926. * @param engine defines the current engine
  8927. * @param defines specifies the list of active defines
  8928. * @param useInstances defines if instances have to be turned on
  8929. * @param useClipPlane defines if clip plane have to be turned on
  8930. */
  8931. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8932. /**
  8933. * Prepares the defines for bones
  8934. * @param mesh The mesh containing the geometry data we will draw
  8935. * @param defines The defines to update
  8936. */
  8937. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8938. /**
  8939. * Prepares the defines for morph targets
  8940. * @param mesh The mesh containing the geometry data we will draw
  8941. * @param defines The defines to update
  8942. */
  8943. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8944. /**
  8945. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8946. * @param mesh The mesh containing the geometry data we will draw
  8947. * @param defines The defines to update
  8948. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8949. * @param useBones Precise whether bones should be used or not (override mesh info)
  8950. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8951. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8952. * @returns false if defines are considered not dirty and have not been checked
  8953. */
  8954. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8955. /**
  8956. * Prepares the defines related to multiview
  8957. * @param scene The scene we are intending to draw
  8958. * @param defines The defines to update
  8959. */
  8960. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8961. /**
  8962. * Prepares the defines related to the light information passed in parameter
  8963. * @param scene The scene we are intending to draw
  8964. * @param mesh The mesh the effect is compiling for
  8965. * @param light The light the effect is compiling for
  8966. * @param lightIndex The index of the light
  8967. * @param defines The defines to update
  8968. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8969. * @param state Defines the current state regarding what is needed (normals, etc...)
  8970. */
  8971. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8972. needNormals: boolean;
  8973. needRebuild: boolean;
  8974. shadowEnabled: boolean;
  8975. specularEnabled: boolean;
  8976. lightmapMode: boolean;
  8977. }): void;
  8978. /**
  8979. * Prepares the defines related to the light information passed in parameter
  8980. * @param scene The scene we are intending to draw
  8981. * @param mesh The mesh the effect is compiling for
  8982. * @param defines The defines to update
  8983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8984. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8985. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8986. * @returns true if normals will be required for the rest of the effect
  8987. */
  8988. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8989. /**
  8990. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8991. * @param lightIndex defines the light index
  8992. * @param uniformsList The uniform list
  8993. * @param samplersList The sampler list
  8994. * @param projectedLightTexture defines if projected texture must be used
  8995. * @param uniformBuffersList defines an optional list of uniform buffers
  8996. */
  8997. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8998. /**
  8999. * Prepares the uniforms and samplers list to be used in the effect
  9000. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9001. * @param samplersList The sampler list
  9002. * @param defines The defines helping in the list generation
  9003. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9004. */
  9005. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9006. /**
  9007. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9008. * @param defines The defines to update while falling back
  9009. * @param fallbacks The authorized effect fallbacks
  9010. * @param maxSimultaneousLights The maximum number of lights allowed
  9011. * @param rank the current rank of the Effect
  9012. * @returns The newly affected rank
  9013. */
  9014. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9015. private static _TmpMorphInfluencers;
  9016. /**
  9017. * Prepares the list of attributes required for morph targets according to the effect defines.
  9018. * @param attribs The current list of supported attribs
  9019. * @param mesh The mesh to prepare the morph targets attributes for
  9020. * @param influencers The number of influencers
  9021. */
  9022. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param defines The current Defines of the effect
  9028. */
  9029. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9030. /**
  9031. * Prepares the list of attributes required for bones according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the bones attributes for
  9034. * @param defines The current Defines of the effect
  9035. * @param fallbacks The current efffect fallback strategy
  9036. */
  9037. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9038. /**
  9039. * Check and prepare the list of attributes required for instances according to the effect defines.
  9040. * @param attribs The current list of supported attribs
  9041. * @param defines The current MaterialDefines of the effect
  9042. */
  9043. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9044. /**
  9045. * Add the list of attributes required for instances to the attribs array.
  9046. * @param attribs The current list of supported attribs
  9047. */
  9048. static PushAttributesForInstances(attribs: string[]): void;
  9049. /**
  9050. * Binds the light shadow information to the effect for the given mesh.
  9051. * @param light The light containing the generator
  9052. * @param scene The scene the lights belongs to
  9053. * @param mesh The mesh we are binding the information to render
  9054. * @param lightIndex The light index in the effect used to render the mesh
  9055. * @param effect The effect we are binding the data to
  9056. */
  9057. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9058. /**
  9059. * Binds the light information to the effect.
  9060. * @param light The light containing the generator
  9061. * @param effect The effect we are binding the data to
  9062. * @param lightIndex The light index in the effect used to render
  9063. */
  9064. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9065. /**
  9066. * Binds the lights information from the scene to the effect for the given mesh.
  9067. * @param light Light to bind
  9068. * @param lightIndex Light index
  9069. * @param scene The scene where the light belongs to
  9070. * @param mesh The mesh we are binding the information to render
  9071. * @param effect The effect we are binding the data to
  9072. * @param useSpecular Defines if specular is supported
  9073. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9074. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9075. */
  9076. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9077. /**
  9078. * Binds the lights information from the scene to the effect for the given mesh.
  9079. * @param scene The scene the lights belongs to
  9080. * @param mesh The mesh we are binding the information to render
  9081. * @param effect The effect we are binding the data to
  9082. * @param defines The generated defines for the effect
  9083. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9084. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9085. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9086. */
  9087. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9088. private static _tempFogColor;
  9089. /**
  9090. * Binds the fog information from the scene to the effect for the given mesh.
  9091. * @param scene The scene the lights belongs to
  9092. * @param mesh The mesh we are binding the information to render
  9093. * @param effect The effect we are binding the data to
  9094. * @param linearSpace Defines if the fog effect is applied in linear space
  9095. */
  9096. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9097. /**
  9098. * Binds the bones information from the mesh to the effect.
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. */
  9102. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9103. /**
  9104. * Binds the morph targets information from the mesh to the effect.
  9105. * @param abstractMesh The mesh we are binding the information to render
  9106. * @param effect The effect we are binding the data to
  9107. */
  9108. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9109. /**
  9110. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9111. * @param defines The generated defines used in the effect
  9112. * @param effect The effect we are binding the data to
  9113. * @param scene The scene we are willing to render with logarithmic scale for
  9114. */
  9115. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Binds the clip plane information from the scene to the effect.
  9118. * @param scene The scene the clip plane information are extracted from
  9119. * @param effect The effect we are binding the data to
  9120. */
  9121. static BindClipPlane(effect: Effect, scene: Scene): void;
  9122. }
  9123. }
  9124. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9125. /** @hidden */
  9126. export var packingFunctions: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9132. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9133. /** @hidden */
  9134. export var shadowMapPixelShader: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9140. /** @hidden */
  9141. export var bonesDeclaration: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9147. /** @hidden */
  9148. export var morphTargetsVertexGlobalDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9161. /** @hidden */
  9162. export var instancesDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9168. /** @hidden */
  9169. export var helperFunctions: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9175. /** @hidden */
  9176. export var morphTargetsVertex: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9182. /** @hidden */
  9183. export var instancesVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9189. /** @hidden */
  9190. export var bonesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9196. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9199. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9202. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9203. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9204. /** @hidden */
  9205. export var shadowMapVertexShader: {
  9206. name: string;
  9207. shader: string;
  9208. };
  9209. }
  9210. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9211. /** @hidden */
  9212. export var depthBoxBlurPixelShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9218. import { Nullable } from "babylonjs/types";
  9219. import { Scene } from "babylonjs/scene";
  9220. import { Matrix } from "babylonjs/Maths/math.vector";
  9221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9223. import { Mesh } from "babylonjs/Meshes/mesh";
  9224. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9225. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9226. import { Effect } from "babylonjs/Materials/effect";
  9227. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9228. import "babylonjs/Shaders/shadowMap.fragment";
  9229. import "babylonjs/Shaders/shadowMap.vertex";
  9230. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9231. import { Observable } from "babylonjs/Misc/observable";
  9232. /**
  9233. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9234. */
  9235. export interface ICustomShaderOptions {
  9236. /**
  9237. * Gets or sets the custom shader name to use
  9238. */
  9239. shaderName: string;
  9240. /**
  9241. * The list of attribute names used in the shader
  9242. */
  9243. attributes?: string[];
  9244. /**
  9245. * The list of unifrom names used in the shader
  9246. */
  9247. uniforms?: string[];
  9248. /**
  9249. * The list of sampler names used in the shader
  9250. */
  9251. samplers?: string[];
  9252. /**
  9253. * The list of defines used in the shader
  9254. */
  9255. defines?: string[];
  9256. }
  9257. /**
  9258. * Interface to implement to create a shadow generator compatible with BJS.
  9259. */
  9260. export interface IShadowGenerator {
  9261. /**
  9262. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9263. * @returns The render target texture if present otherwise, null
  9264. */
  9265. getShadowMap(): Nullable<RenderTargetTexture>;
  9266. /**
  9267. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9268. * @returns The render target texture if the shadow map is present otherwise, null
  9269. */
  9270. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9271. /**
  9272. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9273. * @param subMesh The submesh we want to render in the shadow map
  9274. * @param useInstances Defines wether will draw in the map using instances
  9275. * @returns true if ready otherwise, false
  9276. */
  9277. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9278. /**
  9279. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9280. * @param defines Defines of the material we want to update
  9281. * @param lightIndex Index of the light in the enabled light list of the material
  9282. */
  9283. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9284. /**
  9285. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9286. * defined in the generator but impacting the effect).
  9287. * It implies the unifroms available on the materials are the standard BJS ones.
  9288. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9289. * @param effect The effect we are binfing the information for
  9290. */
  9291. bindShadowLight(lightIndex: string, effect: Effect): void;
  9292. /**
  9293. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9294. * (eq to shadow prjection matrix * light transform matrix)
  9295. * @returns The transform matrix used to create the shadow map
  9296. */
  9297. getTransformMatrix(): Matrix;
  9298. /**
  9299. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9300. * Cube and 2D textures for instance.
  9301. */
  9302. recreateShadowMap(): void;
  9303. /**
  9304. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9305. * @param onCompiled Callback triggered at the and of the effects compilation
  9306. * @param options Sets of optional options forcing the compilation with different modes
  9307. */
  9308. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9309. useInstances: boolean;
  9310. }>): void;
  9311. /**
  9312. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. * @returns A promise that resolves when the compilation completes
  9315. */
  9316. forceCompilationAsync(options?: Partial<{
  9317. useInstances: boolean;
  9318. }>): Promise<void>;
  9319. /**
  9320. * Serializes the shadow generator setup to a json object.
  9321. * @returns The serialized JSON object
  9322. */
  9323. serialize(): any;
  9324. /**
  9325. * Disposes the Shadow map and related Textures and effects.
  9326. */
  9327. dispose(): void;
  9328. }
  9329. /**
  9330. * Default implementation IShadowGenerator.
  9331. * This is the main object responsible of generating shadows in the framework.
  9332. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9333. */
  9334. export class ShadowGenerator implements IShadowGenerator {
  9335. /**
  9336. * Shadow generator mode None: no filtering applied.
  9337. */
  9338. static readonly FILTER_NONE: number;
  9339. /**
  9340. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9346. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9347. */
  9348. static readonly FILTER_POISSONSAMPLING: number;
  9349. /**
  9350. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9351. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9352. */
  9353. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9354. /**
  9355. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9356. * edge artifacts on steep falloff.
  9357. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9358. */
  9359. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9360. /**
  9361. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9362. * edge artifacts on steep falloff.
  9363. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9364. */
  9365. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9366. /**
  9367. * Shadow generator mode PCF: Percentage Closer Filtering
  9368. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9369. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9370. */
  9371. static readonly FILTER_PCF: number;
  9372. /**
  9373. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9374. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9375. * Contact Hardening
  9376. */
  9377. static readonly FILTER_PCSS: number;
  9378. /**
  9379. * Reserved for PCF and PCSS
  9380. * Highest Quality.
  9381. *
  9382. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9383. *
  9384. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9385. */
  9386. static readonly QUALITY_HIGH: number;
  9387. /**
  9388. * Reserved for PCF and PCSS
  9389. * Good tradeoff for quality/perf cross devices
  9390. *
  9391. * Execute PCF on a 3*3 kernel.
  9392. *
  9393. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9394. */
  9395. static readonly QUALITY_MEDIUM: number;
  9396. /**
  9397. * Reserved for PCF and PCSS
  9398. * The lowest quality but the fastest.
  9399. *
  9400. * Execute PCF on a 1*1 kernel.
  9401. *
  9402. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9403. */
  9404. static readonly QUALITY_LOW: number;
  9405. /** Gets or sets the custom shader name to use */
  9406. customShaderOptions: ICustomShaderOptions;
  9407. /**
  9408. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9409. */
  9410. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9411. /**
  9412. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9413. */
  9414. onAfterShadowMapRenderObservable: Observable<Effect>;
  9415. /**
  9416. * Observable triggered before a mesh is rendered in the shadow map.
  9417. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9418. */
  9419. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9420. /**
  9421. * Observable triggered after a mesh is rendered in the shadow map.
  9422. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9423. */
  9424. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9425. private _bias;
  9426. /**
  9427. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9428. */
  9429. /**
  9430. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9431. */
  9432. bias: number;
  9433. private _normalBias;
  9434. /**
  9435. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9436. */
  9437. /**
  9438. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9439. */
  9440. normalBias: number;
  9441. private _blurBoxOffset;
  9442. /**
  9443. * Gets the blur box offset: offset applied during the blur pass.
  9444. * Only useful if useKernelBlur = false
  9445. */
  9446. /**
  9447. * Sets the blur box offset: offset applied during the blur pass.
  9448. * Only useful if useKernelBlur = false
  9449. */
  9450. blurBoxOffset: number;
  9451. private _blurScale;
  9452. /**
  9453. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9454. * 2 means half of the size.
  9455. */
  9456. /**
  9457. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9458. * 2 means half of the size.
  9459. */
  9460. blurScale: number;
  9461. private _blurKernel;
  9462. /**
  9463. * Gets the blur kernel: kernel size of the blur pass.
  9464. * Only useful if useKernelBlur = true
  9465. */
  9466. /**
  9467. * Sets the blur kernel: kernel size of the blur pass.
  9468. * Only useful if useKernelBlur = true
  9469. */
  9470. blurKernel: number;
  9471. private _useKernelBlur;
  9472. /**
  9473. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9474. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9475. */
  9476. /**
  9477. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9478. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9479. */
  9480. useKernelBlur: boolean;
  9481. private _depthScale;
  9482. /**
  9483. * Gets the depth scale used in ESM mode.
  9484. */
  9485. /**
  9486. * Sets the depth scale used in ESM mode.
  9487. * This can override the scale stored on the light.
  9488. */
  9489. depthScale: number;
  9490. private _filter;
  9491. /**
  9492. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9493. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9494. */
  9495. /**
  9496. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9497. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9498. */
  9499. filter: number;
  9500. /**
  9501. * Gets if the current filter is set to Poisson Sampling.
  9502. */
  9503. /**
  9504. * Sets the current filter to Poisson Sampling.
  9505. */
  9506. usePoissonSampling: boolean;
  9507. /**
  9508. * Gets if the current filter is set to ESM.
  9509. */
  9510. /**
  9511. * Sets the current filter is to ESM.
  9512. */
  9513. useExponentialShadowMap: boolean;
  9514. /**
  9515. * Gets if the current filter is set to filtered ESM.
  9516. */
  9517. /**
  9518. * Gets if the current filter is set to filtered ESM.
  9519. */
  9520. useBlurExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9523. * exponential to prevent steep falloff artifacts).
  9524. */
  9525. /**
  9526. * Sets the current filter to "close ESM" (using the inverse of the
  9527. * exponential to prevent steep falloff artifacts).
  9528. */
  9529. useCloseExponentialShadowMap: boolean;
  9530. /**
  9531. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9532. * exponential to prevent steep falloff artifacts).
  9533. */
  9534. /**
  9535. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9536. * exponential to prevent steep falloff artifacts).
  9537. */
  9538. useBlurCloseExponentialShadowMap: boolean;
  9539. /**
  9540. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9541. */
  9542. /**
  9543. * Sets the current filter to "PCF" (percentage closer filtering).
  9544. */
  9545. usePercentageCloserFiltering: boolean;
  9546. private _filteringQuality;
  9547. /**
  9548. * Gets the PCF or PCSS Quality.
  9549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9550. */
  9551. /**
  9552. * Sets the PCF or PCSS Quality.
  9553. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9554. */
  9555. filteringQuality: number;
  9556. /**
  9557. * Gets if the current filter is set to "PCSS" (contact hardening).
  9558. */
  9559. /**
  9560. * Sets the current filter to "PCSS" (contact hardening).
  9561. */
  9562. useContactHardeningShadow: boolean;
  9563. private _contactHardeningLightSizeUVRatio;
  9564. /**
  9565. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9566. * Using a ratio helps keeping shape stability independently of the map size.
  9567. *
  9568. * It does not account for the light projection as it was having too much
  9569. * instability during the light setup or during light position changes.
  9570. *
  9571. * Only valid if useContactHardeningShadow is true.
  9572. */
  9573. /**
  9574. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9575. * Using a ratio helps keeping shape stability independently of the map size.
  9576. *
  9577. * It does not account for the light projection as it was having too much
  9578. * instability during the light setup or during light position changes.
  9579. *
  9580. * Only valid if useContactHardeningShadow is true.
  9581. */
  9582. contactHardeningLightSizeUVRatio: number;
  9583. private _darkness;
  9584. /** Gets or sets the actual darkness of a shadow */
  9585. darkness: number;
  9586. /**
  9587. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9588. * 0 means strongest and 1 would means no shadow.
  9589. * @returns the darkness.
  9590. */
  9591. getDarkness(): number;
  9592. /**
  9593. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9594. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9595. * @returns the shadow generator allowing fluent coding.
  9596. */
  9597. setDarkness(darkness: number): ShadowGenerator;
  9598. private _transparencyShadow;
  9599. /** Gets or sets the ability to have transparent shadow */
  9600. transparencyShadow: boolean;
  9601. /**
  9602. * Sets the ability to have transparent shadow (boolean).
  9603. * @param transparent True if transparent else False
  9604. * @returns the shadow generator allowing fluent coding
  9605. */
  9606. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9607. private _shadowMap;
  9608. private _shadowMap2;
  9609. /**
  9610. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9611. * @returns The render target texture if present otherwise, null
  9612. */
  9613. getShadowMap(): Nullable<RenderTargetTexture>;
  9614. /**
  9615. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9616. * @returns The render target texture if the shadow map is present otherwise, null
  9617. */
  9618. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9619. /**
  9620. * Gets the class name of that object
  9621. * @returns "ShadowGenerator"
  9622. */
  9623. getClassName(): string;
  9624. /**
  9625. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9626. * @param mesh Mesh to add
  9627. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9628. * @returns the Shadow Generator itself
  9629. */
  9630. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9631. /**
  9632. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9633. * @param mesh Mesh to remove
  9634. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Controls the extent to which the shadows fade out at the edge of the frustum
  9640. * Used only by directionals and spots
  9641. */
  9642. frustumEdgeFalloff: number;
  9643. private _light;
  9644. /**
  9645. * Returns the associated light object.
  9646. * @returns the light generating the shadow
  9647. */
  9648. getLight(): IShadowLight;
  9649. /**
  9650. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9651. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9652. * It might on the other hand introduce peter panning.
  9653. */
  9654. forceBackFacesOnly: boolean;
  9655. private _scene;
  9656. private _lightDirection;
  9657. private _effect;
  9658. private _viewMatrix;
  9659. private _projectionMatrix;
  9660. private _transformMatrix;
  9661. private _cachedPosition;
  9662. private _cachedDirection;
  9663. private _cachedDefines;
  9664. private _currentRenderID;
  9665. private _boxBlurPostprocess;
  9666. private _kernelBlurXPostprocess;
  9667. private _kernelBlurYPostprocess;
  9668. private _blurPostProcesses;
  9669. private _mapSize;
  9670. private _currentFaceIndex;
  9671. private _currentFaceIndexCache;
  9672. private _textureType;
  9673. private _defaultTextureMatrix;
  9674. /** @hidden */
  9675. static _SceneComponentInitialization: (scene: Scene) => void;
  9676. /**
  9677. * Creates a ShadowGenerator object.
  9678. * A ShadowGenerator is the required tool to use the shadows.
  9679. * Each light casting shadows needs to use its own ShadowGenerator.
  9680. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9681. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9682. * @param light The light object generating the shadows.
  9683. * @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.
  9684. */
  9685. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9686. private _initializeGenerator;
  9687. private _initializeShadowMap;
  9688. private _initializeBlurRTTAndPostProcesses;
  9689. private _renderForShadowMap;
  9690. private _renderSubMeshForShadowMap;
  9691. private _applyFilterValues;
  9692. /**
  9693. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9694. * @param onCompiled Callback triggered at the and of the effects compilation
  9695. * @param options Sets of optional options forcing the compilation with different modes
  9696. */
  9697. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9698. useInstances: boolean;
  9699. }>): void;
  9700. /**
  9701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. * @returns A promise that resolves when the compilation completes
  9704. */
  9705. forceCompilationAsync(options?: Partial<{
  9706. useInstances: boolean;
  9707. }>): Promise<void>;
  9708. /**
  9709. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9710. * @param subMesh The submesh we want to render in the shadow map
  9711. * @param useInstances Defines wether will draw in the map using instances
  9712. * @returns true if ready otherwise, false
  9713. */
  9714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9715. /**
  9716. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9717. * @param defines Defines of the material we want to update
  9718. * @param lightIndex Index of the light in the enabled light list of the material
  9719. */
  9720. prepareDefines(defines: any, lightIndex: number): void;
  9721. /**
  9722. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9723. * defined in the generator but impacting the effect).
  9724. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9725. * @param effect The effect we are binfing the information for
  9726. */
  9727. bindShadowLight(lightIndex: string, effect: Effect): void;
  9728. /**
  9729. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9730. * (eq to shadow prjection matrix * light transform matrix)
  9731. * @returns The transform matrix used to create the shadow map
  9732. */
  9733. getTransformMatrix(): Matrix;
  9734. /**
  9735. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9736. * Cube and 2D textures for instance.
  9737. */
  9738. recreateShadowMap(): void;
  9739. private _disposeBlurPostProcesses;
  9740. private _disposeRTTandPostProcesses;
  9741. /**
  9742. * Disposes the ShadowGenerator.
  9743. * Returns nothing.
  9744. */
  9745. dispose(): void;
  9746. /**
  9747. * Serializes the shadow generator setup to a json object.
  9748. * @returns The serialized JSON object
  9749. */
  9750. serialize(): any;
  9751. /**
  9752. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9753. * @param parsedShadowGenerator The JSON object to parse
  9754. * @param scene The scene to create the shadow map for
  9755. * @returns The parsed shadow generator
  9756. */
  9757. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9758. }
  9759. }
  9760. declare module "babylonjs/Lights/light" {
  9761. import { Nullable } from "babylonjs/types";
  9762. import { Scene } from "babylonjs/scene";
  9763. import { Vector3 } from "babylonjs/Maths/math.vector";
  9764. import { Color3 } from "babylonjs/Maths/math.color";
  9765. import { Node } from "babylonjs/node";
  9766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9767. import { Effect } from "babylonjs/Materials/effect";
  9768. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9769. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9770. /**
  9771. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9772. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9773. * 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.
  9774. */
  9775. export abstract class Light extends Node {
  9776. /**
  9777. * Falloff Default: light is falling off following the material specification:
  9778. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9779. */
  9780. static readonly FALLOFF_DEFAULT: number;
  9781. /**
  9782. * Falloff Physical: light is falling off following the inverse squared distance law.
  9783. */
  9784. static readonly FALLOFF_PHYSICAL: number;
  9785. /**
  9786. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9787. * to enhance interoperability with other engines.
  9788. */
  9789. static readonly FALLOFF_GLTF: number;
  9790. /**
  9791. * Falloff Standard: light is falling off like in the standard material
  9792. * to enhance interoperability with other materials.
  9793. */
  9794. static readonly FALLOFF_STANDARD: number;
  9795. /**
  9796. * If every light affecting the material is in this lightmapMode,
  9797. * material.lightmapTexture adds or multiplies
  9798. * (depends on material.useLightmapAsShadowmap)
  9799. * after every other light calculations.
  9800. */
  9801. static readonly LIGHTMAP_DEFAULT: number;
  9802. /**
  9803. * material.lightmapTexture as only diffuse lighting from this light
  9804. * adds only specular lighting from this light
  9805. * adds dynamic shadows
  9806. */
  9807. static readonly LIGHTMAP_SPECULAR: number;
  9808. /**
  9809. * material.lightmapTexture as only lighting
  9810. * no light calculation from this light
  9811. * only adds dynamic shadows from this light
  9812. */
  9813. static readonly LIGHTMAP_SHADOWSONLY: number;
  9814. /**
  9815. * Each light type uses the default quantity according to its type:
  9816. * point/spot lights use luminous intensity
  9817. * directional lights use illuminance
  9818. */
  9819. static readonly INTENSITYMODE_AUTOMATIC: number;
  9820. /**
  9821. * lumen (lm)
  9822. */
  9823. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9824. /**
  9825. * candela (lm/sr)
  9826. */
  9827. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9828. /**
  9829. * lux (lm/m^2)
  9830. */
  9831. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9832. /**
  9833. * nit (cd/m^2)
  9834. */
  9835. static readonly INTENSITYMODE_LUMINANCE: number;
  9836. /**
  9837. * Light type const id of the point light.
  9838. */
  9839. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9840. /**
  9841. * Light type const id of the directional light.
  9842. */
  9843. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9844. /**
  9845. * Light type const id of the spot light.
  9846. */
  9847. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9848. /**
  9849. * Light type const id of the hemispheric light.
  9850. */
  9851. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9852. /**
  9853. * Diffuse gives the basic color to an object.
  9854. */
  9855. diffuse: Color3;
  9856. /**
  9857. * Specular produces a highlight color on an object.
  9858. * Note: This is note affecting PBR materials.
  9859. */
  9860. specular: Color3;
  9861. /**
  9862. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9863. * falling off base on range or angle.
  9864. * This can be set to any values in Light.FALLOFF_x.
  9865. *
  9866. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9867. * other types of materials.
  9868. */
  9869. falloffType: number;
  9870. /**
  9871. * Strength of the light.
  9872. * Note: By default it is define in the framework own unit.
  9873. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9874. */
  9875. intensity: number;
  9876. private _range;
  9877. protected _inverseSquaredRange: number;
  9878. /**
  9879. * Defines how far from the source the light is impacting in scene units.
  9880. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9881. */
  9882. /**
  9883. * Defines how far from the source the light is impacting in scene units.
  9884. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9885. */
  9886. range: number;
  9887. /**
  9888. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9889. * of light.
  9890. */
  9891. private _photometricScale;
  9892. private _intensityMode;
  9893. /**
  9894. * Gets the photometric scale used to interpret the intensity.
  9895. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9896. */
  9897. /**
  9898. * Sets the photometric scale used to interpret the intensity.
  9899. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9900. */
  9901. intensityMode: number;
  9902. private _radius;
  9903. /**
  9904. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9905. */
  9906. /**
  9907. * sets the light radius used by PBR Materials to simulate soft area lights.
  9908. */
  9909. radius: number;
  9910. private _renderPriority;
  9911. /**
  9912. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9913. * exceeding the number allowed of the materials.
  9914. */
  9915. renderPriority: number;
  9916. private _shadowEnabled;
  9917. /**
  9918. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9919. * the current shadow generator.
  9920. */
  9921. /**
  9922. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9923. * the current shadow generator.
  9924. */
  9925. shadowEnabled: boolean;
  9926. private _includedOnlyMeshes;
  9927. /**
  9928. * Gets the only meshes impacted by this light.
  9929. */
  9930. /**
  9931. * Sets the only meshes impacted by this light.
  9932. */
  9933. includedOnlyMeshes: AbstractMesh[];
  9934. private _excludedMeshes;
  9935. /**
  9936. * Gets the meshes not impacted by this light.
  9937. */
  9938. /**
  9939. * Sets the meshes not impacted by this light.
  9940. */
  9941. excludedMeshes: AbstractMesh[];
  9942. private _excludeWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are not impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are not impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. excludeWithLayerMask: number;
  9952. private _includeOnlyWithLayerMask;
  9953. /**
  9954. * Gets the layer id use to find what meshes are impacted by the light.
  9955. * Inactive if 0
  9956. */
  9957. /**
  9958. * Sets the layer id use to find what meshes are impacted by the light.
  9959. * Inactive if 0
  9960. */
  9961. includeOnlyWithLayerMask: number;
  9962. private _lightmapMode;
  9963. /**
  9964. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9965. */
  9966. /**
  9967. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9968. */
  9969. lightmapMode: number;
  9970. /**
  9971. * Shadow generator associted to the light.
  9972. * @hidden Internal use only.
  9973. */
  9974. _shadowGenerator: Nullable<IShadowGenerator>;
  9975. /**
  9976. * @hidden Internal use only.
  9977. */
  9978. _excludedMeshesIds: string[];
  9979. /**
  9980. * @hidden Internal use only.
  9981. */
  9982. _includedOnlyMeshesIds: string[];
  9983. /**
  9984. * The current light unifom buffer.
  9985. * @hidden Internal use only.
  9986. */
  9987. _uniformBuffer: UniformBuffer;
  9988. /**
  9989. * Creates a Light object in the scene.
  9990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9991. * @param name The firendly name of the light
  9992. * @param scene The scene the light belongs too
  9993. */
  9994. constructor(name: string, scene: Scene);
  9995. protected abstract _buildUniformLayout(): void;
  9996. /**
  9997. * Sets the passed Effect "effect" with the Light information.
  9998. * @param effect The effect to update
  9999. * @param lightIndex The index of the light in the effect to update
  10000. * @returns The light
  10001. */
  10002. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10007. * @returns The light
  10008. */
  10009. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10010. /**
  10011. * Returns the string "Light".
  10012. * @returns the class name
  10013. */
  10014. getClassName(): string;
  10015. /** @hidden */
  10016. readonly _isLight: boolean;
  10017. /**
  10018. * Converts the light information to a readable string for debug purpose.
  10019. * @param fullDetails Supports for multiple levels of logging within scene loading
  10020. * @returns the human readable light info
  10021. */
  10022. toString(fullDetails?: boolean): string;
  10023. /** @hidden */
  10024. protected _syncParentEnabledState(): void;
  10025. /**
  10026. * Set the enabled state of this node.
  10027. * @param value - the new enabled state
  10028. */
  10029. setEnabled(value: boolean): void;
  10030. /**
  10031. * Returns the Light associated shadow generator if any.
  10032. * @return the associated shadow generator.
  10033. */
  10034. getShadowGenerator(): Nullable<IShadowGenerator>;
  10035. /**
  10036. * Returns a Vector3, the absolute light position in the World.
  10037. * @returns the world space position of the light
  10038. */
  10039. getAbsolutePosition(): Vector3;
  10040. /**
  10041. * Specifies if the light will affect the passed mesh.
  10042. * @param mesh The mesh to test against the light
  10043. * @return true the mesh is affected otherwise, false.
  10044. */
  10045. canAffectMesh(mesh: AbstractMesh): boolean;
  10046. /**
  10047. * Sort function to order lights for rendering.
  10048. * @param a First Light object to compare to second.
  10049. * @param b Second Light object to compare first.
  10050. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10051. */
  10052. static CompareLightsPriority(a: Light, b: Light): number;
  10053. /**
  10054. * Releases resources associated with this node.
  10055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10057. */
  10058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10059. /**
  10060. * Returns the light type ID (integer).
  10061. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10062. */
  10063. getTypeID(): number;
  10064. /**
  10065. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10066. * @returns the scaled intensity in intensity mode unit
  10067. */
  10068. getScaledIntensity(): number;
  10069. /**
  10070. * Returns a new Light object, named "name", from the current one.
  10071. * @param name The name of the cloned light
  10072. * @returns the new created light
  10073. */
  10074. clone(name: string): Nullable<Light>;
  10075. /**
  10076. * Serializes the current light into a Serialization object.
  10077. * @returns the serialized object.
  10078. */
  10079. serialize(): any;
  10080. /**
  10081. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10082. * This new light is named "name" and added to the passed scene.
  10083. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10084. * @param name The friendly name of the light
  10085. * @param scene The scene the new light will belong to
  10086. * @returns the constructor function
  10087. */
  10088. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10089. /**
  10090. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10091. * @param parsedLight The JSON representation of the light
  10092. * @param scene The scene to create the parsed light in
  10093. * @returns the created light after parsing
  10094. */
  10095. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10096. private _hookArrayForExcluded;
  10097. private _hookArrayForIncludedOnly;
  10098. private _resyncMeshes;
  10099. /**
  10100. * Forces the meshes to update their light related information in their rendering used effects
  10101. * @hidden Internal Use Only
  10102. */
  10103. _markMeshesAsLightDirty(): void;
  10104. /**
  10105. * Recomputes the cached photometric scale if needed.
  10106. */
  10107. private _computePhotometricScale;
  10108. /**
  10109. * Returns the Photometric Scale according to the light type and intensity mode.
  10110. */
  10111. private _getPhotometricScale;
  10112. /**
  10113. * Reorder the light in the scene according to their defined priority.
  10114. * @hidden Internal Use Only
  10115. */
  10116. _reorderLightsInScene(): void;
  10117. /**
  10118. * Prepares the list of defines specific to the light type.
  10119. * @param defines the list of defines
  10120. * @param lightIndex defines the index of the light for the effect
  10121. */
  10122. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10123. }
  10124. }
  10125. declare module "babylonjs/Actions/action" {
  10126. import { Observable } from "babylonjs/Misc/observable";
  10127. import { Condition } from "babylonjs/Actions/condition";
  10128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10129. import { ActionManager } from "babylonjs/Actions/actionManager";
  10130. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10131. /**
  10132. * Interface used to define Action
  10133. */
  10134. export interface IAction {
  10135. /**
  10136. * Trigger for the action
  10137. */
  10138. trigger: number;
  10139. /** Options of the trigger */
  10140. triggerOptions: any;
  10141. /**
  10142. * Gets the trigger parameters
  10143. * @returns the trigger parameters
  10144. */
  10145. getTriggerParameter(): any;
  10146. /**
  10147. * Internal only - executes current action event
  10148. * @hidden
  10149. */
  10150. _executeCurrent(evt?: ActionEvent): void;
  10151. /**
  10152. * Serialize placeholder for child classes
  10153. * @param parent of child
  10154. * @returns the serialized object
  10155. */
  10156. serialize(parent: any): any;
  10157. /**
  10158. * Internal only
  10159. * @hidden
  10160. */
  10161. _prepare(): void;
  10162. /**
  10163. * Internal only - manager for action
  10164. * @hidden
  10165. */
  10166. _actionManager: AbstractActionManager;
  10167. /**
  10168. * Adds action to chain of actions, may be a DoNothingAction
  10169. * @param action defines the next action to execute
  10170. * @returns The action passed in
  10171. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10172. */
  10173. then(action: IAction): IAction;
  10174. }
  10175. /**
  10176. * The action to be carried out following a trigger
  10177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10178. */
  10179. export class Action implements IAction {
  10180. /** the trigger, with or without parameters, for the action */
  10181. triggerOptions: any;
  10182. /**
  10183. * Trigger for the action
  10184. */
  10185. trigger: number;
  10186. /**
  10187. * Internal only - manager for action
  10188. * @hidden
  10189. */
  10190. _actionManager: ActionManager;
  10191. private _nextActiveAction;
  10192. private _child;
  10193. private _condition?;
  10194. private _triggerParameter;
  10195. /**
  10196. * An event triggered prior to action being executed.
  10197. */
  10198. onBeforeExecuteObservable: Observable<Action>;
  10199. /**
  10200. * Creates a new Action
  10201. * @param triggerOptions the trigger, with or without parameters, for the action
  10202. * @param condition an optional determinant of action
  10203. */
  10204. constructor(
  10205. /** the trigger, with or without parameters, for the action */
  10206. triggerOptions: any, condition?: Condition);
  10207. /**
  10208. * Internal only
  10209. * @hidden
  10210. */
  10211. _prepare(): void;
  10212. /**
  10213. * Gets the trigger parameters
  10214. * @returns the trigger parameters
  10215. */
  10216. getTriggerParameter(): any;
  10217. /**
  10218. * Internal only - executes current action event
  10219. * @hidden
  10220. */
  10221. _executeCurrent(evt?: ActionEvent): void;
  10222. /**
  10223. * Execute placeholder for child classes
  10224. * @param evt optional action event
  10225. */
  10226. execute(evt?: ActionEvent): void;
  10227. /**
  10228. * Skips to next active action
  10229. */
  10230. skipToNextActiveAction(): void;
  10231. /**
  10232. * Adds action to chain of actions, may be a DoNothingAction
  10233. * @param action defines the next action to execute
  10234. * @returns The action passed in
  10235. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10236. */
  10237. then(action: Action): Action;
  10238. /**
  10239. * Internal only
  10240. * @hidden
  10241. */
  10242. _getProperty(propertyPath: string): string;
  10243. /**
  10244. * Internal only
  10245. * @hidden
  10246. */
  10247. _getEffectiveTarget(target: any, propertyPath: string): any;
  10248. /**
  10249. * Serialize placeholder for child classes
  10250. * @param parent of child
  10251. * @returns the serialized object
  10252. */
  10253. serialize(parent: any): any;
  10254. /**
  10255. * Internal only called by serialize
  10256. * @hidden
  10257. */
  10258. protected _serialize(serializedAction: any, parent?: any): any;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. static _SerializeValueAsString: (value: any) => string;
  10264. /**
  10265. * Internal only
  10266. * @hidden
  10267. */
  10268. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10269. name: string;
  10270. targetType: string;
  10271. value: string;
  10272. };
  10273. }
  10274. }
  10275. declare module "babylonjs/Actions/condition" {
  10276. import { ActionManager } from "babylonjs/Actions/actionManager";
  10277. /**
  10278. * A Condition applied to an Action
  10279. */
  10280. export class Condition {
  10281. /**
  10282. * Internal only - manager for action
  10283. * @hidden
  10284. */
  10285. _actionManager: ActionManager;
  10286. /**
  10287. * Internal only
  10288. * @hidden
  10289. */
  10290. _evaluationId: number;
  10291. /**
  10292. * Internal only
  10293. * @hidden
  10294. */
  10295. _currentResult: boolean;
  10296. /**
  10297. * Creates a new Condition
  10298. * @param actionManager the manager of the action the condition is applied to
  10299. */
  10300. constructor(actionManager: ActionManager);
  10301. /**
  10302. * Check if the current condition is valid
  10303. * @returns a boolean
  10304. */
  10305. isValid(): boolean;
  10306. /**
  10307. * Internal only
  10308. * @hidden
  10309. */
  10310. _getProperty(propertyPath: string): string;
  10311. /**
  10312. * Internal only
  10313. * @hidden
  10314. */
  10315. _getEffectiveTarget(target: any, propertyPath: string): any;
  10316. /**
  10317. * Serialize placeholder for child classes
  10318. * @returns the serialized object
  10319. */
  10320. serialize(): any;
  10321. /**
  10322. * Internal only
  10323. * @hidden
  10324. */
  10325. protected _serialize(serializedCondition: any): any;
  10326. }
  10327. /**
  10328. * Defines specific conditional operators as extensions of Condition
  10329. */
  10330. export class ValueCondition extends Condition {
  10331. /** path to specify the property of the target the conditional operator uses */
  10332. propertyPath: string;
  10333. /** the value compared by the conditional operator against the current value of the property */
  10334. value: any;
  10335. /** the conditional operator, default ValueCondition.IsEqual */
  10336. operator: number;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. private static _IsEqual;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */
  10346. private static _IsDifferent;
  10347. /**
  10348. * Internal only
  10349. * @hidden
  10350. */
  10351. private static _IsGreater;
  10352. /**
  10353. * Internal only
  10354. * @hidden
  10355. */
  10356. private static _IsLesser;
  10357. /**
  10358. * returns the number for IsEqual
  10359. */
  10360. static readonly IsEqual: number;
  10361. /**
  10362. * Returns the number for IsDifferent
  10363. */
  10364. static readonly IsDifferent: number;
  10365. /**
  10366. * Returns the number for IsGreater
  10367. */
  10368. static readonly IsGreater: number;
  10369. /**
  10370. * Returns the number for IsLesser
  10371. */
  10372. static readonly IsLesser: number;
  10373. /**
  10374. * Internal only The action manager for the condition
  10375. * @hidden
  10376. */
  10377. _actionManager: ActionManager;
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. private _target;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. private _effectiveTarget;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. private _property;
  10393. /**
  10394. * Creates a new ValueCondition
  10395. * @param actionManager manager for the action the condition applies to
  10396. * @param target for the action
  10397. * @param propertyPath path to specify the property of the target the conditional operator uses
  10398. * @param value the value compared by the conditional operator against the current value of the property
  10399. * @param operator the conditional operator, default ValueCondition.IsEqual
  10400. */
  10401. constructor(actionManager: ActionManager, target: any,
  10402. /** path to specify the property of the target the conditional operator uses */
  10403. propertyPath: string,
  10404. /** the value compared by the conditional operator against the current value of the property */
  10405. value: any,
  10406. /** the conditional operator, default ValueCondition.IsEqual */
  10407. operator?: number);
  10408. /**
  10409. * Compares the given value with the property value for the specified conditional operator
  10410. * @returns the result of the comparison
  10411. */
  10412. isValid(): boolean;
  10413. /**
  10414. * Serialize the ValueCondition into a JSON compatible object
  10415. * @returns serialization object
  10416. */
  10417. serialize(): any;
  10418. /**
  10419. * Gets the name of the conditional operator for the ValueCondition
  10420. * @param operator the conditional operator
  10421. * @returns the name
  10422. */
  10423. static GetOperatorName(operator: number): string;
  10424. }
  10425. /**
  10426. * Defines a predicate condition as an extension of Condition
  10427. */
  10428. export class PredicateCondition extends Condition {
  10429. /** defines the predicate function used to validate the condition */
  10430. predicate: () => boolean;
  10431. /**
  10432. * Internal only - manager for action
  10433. * @hidden
  10434. */
  10435. _actionManager: ActionManager;
  10436. /**
  10437. * Creates a new PredicateCondition
  10438. * @param actionManager manager for the action the condition applies to
  10439. * @param predicate defines the predicate function used to validate the condition
  10440. */
  10441. constructor(actionManager: ActionManager,
  10442. /** defines the predicate function used to validate the condition */
  10443. predicate: () => boolean);
  10444. /**
  10445. * @returns the validity of the predicate condition
  10446. */
  10447. isValid(): boolean;
  10448. }
  10449. /**
  10450. * Defines a state condition as an extension of Condition
  10451. */
  10452. export class StateCondition extends Condition {
  10453. /** Value to compare with target state */
  10454. value: string;
  10455. /**
  10456. * Internal only - manager for action
  10457. * @hidden
  10458. */
  10459. _actionManager: ActionManager;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private _target;
  10465. /**
  10466. * Creates a new StateCondition
  10467. * @param actionManager manager for the action the condition applies to
  10468. * @param target of the condition
  10469. * @param value to compare with target state
  10470. */
  10471. constructor(actionManager: ActionManager, target: any,
  10472. /** Value to compare with target state */
  10473. value: string);
  10474. /**
  10475. * Gets a boolean indicating if the current condition is met
  10476. * @returns the validity of the state
  10477. */
  10478. isValid(): boolean;
  10479. /**
  10480. * Serialize the StateCondition into a JSON compatible object
  10481. * @returns serialization object
  10482. */
  10483. serialize(): any;
  10484. }
  10485. }
  10486. declare module "babylonjs/Actions/directActions" {
  10487. import { Action } from "babylonjs/Actions/action";
  10488. import { Condition } from "babylonjs/Actions/condition";
  10489. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10490. /**
  10491. * This defines an action responsible to toggle a boolean once triggered.
  10492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10493. */
  10494. export class SwitchBooleanAction extends Action {
  10495. /**
  10496. * The path to the boolean property in the target object
  10497. */
  10498. propertyPath: string;
  10499. private _target;
  10500. private _effectiveTarget;
  10501. private _property;
  10502. /**
  10503. * Instantiate the action
  10504. * @param triggerOptions defines the trigger options
  10505. * @param target defines the object containing the boolean
  10506. * @param propertyPath defines the path to the boolean property in the target object
  10507. * @param condition defines the trigger related conditions
  10508. */
  10509. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10510. /** @hidden */
  10511. _prepare(): void;
  10512. /**
  10513. * Execute the action toggle the boolean value.
  10514. */
  10515. execute(): void;
  10516. /**
  10517. * Serializes the actions and its related information.
  10518. * @param parent defines the object to serialize in
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. }
  10523. /**
  10524. * This defines an action responsible to set a the state field of the target
  10525. * to a desired value once triggered.
  10526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10527. */
  10528. export class SetStateAction extends Action {
  10529. /**
  10530. * The value to store in the state field.
  10531. */
  10532. value: string;
  10533. private _target;
  10534. /**
  10535. * Instantiate the action
  10536. * @param triggerOptions defines the trigger options
  10537. * @param target defines the object containing the state property
  10538. * @param value defines the value to store in the state field
  10539. * @param condition defines the trigger related conditions
  10540. */
  10541. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10542. /**
  10543. * Execute the action and store the value on the target state property.
  10544. */
  10545. execute(): void;
  10546. /**
  10547. * Serializes the actions and its related information.
  10548. * @param parent defines the object to serialize in
  10549. * @returns the serialized object
  10550. */
  10551. serialize(parent: any): any;
  10552. }
  10553. /**
  10554. * This defines an action responsible to set a property of the target
  10555. * to a desired value once triggered.
  10556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10557. */
  10558. export class SetValueAction extends Action {
  10559. /**
  10560. * The path of the property to set in the target.
  10561. */
  10562. propertyPath: string;
  10563. /**
  10564. * The value to set in the property
  10565. */
  10566. value: any;
  10567. private _target;
  10568. private _effectiveTarget;
  10569. private _property;
  10570. /**
  10571. * Instantiate the action
  10572. * @param triggerOptions defines the trigger options
  10573. * @param target defines the object containing the property
  10574. * @param propertyPath defines the path of the property to set in the target
  10575. * @param value defines the value to set in the property
  10576. * @param condition defines the trigger related conditions
  10577. */
  10578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10579. /** @hidden */
  10580. _prepare(): void;
  10581. /**
  10582. * Execute the action and set the targetted property to the desired value.
  10583. */
  10584. execute(): void;
  10585. /**
  10586. * Serializes the actions and its related information.
  10587. * @param parent defines the object to serialize in
  10588. * @returns the serialized object
  10589. */
  10590. serialize(parent: any): any;
  10591. }
  10592. /**
  10593. * This defines an action responsible to increment the target value
  10594. * to a desired value once triggered.
  10595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class IncrementValueAction extends Action {
  10598. /**
  10599. * The path of the property to increment in the target.
  10600. */
  10601. propertyPath: string;
  10602. /**
  10603. * The value we should increment the property by.
  10604. */
  10605. value: any;
  10606. private _target;
  10607. private _effectiveTarget;
  10608. private _property;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param target defines the object containing the property
  10613. * @param propertyPath defines the path of the property to increment in the target
  10614. * @param value defines the value value we should increment the property by
  10615. * @param condition defines the trigger related conditions
  10616. */
  10617. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10618. /** @hidden */
  10619. _prepare(): void;
  10620. /**
  10621. * Execute the action and increment the target of the value amount.
  10622. */
  10623. execute(): void;
  10624. /**
  10625. * Serializes the actions and its related information.
  10626. * @param parent defines the object to serialize in
  10627. * @returns the serialized object
  10628. */
  10629. serialize(parent: any): any;
  10630. }
  10631. /**
  10632. * This defines an action responsible to start an animation once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class PlayAnimationAction extends Action {
  10636. /**
  10637. * Where the animation should start (animation frame)
  10638. */
  10639. from: number;
  10640. /**
  10641. * Where the animation should stop (animation frame)
  10642. */
  10643. to: number;
  10644. /**
  10645. * Define if the animation should loop or stop after the first play.
  10646. */
  10647. loop?: boolean;
  10648. private _target;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the target animation or animation name
  10653. * @param from defines from where the animation should start (animation frame)
  10654. * @param end defines where the animation should stop (animation frame)
  10655. * @param loop defines if the animation should loop or stop after the first play
  10656. * @param condition defines the trigger related conditions
  10657. */
  10658. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10659. /** @hidden */
  10660. _prepare(): void;
  10661. /**
  10662. * Execute the action and play the animation.
  10663. */
  10664. execute(): void;
  10665. /**
  10666. * Serializes the actions and its related information.
  10667. * @param parent defines the object to serialize in
  10668. * @returns the serialized object
  10669. */
  10670. serialize(parent: any): any;
  10671. }
  10672. /**
  10673. * This defines an action responsible to stop an animation once triggered.
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10675. */
  10676. export class StopAnimationAction extends Action {
  10677. private _target;
  10678. /**
  10679. * Instantiate the action
  10680. * @param triggerOptions defines the trigger options
  10681. * @param target defines the target animation or animation name
  10682. * @param condition defines the trigger related conditions
  10683. */
  10684. constructor(triggerOptions: any, target: any, condition?: Condition);
  10685. /** @hidden */
  10686. _prepare(): void;
  10687. /**
  10688. * Execute the action and stop the animation.
  10689. */
  10690. execute(): void;
  10691. /**
  10692. * Serializes the actions and its related information.
  10693. * @param parent defines the object to serialize in
  10694. * @returns the serialized object
  10695. */
  10696. serialize(parent: any): any;
  10697. }
  10698. /**
  10699. * This defines an action responsible that does nothing once triggered.
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10701. */
  10702. export class DoNothingAction extends Action {
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param condition defines the trigger related conditions
  10707. */
  10708. constructor(triggerOptions?: any, condition?: Condition);
  10709. /**
  10710. * Execute the action and do nothing.
  10711. */
  10712. execute(): void;
  10713. /**
  10714. * Serializes the actions and its related information.
  10715. * @param parent defines the object to serialize in
  10716. * @returns the serialized object
  10717. */
  10718. serialize(parent: any): any;
  10719. }
  10720. /**
  10721. * This defines an action responsible to trigger several actions once triggered.
  10722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10723. */
  10724. export class CombineAction extends Action {
  10725. /**
  10726. * The list of aggregated animations to run.
  10727. */
  10728. children: Action[];
  10729. /**
  10730. * Instantiate the action
  10731. * @param triggerOptions defines the trigger options
  10732. * @param children defines the list of aggregated animations to run
  10733. * @param condition defines the trigger related conditions
  10734. */
  10735. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10736. /** @hidden */
  10737. _prepare(): void;
  10738. /**
  10739. * Execute the action and executes all the aggregated actions.
  10740. */
  10741. execute(evt: ActionEvent): void;
  10742. /**
  10743. * Serializes the actions and its related information.
  10744. * @param parent defines the object to serialize in
  10745. * @returns the serialized object
  10746. */
  10747. serialize(parent: any): any;
  10748. }
  10749. /**
  10750. * This defines an action responsible to run code (external event) once triggered.
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10752. */
  10753. export class ExecuteCodeAction extends Action {
  10754. /**
  10755. * The callback function to run.
  10756. */
  10757. func: (evt: ActionEvent) => void;
  10758. /**
  10759. * Instantiate the action
  10760. * @param triggerOptions defines the trigger options
  10761. * @param func defines the callback function to run
  10762. * @param condition defines the trigger related conditions
  10763. */
  10764. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10765. /**
  10766. * Execute the action and run the attached code.
  10767. */
  10768. execute(evt: ActionEvent): void;
  10769. }
  10770. /**
  10771. * This defines an action responsible to set the parent property of the target once triggered.
  10772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10773. */
  10774. export class SetParentAction extends Action {
  10775. private _parent;
  10776. private _target;
  10777. /**
  10778. * Instantiate the action
  10779. * @param triggerOptions defines the trigger options
  10780. * @param target defines the target containing the parent property
  10781. * @param parent defines from where the animation should start (animation frame)
  10782. * @param condition defines the trigger related conditions
  10783. */
  10784. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10785. /** @hidden */
  10786. _prepare(): void;
  10787. /**
  10788. * Execute the action and set the parent property.
  10789. */
  10790. execute(): void;
  10791. /**
  10792. * Serializes the actions and its related information.
  10793. * @param parent defines the object to serialize in
  10794. * @returns the serialized object
  10795. */
  10796. serialize(parent: any): any;
  10797. }
  10798. }
  10799. declare module "babylonjs/Actions/actionManager" {
  10800. import { Nullable } from "babylonjs/types";
  10801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10802. import { Scene } from "babylonjs/scene";
  10803. import { IAction } from "babylonjs/Actions/action";
  10804. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10805. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10806. /**
  10807. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10808. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class ActionManager extends AbstractActionManager {
  10812. /**
  10813. * Nothing
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10815. */
  10816. static readonly NothingTrigger: number;
  10817. /**
  10818. * On pick
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10820. */
  10821. static readonly OnPickTrigger: number;
  10822. /**
  10823. * On left pick
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10825. */
  10826. static readonly OnLeftPickTrigger: number;
  10827. /**
  10828. * On right pick
  10829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10830. */
  10831. static readonly OnRightPickTrigger: number;
  10832. /**
  10833. * On center pick
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10835. */
  10836. static readonly OnCenterPickTrigger: number;
  10837. /**
  10838. * On pick down
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10840. */
  10841. static readonly OnPickDownTrigger: number;
  10842. /**
  10843. * On double pick
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10845. */
  10846. static readonly OnDoublePickTrigger: number;
  10847. /**
  10848. * On pick up
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10850. */
  10851. static readonly OnPickUpTrigger: number;
  10852. /**
  10853. * On pick out.
  10854. * This trigger will only be raised if you also declared a OnPickDown
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10856. */
  10857. static readonly OnPickOutTrigger: number;
  10858. /**
  10859. * On long press
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly OnLongPressTrigger: number;
  10863. /**
  10864. * On pointer over
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPointerOverTrigger: number;
  10868. /**
  10869. * On pointer out
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnPointerOutTrigger: number;
  10873. /**
  10874. * On every frame
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnEveryFrameTrigger: number;
  10878. /**
  10879. * On intersection enter
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnIntersectionEnterTrigger: number;
  10883. /**
  10884. * On intersection exit
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnIntersectionExitTrigger: number;
  10888. /**
  10889. * On key down
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnKeyDownTrigger: number;
  10893. /**
  10894. * On key up
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnKeyUpTrigger: number;
  10898. private _scene;
  10899. /**
  10900. * Creates a new action manager
  10901. * @param scene defines the hosting scene
  10902. */
  10903. constructor(scene: Scene);
  10904. /**
  10905. * Releases all associated resources
  10906. */
  10907. dispose(): void;
  10908. /**
  10909. * Gets hosting scene
  10910. * @returns the hosting scene
  10911. */
  10912. getScene(): Scene;
  10913. /**
  10914. * Does this action manager handles actions of any of the given triggers
  10915. * @param triggers defines the triggers to be tested
  10916. * @return a boolean indicating whether one (or more) of the triggers is handled
  10917. */
  10918. hasSpecificTriggers(triggers: number[]): boolean;
  10919. /**
  10920. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10921. * speed.
  10922. * @param triggerA defines the trigger to be tested
  10923. * @param triggerB defines the trigger to be tested
  10924. * @return a boolean indicating whether one (or more) of the triggers is handled
  10925. */
  10926. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10927. /**
  10928. * Does this action manager handles actions of a given trigger
  10929. * @param trigger defines the trigger to be tested
  10930. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10931. * @return whether the trigger is handled
  10932. */
  10933. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10934. /**
  10935. * Does this action manager has pointer triggers
  10936. */
  10937. readonly hasPointerTriggers: boolean;
  10938. /**
  10939. * Does this action manager has pick triggers
  10940. */
  10941. readonly hasPickTriggers: boolean;
  10942. /**
  10943. * Registers an action to this action manager
  10944. * @param action defines the action to be registered
  10945. * @return the action amended (prepared) after registration
  10946. */
  10947. registerAction(action: IAction): Nullable<IAction>;
  10948. /**
  10949. * Unregisters an action to this action manager
  10950. * @param action defines the action to be unregistered
  10951. * @return a boolean indicating whether the action has been unregistered
  10952. */
  10953. unregisterAction(action: IAction): Boolean;
  10954. /**
  10955. * Process a specific trigger
  10956. * @param trigger defines the trigger to process
  10957. * @param evt defines the event details to be processed
  10958. */
  10959. processTrigger(trigger: number, evt?: IActionEvent): void;
  10960. /** @hidden */
  10961. _getEffectiveTarget(target: any, propertyPath: string): any;
  10962. /** @hidden */
  10963. _getProperty(propertyPath: string): string;
  10964. /**
  10965. * Serialize this manager to a JSON object
  10966. * @param name defines the property name to store this manager
  10967. * @returns a JSON representation of this manager
  10968. */
  10969. serialize(name: string): any;
  10970. /**
  10971. * Creates a new ActionManager from a JSON data
  10972. * @param parsedActions defines the JSON data to read from
  10973. * @param object defines the hosting mesh
  10974. * @param scene defines the hosting scene
  10975. */
  10976. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10977. /**
  10978. * Get a trigger name by index
  10979. * @param trigger defines the trigger index
  10980. * @returns a trigger name
  10981. */
  10982. static GetTriggerName(trigger: number): string;
  10983. }
  10984. }
  10985. declare module "babylonjs/Culling/ray" {
  10986. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10987. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10989. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10990. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10991. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10992. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10993. import { Plane } from "babylonjs/Maths/math.plane";
  10994. /**
  10995. * Class representing a ray with position and direction
  10996. */
  10997. export class Ray {
  10998. /** origin point */
  10999. origin: Vector3;
  11000. /** direction */
  11001. direction: Vector3;
  11002. /** length of the ray */
  11003. length: number;
  11004. private static readonly TmpVector3;
  11005. private _tmpRay;
  11006. /**
  11007. * Creates a new ray
  11008. * @param origin origin point
  11009. * @param direction direction
  11010. * @param length length of the ray
  11011. */
  11012. constructor(
  11013. /** origin point */
  11014. origin: Vector3,
  11015. /** direction */
  11016. direction: Vector3,
  11017. /** length of the ray */
  11018. length?: number);
  11019. /**
  11020. * Checks if the ray intersects a box
  11021. * @param minimum bound of the box
  11022. * @param maximum bound of the box
  11023. * @param intersectionTreshold extra extend to be added to the box in all direction
  11024. * @returns if the box was hit
  11025. */
  11026. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11027. /**
  11028. * Checks if the ray intersects a box
  11029. * @param box the bounding box to check
  11030. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * If the ray hits a sphere
  11036. * @param sphere the bounding sphere to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11038. * @returns true if it hits the sphere
  11039. */
  11040. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a triange
  11043. * @param vertex0 triangle vertex
  11044. * @param vertex1 triangle vertex
  11045. * @param vertex2 triangle vertex
  11046. * @returns intersection information if hit
  11047. */
  11048. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11049. /**
  11050. * Checks if ray intersects a plane
  11051. * @param plane the plane to check
  11052. * @returns the distance away it was hit
  11053. */
  11054. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11055. /**
  11056. * Calculate the intercept of a ray on a given axis
  11057. * @param axis to check 'x' | 'y' | 'z'
  11058. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11059. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11060. */
  11061. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11062. /**
  11063. * Checks if ray intersects a mesh
  11064. * @param mesh the mesh to check
  11065. * @param fastCheck if only the bounding box should checked
  11066. * @returns picking info of the intersecton
  11067. */
  11068. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param meshes the meshes to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @param results array to store result in
  11074. * @returns Array of picking infos
  11075. */
  11076. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11077. private _comparePickingInfo;
  11078. private static smallnum;
  11079. private static rayl;
  11080. /**
  11081. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11082. * @param sega the first point of the segment to test the intersection against
  11083. * @param segb the second point of the segment to test the intersection against
  11084. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11085. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11086. */
  11087. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11088. /**
  11089. * Update the ray from viewport position
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns this ray updated
  11098. */
  11099. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * Creates a ray with origin and direction of 0,0,0
  11102. * @returns the new ray
  11103. */
  11104. static Zero(): Ray;
  11105. /**
  11106. * Creates a new ray from screen space and viewport
  11107. * @param x position
  11108. * @param y y position
  11109. * @param viewportWidth viewport width
  11110. * @param viewportHeight viewport height
  11111. * @param world world matrix
  11112. * @param view view matrix
  11113. * @param projection projection matrix
  11114. * @returns new ray
  11115. */
  11116. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11117. /**
  11118. * 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
  11119. * transformed to the given world matrix.
  11120. * @param origin The origin point
  11121. * @param end The end point
  11122. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11123. * @returns the new ray
  11124. */
  11125. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11126. /**
  11127. * Transforms a ray by a matrix
  11128. * @param ray ray to transform
  11129. * @param matrix matrix to apply
  11130. * @returns the resulting new ray
  11131. */
  11132. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @param result ray to store result in
  11138. */
  11139. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11140. /**
  11141. * Unproject a ray from screen space to object space
  11142. * @param sourceX defines the screen space x coordinate to use
  11143. * @param sourceY defines the screen space y coordinate to use
  11144. * @param viewportWidth defines the current width of the viewport
  11145. * @param viewportHeight defines the current height of the viewport
  11146. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11147. * @param view defines the view matrix to use
  11148. * @param projection defines the projection matrix to use
  11149. */
  11150. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11151. }
  11152. /**
  11153. * Type used to define predicate used to select faces when a mesh intersection is detected
  11154. */
  11155. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11156. module "babylonjs/scene" {
  11157. interface Scene {
  11158. /** @hidden */
  11159. _tempPickingRay: Nullable<Ray>;
  11160. /** @hidden */
  11161. _cachedRayForTransform: Ray;
  11162. /** @hidden */
  11163. _pickWithRayInverseMatrix: Matrix;
  11164. /** @hidden */
  11165. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11166. /** @hidden */
  11167. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11168. }
  11169. }
  11170. }
  11171. declare module "babylonjs/sceneComponent" {
  11172. import { Scene } from "babylonjs/scene";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11175. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11176. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11177. import { Nullable } from "babylonjs/types";
  11178. import { Camera } from "babylonjs/Cameras/camera";
  11179. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11180. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11181. import { AbstractScene } from "babylonjs/abstractScene";
  11182. /**
  11183. * Groups all the scene component constants in one place to ease maintenance.
  11184. * @hidden
  11185. */
  11186. export class SceneComponentConstants {
  11187. static readonly NAME_EFFECTLAYER: string;
  11188. static readonly NAME_LAYER: string;
  11189. static readonly NAME_LENSFLARESYSTEM: string;
  11190. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11191. static readonly NAME_PARTICLESYSTEM: string;
  11192. static readonly NAME_GAMEPAD: string;
  11193. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11194. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11195. static readonly NAME_DEPTHRENDERER: string;
  11196. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11197. static readonly NAME_SPRITE: string;
  11198. static readonly NAME_OUTLINERENDERER: string;
  11199. static readonly NAME_PROCEDURALTEXTURE: string;
  11200. static readonly NAME_SHADOWGENERATOR: string;
  11201. static readonly NAME_OCTREE: string;
  11202. static readonly NAME_PHYSICSENGINE: string;
  11203. static readonly NAME_AUDIO: string;
  11204. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11205. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11206. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11207. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11208. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11209. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11210. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11211. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11212. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11213. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11214. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11215. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11216. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11217. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11218. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11219. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11220. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11221. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11222. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11223. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11224. static readonly STEP_AFTERRENDER_AUDIO: number;
  11225. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11226. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11227. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11228. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11229. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11230. static readonly STEP_POINTERMOVE_SPRITE: number;
  11231. static readonly STEP_POINTERDOWN_SPRITE: number;
  11232. static readonly STEP_POINTERUP_SPRITE: number;
  11233. }
  11234. /**
  11235. * This represents a scene component.
  11236. *
  11237. * This is used to decouple the dependency the scene is having on the different workloads like
  11238. * layers, post processes...
  11239. */
  11240. export interface ISceneComponent {
  11241. /**
  11242. * The name of the component. Each component must have a unique name.
  11243. */
  11244. name: string;
  11245. /**
  11246. * The scene the component belongs to.
  11247. */
  11248. scene: Scene;
  11249. /**
  11250. * Register the component to one instance of a scene.
  11251. */
  11252. register(): void;
  11253. /**
  11254. * Rebuilds the elements related to this component in case of
  11255. * context lost for instance.
  11256. */
  11257. rebuild(): void;
  11258. /**
  11259. * Disposes the component and the associated ressources.
  11260. */
  11261. dispose(): void;
  11262. }
  11263. /**
  11264. * This represents a SERIALIZABLE scene component.
  11265. *
  11266. * This extends Scene Component to add Serialization methods on top.
  11267. */
  11268. export interface ISceneSerializableComponent extends ISceneComponent {
  11269. /**
  11270. * Adds all the elements from the container to the scene
  11271. * @param container the container holding the elements
  11272. */
  11273. addFromContainer(container: AbstractScene): void;
  11274. /**
  11275. * Removes all the elements in the container from the scene
  11276. * @param container contains the elements to remove
  11277. * @param dispose if the removed element should be disposed (default: false)
  11278. */
  11279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11280. /**
  11281. * Serializes the component data to the specified json object
  11282. * @param serializationObject The object to serialize to
  11283. */
  11284. serialize(serializationObject: any): void;
  11285. }
  11286. /**
  11287. * Strong typing of a Mesh related stage step action
  11288. */
  11289. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11290. /**
  11291. * Strong typing of a Evaluate Sub Mesh related stage step action
  11292. */
  11293. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11294. /**
  11295. * Strong typing of a Active Mesh related stage step action
  11296. */
  11297. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11298. /**
  11299. * Strong typing of a Camera related stage step action
  11300. */
  11301. export type CameraStageAction = (camera: Camera) => void;
  11302. /**
  11303. * Strong typing of a Camera Frame buffer related stage step action
  11304. */
  11305. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11306. /**
  11307. * Strong typing of a Render Target related stage step action
  11308. */
  11309. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11310. /**
  11311. * Strong typing of a RenderingGroup related stage step action
  11312. */
  11313. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11314. /**
  11315. * Strong typing of a Mesh Render related stage step action
  11316. */
  11317. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11318. /**
  11319. * Strong typing of a simple stage step action
  11320. */
  11321. export type SimpleStageAction = () => void;
  11322. /**
  11323. * Strong typing of a render target action.
  11324. */
  11325. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11326. /**
  11327. * Strong typing of a pointer move action.
  11328. */
  11329. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11330. /**
  11331. * Strong typing of a pointer up/down action.
  11332. */
  11333. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11334. /**
  11335. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11336. * @hidden
  11337. */
  11338. export class Stage<T extends Function> extends Array<{
  11339. index: number;
  11340. component: ISceneComponent;
  11341. action: T;
  11342. }> {
  11343. /**
  11344. * Hide ctor from the rest of the world.
  11345. * @param items The items to add.
  11346. */
  11347. private constructor();
  11348. /**
  11349. * Creates a new Stage.
  11350. * @returns A new instance of a Stage
  11351. */
  11352. static Create<T extends Function>(): Stage<T>;
  11353. /**
  11354. * Registers a step in an ordered way in the targeted stage.
  11355. * @param index Defines the position to register the step in
  11356. * @param component Defines the component attached to the step
  11357. * @param action Defines the action to launch during the step
  11358. */
  11359. registerStep(index: number, component: ISceneComponent, action: T): void;
  11360. /**
  11361. * Clears all the steps from the stage.
  11362. */
  11363. clear(): void;
  11364. }
  11365. }
  11366. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11367. import { Nullable } from "babylonjs/types";
  11368. import { Observable } from "babylonjs/Misc/observable";
  11369. import { Scene } from "babylonjs/scene";
  11370. import { Sprite } from "babylonjs/Sprites/sprite";
  11371. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11372. import { Ray } from "babylonjs/Culling/ray";
  11373. import { Camera } from "babylonjs/Cameras/camera";
  11374. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11375. import { ISceneComponent } from "babylonjs/sceneComponent";
  11376. module "babylonjs/scene" {
  11377. interface Scene {
  11378. /** @hidden */
  11379. _pointerOverSprite: Nullable<Sprite>;
  11380. /** @hidden */
  11381. _pickedDownSprite: Nullable<Sprite>;
  11382. /** @hidden */
  11383. _tempSpritePickingRay: Nullable<Ray>;
  11384. /**
  11385. * All of the sprite managers added to this scene
  11386. * @see http://doc.babylonjs.com/babylon101/sprites
  11387. */
  11388. spriteManagers: Array<ISpriteManager>;
  11389. /**
  11390. * An event triggered when sprites rendering is about to start
  11391. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11392. */
  11393. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11394. /**
  11395. * An event triggered when sprites rendering is done
  11396. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11397. */
  11398. onAfterSpritesRenderingObservable: Observable<Scene>;
  11399. /** @hidden */
  11400. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /** Launch a ray to try to pick a sprite in the scene
  11402. * @param x position on screen
  11403. * @param y position on screen
  11404. * @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
  11405. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11406. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11407. * @returns a PickingInfo
  11408. */
  11409. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11410. /** Use the given ray to pick a sprite in the scene
  11411. * @param ray The ray (in world space) to use to pick meshes
  11412. * @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
  11413. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11414. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11415. * @returns a PickingInfo
  11416. */
  11417. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11418. /** @hidden */
  11419. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11420. /** Launch a ray to try to pick sprites in the scene
  11421. * @param x position on screen
  11422. * @param y position on screen
  11423. * @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
  11424. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11425. * @returns a PickingInfo array
  11426. */
  11427. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11428. /** Use the given ray to pick sprites in the scene
  11429. * @param ray The ray (in world space) to use to pick meshes
  11430. * @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
  11431. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /**
  11436. * Force the sprite under the pointer
  11437. * @param sprite defines the sprite to use
  11438. */
  11439. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11440. /**
  11441. * Gets the sprite under the pointer
  11442. * @returns a Sprite or null if no sprite is under the pointer
  11443. */
  11444. getPointerOverSprite(): Nullable<Sprite>;
  11445. }
  11446. }
  11447. /**
  11448. * Defines the sprite scene component responsible to manage sprites
  11449. * in a given scene.
  11450. */
  11451. export class SpriteSceneComponent implements ISceneComponent {
  11452. /**
  11453. * The component name helpfull to identify the component in the list of scene components.
  11454. */
  11455. readonly name: string;
  11456. /**
  11457. * The scene the component belongs to.
  11458. */
  11459. scene: Scene;
  11460. /** @hidden */
  11461. private _spritePredicate;
  11462. /**
  11463. * Creates a new instance of the component for the given scene
  11464. * @param scene Defines the scene to register the component in
  11465. */
  11466. constructor(scene: Scene);
  11467. /**
  11468. * Registers the component in a given scene
  11469. */
  11470. register(): void;
  11471. /**
  11472. * Rebuilds the elements related to this component in case of
  11473. * context lost for instance.
  11474. */
  11475. rebuild(): void;
  11476. /**
  11477. * Disposes the component and the associated ressources.
  11478. */
  11479. dispose(): void;
  11480. private _pickSpriteButKeepRay;
  11481. private _pointerMove;
  11482. private _pointerDown;
  11483. private _pointerUp;
  11484. }
  11485. }
  11486. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11487. /** @hidden */
  11488. export var fogFragmentDeclaration: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11494. /** @hidden */
  11495. export var fogFragment: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/sprites.fragment" {
  11501. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11502. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11503. /** @hidden */
  11504. export var spritesPixelShader: {
  11505. name: string;
  11506. shader: string;
  11507. };
  11508. }
  11509. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11510. /** @hidden */
  11511. export var fogVertexDeclaration: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/sprites.vertex" {
  11517. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11518. /** @hidden */
  11519. export var spritesVertexShader: {
  11520. name: string;
  11521. shader: string;
  11522. };
  11523. }
  11524. declare module "babylonjs/Sprites/spriteManager" {
  11525. import { IDisposable, Scene } from "babylonjs/scene";
  11526. import { Nullable } from "babylonjs/types";
  11527. import { Observable } from "babylonjs/Misc/observable";
  11528. import { Sprite } from "babylonjs/Sprites/sprite";
  11529. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11530. import { Camera } from "babylonjs/Cameras/camera";
  11531. import { Texture } from "babylonjs/Materials/Textures/texture";
  11532. import "babylonjs/Shaders/sprites.fragment";
  11533. import "babylonjs/Shaders/sprites.vertex";
  11534. import { Ray } from "babylonjs/Culling/ray";
  11535. /**
  11536. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11537. */
  11538. export interface ISpriteManager extends IDisposable {
  11539. /**
  11540. * Restricts the camera to viewing objects with the same layerMask.
  11541. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11542. */
  11543. layerMask: number;
  11544. /**
  11545. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11546. */
  11547. isPickable: boolean;
  11548. /**
  11549. * Specifies the rendering group id for this mesh (0 by default)
  11550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11551. */
  11552. renderingGroupId: number;
  11553. /**
  11554. * Defines the list of sprites managed by the manager.
  11555. */
  11556. sprites: Array<Sprite>;
  11557. /**
  11558. * Tests the intersection of a sprite with a specific ray.
  11559. * @param ray The ray we are sending to test the collision
  11560. * @param camera The camera space we are sending rays in
  11561. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11562. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11563. * @returns picking info or null.
  11564. */
  11565. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11566. /**
  11567. * Intersects the sprites with a ray
  11568. * @param ray defines the ray to intersect with
  11569. * @param camera defines the current active camera
  11570. * @param predicate defines a predicate used to select candidate sprites
  11571. * @returns null if no hit or a PickingInfo array
  11572. */
  11573. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11574. /**
  11575. * Renders the list of sprites on screen.
  11576. */
  11577. render(): void;
  11578. }
  11579. /**
  11580. * Class used to manage multiple sprites on the same spritesheet
  11581. * @see http://doc.babylonjs.com/babylon101/sprites
  11582. */
  11583. export class SpriteManager implements ISpriteManager {
  11584. /** defines the manager's name */
  11585. name: string;
  11586. /** Gets the list of sprites */
  11587. sprites: Sprite[];
  11588. /** Gets or sets the rendering group id (0 by default) */
  11589. renderingGroupId: number;
  11590. /** Gets or sets camera layer mask */
  11591. layerMask: number;
  11592. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11593. fogEnabled: boolean;
  11594. /** Gets or sets a boolean indicating if the sprites are pickable */
  11595. isPickable: boolean;
  11596. /** Defines the default width of a cell in the spritesheet */
  11597. cellWidth: number;
  11598. /** Defines the default height of a cell in the spritesheet */
  11599. cellHeight: number;
  11600. /** Associative array from JSON sprite data file */
  11601. private _cellData;
  11602. /** Array of sprite names from JSON sprite data file */
  11603. private _spriteMap;
  11604. /** True when packed cell data from JSON file is ready*/
  11605. private _packedAndReady;
  11606. /**
  11607. * An event triggered when the manager is disposed.
  11608. */
  11609. onDisposeObservable: Observable<SpriteManager>;
  11610. private _onDisposeObserver;
  11611. /**
  11612. * Callback called when the manager is disposed
  11613. */
  11614. onDispose: () => void;
  11615. private _capacity;
  11616. private _fromPacked;
  11617. private _spriteTexture;
  11618. private _epsilon;
  11619. private _scene;
  11620. private _vertexData;
  11621. private _buffer;
  11622. private _vertexBuffers;
  11623. private _indexBuffer;
  11624. private _effectBase;
  11625. private _effectFog;
  11626. /**
  11627. * Gets or sets the spritesheet texture
  11628. */
  11629. texture: Texture;
  11630. /**
  11631. * Creates a new sprite manager
  11632. * @param name defines the manager's name
  11633. * @param imgUrl defines the sprite sheet url
  11634. * @param capacity defines the maximum allowed number of sprites
  11635. * @param cellSize defines the size of a sprite cell
  11636. * @param scene defines the hosting scene
  11637. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11638. * @param samplingMode defines the smapling mode to use with spritesheet
  11639. * @param fromPacked set to false; do not alter
  11640. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11641. */
  11642. constructor(
  11643. /** defines the manager's name */
  11644. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11645. private _makePacked;
  11646. private _appendSpriteVertex;
  11647. /**
  11648. * Intersects the sprites with a ray
  11649. * @param ray defines the ray to intersect with
  11650. * @param camera defines the current active camera
  11651. * @param predicate defines a predicate used to select candidate sprites
  11652. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11653. * @returns null if no hit or a PickingInfo
  11654. */
  11655. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11656. /**
  11657. * Intersects the sprites with a ray
  11658. * @param ray defines the ray to intersect with
  11659. * @param camera defines the current active camera
  11660. * @param predicate defines a predicate used to select candidate sprites
  11661. * @returns null if no hit or a PickingInfo array
  11662. */
  11663. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11664. /**
  11665. * Render all child sprites
  11666. */
  11667. render(): void;
  11668. /**
  11669. * Release associated resources
  11670. */
  11671. dispose(): void;
  11672. }
  11673. }
  11674. declare module "babylonjs/Sprites/sprite" {
  11675. import { Vector3 } from "babylonjs/Maths/math.vector";
  11676. import { Nullable } from "babylonjs/types";
  11677. import { ActionManager } from "babylonjs/Actions/actionManager";
  11678. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11679. import { Color4 } from "babylonjs/Maths/math.color";
  11680. /**
  11681. * Class used to represent a sprite
  11682. * @see http://doc.babylonjs.com/babylon101/sprites
  11683. */
  11684. export class Sprite {
  11685. /** defines the name */
  11686. name: string;
  11687. /** Gets or sets the current world position */
  11688. position: Vector3;
  11689. /** Gets or sets the main color */
  11690. color: Color4;
  11691. /** Gets or sets the width */
  11692. width: number;
  11693. /** Gets or sets the height */
  11694. height: number;
  11695. /** Gets or sets rotation angle */
  11696. angle: number;
  11697. /** Gets or sets the cell index in the sprite sheet */
  11698. cellIndex: number;
  11699. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11700. cellRef: string;
  11701. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11702. invertU: number;
  11703. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11704. invertV: number;
  11705. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11706. disposeWhenFinishedAnimating: boolean;
  11707. /** Gets the list of attached animations */
  11708. animations: Animation[];
  11709. /** Gets or sets a boolean indicating if the sprite can be picked */
  11710. isPickable: boolean;
  11711. /**
  11712. * Gets or sets the associated action manager
  11713. */
  11714. actionManager: Nullable<ActionManager>;
  11715. private _animationStarted;
  11716. private _loopAnimation;
  11717. private _fromIndex;
  11718. private _toIndex;
  11719. private _delay;
  11720. private _direction;
  11721. private _manager;
  11722. private _time;
  11723. private _onAnimationEnd;
  11724. /**
  11725. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11726. */
  11727. isVisible: boolean;
  11728. /**
  11729. * Gets or sets the sprite size
  11730. */
  11731. size: number;
  11732. /**
  11733. * Creates a new Sprite
  11734. * @param name defines the name
  11735. * @param manager defines the manager
  11736. */
  11737. constructor(
  11738. /** defines the name */
  11739. name: string, manager: ISpriteManager);
  11740. /**
  11741. * Starts an animation
  11742. * @param from defines the initial key
  11743. * @param to defines the end key
  11744. * @param loop defines if the animation must loop
  11745. * @param delay defines the start delay (in ms)
  11746. * @param onAnimationEnd defines a callback to call when animation ends
  11747. */
  11748. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11749. /** Stops current animation (if any) */
  11750. stopAnimation(): void;
  11751. /** @hidden */
  11752. _animate(deltaTime: number): void;
  11753. /** Release associated resources */
  11754. dispose(): void;
  11755. }
  11756. }
  11757. declare module "babylonjs/Collisions/pickingInfo" {
  11758. import { Nullable } from "babylonjs/types";
  11759. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11761. import { Sprite } from "babylonjs/Sprites/sprite";
  11762. import { Ray } from "babylonjs/Culling/ray";
  11763. /**
  11764. * Information about the result of picking within a scene
  11765. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11766. */
  11767. export class PickingInfo {
  11768. /** @hidden */
  11769. _pickingUnavailable: boolean;
  11770. /**
  11771. * If the pick collided with an object
  11772. */
  11773. hit: boolean;
  11774. /**
  11775. * Distance away where the pick collided
  11776. */
  11777. distance: number;
  11778. /**
  11779. * The location of pick collision
  11780. */
  11781. pickedPoint: Nullable<Vector3>;
  11782. /**
  11783. * The mesh corresponding the the pick collision
  11784. */
  11785. pickedMesh: Nullable<AbstractMesh>;
  11786. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11787. bu: number;
  11788. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11789. bv: number;
  11790. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11791. faceId: number;
  11792. /** Id of the the submesh that was picked */
  11793. subMeshId: number;
  11794. /** If a sprite was picked, this will be the sprite the pick collided with */
  11795. pickedSprite: Nullable<Sprite>;
  11796. /**
  11797. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11798. */
  11799. originMesh: Nullable<AbstractMesh>;
  11800. /**
  11801. * The ray that was used to perform the picking.
  11802. */
  11803. ray: Nullable<Ray>;
  11804. /**
  11805. * Gets the normal correspodning to the face the pick collided with
  11806. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11807. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11808. * @returns The normal correspodning to the face the pick collided with
  11809. */
  11810. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11811. /**
  11812. * Gets the texture coordinates of where the pick occured
  11813. * @returns the vector containing the coordnates of the texture
  11814. */
  11815. getTextureCoordinates(): Nullable<Vector2>;
  11816. }
  11817. }
  11818. declare module "babylonjs/Events/pointerEvents" {
  11819. import { Nullable } from "babylonjs/types";
  11820. import { Vector2 } from "babylonjs/Maths/math.vector";
  11821. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11822. import { Ray } from "babylonjs/Culling/ray";
  11823. /**
  11824. * Gather the list of pointer event types as constants.
  11825. */
  11826. export class PointerEventTypes {
  11827. /**
  11828. * 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.
  11829. */
  11830. static readonly POINTERDOWN: number;
  11831. /**
  11832. * The pointerup event is fired when a pointer is no longer active.
  11833. */
  11834. static readonly POINTERUP: number;
  11835. /**
  11836. * The pointermove event is fired when a pointer changes coordinates.
  11837. */
  11838. static readonly POINTERMOVE: number;
  11839. /**
  11840. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11841. */
  11842. static readonly POINTERWHEEL: number;
  11843. /**
  11844. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11845. */
  11846. static readonly POINTERPICK: number;
  11847. /**
  11848. * The pointertap event is fired when a the object has been touched and released without drag.
  11849. */
  11850. static readonly POINTERTAP: number;
  11851. /**
  11852. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11853. */
  11854. static readonly POINTERDOUBLETAP: number;
  11855. }
  11856. /**
  11857. * Base class of pointer info types.
  11858. */
  11859. export class PointerInfoBase {
  11860. /**
  11861. * Defines the type of event (PointerEventTypes)
  11862. */
  11863. type: number;
  11864. /**
  11865. * Defines the related dom event
  11866. */
  11867. event: PointerEvent | MouseWheelEvent;
  11868. /**
  11869. * Instantiates the base class of pointers info.
  11870. * @param type Defines the type of event (PointerEventTypes)
  11871. * @param event Defines the related dom event
  11872. */
  11873. constructor(
  11874. /**
  11875. * Defines the type of event (PointerEventTypes)
  11876. */
  11877. type: number,
  11878. /**
  11879. * Defines the related dom event
  11880. */
  11881. event: PointerEvent | MouseWheelEvent);
  11882. }
  11883. /**
  11884. * This class is used to store pointer related info for the onPrePointerObservable event.
  11885. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11886. */
  11887. export class PointerInfoPre extends PointerInfoBase {
  11888. /**
  11889. * Ray from a pointer if availible (eg. 6dof controller)
  11890. */
  11891. ray: Nullable<Ray>;
  11892. /**
  11893. * Defines the local position of the pointer on the canvas.
  11894. */
  11895. localPosition: Vector2;
  11896. /**
  11897. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11898. */
  11899. skipOnPointerObservable: boolean;
  11900. /**
  11901. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11902. * @param type Defines the type of event (PointerEventTypes)
  11903. * @param event Defines the related dom event
  11904. * @param localX Defines the local x coordinates of the pointer when the event occured
  11905. * @param localY Defines the local y coordinates of the pointer when the event occured
  11906. */
  11907. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11908. }
  11909. /**
  11910. * This type contains all the data related to a pointer event in Babylon.js.
  11911. * 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.
  11912. */
  11913. export class PointerInfo extends PointerInfoBase {
  11914. /**
  11915. * Defines the picking info associated to the info (if any)\
  11916. */
  11917. pickInfo: Nullable<PickingInfo>;
  11918. /**
  11919. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11920. * @param type Defines the type of event (PointerEventTypes)
  11921. * @param event Defines the related dom event
  11922. * @param pickInfo Defines the picking info associated to the info (if any)\
  11923. */
  11924. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11925. /**
  11926. * Defines the picking info associated to the info (if any)\
  11927. */
  11928. pickInfo: Nullable<PickingInfo>);
  11929. }
  11930. /**
  11931. * Data relating to a touch event on the screen.
  11932. */
  11933. export interface PointerTouch {
  11934. /**
  11935. * X coordinate of touch.
  11936. */
  11937. x: number;
  11938. /**
  11939. * Y coordinate of touch.
  11940. */
  11941. y: number;
  11942. /**
  11943. * Id of touch. Unique for each finger.
  11944. */
  11945. pointerId: number;
  11946. /**
  11947. * Event type passed from DOM.
  11948. */
  11949. type: any;
  11950. }
  11951. }
  11952. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11953. import { Observable } from "babylonjs/Misc/observable";
  11954. import { Nullable } from "babylonjs/types";
  11955. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11956. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11957. /**
  11958. * Manage the mouse inputs to control the movement of a free camera.
  11959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11960. */
  11961. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11962. /**
  11963. * Define if touch is enabled in the mouse input
  11964. */
  11965. touchEnabled: boolean;
  11966. /**
  11967. * Defines the camera the input is attached to.
  11968. */
  11969. camera: FreeCamera;
  11970. /**
  11971. * Defines the buttons associated with the input to handle camera move.
  11972. */
  11973. buttons: number[];
  11974. /**
  11975. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11976. */
  11977. angularSensibility: number;
  11978. private _pointerInput;
  11979. private _onMouseMove;
  11980. private _observer;
  11981. private previousPosition;
  11982. /**
  11983. * Observable for when a pointer move event occurs containing the move offset
  11984. */
  11985. onPointerMovedObservable: Observable<{
  11986. offsetX: number;
  11987. offsetY: number;
  11988. }>;
  11989. /**
  11990. * @hidden
  11991. * If the camera should be rotated automatically based on pointer movement
  11992. */
  11993. _allowCameraRotation: boolean;
  11994. /**
  11995. * Manage the mouse inputs to control the movement of a free camera.
  11996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11997. * @param touchEnabled Defines if touch is enabled or not
  11998. */
  11999. constructor(
  12000. /**
  12001. * Define if touch is enabled in the mouse input
  12002. */
  12003. touchEnabled?: boolean);
  12004. /**
  12005. * Attach the input controls to a specific dom element to get the input from.
  12006. * @param element Defines the element the controls should be listened from
  12007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12008. */
  12009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12010. /**
  12011. * Called on JS contextmenu event.
  12012. * Override this method to provide functionality.
  12013. */
  12014. protected onContextMenu(evt: PointerEvent): void;
  12015. /**
  12016. * Detach the current controls from the specified dom element.
  12017. * @param element Defines the element to stop listening the inputs from
  12018. */
  12019. detachControl(element: Nullable<HTMLElement>): void;
  12020. /**
  12021. * Gets the class name of the current intput.
  12022. * @returns the class name
  12023. */
  12024. getClassName(): string;
  12025. /**
  12026. * Get the friendly name associated with the input class.
  12027. * @returns the input friendly name
  12028. */
  12029. getSimpleName(): string;
  12030. }
  12031. }
  12032. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12033. import { Nullable } from "babylonjs/types";
  12034. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12035. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12036. /**
  12037. * Manage the touch inputs to control the movement of a free camera.
  12038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12039. */
  12040. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12041. /**
  12042. * Defines the camera the input is attached to.
  12043. */
  12044. camera: FreeCamera;
  12045. /**
  12046. * Defines the touch sensibility for rotation.
  12047. * The higher the faster.
  12048. */
  12049. touchAngularSensibility: number;
  12050. /**
  12051. * Defines the touch sensibility for move.
  12052. * The higher the faster.
  12053. */
  12054. touchMoveSensibility: number;
  12055. private _offsetX;
  12056. private _offsetY;
  12057. private _pointerPressed;
  12058. private _pointerInput;
  12059. private _observer;
  12060. private _onLostFocus;
  12061. /**
  12062. * Attach the input controls to a specific dom element to get the input from.
  12063. * @param element Defines the element the controls should be listened from
  12064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12065. */
  12066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12067. /**
  12068. * Detach the current controls from the specified dom element.
  12069. * @param element Defines the element to stop listening the inputs from
  12070. */
  12071. detachControl(element: Nullable<HTMLElement>): void;
  12072. /**
  12073. * Update the current camera state depending on the inputs that have been used this frame.
  12074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12075. */
  12076. checkInputs(): void;
  12077. /**
  12078. * Gets the class name of the current intput.
  12079. * @returns the class name
  12080. */
  12081. getClassName(): string;
  12082. /**
  12083. * Get the friendly name associated with the input class.
  12084. * @returns the input friendly name
  12085. */
  12086. getSimpleName(): string;
  12087. }
  12088. }
  12089. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12090. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12091. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12092. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12093. import { Nullable } from "babylonjs/types";
  12094. /**
  12095. * Default Inputs manager for the FreeCamera.
  12096. * It groups all the default supported inputs for ease of use.
  12097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12098. */
  12099. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12100. /**
  12101. * @hidden
  12102. */
  12103. _mouseInput: Nullable<FreeCameraMouseInput>;
  12104. /**
  12105. * Instantiates a new FreeCameraInputsManager.
  12106. * @param camera Defines the camera the inputs belong to
  12107. */
  12108. constructor(camera: FreeCamera);
  12109. /**
  12110. * Add keyboard input support to the input manager.
  12111. * @returns the current input manager
  12112. */
  12113. addKeyboard(): FreeCameraInputsManager;
  12114. /**
  12115. * Add mouse input support to the input manager.
  12116. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12117. * @returns the current input manager
  12118. */
  12119. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12120. /**
  12121. * Removes the mouse input support from the manager
  12122. * @returns the current input manager
  12123. */
  12124. removeMouse(): FreeCameraInputsManager;
  12125. /**
  12126. * Add touch input support to the input manager.
  12127. * @returns the current input manager
  12128. */
  12129. addTouch(): FreeCameraInputsManager;
  12130. /**
  12131. * Remove all attached input methods from a camera
  12132. */
  12133. clear(): void;
  12134. }
  12135. }
  12136. declare module "babylonjs/Cameras/freeCamera" {
  12137. import { Vector3 } from "babylonjs/Maths/math.vector";
  12138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12139. import { Scene } from "babylonjs/scene";
  12140. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12141. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12142. /**
  12143. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12144. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12145. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12146. */
  12147. export class FreeCamera extends TargetCamera {
  12148. /**
  12149. * Define the collision ellipsoid of the camera.
  12150. * This is helpful to simulate a camera body like the player body around the camera
  12151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12152. */
  12153. ellipsoid: Vector3;
  12154. /**
  12155. * Define an offset for the position of the ellipsoid around the camera.
  12156. * This can be helpful to determine the center of the body near the gravity center of the body
  12157. * instead of its head.
  12158. */
  12159. ellipsoidOffset: Vector3;
  12160. /**
  12161. * Enable or disable collisions of the camera with the rest of the scene objects.
  12162. */
  12163. checkCollisions: boolean;
  12164. /**
  12165. * Enable or disable gravity on the camera.
  12166. */
  12167. applyGravity: boolean;
  12168. /**
  12169. * Define the input manager associated to the camera.
  12170. */
  12171. inputs: FreeCameraInputsManager;
  12172. /**
  12173. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12174. * Higher values reduce sensitivity.
  12175. */
  12176. /**
  12177. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12178. * Higher values reduce sensitivity.
  12179. */
  12180. angularSensibility: number;
  12181. /**
  12182. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12183. */
  12184. keysUp: number[];
  12185. /**
  12186. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12187. */
  12188. keysDown: number[];
  12189. /**
  12190. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12191. */
  12192. keysLeft: number[];
  12193. /**
  12194. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12195. */
  12196. keysRight: number[];
  12197. /**
  12198. * Event raised when the camera collide with a mesh in the scene.
  12199. */
  12200. onCollide: (collidedMesh: AbstractMesh) => void;
  12201. private _collider;
  12202. private _needMoveForGravity;
  12203. private _oldPosition;
  12204. private _diffPosition;
  12205. private _newPosition;
  12206. /** @hidden */
  12207. _localDirection: Vector3;
  12208. /** @hidden */
  12209. _transformedDirection: Vector3;
  12210. /**
  12211. * Instantiates a Free Camera.
  12212. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12213. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12214. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12215. * @param name Define the name of the camera in the scene
  12216. * @param position Define the start position of the camera in the scene
  12217. * @param scene Define the scene the camera belongs to
  12218. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12219. */
  12220. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12221. /**
  12222. * Attached controls to the current camera.
  12223. * @param element Defines the element the controls should be listened from
  12224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12225. */
  12226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12227. /**
  12228. * Detach the current controls from the camera.
  12229. * The camera will stop reacting to inputs.
  12230. * @param element Defines the element to stop listening the inputs from
  12231. */
  12232. detachControl(element: HTMLElement): void;
  12233. private _collisionMask;
  12234. /**
  12235. * Define a collision mask to limit the list of object the camera can collide with
  12236. */
  12237. collisionMask: number;
  12238. /** @hidden */
  12239. _collideWithWorld(displacement: Vector3): void;
  12240. private _onCollisionPositionChange;
  12241. /** @hidden */
  12242. _checkInputs(): void;
  12243. /** @hidden */
  12244. _decideIfNeedsToMove(): boolean;
  12245. /** @hidden */
  12246. _updatePosition(): void;
  12247. /**
  12248. * Destroy the camera and release the current resources hold by it.
  12249. */
  12250. dispose(): void;
  12251. /**
  12252. * Gets the current object class name.
  12253. * @return the class name
  12254. */
  12255. getClassName(): string;
  12256. }
  12257. }
  12258. declare module "babylonjs/Gamepads/gamepad" {
  12259. import { Observable } from "babylonjs/Misc/observable";
  12260. /**
  12261. * Represents a gamepad control stick position
  12262. */
  12263. export class StickValues {
  12264. /**
  12265. * The x component of the control stick
  12266. */
  12267. x: number;
  12268. /**
  12269. * The y component of the control stick
  12270. */
  12271. y: number;
  12272. /**
  12273. * Initializes the gamepad x and y control stick values
  12274. * @param x The x component of the gamepad control stick value
  12275. * @param y The y component of the gamepad control stick value
  12276. */
  12277. constructor(
  12278. /**
  12279. * The x component of the control stick
  12280. */
  12281. x: number,
  12282. /**
  12283. * The y component of the control stick
  12284. */
  12285. y: number);
  12286. }
  12287. /**
  12288. * An interface which manages callbacks for gamepad button changes
  12289. */
  12290. export interface GamepadButtonChanges {
  12291. /**
  12292. * Called when a gamepad has been changed
  12293. */
  12294. changed: boolean;
  12295. /**
  12296. * Called when a gamepad press event has been triggered
  12297. */
  12298. pressChanged: boolean;
  12299. /**
  12300. * Called when a touch event has been triggered
  12301. */
  12302. touchChanged: boolean;
  12303. /**
  12304. * Called when a value has changed
  12305. */
  12306. valueChanged: boolean;
  12307. }
  12308. /**
  12309. * Represents a gamepad
  12310. */
  12311. export class Gamepad {
  12312. /**
  12313. * The id of the gamepad
  12314. */
  12315. id: string;
  12316. /**
  12317. * The index of the gamepad
  12318. */
  12319. index: number;
  12320. /**
  12321. * The browser gamepad
  12322. */
  12323. browserGamepad: any;
  12324. /**
  12325. * Specifies what type of gamepad this represents
  12326. */
  12327. type: number;
  12328. private _leftStick;
  12329. private _rightStick;
  12330. /** @hidden */
  12331. _isConnected: boolean;
  12332. private _leftStickAxisX;
  12333. private _leftStickAxisY;
  12334. private _rightStickAxisX;
  12335. private _rightStickAxisY;
  12336. /**
  12337. * Triggered when the left control stick has been changed
  12338. */
  12339. private _onleftstickchanged;
  12340. /**
  12341. * Triggered when the right control stick has been changed
  12342. */
  12343. private _onrightstickchanged;
  12344. /**
  12345. * Represents a gamepad controller
  12346. */
  12347. static GAMEPAD: number;
  12348. /**
  12349. * Represents a generic controller
  12350. */
  12351. static GENERIC: number;
  12352. /**
  12353. * Represents an XBox controller
  12354. */
  12355. static XBOX: number;
  12356. /**
  12357. * Represents a pose-enabled controller
  12358. */
  12359. static POSE_ENABLED: number;
  12360. /**
  12361. * Represents an Dual Shock controller
  12362. */
  12363. static DUALSHOCK: number;
  12364. /**
  12365. * Specifies whether the left control stick should be Y-inverted
  12366. */
  12367. protected _invertLeftStickY: boolean;
  12368. /**
  12369. * Specifies if the gamepad has been connected
  12370. */
  12371. readonly isConnected: boolean;
  12372. /**
  12373. * Initializes the gamepad
  12374. * @param id The id of the gamepad
  12375. * @param index The index of the gamepad
  12376. * @param browserGamepad The browser gamepad
  12377. * @param leftStickX The x component of the left joystick
  12378. * @param leftStickY The y component of the left joystick
  12379. * @param rightStickX The x component of the right joystick
  12380. * @param rightStickY The y component of the right joystick
  12381. */
  12382. constructor(
  12383. /**
  12384. * The id of the gamepad
  12385. */
  12386. id: string,
  12387. /**
  12388. * The index of the gamepad
  12389. */
  12390. index: number,
  12391. /**
  12392. * The browser gamepad
  12393. */
  12394. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12395. /**
  12396. * Callback triggered when the left joystick has changed
  12397. * @param callback
  12398. */
  12399. onleftstickchanged(callback: (values: StickValues) => void): void;
  12400. /**
  12401. * Callback triggered when the right joystick has changed
  12402. * @param callback
  12403. */
  12404. onrightstickchanged(callback: (values: StickValues) => void): void;
  12405. /**
  12406. * Gets the left joystick
  12407. */
  12408. /**
  12409. * Sets the left joystick values
  12410. */
  12411. leftStick: StickValues;
  12412. /**
  12413. * Gets the right joystick
  12414. */
  12415. /**
  12416. * Sets the right joystick value
  12417. */
  12418. rightStick: StickValues;
  12419. /**
  12420. * Updates the gamepad joystick positions
  12421. */
  12422. update(): void;
  12423. /**
  12424. * Disposes the gamepad
  12425. */
  12426. dispose(): void;
  12427. }
  12428. /**
  12429. * Represents a generic gamepad
  12430. */
  12431. export class GenericPad extends Gamepad {
  12432. private _buttons;
  12433. private _onbuttondown;
  12434. private _onbuttonup;
  12435. /**
  12436. * Observable triggered when a button has been pressed
  12437. */
  12438. onButtonDownObservable: Observable<number>;
  12439. /**
  12440. * Observable triggered when a button has been released
  12441. */
  12442. onButtonUpObservable: Observable<number>;
  12443. /**
  12444. * Callback triggered when a button has been pressed
  12445. * @param callback Called when a button has been pressed
  12446. */
  12447. onbuttondown(callback: (buttonPressed: number) => void): void;
  12448. /**
  12449. * Callback triggered when a button has been released
  12450. * @param callback Called when a button has been released
  12451. */
  12452. onbuttonup(callback: (buttonReleased: number) => void): void;
  12453. /**
  12454. * Initializes the generic gamepad
  12455. * @param id The id of the generic gamepad
  12456. * @param index The index of the generic gamepad
  12457. * @param browserGamepad The browser gamepad
  12458. */
  12459. constructor(id: string, index: number, browserGamepad: any);
  12460. private _setButtonValue;
  12461. /**
  12462. * Updates the generic gamepad
  12463. */
  12464. update(): void;
  12465. /**
  12466. * Disposes the generic gamepad
  12467. */
  12468. dispose(): void;
  12469. }
  12470. }
  12471. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12472. import { Nullable } from "babylonjs/types";
  12473. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12474. import { Scene } from "babylonjs/scene";
  12475. module "babylonjs/Engines/engine" {
  12476. interface Engine {
  12477. /**
  12478. * Creates a raw texture
  12479. * @param data defines the data to store in the texture
  12480. * @param width defines the width of the texture
  12481. * @param height defines the height of the texture
  12482. * @param format defines the format of the data
  12483. * @param generateMipMaps defines if the engine should generate the mip levels
  12484. * @param invertY defines if data must be stored with Y axis inverted
  12485. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12486. * @param compression defines the compression used (null by default)
  12487. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12488. * @returns the raw texture inside an InternalTexture
  12489. */
  12490. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12491. /**
  12492. * Update a raw texture
  12493. * @param texture defines the texture to update
  12494. * @param data defines the data to store in the texture
  12495. * @param format defines the format of the data
  12496. * @param invertY defines if data must be stored with Y axis inverted
  12497. */
  12498. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12499. /**
  12500. * Update a raw texture
  12501. * @param texture defines the texture to update
  12502. * @param data defines the data to store in the texture
  12503. * @param format defines the format of the data
  12504. * @param invertY defines if data must be stored with Y axis inverted
  12505. * @param compression defines the compression used (null by default)
  12506. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12507. */
  12508. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12509. /**
  12510. * Creates a new raw cube texture
  12511. * @param data defines the array of data to use to create each face
  12512. * @param size defines the size of the textures
  12513. * @param format defines the format of the data
  12514. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12515. * @param generateMipMaps defines if the engine should generate the mip levels
  12516. * @param invertY defines if data must be stored with Y axis inverted
  12517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12518. * @param compression defines the compression used (null by default)
  12519. * @returns the cube texture as an InternalTexture
  12520. */
  12521. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12522. /**
  12523. * Update a raw cube texture
  12524. * @param texture defines the texture to udpdate
  12525. * @param data defines the data to store
  12526. * @param format defines the data format
  12527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12528. * @param invertY defines if data must be stored with Y axis inverted
  12529. */
  12530. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12531. /**
  12532. * Update a raw cube texture
  12533. * @param texture defines the texture to udpdate
  12534. * @param data defines the data to store
  12535. * @param format defines the data format
  12536. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12537. * @param invertY defines if data must be stored with Y axis inverted
  12538. * @param compression defines the compression used (null by default)
  12539. */
  12540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12541. /**
  12542. * Update a raw cube texture
  12543. * @param texture defines the texture to udpdate
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12547. * @param invertY defines if data must be stored with Y axis inverted
  12548. * @param compression defines the compression used (null by default)
  12549. * @param level defines which level of the texture to update
  12550. */
  12551. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12552. /**
  12553. * Creates a new raw cube texture from a specified url
  12554. * @param url defines the url where the data is located
  12555. * @param scene defines the current scene
  12556. * @param size defines the size of the textures
  12557. * @param format defines the format of the data
  12558. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12559. * @param noMipmap defines if the engine should avoid generating the mip levels
  12560. * @param callback defines a callback used to extract texture data from loaded data
  12561. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12562. * @param onLoad defines a callback called when texture is loaded
  12563. * @param onError defines a callback called if there is an error
  12564. * @returns the cube texture as an InternalTexture
  12565. */
  12566. 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;
  12567. /**
  12568. * Creates a new raw cube texture from a specified url
  12569. * @param url defines the url where the data is located
  12570. * @param scene defines the current scene
  12571. * @param size defines the size of the textures
  12572. * @param format defines the format of the data
  12573. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12574. * @param noMipmap defines if the engine should avoid generating the mip levels
  12575. * @param callback defines a callback used to extract texture data from loaded data
  12576. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12577. * @param onLoad defines a callback called when texture is loaded
  12578. * @param onError defines a callback called if there is an error
  12579. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12580. * @param invertY defines if data must be stored with Y axis inverted
  12581. * @returns the cube texture as an InternalTexture
  12582. */
  12583. 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;
  12584. /**
  12585. * Creates a new raw 3D texture
  12586. * @param data defines the data used to create the texture
  12587. * @param width defines the width of the texture
  12588. * @param height defines the height of the texture
  12589. * @param depth defines the depth of the texture
  12590. * @param format defines the format of the texture
  12591. * @param generateMipMaps defines if the engine must generate mip levels
  12592. * @param invertY defines if data must be stored with Y axis inverted
  12593. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12594. * @param compression defines the compressed used (can be null)
  12595. * @param textureType defines the compressed used (can be null)
  12596. * @returns a new raw 3D texture (stored in an InternalTexture)
  12597. */
  12598. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12599. /**
  12600. * Update a raw 3D texture
  12601. * @param texture defines the texture to update
  12602. * @param data defines the data to store
  12603. * @param format defines the data format
  12604. * @param invertY defines if data must be stored with Y axis inverted
  12605. */
  12606. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12607. /**
  12608. * Update a raw 3D texture
  12609. * @param texture defines the texture to update
  12610. * @param data defines the data to store
  12611. * @param format defines the data format
  12612. * @param invertY defines if data must be stored with Y axis inverted
  12613. * @param compression defines the used compression (can be null)
  12614. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12615. */
  12616. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12617. }
  12618. }
  12619. }
  12620. declare module "babylonjs/Materials/Textures/rawTexture" {
  12621. import { Scene } from "babylonjs/scene";
  12622. import { Texture } from "babylonjs/Materials/Textures/texture";
  12623. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12624. /**
  12625. * Raw texture can help creating a texture directly from an array of data.
  12626. * This can be super useful if you either get the data from an uncompressed source or
  12627. * if you wish to create your texture pixel by pixel.
  12628. */
  12629. export class RawTexture extends Texture {
  12630. /**
  12631. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12632. */
  12633. format: number;
  12634. private _engine;
  12635. /**
  12636. * Instantiates a new RawTexture.
  12637. * Raw texture can help creating a texture directly from an array of data.
  12638. * This can be super useful if you either get the data from an uncompressed source or
  12639. * if you wish to create your texture pixel by pixel.
  12640. * @param data define the array of data to use to create the texture
  12641. * @param width define the width of the texture
  12642. * @param height define the height of the texture
  12643. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12644. * @param scene define the scene the texture belongs to
  12645. * @param generateMipMaps define whether mip maps should be generated or not
  12646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12649. */
  12650. constructor(data: ArrayBufferView, width: number, height: number,
  12651. /**
  12652. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12653. */
  12654. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12655. /**
  12656. * Updates the texture underlying data.
  12657. * @param data Define the new data of the texture
  12658. */
  12659. update(data: ArrayBufferView): void;
  12660. /**
  12661. * Creates a luminance texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @returns the luminance texture
  12670. */
  12671. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12672. /**
  12673. * Creates a luminance alpha texture from some data.
  12674. * @param data Define the texture data
  12675. * @param width Define the width of the texture
  12676. * @param height Define the height of the texture
  12677. * @param scene Define the scene the texture belongs to
  12678. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12679. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12680. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12681. * @returns the luminance alpha texture
  12682. */
  12683. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12684. /**
  12685. * Creates an alpha texture from some data.
  12686. * @param data Define the texture data
  12687. * @param width Define the width of the texture
  12688. * @param height Define the height of the texture
  12689. * @param scene Define the scene the texture belongs to
  12690. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12693. * @returns the alpha texture
  12694. */
  12695. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12696. /**
  12697. * Creates a RGB texture from some data.
  12698. * @param data Define the texture data
  12699. * @param width Define the width of the texture
  12700. * @param height Define the height of the texture
  12701. * @param scene Define the scene the texture belongs to
  12702. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12703. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12704. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12705. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12706. * @returns the RGB alpha texture
  12707. */
  12708. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12709. /**
  12710. * Creates a RGBA texture from some data.
  12711. * @param data Define the texture data
  12712. * @param width Define the width of the texture
  12713. * @param height Define the height of the texture
  12714. * @param scene Define the scene the texture belongs to
  12715. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12716. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12717. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12718. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12719. * @returns the RGBA texture
  12720. */
  12721. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12722. /**
  12723. * Creates a R 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12732. * @returns the R texture
  12733. */
  12734. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12735. }
  12736. }
  12737. declare module "babylonjs/Maths/math.size" {
  12738. /**
  12739. * Interface for the size containing width and height
  12740. */
  12741. export interface ISize {
  12742. /**
  12743. * Width
  12744. */
  12745. width: number;
  12746. /**
  12747. * Heighht
  12748. */
  12749. height: number;
  12750. }
  12751. /**
  12752. * Size containing widht and height
  12753. */
  12754. export class Size implements ISize {
  12755. /**
  12756. * Width
  12757. */
  12758. width: number;
  12759. /**
  12760. * Height
  12761. */
  12762. height: number;
  12763. /**
  12764. * Creates a Size object from the given width and height (floats).
  12765. * @param width width of the new size
  12766. * @param height height of the new size
  12767. */
  12768. constructor(width: number, height: number);
  12769. /**
  12770. * Returns a string with the Size width and height
  12771. * @returns a string with the Size width and height
  12772. */
  12773. toString(): string;
  12774. /**
  12775. * "Size"
  12776. * @returns the string "Size"
  12777. */
  12778. getClassName(): string;
  12779. /**
  12780. * Returns the Size hash code.
  12781. * @returns a hash code for a unique width and height
  12782. */
  12783. getHashCode(): number;
  12784. /**
  12785. * Updates the current size from the given one.
  12786. * @param src the given size
  12787. */
  12788. copyFrom(src: Size): void;
  12789. /**
  12790. * Updates in place the current Size from the given floats.
  12791. * @param width width of the new size
  12792. * @param height height of the new size
  12793. * @returns the updated Size.
  12794. */
  12795. copyFromFloats(width: number, height: number): Size;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width to set
  12799. * @param height height to set
  12800. * @returns the updated Size.
  12801. */
  12802. set(width: number, height: number): Size;
  12803. /**
  12804. * Multiplies the width and height by numbers
  12805. * @param w factor to multiple the width by
  12806. * @param h factor to multiple the height by
  12807. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12808. */
  12809. multiplyByFloats(w: number, h: number): Size;
  12810. /**
  12811. * Clones the size
  12812. * @returns a new Size copied from the given one.
  12813. */
  12814. clone(): Size;
  12815. /**
  12816. * True if the current Size and the given one width and height are strictly equal.
  12817. * @param other the other size to compare against
  12818. * @returns True if the current Size and the given one width and height are strictly equal.
  12819. */
  12820. equals(other: Size): boolean;
  12821. /**
  12822. * The surface of the Size : width * height (float).
  12823. */
  12824. readonly surface: number;
  12825. /**
  12826. * Create a new size of zero
  12827. * @returns a new Size set to (0.0, 0.0)
  12828. */
  12829. static Zero(): Size;
  12830. /**
  12831. * Sums the width and height of two sizes
  12832. * @param otherSize size to add to this size
  12833. * @returns a new Size set as the addition result of the current Size and the given one.
  12834. */
  12835. add(otherSize: Size): Size;
  12836. /**
  12837. * Subtracts the width and height of two
  12838. * @param otherSize size to subtract to this size
  12839. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12840. */
  12841. subtract(otherSize: Size): Size;
  12842. /**
  12843. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12844. * @param start starting size to lerp between
  12845. * @param end end size to lerp between
  12846. * @param amount amount to lerp between the start and end values
  12847. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12848. */
  12849. static Lerp(start: Size, end: Size, amount: number): Size;
  12850. }
  12851. }
  12852. declare module "babylonjs/Animations/runtimeAnimation" {
  12853. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12854. import { Animatable } from "babylonjs/Animations/animatable";
  12855. import { Scene } from "babylonjs/scene";
  12856. /**
  12857. * Defines a runtime animation
  12858. */
  12859. export class RuntimeAnimation {
  12860. private _events;
  12861. /**
  12862. * The current frame of the runtime animation
  12863. */
  12864. private _currentFrame;
  12865. /**
  12866. * The animation used by the runtime animation
  12867. */
  12868. private _animation;
  12869. /**
  12870. * The target of the runtime animation
  12871. */
  12872. private _target;
  12873. /**
  12874. * The initiating animatable
  12875. */
  12876. private _host;
  12877. /**
  12878. * The original value of the runtime animation
  12879. */
  12880. private _originalValue;
  12881. /**
  12882. * The original blend value of the runtime animation
  12883. */
  12884. private _originalBlendValue;
  12885. /**
  12886. * The offsets cache of the runtime animation
  12887. */
  12888. private _offsetsCache;
  12889. /**
  12890. * The high limits cache of the runtime animation
  12891. */
  12892. private _highLimitsCache;
  12893. /**
  12894. * Specifies if the runtime animation has been stopped
  12895. */
  12896. private _stopped;
  12897. /**
  12898. * The blending factor of the runtime animation
  12899. */
  12900. private _blendingFactor;
  12901. /**
  12902. * The BabylonJS scene
  12903. */
  12904. private _scene;
  12905. /**
  12906. * The current value of the runtime animation
  12907. */
  12908. private _currentValue;
  12909. /** @hidden */
  12910. _animationState: _IAnimationState;
  12911. /**
  12912. * The active target of the runtime animation
  12913. */
  12914. private _activeTargets;
  12915. private _currentActiveTarget;
  12916. private _directTarget;
  12917. /**
  12918. * The target path of the runtime animation
  12919. */
  12920. private _targetPath;
  12921. /**
  12922. * The weight of the runtime animation
  12923. */
  12924. private _weight;
  12925. /**
  12926. * The ratio offset of the runtime animation
  12927. */
  12928. private _ratioOffset;
  12929. /**
  12930. * The previous delay of the runtime animation
  12931. */
  12932. private _previousDelay;
  12933. /**
  12934. * The previous ratio of the runtime animation
  12935. */
  12936. private _previousRatio;
  12937. private _enableBlending;
  12938. private _keys;
  12939. private _minFrame;
  12940. private _maxFrame;
  12941. private _minValue;
  12942. private _maxValue;
  12943. private _targetIsArray;
  12944. /**
  12945. * Gets the current frame of the runtime animation
  12946. */
  12947. readonly currentFrame: number;
  12948. /**
  12949. * Gets the weight of the runtime animation
  12950. */
  12951. readonly weight: number;
  12952. /**
  12953. * Gets the current value of the runtime animation
  12954. */
  12955. readonly currentValue: any;
  12956. /**
  12957. * Gets the target path of the runtime animation
  12958. */
  12959. readonly targetPath: string;
  12960. /**
  12961. * Gets the actual target of the runtime animation
  12962. */
  12963. readonly target: any;
  12964. /** @hidden */
  12965. _onLoop: () => void;
  12966. /**
  12967. * Create a new RuntimeAnimation object
  12968. * @param target defines the target of the animation
  12969. * @param animation defines the source animation object
  12970. * @param scene defines the hosting scene
  12971. * @param host defines the initiating Animatable
  12972. */
  12973. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12974. private _preparePath;
  12975. /**
  12976. * Gets the animation from the runtime animation
  12977. */
  12978. readonly animation: Animation;
  12979. /**
  12980. * Resets the runtime animation to the beginning
  12981. * @param restoreOriginal defines whether to restore the target property to the original value
  12982. */
  12983. reset(restoreOriginal?: boolean): void;
  12984. /**
  12985. * Specifies if the runtime animation is stopped
  12986. * @returns Boolean specifying if the runtime animation is stopped
  12987. */
  12988. isStopped(): boolean;
  12989. /**
  12990. * Disposes of the runtime animation
  12991. */
  12992. dispose(): void;
  12993. /**
  12994. * Apply the interpolated value to the target
  12995. * @param currentValue defines the value computed by the animation
  12996. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12997. */
  12998. setValue(currentValue: any, weight: number): void;
  12999. private _getOriginalValues;
  13000. private _setValue;
  13001. /**
  13002. * Gets the loop pmode of the runtime animation
  13003. * @returns Loop Mode
  13004. */
  13005. private _getCorrectLoopMode;
  13006. /**
  13007. * Move the current animation to a given frame
  13008. * @param frame defines the frame to move to
  13009. */
  13010. goToFrame(frame: number): void;
  13011. /**
  13012. * @hidden Internal use only
  13013. */
  13014. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13015. /**
  13016. * Execute the current animation
  13017. * @param delay defines the delay to add to the current frame
  13018. * @param from defines the lower bound of the animation range
  13019. * @param to defines the upper bound of the animation range
  13020. * @param loop defines if the current animation must loop
  13021. * @param speedRatio defines the current speed ratio
  13022. * @param weight defines the weight of the animation (default is -1 so no weight)
  13023. * @param onLoop optional callback called when animation loops
  13024. * @returns a boolean indicating if the animation is running
  13025. */
  13026. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13027. }
  13028. }
  13029. declare module "babylonjs/Animations/animatable" {
  13030. import { Animation } from "babylonjs/Animations/animation";
  13031. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13032. import { Nullable } from "babylonjs/types";
  13033. import { Observable } from "babylonjs/Misc/observable";
  13034. import { Scene } from "babylonjs/scene";
  13035. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13036. import { Node } from "babylonjs/node";
  13037. /**
  13038. * Class used to store an actual running animation
  13039. */
  13040. export class Animatable {
  13041. /** defines the target object */
  13042. target: any;
  13043. /** defines the starting frame number (default is 0) */
  13044. fromFrame: number;
  13045. /** defines the ending frame number (default is 100) */
  13046. toFrame: number;
  13047. /** defines if the animation must loop (default is false) */
  13048. loopAnimation: boolean;
  13049. /** defines a callback to call when animation ends if it is not looping */
  13050. onAnimationEnd?: (() => void) | null | undefined;
  13051. /** defines a callback to call when animation loops */
  13052. onAnimationLoop?: (() => void) | null | undefined;
  13053. private _localDelayOffset;
  13054. private _pausedDelay;
  13055. private _runtimeAnimations;
  13056. private _paused;
  13057. private _scene;
  13058. private _speedRatio;
  13059. private _weight;
  13060. private _syncRoot;
  13061. /**
  13062. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13063. * This will only apply for non looping animation (default is true)
  13064. */
  13065. disposeOnEnd: boolean;
  13066. /**
  13067. * Gets a boolean indicating if the animation has started
  13068. */
  13069. animationStarted: boolean;
  13070. /**
  13071. * Observer raised when the animation ends
  13072. */
  13073. onAnimationEndObservable: Observable<Animatable>;
  13074. /**
  13075. * Observer raised when the animation loops
  13076. */
  13077. onAnimationLoopObservable: Observable<Animatable>;
  13078. /**
  13079. * Gets the root Animatable used to synchronize and normalize animations
  13080. */
  13081. readonly syncRoot: Nullable<Animatable>;
  13082. /**
  13083. * Gets the current frame of the first RuntimeAnimation
  13084. * Used to synchronize Animatables
  13085. */
  13086. readonly masterFrame: number;
  13087. /**
  13088. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13089. */
  13090. weight: number;
  13091. /**
  13092. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13093. */
  13094. speedRatio: number;
  13095. /**
  13096. * Creates a new Animatable
  13097. * @param scene defines the hosting scene
  13098. * @param target defines the target object
  13099. * @param fromFrame defines the starting frame number (default is 0)
  13100. * @param toFrame defines the ending frame number (default is 100)
  13101. * @param loopAnimation defines if the animation must loop (default is false)
  13102. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13103. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13104. * @param animations defines a group of animation to add to the new Animatable
  13105. * @param onAnimationLoop defines a callback to call when animation loops
  13106. */
  13107. constructor(scene: Scene,
  13108. /** defines the target object */
  13109. target: any,
  13110. /** defines the starting frame number (default is 0) */
  13111. fromFrame?: number,
  13112. /** defines the ending frame number (default is 100) */
  13113. toFrame?: number,
  13114. /** defines if the animation must loop (default is false) */
  13115. loopAnimation?: boolean, speedRatio?: number,
  13116. /** defines a callback to call when animation ends if it is not looping */
  13117. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13118. /** defines a callback to call when animation loops */
  13119. onAnimationLoop?: (() => void) | null | undefined);
  13120. /**
  13121. * Synchronize and normalize current Animatable with a source Animatable
  13122. * This is useful when using animation weights and when animations are not of the same length
  13123. * @param root defines the root Animatable to synchronize with
  13124. * @returns the current Animatable
  13125. */
  13126. syncWith(root: Animatable): Animatable;
  13127. /**
  13128. * Gets the list of runtime animations
  13129. * @returns an array of RuntimeAnimation
  13130. */
  13131. getAnimations(): RuntimeAnimation[];
  13132. /**
  13133. * Adds more animations to the current animatable
  13134. * @param target defines the target of the animations
  13135. * @param animations defines the new animations to add
  13136. */
  13137. appendAnimations(target: any, animations: Animation[]): void;
  13138. /**
  13139. * Gets the source animation for a specific property
  13140. * @param property defines the propertyu to look for
  13141. * @returns null or the source animation for the given property
  13142. */
  13143. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13144. /**
  13145. * Gets the runtime animation for a specific property
  13146. * @param property defines the propertyu to look for
  13147. * @returns null or the runtime animation for the given property
  13148. */
  13149. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13150. /**
  13151. * Resets the animatable to its original state
  13152. */
  13153. reset(): void;
  13154. /**
  13155. * Allows the animatable to blend with current running animations
  13156. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13157. * @param blendingSpeed defines the blending speed to use
  13158. */
  13159. enableBlending(blendingSpeed: number): void;
  13160. /**
  13161. * Disable animation blending
  13162. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13163. */
  13164. disableBlending(): void;
  13165. /**
  13166. * Jump directly to a given frame
  13167. * @param frame defines the frame to jump to
  13168. */
  13169. goToFrame(frame: number): void;
  13170. /**
  13171. * Pause the animation
  13172. */
  13173. pause(): void;
  13174. /**
  13175. * Restart the animation
  13176. */
  13177. restart(): void;
  13178. private _raiseOnAnimationEnd;
  13179. /**
  13180. * Stop and delete the current animation
  13181. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13182. * @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)
  13183. */
  13184. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13185. /**
  13186. * Wait asynchronously for the animation to end
  13187. * @returns a promise which will be fullfilled when the animation ends
  13188. */
  13189. waitAsync(): Promise<Animatable>;
  13190. /** @hidden */
  13191. _animate(delay: number): boolean;
  13192. }
  13193. module "babylonjs/scene" {
  13194. interface Scene {
  13195. /** @hidden */
  13196. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13197. /** @hidden */
  13198. _processLateAnimationBindingsForMatrices(holder: {
  13199. totalWeight: number;
  13200. animations: RuntimeAnimation[];
  13201. originalValue: Matrix;
  13202. }): any;
  13203. /** @hidden */
  13204. _processLateAnimationBindingsForQuaternions(holder: {
  13205. totalWeight: number;
  13206. animations: RuntimeAnimation[];
  13207. originalValue: Quaternion;
  13208. }, refQuaternion: Quaternion): Quaternion;
  13209. /** @hidden */
  13210. _processLateAnimationBindings(): void;
  13211. /**
  13212. * Will start the animation sequence of a given target
  13213. * @param target defines the target
  13214. * @param from defines from which frame should animation start
  13215. * @param to defines until which frame should animation run.
  13216. * @param weight defines the weight to apply to the animation (1.0 by default)
  13217. * @param loop defines if the animation loops
  13218. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13219. * @param onAnimationEnd defines the function to be executed when the animation ends
  13220. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13221. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13222. * @param onAnimationLoop defines the callback to call when an animation loops
  13223. * @returns the animatable object created for this animation
  13224. */
  13225. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13226. /**
  13227. * Will start the animation sequence of a given target
  13228. * @param target defines the target
  13229. * @param from defines from which frame should animation start
  13230. * @param to defines until which frame should animation run.
  13231. * @param loop defines if the animation loops
  13232. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13233. * @param onAnimationEnd defines the function to be executed when the animation ends
  13234. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13235. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13236. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13237. * @param onAnimationLoop defines the callback to call when an animation loops
  13238. * @returns the animatable object created for this animation
  13239. */
  13240. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13241. /**
  13242. * Will start the animation sequence of a given target and its hierarchy
  13243. * @param target defines the target
  13244. * @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.
  13245. * @param from defines from which frame should animation start
  13246. * @param to defines until which frame should animation run.
  13247. * @param loop defines if the animation loops
  13248. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13249. * @param onAnimationEnd defines the function to be executed when the animation ends
  13250. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13251. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13252. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13253. * @param onAnimationLoop defines the callback to call when an animation loops
  13254. * @returns the list of created animatables
  13255. */
  13256. 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[];
  13257. /**
  13258. * Begin a new animation on a given node
  13259. * @param target defines the target where the animation will take place
  13260. * @param animations defines the list of animations to start
  13261. * @param from defines the initial value
  13262. * @param to defines the final value
  13263. * @param loop defines if you want animation to loop (off by default)
  13264. * @param speedRatio defines the speed ratio to apply to all animations
  13265. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13266. * @param onAnimationLoop defines the callback to call when an animation loops
  13267. * @returns the list of created animatables
  13268. */
  13269. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13270. /**
  13271. * Begin a new animation on a given node and its hierarchy
  13272. * @param target defines the root node where the animation will take place
  13273. * @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.
  13274. * @param animations defines the list of animations to start
  13275. * @param from defines the initial value
  13276. * @param to defines the final value
  13277. * @param loop defines if you want animation to loop (off by default)
  13278. * @param speedRatio defines the speed ratio to apply to all animations
  13279. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13280. * @param onAnimationLoop defines the callback to call when an animation loops
  13281. * @returns the list of animatables created for all nodes
  13282. */
  13283. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13284. /**
  13285. * Gets the animatable associated with a specific target
  13286. * @param target defines the target of the animatable
  13287. * @returns the required animatable if found
  13288. */
  13289. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13290. /**
  13291. * Gets all animatables associated with a given target
  13292. * @param target defines the target to look animatables for
  13293. * @returns an array of Animatables
  13294. */
  13295. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13296. /**
  13297. * Stops and removes all animations that have been applied to the scene
  13298. */
  13299. stopAllAnimations(): void;
  13300. }
  13301. }
  13302. module "babylonjs/Bones/bone" {
  13303. interface Bone {
  13304. /**
  13305. * Copy an animation range from another bone
  13306. * @param source defines the source bone
  13307. * @param rangeName defines the range name to copy
  13308. * @param frameOffset defines the frame offset
  13309. * @param rescaleAsRequired defines if rescaling must be applied if required
  13310. * @param skelDimensionsRatio defines the scaling ratio
  13311. * @returns true if operation was successful
  13312. */
  13313. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13314. }
  13315. }
  13316. }
  13317. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13318. /**
  13319. * Class used to override all child animations of a given target
  13320. */
  13321. export class AnimationPropertiesOverride {
  13322. /**
  13323. * Gets or sets a value indicating if animation blending must be used
  13324. */
  13325. enableBlending: boolean;
  13326. /**
  13327. * Gets or sets the blending speed to use when enableBlending is true
  13328. */
  13329. blendingSpeed: number;
  13330. /**
  13331. * Gets or sets the default loop mode to use
  13332. */
  13333. loopMode: number;
  13334. }
  13335. }
  13336. declare module "babylonjs/Bones/skeleton" {
  13337. import { Bone } from "babylonjs/Bones/bone";
  13338. import { Observable } from "babylonjs/Misc/observable";
  13339. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13340. import { Scene } from "babylonjs/scene";
  13341. import { Nullable } from "babylonjs/types";
  13342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13343. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13344. import { Animatable } from "babylonjs/Animations/animatable";
  13345. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13346. import { Animation } from "babylonjs/Animations/animation";
  13347. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13348. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13349. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13350. /**
  13351. * Class used to handle skinning animations
  13352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13353. */
  13354. export class Skeleton implements IAnimatable {
  13355. /** defines the skeleton name */
  13356. name: string;
  13357. /** defines the skeleton Id */
  13358. id: string;
  13359. /**
  13360. * Defines the list of child bones
  13361. */
  13362. bones: Bone[];
  13363. /**
  13364. * Defines an estimate of the dimension of the skeleton at rest
  13365. */
  13366. dimensionsAtRest: Vector3;
  13367. /**
  13368. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13369. */
  13370. needInitialSkinMatrix: boolean;
  13371. /**
  13372. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13373. */
  13374. overrideMesh: Nullable<AbstractMesh>;
  13375. /**
  13376. * Gets the list of animations attached to this skeleton
  13377. */
  13378. animations: Array<Animation>;
  13379. private _scene;
  13380. private _isDirty;
  13381. private _transformMatrices;
  13382. private _transformMatrixTexture;
  13383. private _meshesWithPoseMatrix;
  13384. private _animatables;
  13385. private _identity;
  13386. private _synchronizedWithMesh;
  13387. private _ranges;
  13388. private _lastAbsoluteTransformsUpdateId;
  13389. private _canUseTextureForBones;
  13390. private _uniqueId;
  13391. /** @hidden */
  13392. _numBonesWithLinkedTransformNode: number;
  13393. /** @hidden */
  13394. _hasWaitingData: Nullable<boolean>;
  13395. /**
  13396. * Specifies if the skeleton should be serialized
  13397. */
  13398. doNotSerialize: boolean;
  13399. private _useTextureToStoreBoneMatrices;
  13400. /**
  13401. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13402. * Please note that this option is not available if the hardware does not support it
  13403. */
  13404. useTextureToStoreBoneMatrices: boolean;
  13405. private _animationPropertiesOverride;
  13406. /**
  13407. * Gets or sets the animation properties override
  13408. */
  13409. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13410. /**
  13411. * List of inspectable custom properties (used by the Inspector)
  13412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13413. */
  13414. inspectableCustomProperties: IInspectable[];
  13415. /**
  13416. * An observable triggered before computing the skeleton's matrices
  13417. */
  13418. onBeforeComputeObservable: Observable<Skeleton>;
  13419. /**
  13420. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13421. */
  13422. readonly isUsingTextureForMatrices: boolean;
  13423. /**
  13424. * Gets the unique ID of this skeleton
  13425. */
  13426. readonly uniqueId: number;
  13427. /**
  13428. * Creates a new skeleton
  13429. * @param name defines the skeleton name
  13430. * @param id defines the skeleton Id
  13431. * @param scene defines the hosting scene
  13432. */
  13433. constructor(
  13434. /** defines the skeleton name */
  13435. name: string,
  13436. /** defines the skeleton Id */
  13437. id: string, scene: Scene);
  13438. /**
  13439. * Gets the current object class name.
  13440. * @return the class name
  13441. */
  13442. getClassName(): string;
  13443. /**
  13444. * Returns an array containing the root bones
  13445. * @returns an array containing the root bones
  13446. */
  13447. getChildren(): Array<Bone>;
  13448. /**
  13449. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13450. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13451. * @returns a Float32Array containing matrices data
  13452. */
  13453. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13454. /**
  13455. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13456. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13457. * @returns a raw texture containing the data
  13458. */
  13459. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13460. /**
  13461. * Gets the current hosting scene
  13462. * @returns a scene object
  13463. */
  13464. getScene(): Scene;
  13465. /**
  13466. * Gets a string representing the current skeleton data
  13467. * @param fullDetails defines a boolean indicating if we want a verbose version
  13468. * @returns a string representing the current skeleton data
  13469. */
  13470. toString(fullDetails?: boolean): string;
  13471. /**
  13472. * Get bone's index searching by name
  13473. * @param name defines bone's name to search for
  13474. * @return the indice of the bone. Returns -1 if not found
  13475. */
  13476. getBoneIndexByName(name: string): number;
  13477. /**
  13478. * Creater a new animation range
  13479. * @param name defines the name of the range
  13480. * @param from defines the start key
  13481. * @param to defines the end key
  13482. */
  13483. createAnimationRange(name: string, from: number, to: number): void;
  13484. /**
  13485. * Delete a specific animation range
  13486. * @param name defines the name of the range
  13487. * @param deleteFrames defines if frames must be removed as well
  13488. */
  13489. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13490. /**
  13491. * Gets a specific animation range
  13492. * @param name defines the name of the range to look for
  13493. * @returns the requested animation range or null if not found
  13494. */
  13495. getAnimationRange(name: string): Nullable<AnimationRange>;
  13496. /**
  13497. * Gets the list of all animation ranges defined on this skeleton
  13498. * @returns an array
  13499. */
  13500. getAnimationRanges(): Nullable<AnimationRange>[];
  13501. /**
  13502. * Copy animation range from a source skeleton.
  13503. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13504. * @param source defines the source skeleton
  13505. * @param name defines the name of the range to copy
  13506. * @param rescaleAsRequired defines if rescaling must be applied if required
  13507. * @returns true if operation was successful
  13508. */
  13509. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13510. /**
  13511. * Forces the skeleton to go to rest pose
  13512. */
  13513. returnToRest(): void;
  13514. private _getHighestAnimationFrame;
  13515. /**
  13516. * Begin a specific animation range
  13517. * @param name defines the name of the range to start
  13518. * @param loop defines if looping must be turned on (false by default)
  13519. * @param speedRatio defines the speed ratio to apply (1 by default)
  13520. * @param onAnimationEnd defines a callback which will be called when animation will end
  13521. * @returns a new animatable
  13522. */
  13523. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13524. /** @hidden */
  13525. _markAsDirty(): void;
  13526. /** @hidden */
  13527. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13528. /** @hidden */
  13529. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13530. private _computeTransformMatrices;
  13531. /**
  13532. * Build all resources required to render a skeleton
  13533. */
  13534. prepare(): void;
  13535. /**
  13536. * Gets the list of animatables currently running for this skeleton
  13537. * @returns an array of animatables
  13538. */
  13539. getAnimatables(): IAnimatable[];
  13540. /**
  13541. * Clone the current skeleton
  13542. * @param name defines the name of the new skeleton
  13543. * @param id defines the id of the new skeleton
  13544. * @returns the new skeleton
  13545. */
  13546. clone(name: string, id: string): Skeleton;
  13547. /**
  13548. * Enable animation blending for this skeleton
  13549. * @param blendingSpeed defines the blending speed to apply
  13550. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13551. */
  13552. enableBlending(blendingSpeed?: number): void;
  13553. /**
  13554. * Releases all resources associated with the current skeleton
  13555. */
  13556. dispose(): void;
  13557. /**
  13558. * Serialize the skeleton in a JSON object
  13559. * @returns a JSON object
  13560. */
  13561. serialize(): any;
  13562. /**
  13563. * Creates a new skeleton from serialized data
  13564. * @param parsedSkeleton defines the serialized data
  13565. * @param scene defines the hosting scene
  13566. * @returns a new skeleton
  13567. */
  13568. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13569. /**
  13570. * Compute all node absolute transforms
  13571. * @param forceUpdate defines if computation must be done even if cache is up to date
  13572. */
  13573. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13574. /**
  13575. * Gets the root pose matrix
  13576. * @returns a matrix
  13577. */
  13578. getPoseMatrix(): Nullable<Matrix>;
  13579. /**
  13580. * Sorts bones per internal index
  13581. */
  13582. sortBones(): void;
  13583. private _sortBones;
  13584. }
  13585. }
  13586. declare module "babylonjs/Bones/bone" {
  13587. import { Skeleton } from "babylonjs/Bones/skeleton";
  13588. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13589. import { Nullable } from "babylonjs/types";
  13590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13592. import { Node } from "babylonjs/node";
  13593. import { Space } from "babylonjs/Maths/math.axis";
  13594. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13595. /**
  13596. * Class used to store bone information
  13597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13598. */
  13599. export class Bone extends Node {
  13600. /**
  13601. * defines the bone name
  13602. */
  13603. name: string;
  13604. private static _tmpVecs;
  13605. private static _tmpQuat;
  13606. private static _tmpMats;
  13607. /**
  13608. * Gets the list of child bones
  13609. */
  13610. children: Bone[];
  13611. /** Gets the animations associated with this bone */
  13612. animations: import("babylonjs/Animations/animation").Animation[];
  13613. /**
  13614. * Gets or sets bone length
  13615. */
  13616. length: number;
  13617. /**
  13618. * @hidden Internal only
  13619. * Set this value to map this bone to a different index in the transform matrices
  13620. * Set this value to -1 to exclude the bone from the transform matrices
  13621. */
  13622. _index: Nullable<number>;
  13623. private _skeleton;
  13624. private _localMatrix;
  13625. private _restPose;
  13626. private _baseMatrix;
  13627. private _absoluteTransform;
  13628. private _invertedAbsoluteTransform;
  13629. private _parent;
  13630. private _scalingDeterminant;
  13631. private _worldTransform;
  13632. private _localScaling;
  13633. private _localRotation;
  13634. private _localPosition;
  13635. private _needToDecompose;
  13636. private _needToCompose;
  13637. /** @hidden */
  13638. _linkedTransformNode: Nullable<TransformNode>;
  13639. /** @hidden */
  13640. _waitingTransformNodeId: Nullable<string>;
  13641. /** @hidden */
  13642. /** @hidden */
  13643. _matrix: Matrix;
  13644. /**
  13645. * Create a new bone
  13646. * @param name defines the bone name
  13647. * @param skeleton defines the parent skeleton
  13648. * @param parentBone defines the parent (can be null if the bone is the root)
  13649. * @param localMatrix defines the local matrix
  13650. * @param restPose defines the rest pose matrix
  13651. * @param baseMatrix defines the base matrix
  13652. * @param index defines index of the bone in the hiearchy
  13653. */
  13654. constructor(
  13655. /**
  13656. * defines the bone name
  13657. */
  13658. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13659. /**
  13660. * Gets the current object class name.
  13661. * @return the class name
  13662. */
  13663. getClassName(): string;
  13664. /**
  13665. * Gets the parent skeleton
  13666. * @returns a skeleton
  13667. */
  13668. getSkeleton(): Skeleton;
  13669. /**
  13670. * Gets parent bone
  13671. * @returns a bone or null if the bone is the root of the bone hierarchy
  13672. */
  13673. getParent(): Nullable<Bone>;
  13674. /**
  13675. * Returns an array containing the root bones
  13676. * @returns an array containing the root bones
  13677. */
  13678. getChildren(): Array<Bone>;
  13679. /**
  13680. * Sets the parent bone
  13681. * @param parent defines the parent (can be null if the bone is the root)
  13682. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13683. */
  13684. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13685. /**
  13686. * Gets the local matrix
  13687. * @returns a matrix
  13688. */
  13689. getLocalMatrix(): Matrix;
  13690. /**
  13691. * Gets the base matrix (initial matrix which remains unchanged)
  13692. * @returns a matrix
  13693. */
  13694. getBaseMatrix(): Matrix;
  13695. /**
  13696. * Gets the rest pose matrix
  13697. * @returns a matrix
  13698. */
  13699. getRestPose(): Matrix;
  13700. /**
  13701. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13702. */
  13703. getWorldMatrix(): Matrix;
  13704. /**
  13705. * Sets the local matrix to rest pose matrix
  13706. */
  13707. returnToRest(): void;
  13708. /**
  13709. * Gets the inverse of the absolute transform matrix.
  13710. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13711. * @returns a matrix
  13712. */
  13713. getInvertedAbsoluteTransform(): Matrix;
  13714. /**
  13715. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13716. * @returns a matrix
  13717. */
  13718. getAbsoluteTransform(): Matrix;
  13719. /**
  13720. * Links with the given transform node.
  13721. * The local matrix of this bone is copied from the transform node every frame.
  13722. * @param transformNode defines the transform node to link to
  13723. */
  13724. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13725. /**
  13726. * Gets the node used to drive the bone's transformation
  13727. * @returns a transform node or null
  13728. */
  13729. getTransformNode(): Nullable<TransformNode>;
  13730. /** Gets or sets current position (in local space) */
  13731. position: Vector3;
  13732. /** Gets or sets current rotation (in local space) */
  13733. rotation: Vector3;
  13734. /** Gets or sets current rotation quaternion (in local space) */
  13735. rotationQuaternion: Quaternion;
  13736. /** Gets or sets current scaling (in local space) */
  13737. scaling: Vector3;
  13738. /**
  13739. * Gets the animation properties override
  13740. */
  13741. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13742. private _decompose;
  13743. private _compose;
  13744. /**
  13745. * Update the base and local matrices
  13746. * @param matrix defines the new base or local matrix
  13747. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13748. * @param updateLocalMatrix defines if the local matrix should be updated
  13749. */
  13750. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13751. /** @hidden */
  13752. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13753. /**
  13754. * Flag the bone as dirty (Forcing it to update everything)
  13755. */
  13756. markAsDirty(): void;
  13757. /** @hidden */
  13758. _markAsDirtyAndCompose(): void;
  13759. private _markAsDirtyAndDecompose;
  13760. /**
  13761. * Translate the bone in local or world space
  13762. * @param vec The amount to translate the bone
  13763. * @param space The space that the translation is in
  13764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13765. */
  13766. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13767. /**
  13768. * Set the postion of the bone in local or world space
  13769. * @param position The position to set the bone
  13770. * @param space The space that the position is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the absolute position of the bone (world space)
  13776. * @param position The position to set the bone
  13777. * @param mesh The mesh that this bone is attached to
  13778. */
  13779. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13780. /**
  13781. * Scale the bone on the x, y and z axes (in local space)
  13782. * @param x The amount to scale the bone on the x axis
  13783. * @param y The amount to scale the bone on the y axis
  13784. * @param z The amount to scale the bone on the z axis
  13785. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13786. */
  13787. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13788. /**
  13789. * Set the bone scaling in local space
  13790. * @param scale defines the scaling vector
  13791. */
  13792. setScale(scale: Vector3): void;
  13793. /**
  13794. * Gets the current scaling in local space
  13795. * @returns the current scaling vector
  13796. */
  13797. getScale(): Vector3;
  13798. /**
  13799. * Gets the current scaling in local space and stores it in a target vector
  13800. * @param result defines the target vector
  13801. */
  13802. getScaleToRef(result: Vector3): void;
  13803. /**
  13804. * Set the yaw, pitch, and roll of the bone in local or world space
  13805. * @param yaw The rotation of the bone on the y axis
  13806. * @param pitch The rotation of the bone on the x axis
  13807. * @param roll The rotation of the bone on the z axis
  13808. * @param space The space that the axes of rotation are in
  13809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13810. */
  13811. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13812. /**
  13813. * Add a rotation to the bone on an axis in local or world space
  13814. * @param axis The axis to rotate the bone on
  13815. * @param amount The amount to rotate the bone
  13816. * @param space The space that the axis is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the rotation of the bone to a particular axis angle in local or world space
  13822. * @param axis The axis to rotate the bone on
  13823. * @param angle The angle that the bone should be rotated to
  13824. * @param space The space that the axis is in
  13825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13826. */
  13827. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13828. /**
  13829. * Set the euler rotation of the bone in local of world space
  13830. * @param rotation The euler rotation that the bone should be set to
  13831. * @param space The space that the rotation is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the quaternion rotation of the bone in local of world space
  13837. * @param quat The quaternion rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the rotation matrix of the bone in local of world space
  13844. * @param rotMat The rotation matrix that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13849. private _rotateWithMatrix;
  13850. private _getNegativeRotationToRef;
  13851. /**
  13852. * Get the position of the bone in local or world space
  13853. * @param space The space that the returned position is in
  13854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13855. * @returns The position of the bone
  13856. */
  13857. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13858. /**
  13859. * Copy the position of the bone to a vector3 in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @param result The vector3 to copy the position to
  13863. */
  13864. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13865. /**
  13866. * Get the absolute position of the bone (world space)
  13867. * @param mesh The mesh that this bone is attached to
  13868. * @returns The absolute position of the bone
  13869. */
  13870. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13871. /**
  13872. * Copy the absolute position of the bone (world space) to the result param
  13873. * @param mesh The mesh that this bone is attached to
  13874. * @param result The vector3 to copy the absolute position to
  13875. */
  13876. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13877. /**
  13878. * Compute the absolute transforms of this bone and its children
  13879. */
  13880. computeAbsoluteTransforms(): void;
  13881. /**
  13882. * Get the world direction from an axis that is in the local space of the bone
  13883. * @param localAxis The local direction that is used to compute the world direction
  13884. * @param mesh The mesh that this bone is attached to
  13885. * @returns The world direction
  13886. */
  13887. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13888. /**
  13889. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @param result The vector3 that the world direction will be copied to
  13893. */
  13894. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13895. /**
  13896. * Get the euler rotation of the bone in local or world space
  13897. * @param space The space that the rotation should be in
  13898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13899. * @returns The euler rotation
  13900. */
  13901. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13902. /**
  13903. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @param result The vector3 that the rotation should be copied to
  13907. */
  13908. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13909. /**
  13910. * Get the quaternion rotation of the bone in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @returns The quaternion rotation
  13914. */
  13915. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13916. /**
  13917. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @param result The quaternion that the rotation should be copied to
  13921. */
  13922. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13923. /**
  13924. * Get the rotation matrix of the bone in local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @returns The rotation matrix
  13928. */
  13929. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13930. /**
  13931. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @param result The quaternion that the rotation should be copied to
  13935. */
  13936. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13937. /**
  13938. * Get the world position of a point that is in the local space of the bone
  13939. * @param position The local position
  13940. * @param mesh The mesh that this bone is attached to
  13941. * @returns The world position
  13942. */
  13943. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @param result The vector3 that the world position should be copied to
  13949. */
  13950. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13951. /**
  13952. * Get the local position of a point that is in world space
  13953. * @param position The world position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @returns The local position
  13956. */
  13957. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13958. /**
  13959. * Get the local position of a point that is in world space and copy it to the result param
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @param result The vector3 that the local position should be copied to
  13963. */
  13964. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13965. }
  13966. }
  13967. declare module "babylonjs/Meshes/transformNode" {
  13968. import { DeepImmutable } from "babylonjs/types";
  13969. import { Observable } from "babylonjs/Misc/observable";
  13970. import { Nullable } from "babylonjs/types";
  13971. import { Camera } from "babylonjs/Cameras/camera";
  13972. import { Scene } from "babylonjs/scene";
  13973. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13974. import { Node } from "babylonjs/node";
  13975. import { Bone } from "babylonjs/Bones/bone";
  13976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13977. import { Space } from "babylonjs/Maths/math.axis";
  13978. /**
  13979. * 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.
  13980. * @see https://doc.babylonjs.com/how_to/transformnode
  13981. */
  13982. export class TransformNode extends Node {
  13983. /**
  13984. * Object will not rotate to face the camera
  13985. */
  13986. static BILLBOARDMODE_NONE: number;
  13987. /**
  13988. * Object will rotate to face the camera but only on the x axis
  13989. */
  13990. static BILLBOARDMODE_X: number;
  13991. /**
  13992. * Object will rotate to face the camera but only on the y axis
  13993. */
  13994. static BILLBOARDMODE_Y: number;
  13995. /**
  13996. * Object will rotate to face the camera but only on the z axis
  13997. */
  13998. static BILLBOARDMODE_Z: number;
  13999. /**
  14000. * Object will rotate to face the camera
  14001. */
  14002. static BILLBOARDMODE_ALL: number;
  14003. /**
  14004. * Object will rotate to face the camera's position instead of orientation
  14005. */
  14006. static BILLBOARDMODE_USE_POSITION: number;
  14007. private _forward;
  14008. private _forwardInverted;
  14009. private _up;
  14010. private _right;
  14011. private _rightInverted;
  14012. private _position;
  14013. private _rotation;
  14014. private _rotationQuaternion;
  14015. protected _scaling: Vector3;
  14016. protected _isDirty: boolean;
  14017. private _transformToBoneReferal;
  14018. private _isAbsoluteSynced;
  14019. private _billboardMode;
  14020. /**
  14021. * Gets or sets the billboard mode. Default is 0.
  14022. *
  14023. * | Value | Type | Description |
  14024. * | --- | --- | --- |
  14025. * | 0 | BILLBOARDMODE_NONE | |
  14026. * | 1 | BILLBOARDMODE_X | |
  14027. * | 2 | BILLBOARDMODE_Y | |
  14028. * | 4 | BILLBOARDMODE_Z | |
  14029. * | 7 | BILLBOARDMODE_ALL | |
  14030. *
  14031. */
  14032. billboardMode: number;
  14033. private _preserveParentRotationForBillboard;
  14034. /**
  14035. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14036. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14037. */
  14038. preserveParentRotationForBillboard: boolean;
  14039. /**
  14040. * 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
  14041. */
  14042. scalingDeterminant: number;
  14043. private _infiniteDistance;
  14044. /**
  14045. * Gets or sets the distance of the object to max, often used by skybox
  14046. */
  14047. infiniteDistance: boolean;
  14048. /**
  14049. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14050. * By default the system will update normals to compensate
  14051. */
  14052. ignoreNonUniformScaling: boolean;
  14053. /**
  14054. * 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
  14055. */
  14056. reIntegrateRotationIntoRotationQuaternion: boolean;
  14057. /** @hidden */
  14058. _poseMatrix: Nullable<Matrix>;
  14059. /** @hidden */
  14060. _localMatrix: Matrix;
  14061. private _usePivotMatrix;
  14062. private _absolutePosition;
  14063. private _absoluteScaling;
  14064. private _absoluteRotationQuaternion;
  14065. private _pivotMatrix;
  14066. private _pivotMatrixInverse;
  14067. protected _postMultiplyPivotMatrix: boolean;
  14068. protected _isWorldMatrixFrozen: boolean;
  14069. /** @hidden */
  14070. _indexInSceneTransformNodesArray: number;
  14071. /**
  14072. * An event triggered after the world matrix is updated
  14073. */
  14074. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14075. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14076. /**
  14077. * Gets a string identifying the name of the class
  14078. * @returns "TransformNode" string
  14079. */
  14080. getClassName(): string;
  14081. /**
  14082. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14083. */
  14084. position: Vector3;
  14085. /**
  14086. * 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)).
  14087. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14088. */
  14089. rotation: Vector3;
  14090. /**
  14091. * 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)).
  14092. */
  14093. scaling: Vector3;
  14094. /**
  14095. * 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).
  14096. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14097. */
  14098. rotationQuaternion: Nullable<Quaternion>;
  14099. /**
  14100. * The forward direction of that transform in world space.
  14101. */
  14102. readonly forward: Vector3;
  14103. /**
  14104. * The up direction of that transform in world space.
  14105. */
  14106. readonly up: Vector3;
  14107. /**
  14108. * The right direction of that transform in world space.
  14109. */
  14110. readonly right: Vector3;
  14111. /**
  14112. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14113. * @param matrix the matrix to copy the pose from
  14114. * @returns this TransformNode.
  14115. */
  14116. updatePoseMatrix(matrix: Matrix): TransformNode;
  14117. /**
  14118. * Returns the mesh Pose matrix.
  14119. * @returns the pose matrix
  14120. */
  14121. getPoseMatrix(): Matrix;
  14122. /** @hidden */
  14123. _isSynchronized(): boolean;
  14124. /** @hidden */
  14125. _initCache(): void;
  14126. /**
  14127. * Flag the transform node as dirty (Forcing it to update everything)
  14128. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14129. * @returns this transform node
  14130. */
  14131. markAsDirty(property: string): TransformNode;
  14132. /**
  14133. * Returns the current mesh absolute position.
  14134. * Returns a Vector3.
  14135. */
  14136. readonly absolutePosition: Vector3;
  14137. /**
  14138. * Returns the current mesh absolute scaling.
  14139. * Returns a Vector3.
  14140. */
  14141. readonly absoluteScaling: Vector3;
  14142. /**
  14143. * Returns the current mesh absolute rotation.
  14144. * Returns a Quaternion.
  14145. */
  14146. readonly absoluteRotationQuaternion: Quaternion;
  14147. /**
  14148. * Sets a new matrix to apply before all other transformation
  14149. * @param matrix defines the transform matrix
  14150. * @returns the current TransformNode
  14151. */
  14152. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14153. /**
  14154. * Sets a new pivot matrix to the current node
  14155. * @param matrix defines the new pivot matrix to use
  14156. * @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
  14157. * @returns the current TransformNode
  14158. */
  14159. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14160. /**
  14161. * Returns the mesh pivot matrix.
  14162. * Default : Identity.
  14163. * @returns the matrix
  14164. */
  14165. getPivotMatrix(): Matrix;
  14166. /**
  14167. * Instantiate (when possible) or clone that node with its hierarchy
  14168. * @param newParent defines the new parent to use for the instance (or clone)
  14169. * @returns an instance (or a clone) of the current node with its hiearchy
  14170. */
  14171. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14172. /**
  14173. * Prevents the World matrix to be computed any longer
  14174. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14175. * @returns the TransformNode.
  14176. */
  14177. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14178. /**
  14179. * Allows back the World matrix computation.
  14180. * @returns the TransformNode.
  14181. */
  14182. unfreezeWorldMatrix(): this;
  14183. /**
  14184. * True if the World matrix has been frozen.
  14185. */
  14186. readonly isWorldMatrixFrozen: boolean;
  14187. /**
  14188. * Retuns the mesh absolute position in the World.
  14189. * @returns a Vector3.
  14190. */
  14191. getAbsolutePosition(): Vector3;
  14192. /**
  14193. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14194. * @param absolutePosition the absolute position to set
  14195. * @returns the TransformNode.
  14196. */
  14197. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14198. /**
  14199. * Sets the mesh position in its local space.
  14200. * @param vector3 the position to set in localspace
  14201. * @returns the TransformNode.
  14202. */
  14203. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14204. /**
  14205. * Returns the mesh position in the local space from the current World matrix values.
  14206. * @returns a new Vector3.
  14207. */
  14208. getPositionExpressedInLocalSpace(): Vector3;
  14209. /**
  14210. * Translates the mesh along the passed Vector3 in its local space.
  14211. * @param vector3 the distance to translate in localspace
  14212. * @returns the TransformNode.
  14213. */
  14214. locallyTranslate(vector3: Vector3): TransformNode;
  14215. private static _lookAtVectorCache;
  14216. /**
  14217. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14218. * @param targetPoint the position (must be in same space as current mesh) to look at
  14219. * @param yawCor optional yaw (y-axis) correction in radians
  14220. * @param pitchCor optional pitch (x-axis) correction in radians
  14221. * @param rollCor optional roll (z-axis) correction in radians
  14222. * @param space the choosen space of the target
  14223. * @returns the TransformNode.
  14224. */
  14225. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14226. /**
  14227. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14228. * This Vector3 is expressed in the World space.
  14229. * @param localAxis axis to rotate
  14230. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14231. */
  14232. getDirection(localAxis: Vector3): Vector3;
  14233. /**
  14234. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14235. * localAxis is expressed in the mesh local space.
  14236. * result is computed in the Wordl space from the mesh World matrix.
  14237. * @param localAxis axis to rotate
  14238. * @param result the resulting transformnode
  14239. * @returns this TransformNode.
  14240. */
  14241. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14242. /**
  14243. * Sets this transform node rotation to the given local axis.
  14244. * @param localAxis the axis in local space
  14245. * @param yawCor optional yaw (y-axis) correction in radians
  14246. * @param pitchCor optional pitch (x-axis) correction in radians
  14247. * @param rollCor optional roll (z-axis) correction in radians
  14248. * @returns this TransformNode
  14249. */
  14250. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14251. /**
  14252. * Sets a new pivot point to the current node
  14253. * @param point defines the new pivot point to use
  14254. * @param space defines if the point is in world or local space (local by default)
  14255. * @returns the current TransformNode
  14256. */
  14257. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14258. /**
  14259. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14260. * @returns the pivot point
  14261. */
  14262. getPivotPoint(): Vector3;
  14263. /**
  14264. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14265. * @param result the vector3 to store the result
  14266. * @returns this TransformNode.
  14267. */
  14268. getPivotPointToRef(result: Vector3): TransformNode;
  14269. /**
  14270. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14271. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14272. */
  14273. getAbsolutePivotPoint(): Vector3;
  14274. /**
  14275. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14276. * @param result vector3 to store the result
  14277. * @returns this TransformNode.
  14278. */
  14279. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14280. /**
  14281. * Defines the passed node as the parent of the current node.
  14282. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14283. * @see https://doc.babylonjs.com/how_to/parenting
  14284. * @param node the node ot set as the parent
  14285. * @returns this TransformNode.
  14286. */
  14287. setParent(node: Nullable<Node>): TransformNode;
  14288. private _nonUniformScaling;
  14289. /**
  14290. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14291. */
  14292. readonly nonUniformScaling: boolean;
  14293. /** @hidden */
  14294. _updateNonUniformScalingState(value: boolean): boolean;
  14295. /**
  14296. * Attach the current TransformNode to another TransformNode associated with a bone
  14297. * @param bone Bone affecting the TransformNode
  14298. * @param affectedTransformNode TransformNode associated with the bone
  14299. * @returns this object
  14300. */
  14301. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14302. /**
  14303. * Detach the transform node if its associated with a bone
  14304. * @returns this object
  14305. */
  14306. detachFromBone(): TransformNode;
  14307. private static _rotationAxisCache;
  14308. /**
  14309. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14310. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14311. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14312. * The passed axis is also normalized.
  14313. * @param axis the axis to rotate around
  14314. * @param amount the amount to rotate in radians
  14315. * @param space Space to rotate in (Default: local)
  14316. * @returns the TransformNode.
  14317. */
  14318. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14319. /**
  14320. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14321. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14322. * The passed axis is also normalized. .
  14323. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14324. * @param point the point to rotate around
  14325. * @param axis the axis to rotate around
  14326. * @param amount the amount to rotate in radians
  14327. * @returns the TransformNode
  14328. */
  14329. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14330. /**
  14331. * Translates the mesh along the axis vector for the passed distance in the given space.
  14332. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14333. * @param axis the axis to translate in
  14334. * @param distance the distance to translate
  14335. * @param space Space to rotate in (Default: local)
  14336. * @returns the TransformNode.
  14337. */
  14338. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14339. /**
  14340. * Adds a rotation step to the mesh current rotation.
  14341. * x, y, z are Euler angles expressed in radians.
  14342. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14343. * This means this rotation is made in the mesh local space only.
  14344. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14345. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14346. * ```javascript
  14347. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14348. * ```
  14349. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14350. * 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.
  14351. * @param x Rotation to add
  14352. * @param y Rotation to add
  14353. * @param z Rotation to add
  14354. * @returns the TransformNode.
  14355. */
  14356. addRotation(x: number, y: number, z: number): TransformNode;
  14357. /**
  14358. * @hidden
  14359. */
  14360. protected _getEffectiveParent(): Nullable<Node>;
  14361. /**
  14362. * Computes the world matrix of the node
  14363. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14364. * @returns the world matrix
  14365. */
  14366. computeWorldMatrix(force?: boolean): Matrix;
  14367. protected _afterComputeWorldMatrix(): void;
  14368. /**
  14369. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14370. * @param func callback function to add
  14371. *
  14372. * @returns the TransformNode.
  14373. */
  14374. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14375. /**
  14376. * Removes a registered callback function.
  14377. * @param func callback function to remove
  14378. * @returns the TransformNode.
  14379. */
  14380. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14381. /**
  14382. * Gets the position of the current mesh in camera space
  14383. * @param camera defines the camera to use
  14384. * @returns a position
  14385. */
  14386. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14387. /**
  14388. * Returns the distance from the mesh to the active camera
  14389. * @param camera defines the camera to use
  14390. * @returns the distance
  14391. */
  14392. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14393. /**
  14394. * Clone the current transform node
  14395. * @param name Name of the new clone
  14396. * @param newParent New parent for the clone
  14397. * @param doNotCloneChildren Do not clone children hierarchy
  14398. * @returns the new transform node
  14399. */
  14400. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14401. /**
  14402. * Serializes the objects information.
  14403. * @param currentSerializationObject defines the object to serialize in
  14404. * @returns the serialized object
  14405. */
  14406. serialize(currentSerializationObject?: any): any;
  14407. /**
  14408. * Returns a new TransformNode object parsed from the source provided.
  14409. * @param parsedTransformNode is the source.
  14410. * @param scene the scne the object belongs to
  14411. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14412. * @returns a new TransformNode object parsed from the source provided.
  14413. */
  14414. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14415. /**
  14416. * Get all child-transformNodes of this node
  14417. * @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
  14418. * @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
  14419. * @returns an array of TransformNode
  14420. */
  14421. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14422. /**
  14423. * Releases resources associated with this transform node.
  14424. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14425. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14426. */
  14427. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14428. /**
  14429. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14430. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14431. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14432. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14433. * @returns the current mesh
  14434. */
  14435. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14436. private _syncAbsoluteScalingAndRotation;
  14437. }
  14438. }
  14439. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14440. import { Observable } from "babylonjs/Misc/observable";
  14441. import { Nullable } from "babylonjs/types";
  14442. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14443. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14445. import { Ray } from "babylonjs/Culling/ray";
  14446. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14447. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14448. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14449. /**
  14450. * Defines the types of pose enabled controllers that are supported
  14451. */
  14452. export enum PoseEnabledControllerType {
  14453. /**
  14454. * HTC Vive
  14455. */
  14456. VIVE = 0,
  14457. /**
  14458. * Oculus Rift
  14459. */
  14460. OCULUS = 1,
  14461. /**
  14462. * Windows mixed reality
  14463. */
  14464. WINDOWS = 2,
  14465. /**
  14466. * Samsung gear VR
  14467. */
  14468. GEAR_VR = 3,
  14469. /**
  14470. * Google Daydream
  14471. */
  14472. DAYDREAM = 4,
  14473. /**
  14474. * Generic
  14475. */
  14476. GENERIC = 5
  14477. }
  14478. /**
  14479. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14480. */
  14481. export interface MutableGamepadButton {
  14482. /**
  14483. * Value of the button/trigger
  14484. */
  14485. value: number;
  14486. /**
  14487. * If the button/trigger is currently touched
  14488. */
  14489. touched: boolean;
  14490. /**
  14491. * If the button/trigger is currently pressed
  14492. */
  14493. pressed: boolean;
  14494. }
  14495. /**
  14496. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14497. * @hidden
  14498. */
  14499. export interface ExtendedGamepadButton extends GamepadButton {
  14500. /**
  14501. * If the button/trigger is currently pressed
  14502. */
  14503. readonly pressed: boolean;
  14504. /**
  14505. * If the button/trigger is currently touched
  14506. */
  14507. readonly touched: boolean;
  14508. /**
  14509. * Value of the button/trigger
  14510. */
  14511. readonly value: number;
  14512. }
  14513. /** @hidden */
  14514. export interface _GamePadFactory {
  14515. /**
  14516. * Returns wether or not the current gamepad can be created for this type of controller.
  14517. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14518. * @returns true if it can be created, otherwise false
  14519. */
  14520. canCreate(gamepadInfo: any): boolean;
  14521. /**
  14522. * Creates a new instance of the Gamepad.
  14523. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14524. * @returns the new gamepad instance
  14525. */
  14526. create(gamepadInfo: any): Gamepad;
  14527. }
  14528. /**
  14529. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14530. */
  14531. export class PoseEnabledControllerHelper {
  14532. /** @hidden */
  14533. static _ControllerFactories: _GamePadFactory[];
  14534. /** @hidden */
  14535. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14536. /**
  14537. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14538. * @param vrGamepad the gamepad to initialized
  14539. * @returns a vr controller of the type the gamepad identified as
  14540. */
  14541. static InitiateController(vrGamepad: any): Gamepad;
  14542. }
  14543. /**
  14544. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14545. */
  14546. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14547. /**
  14548. * If the controller is used in a webXR session
  14549. */
  14550. isXR: boolean;
  14551. private _deviceRoomPosition;
  14552. private _deviceRoomRotationQuaternion;
  14553. /**
  14554. * The device position in babylon space
  14555. */
  14556. devicePosition: Vector3;
  14557. /**
  14558. * The device rotation in babylon space
  14559. */
  14560. deviceRotationQuaternion: Quaternion;
  14561. /**
  14562. * The scale factor of the device in babylon space
  14563. */
  14564. deviceScaleFactor: number;
  14565. /**
  14566. * (Likely devicePosition should be used instead) The device position in its room space
  14567. */
  14568. position: Vector3;
  14569. /**
  14570. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14571. */
  14572. rotationQuaternion: Quaternion;
  14573. /**
  14574. * The type of controller (Eg. Windows mixed reality)
  14575. */
  14576. controllerType: PoseEnabledControllerType;
  14577. protected _calculatedPosition: Vector3;
  14578. private _calculatedRotation;
  14579. /**
  14580. * The raw pose from the device
  14581. */
  14582. rawPose: DevicePose;
  14583. private _trackPosition;
  14584. private _maxRotationDistFromHeadset;
  14585. private _draggedRoomRotation;
  14586. /**
  14587. * @hidden
  14588. */
  14589. _disableTrackPosition(fixedPosition: Vector3): void;
  14590. /**
  14591. * Internal, the mesh attached to the controller
  14592. * @hidden
  14593. */
  14594. _mesh: Nullable<AbstractMesh>;
  14595. private _poseControlledCamera;
  14596. private _leftHandSystemQuaternion;
  14597. /**
  14598. * Internal, matrix used to convert room space to babylon space
  14599. * @hidden
  14600. */
  14601. _deviceToWorld: Matrix;
  14602. /**
  14603. * Node to be used when casting a ray from the controller
  14604. * @hidden
  14605. */
  14606. _pointingPoseNode: Nullable<TransformNode>;
  14607. /**
  14608. * Name of the child mesh that can be used to cast a ray from the controller
  14609. */
  14610. static readonly POINTING_POSE: string;
  14611. /**
  14612. * Creates a new PoseEnabledController from a gamepad
  14613. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14614. */
  14615. constructor(browserGamepad: any);
  14616. private _workingMatrix;
  14617. /**
  14618. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14619. */
  14620. update(): void;
  14621. /**
  14622. * Updates only the pose device and mesh without doing any button event checking
  14623. */
  14624. protected _updatePoseAndMesh(): void;
  14625. /**
  14626. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14627. * @param poseData raw pose fromthe device
  14628. */
  14629. updateFromDevice(poseData: DevicePose): void;
  14630. /**
  14631. * @hidden
  14632. */
  14633. _meshAttachedObservable: Observable<AbstractMesh>;
  14634. /**
  14635. * Attaches a mesh to the controller
  14636. * @param mesh the mesh to be attached
  14637. */
  14638. attachToMesh(mesh: AbstractMesh): void;
  14639. /**
  14640. * Attaches the controllers mesh to a camera
  14641. * @param camera the camera the mesh should be attached to
  14642. */
  14643. attachToPoseControlledCamera(camera: TargetCamera): void;
  14644. /**
  14645. * Disposes of the controller
  14646. */
  14647. dispose(): void;
  14648. /**
  14649. * The mesh that is attached to the controller
  14650. */
  14651. readonly mesh: Nullable<AbstractMesh>;
  14652. /**
  14653. * Gets the ray of the controller in the direction the controller is pointing
  14654. * @param length the length the resulting ray should be
  14655. * @returns a ray in the direction the controller is pointing
  14656. */
  14657. getForwardRay(length?: number): Ray;
  14658. }
  14659. }
  14660. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14661. import { Observable } from "babylonjs/Misc/observable";
  14662. import { Scene } from "babylonjs/scene";
  14663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14664. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14665. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14666. /**
  14667. * Defines the WebVRController object that represents controllers tracked in 3D space
  14668. */
  14669. export abstract class WebVRController extends PoseEnabledController {
  14670. /**
  14671. * Internal, the default controller model for the controller
  14672. */
  14673. protected _defaultModel: AbstractMesh;
  14674. /**
  14675. * Fired when the trigger state has changed
  14676. */
  14677. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14678. /**
  14679. * Fired when the main button state has changed
  14680. */
  14681. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14682. /**
  14683. * Fired when the secondary button state has changed
  14684. */
  14685. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14686. /**
  14687. * Fired when the pad state has changed
  14688. */
  14689. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14690. /**
  14691. * Fired when controllers stick values have changed
  14692. */
  14693. onPadValuesChangedObservable: Observable<StickValues>;
  14694. /**
  14695. * Array of button availible on the controller
  14696. */
  14697. protected _buttons: Array<MutableGamepadButton>;
  14698. private _onButtonStateChange;
  14699. /**
  14700. * Fired when a controller button's state has changed
  14701. * @param callback the callback containing the button that was modified
  14702. */
  14703. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14704. /**
  14705. * X and Y axis corresponding to the controllers joystick
  14706. */
  14707. pad: StickValues;
  14708. /**
  14709. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14710. */
  14711. hand: string;
  14712. /**
  14713. * The default controller model for the controller
  14714. */
  14715. readonly defaultModel: AbstractMesh;
  14716. /**
  14717. * Creates a new WebVRController from a gamepad
  14718. * @param vrGamepad the gamepad that the WebVRController should be created from
  14719. */
  14720. constructor(vrGamepad: any);
  14721. /**
  14722. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14723. */
  14724. update(): void;
  14725. /**
  14726. * Function to be called when a button is modified
  14727. */
  14728. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14729. /**
  14730. * Loads a mesh and attaches it to the controller
  14731. * @param scene the scene the mesh should be added to
  14732. * @param meshLoaded callback for when the mesh has been loaded
  14733. */
  14734. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14735. private _setButtonValue;
  14736. private _changes;
  14737. private _checkChanges;
  14738. /**
  14739. * Disposes of th webVRCOntroller
  14740. */
  14741. dispose(): void;
  14742. }
  14743. }
  14744. declare module "babylonjs/Lights/hemisphericLight" {
  14745. import { Nullable } from "babylonjs/types";
  14746. import { Scene } from "babylonjs/scene";
  14747. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14748. import { Color3 } from "babylonjs/Maths/math.color";
  14749. import { Effect } from "babylonjs/Materials/effect";
  14750. import { Light } from "babylonjs/Lights/light";
  14751. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14752. /**
  14753. * The HemisphericLight simulates the ambient environment light,
  14754. * so the passed direction is the light reflection direction, not the incoming direction.
  14755. */
  14756. export class HemisphericLight extends Light {
  14757. /**
  14758. * The groundColor is the light in the opposite direction to the one specified during creation.
  14759. * 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.
  14760. */
  14761. groundColor: Color3;
  14762. /**
  14763. * The light reflection direction, not the incoming direction.
  14764. */
  14765. direction: Vector3;
  14766. /**
  14767. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14768. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14769. * The HemisphericLight can't cast shadows.
  14770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14771. * @param name The friendly name of the light
  14772. * @param direction The direction of the light reflection
  14773. * @param scene The scene the light belongs to
  14774. */
  14775. constructor(name: string, direction: Vector3, scene: Scene);
  14776. protected _buildUniformLayout(): void;
  14777. /**
  14778. * Returns the string "HemisphericLight".
  14779. * @return The class name
  14780. */
  14781. getClassName(): string;
  14782. /**
  14783. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14784. * Returns the updated direction.
  14785. * @param target The target the direction should point to
  14786. * @return The computed direction
  14787. */
  14788. setDirectionToTarget(target: Vector3): Vector3;
  14789. /**
  14790. * Returns the shadow generator associated to the light.
  14791. * @returns Always null for hemispheric lights because it does not support shadows.
  14792. */
  14793. getShadowGenerator(): Nullable<IShadowGenerator>;
  14794. /**
  14795. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14796. * @param effect The effect to update
  14797. * @param lightIndex The index of the light in the effect to update
  14798. * @returns The hemispheric light
  14799. */
  14800. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14801. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14802. /**
  14803. * Computes the world matrix of the node
  14804. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14805. * @param useWasUpdatedFlag defines a reserved property
  14806. * @returns the world matrix
  14807. */
  14808. computeWorldMatrix(): Matrix;
  14809. /**
  14810. * Returns the integer 3.
  14811. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14812. */
  14813. getTypeID(): number;
  14814. /**
  14815. * Prepares the list of defines specific to the light type.
  14816. * @param defines the list of defines
  14817. * @param lightIndex defines the index of the light for the effect
  14818. */
  14819. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14820. }
  14821. }
  14822. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14823. /** @hidden */
  14824. export var vrMultiviewToSingleviewPixelShader: {
  14825. name: string;
  14826. shader: string;
  14827. };
  14828. }
  14829. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14831. import { Scene } from "babylonjs/scene";
  14832. /**
  14833. * Renders to multiple views with a single draw call
  14834. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14835. */
  14836. export class MultiviewRenderTarget extends RenderTargetTexture {
  14837. /**
  14838. * Creates a multiview render target
  14839. * @param scene scene used with the render target
  14840. * @param size the size of the render target (used for each view)
  14841. */
  14842. constructor(scene: Scene, size?: number | {
  14843. width: number;
  14844. height: number;
  14845. } | {
  14846. ratio: number;
  14847. });
  14848. /**
  14849. * @hidden
  14850. * @param faceIndex the face index, if its a cube texture
  14851. */
  14852. _bindFrameBuffer(faceIndex?: number): void;
  14853. /**
  14854. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14855. * @returns the view count
  14856. */
  14857. getViewCount(): number;
  14858. }
  14859. }
  14860. declare module "babylonjs/Maths/math.frustum" {
  14861. import { Matrix } from "babylonjs/Maths/math.vector";
  14862. import { DeepImmutable } from "babylonjs/types";
  14863. import { Plane } from "babylonjs/Maths/math.plane";
  14864. /**
  14865. * Reprasents a camera frustum
  14866. */
  14867. export class Frustum {
  14868. /**
  14869. * Gets the planes representing the frustum
  14870. * @param transform matrix to be applied to the returned planes
  14871. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14872. */
  14873. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14874. /**
  14875. * Gets the near frustum plane transformed by the transform matrix
  14876. * @param transform transformation matrix to be applied to the resulting frustum plane
  14877. * @param frustumPlane the resuling frustum plane
  14878. */
  14879. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14880. /**
  14881. * Gets the far frustum plane transformed by the transform matrix
  14882. * @param transform transformation matrix to be applied to the resulting frustum plane
  14883. * @param frustumPlane the resuling frustum plane
  14884. */
  14885. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14886. /**
  14887. * Gets the left frustum plane transformed by the transform matrix
  14888. * @param transform transformation matrix to be applied to the resulting frustum plane
  14889. * @param frustumPlane the resuling frustum plane
  14890. */
  14891. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14892. /**
  14893. * Gets the right frustum plane transformed by the transform matrix
  14894. * @param transform transformation matrix to be applied to the resulting frustum plane
  14895. * @param frustumPlane the resuling frustum plane
  14896. */
  14897. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14898. /**
  14899. * Gets the top frustum plane transformed by the transform matrix
  14900. * @param transform transformation matrix to be applied to the resulting frustum plane
  14901. * @param frustumPlane the resuling frustum plane
  14902. */
  14903. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14904. /**
  14905. * Gets the bottom frustum plane transformed by the transform matrix
  14906. * @param transform transformation matrix to be applied to the resulting frustum plane
  14907. * @param frustumPlane the resuling frustum plane
  14908. */
  14909. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14910. /**
  14911. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14912. * @param transform transformation matrix to be applied to the resulting frustum planes
  14913. * @param frustumPlanes the resuling frustum planes
  14914. */
  14915. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14916. }
  14917. }
  14918. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14919. import { Camera } from "babylonjs/Cameras/camera";
  14920. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14921. import { Nullable } from "babylonjs/types";
  14922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14923. import { Matrix } from "babylonjs/Maths/math.vector";
  14924. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14925. module "babylonjs/Engines/engine" {
  14926. interface Engine {
  14927. /**
  14928. * Creates a new multiview render target
  14929. * @param width defines the width of the texture
  14930. * @param height defines the height of the texture
  14931. * @returns the created multiview texture
  14932. */
  14933. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14934. /**
  14935. * Binds a multiview framebuffer to be drawn to
  14936. * @param multiviewTexture texture to bind
  14937. */
  14938. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14939. }
  14940. }
  14941. module "babylonjs/Cameras/camera" {
  14942. interface Camera {
  14943. /**
  14944. * @hidden
  14945. * 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)
  14946. */
  14947. _useMultiviewToSingleView: boolean;
  14948. /**
  14949. * @hidden
  14950. * 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)
  14951. */
  14952. _multiviewTexture: Nullable<RenderTargetTexture>;
  14953. /**
  14954. * @hidden
  14955. * ensures the multiview texture of the camera exists and has the specified width/height
  14956. * @param width height to set on the multiview texture
  14957. * @param height width to set on the multiview texture
  14958. */
  14959. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14960. }
  14961. }
  14962. module "babylonjs/scene" {
  14963. interface Scene {
  14964. /** @hidden */
  14965. _transformMatrixR: Matrix;
  14966. /** @hidden */
  14967. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14968. /** @hidden */
  14969. _createMultiviewUbo(): void;
  14970. /** @hidden */
  14971. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14972. /** @hidden */
  14973. _renderMultiviewToSingleView(camera: Camera): void;
  14974. }
  14975. }
  14976. }
  14977. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14978. import { Camera } from "babylonjs/Cameras/camera";
  14979. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14980. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14981. import "babylonjs/Engines/Extensions/engine.multiview";
  14982. /**
  14983. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14984. * This will not be used for webXR as it supports displaying texture arrays directly
  14985. */
  14986. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14987. /**
  14988. * Initializes a VRMultiviewToSingleview
  14989. * @param name name of the post process
  14990. * @param camera camera to be applied to
  14991. * @param scaleFactor scaling factor to the size of the output texture
  14992. */
  14993. constructor(name: string, camera: Camera, scaleFactor: number);
  14994. }
  14995. }
  14996. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14997. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14998. import { Nullable } from "babylonjs/types";
  14999. import { Size } from "babylonjs/Maths/math.size";
  15000. import { Observable } from "babylonjs/Misc/observable";
  15001. module "babylonjs/Engines/engine" {
  15002. interface Engine {
  15003. /** @hidden */
  15004. _vrDisplay: any;
  15005. /** @hidden */
  15006. _vrSupported: boolean;
  15007. /** @hidden */
  15008. _oldSize: Size;
  15009. /** @hidden */
  15010. _oldHardwareScaleFactor: number;
  15011. /** @hidden */
  15012. _vrExclusivePointerMode: boolean;
  15013. /** @hidden */
  15014. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15015. /** @hidden */
  15016. _onVRDisplayPointerRestricted: () => void;
  15017. /** @hidden */
  15018. _onVRDisplayPointerUnrestricted: () => void;
  15019. /** @hidden */
  15020. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15021. /** @hidden */
  15022. _onVrDisplayDisconnect: Nullable<() => void>;
  15023. /** @hidden */
  15024. _onVrDisplayPresentChange: Nullable<() => void>;
  15025. /**
  15026. * Observable signaled when VR display mode changes
  15027. */
  15028. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15029. /**
  15030. * Observable signaled when VR request present is complete
  15031. */
  15032. onVRRequestPresentComplete: Observable<boolean>;
  15033. /**
  15034. * Observable signaled when VR request present starts
  15035. */
  15036. onVRRequestPresentStart: Observable<Engine>;
  15037. /**
  15038. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15039. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15040. */
  15041. isInVRExclusivePointerMode: boolean;
  15042. /**
  15043. * Gets a boolean indicating if a webVR device was detected
  15044. * @returns true if a webVR device was detected
  15045. */
  15046. isVRDevicePresent(): boolean;
  15047. /**
  15048. * Gets the current webVR device
  15049. * @returns the current webVR device (or null)
  15050. */
  15051. getVRDevice(): any;
  15052. /**
  15053. * Initializes a webVR display and starts listening to display change events
  15054. * The onVRDisplayChangedObservable will be notified upon these changes
  15055. * @returns A promise containing a VRDisplay and if vr is supported
  15056. */
  15057. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15058. /** @hidden */
  15059. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15060. /**
  15061. * Call this function to switch to webVR mode
  15062. * Will do nothing if webVR is not supported or if there is no webVR device
  15063. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15064. */
  15065. enableVR(): void;
  15066. /** @hidden */
  15067. _onVRFullScreenTriggered(): void;
  15068. }
  15069. }
  15070. }
  15071. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15072. import { Nullable } from "babylonjs/types";
  15073. import { Observable } from "babylonjs/Misc/observable";
  15074. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15075. import { Scene } from "babylonjs/scene";
  15076. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15077. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15078. import { Node } from "babylonjs/node";
  15079. import { Ray } from "babylonjs/Culling/ray";
  15080. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15081. import "babylonjs/Engines/Extensions/engine.webVR";
  15082. /**
  15083. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15084. * IMPORTANT!! The data is right-hand data.
  15085. * @export
  15086. * @interface DevicePose
  15087. */
  15088. export interface DevicePose {
  15089. /**
  15090. * The position of the device, values in array are [x,y,z].
  15091. */
  15092. readonly position: Nullable<Float32Array>;
  15093. /**
  15094. * The linearVelocity of the device, values in array are [x,y,z].
  15095. */
  15096. readonly linearVelocity: Nullable<Float32Array>;
  15097. /**
  15098. * The linearAcceleration of the device, values in array are [x,y,z].
  15099. */
  15100. readonly linearAcceleration: Nullable<Float32Array>;
  15101. /**
  15102. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15103. */
  15104. readonly orientation: Nullable<Float32Array>;
  15105. /**
  15106. * The angularVelocity of the device, values in array are [x,y,z].
  15107. */
  15108. readonly angularVelocity: Nullable<Float32Array>;
  15109. /**
  15110. * The angularAcceleration of the device, values in array are [x,y,z].
  15111. */
  15112. readonly angularAcceleration: Nullable<Float32Array>;
  15113. }
  15114. /**
  15115. * Interface representing a pose controlled object in Babylon.
  15116. * A pose controlled object has both regular pose values as well as pose values
  15117. * from an external device such as a VR head mounted display
  15118. */
  15119. export interface PoseControlled {
  15120. /**
  15121. * The position of the object in babylon space.
  15122. */
  15123. position: Vector3;
  15124. /**
  15125. * The rotation quaternion of the object in babylon space.
  15126. */
  15127. rotationQuaternion: Quaternion;
  15128. /**
  15129. * The position of the device in babylon space.
  15130. */
  15131. devicePosition?: Vector3;
  15132. /**
  15133. * The rotation quaternion of the device in babylon space.
  15134. */
  15135. deviceRotationQuaternion: Quaternion;
  15136. /**
  15137. * The raw pose coming from the device.
  15138. */
  15139. rawPose: Nullable<DevicePose>;
  15140. /**
  15141. * The scale of the device to be used when translating from device space to babylon space.
  15142. */
  15143. deviceScaleFactor: number;
  15144. /**
  15145. * Updates the poseControlled values based on the input device pose.
  15146. * @param poseData the pose data to update the object with
  15147. */
  15148. updateFromDevice(poseData: DevicePose): void;
  15149. }
  15150. /**
  15151. * Set of options to customize the webVRCamera
  15152. */
  15153. export interface WebVROptions {
  15154. /**
  15155. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15156. */
  15157. trackPosition?: boolean;
  15158. /**
  15159. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15160. */
  15161. positionScale?: number;
  15162. /**
  15163. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15164. */
  15165. displayName?: string;
  15166. /**
  15167. * Should the native controller meshes be initialized. (default: true)
  15168. */
  15169. controllerMeshes?: boolean;
  15170. /**
  15171. * Creating a default HemiLight only on controllers. (default: true)
  15172. */
  15173. defaultLightingOnControllers?: boolean;
  15174. /**
  15175. * If you don't want to use the default VR button of the helper. (default: false)
  15176. */
  15177. useCustomVRButton?: boolean;
  15178. /**
  15179. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15180. */
  15181. customVRButton?: HTMLButtonElement;
  15182. /**
  15183. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15184. */
  15185. rayLength?: number;
  15186. /**
  15187. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15188. */
  15189. defaultHeight?: number;
  15190. /**
  15191. * If multiview should be used if availible (default: false)
  15192. */
  15193. useMultiview?: boolean;
  15194. }
  15195. /**
  15196. * This represents a WebVR camera.
  15197. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15198. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15199. */
  15200. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15201. private webVROptions;
  15202. /**
  15203. * @hidden
  15204. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15205. */
  15206. _vrDevice: any;
  15207. /**
  15208. * The rawPose of the vrDevice.
  15209. */
  15210. rawPose: Nullable<DevicePose>;
  15211. private _onVREnabled;
  15212. private _specsVersion;
  15213. private _attached;
  15214. private _frameData;
  15215. protected _descendants: Array<Node>;
  15216. private _deviceRoomPosition;
  15217. /** @hidden */
  15218. _deviceRoomRotationQuaternion: Quaternion;
  15219. private _standingMatrix;
  15220. /**
  15221. * Represents device position in babylon space.
  15222. */
  15223. devicePosition: Vector3;
  15224. /**
  15225. * Represents device rotation in babylon space.
  15226. */
  15227. deviceRotationQuaternion: Quaternion;
  15228. /**
  15229. * The scale of the device to be used when translating from device space to babylon space.
  15230. */
  15231. deviceScaleFactor: number;
  15232. private _deviceToWorld;
  15233. private _worldToDevice;
  15234. /**
  15235. * References to the webVR controllers for the vrDevice.
  15236. */
  15237. controllers: Array<WebVRController>;
  15238. /**
  15239. * Emits an event when a controller is attached.
  15240. */
  15241. onControllersAttachedObservable: Observable<WebVRController[]>;
  15242. /**
  15243. * Emits an event when a controller's mesh has been loaded;
  15244. */
  15245. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15246. /**
  15247. * Emits an event when the HMD's pose has been updated.
  15248. */
  15249. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15250. private _poseSet;
  15251. /**
  15252. * If the rig cameras be used as parent instead of this camera.
  15253. */
  15254. rigParenting: boolean;
  15255. private _lightOnControllers;
  15256. private _defaultHeight?;
  15257. /**
  15258. * Instantiates a WebVRFreeCamera.
  15259. * @param name The name of the WebVRFreeCamera
  15260. * @param position The starting anchor position for the camera
  15261. * @param scene The scene the camera belongs to
  15262. * @param webVROptions a set of customizable options for the webVRCamera
  15263. */
  15264. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15265. /**
  15266. * Gets the device distance from the ground in meters.
  15267. * @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.
  15268. */
  15269. deviceDistanceToRoomGround(): number;
  15270. /**
  15271. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15272. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15273. */
  15274. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15275. /**
  15276. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15277. * @returns A promise with a boolean set to if the standing matrix is supported.
  15278. */
  15279. useStandingMatrixAsync(): Promise<boolean>;
  15280. /**
  15281. * Disposes the camera
  15282. */
  15283. dispose(): void;
  15284. /**
  15285. * Gets a vrController by name.
  15286. * @param name The name of the controller to retreive
  15287. * @returns the controller matching the name specified or null if not found
  15288. */
  15289. getControllerByName(name: string): Nullable<WebVRController>;
  15290. private _leftController;
  15291. /**
  15292. * The controller corresponding to the users left hand.
  15293. */
  15294. readonly leftController: Nullable<WebVRController>;
  15295. private _rightController;
  15296. /**
  15297. * The controller corresponding to the users right hand.
  15298. */
  15299. readonly rightController: Nullable<WebVRController>;
  15300. /**
  15301. * Casts a ray forward from the vrCamera's gaze.
  15302. * @param length Length of the ray (default: 100)
  15303. * @returns the ray corresponding to the gaze
  15304. */
  15305. getForwardRay(length?: number): Ray;
  15306. /**
  15307. * @hidden
  15308. * Updates the camera based on device's frame data
  15309. */
  15310. _checkInputs(): void;
  15311. /**
  15312. * Updates the poseControlled values based on the input device pose.
  15313. * @param poseData Pose coming from the device
  15314. */
  15315. updateFromDevice(poseData: DevicePose): void;
  15316. private _htmlElementAttached;
  15317. private _detachIfAttached;
  15318. /**
  15319. * WebVR's attach control will start broadcasting frames to the device.
  15320. * Note that in certain browsers (chrome for example) this function must be called
  15321. * within a user-interaction callback. Example:
  15322. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15323. *
  15324. * @param element html element to attach the vrDevice to
  15325. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15326. */
  15327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15328. /**
  15329. * Detaches the camera from the html element and disables VR
  15330. *
  15331. * @param element html element to detach from
  15332. */
  15333. detachControl(element: HTMLElement): void;
  15334. /**
  15335. * @returns the name of this class
  15336. */
  15337. getClassName(): string;
  15338. /**
  15339. * Calls resetPose on the vrDisplay
  15340. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15341. */
  15342. resetToCurrentRotation(): void;
  15343. /**
  15344. * @hidden
  15345. * Updates the rig cameras (left and right eye)
  15346. */
  15347. _updateRigCameras(): void;
  15348. private _workingVector;
  15349. private _oneVector;
  15350. private _workingMatrix;
  15351. private updateCacheCalled;
  15352. private _correctPositionIfNotTrackPosition;
  15353. /**
  15354. * @hidden
  15355. * Updates the cached values of the camera
  15356. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15357. */
  15358. _updateCache(ignoreParentClass?: boolean): void;
  15359. /**
  15360. * @hidden
  15361. * Get current device position in babylon world
  15362. */
  15363. _computeDevicePosition(): void;
  15364. /**
  15365. * Updates the current device position and rotation in the babylon world
  15366. */
  15367. update(): void;
  15368. /**
  15369. * @hidden
  15370. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15371. * @returns an identity matrix
  15372. */
  15373. _getViewMatrix(): Matrix;
  15374. private _tmpMatrix;
  15375. /**
  15376. * This function is called by the two RIG cameras.
  15377. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15378. * @hidden
  15379. */
  15380. _getWebVRViewMatrix(): Matrix;
  15381. /** @hidden */
  15382. _getWebVRProjectionMatrix(): Matrix;
  15383. private _onGamepadConnectedObserver;
  15384. private _onGamepadDisconnectedObserver;
  15385. private _updateCacheWhenTrackingDisabledObserver;
  15386. /**
  15387. * Initializes the controllers and their meshes
  15388. */
  15389. initControllers(): void;
  15390. }
  15391. }
  15392. declare module "babylonjs/PostProcesses/postProcess" {
  15393. import { Nullable } from "babylonjs/types";
  15394. import { SmartArray } from "babylonjs/Misc/smartArray";
  15395. import { Observable } from "babylonjs/Misc/observable";
  15396. import { Vector2 } from "babylonjs/Maths/math.vector";
  15397. import { Camera } from "babylonjs/Cameras/camera";
  15398. import { Effect } from "babylonjs/Materials/effect";
  15399. import "babylonjs/Shaders/postprocess.vertex";
  15400. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15401. import { Engine } from "babylonjs/Engines/engine";
  15402. import { Color4 } from "babylonjs/Maths/math.color";
  15403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15404. /**
  15405. * Size options for a post process
  15406. */
  15407. export type PostProcessOptions = {
  15408. width: number;
  15409. height: number;
  15410. };
  15411. /**
  15412. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15413. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15414. */
  15415. export class PostProcess {
  15416. /** Name of the PostProcess. */
  15417. name: string;
  15418. /**
  15419. * Gets or sets the unique id of the post process
  15420. */
  15421. uniqueId: number;
  15422. /**
  15423. * Width of the texture to apply the post process on
  15424. */
  15425. width: number;
  15426. /**
  15427. * Height of the texture to apply the post process on
  15428. */
  15429. height: number;
  15430. /**
  15431. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15432. * @hidden
  15433. */
  15434. _outputTexture: Nullable<InternalTexture>;
  15435. /**
  15436. * Sampling mode used by the shader
  15437. * See https://doc.babylonjs.com/classes/3.1/texture
  15438. */
  15439. renderTargetSamplingMode: number;
  15440. /**
  15441. * Clear color to use when screen clearing
  15442. */
  15443. clearColor: Color4;
  15444. /**
  15445. * If the buffer needs to be cleared before applying the post process. (default: true)
  15446. * Should be set to false if shader will overwrite all previous pixels.
  15447. */
  15448. autoClear: boolean;
  15449. /**
  15450. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15451. */
  15452. alphaMode: number;
  15453. /**
  15454. * Sets the setAlphaBlendConstants of the babylon engine
  15455. */
  15456. alphaConstants: Color4;
  15457. /**
  15458. * Animations to be used for the post processing
  15459. */
  15460. animations: import("babylonjs/Animations/animation").Animation[];
  15461. /**
  15462. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15463. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15464. */
  15465. enablePixelPerfectMode: boolean;
  15466. /**
  15467. * Force the postprocess to be applied without taking in account viewport
  15468. */
  15469. forceFullscreenViewport: boolean;
  15470. /**
  15471. * List of inspectable custom properties (used by the Inspector)
  15472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15473. */
  15474. inspectableCustomProperties: IInspectable[];
  15475. /**
  15476. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15477. *
  15478. * | Value | Type | Description |
  15479. * | ----- | ----------------------------------- | ----------- |
  15480. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15481. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15482. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15483. *
  15484. */
  15485. scaleMode: number;
  15486. /**
  15487. * Force textures to be a power of two (default: false)
  15488. */
  15489. alwaysForcePOT: boolean;
  15490. private _samples;
  15491. /**
  15492. * Number of sample textures (default: 1)
  15493. */
  15494. samples: number;
  15495. /**
  15496. * Modify the scale of the post process to be the same as the viewport (default: false)
  15497. */
  15498. adaptScaleToCurrentViewport: boolean;
  15499. private _camera;
  15500. private _scene;
  15501. private _engine;
  15502. private _options;
  15503. private _reusable;
  15504. private _textureType;
  15505. /**
  15506. * Smart array of input and output textures for the post process.
  15507. * @hidden
  15508. */
  15509. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15510. /**
  15511. * The index in _textures that corresponds to the output texture.
  15512. * @hidden
  15513. */
  15514. _currentRenderTextureInd: number;
  15515. private _effect;
  15516. private _samplers;
  15517. private _fragmentUrl;
  15518. private _vertexUrl;
  15519. private _parameters;
  15520. private _scaleRatio;
  15521. protected _indexParameters: any;
  15522. private _shareOutputWithPostProcess;
  15523. private _texelSize;
  15524. private _forcedOutputTexture;
  15525. /**
  15526. * Returns the fragment url or shader name used in the post process.
  15527. * @returns the fragment url or name in the shader store.
  15528. */
  15529. getEffectName(): string;
  15530. /**
  15531. * An event triggered when the postprocess is activated.
  15532. */
  15533. onActivateObservable: Observable<Camera>;
  15534. private _onActivateObserver;
  15535. /**
  15536. * A function that is added to the onActivateObservable
  15537. */
  15538. onActivate: Nullable<(camera: Camera) => void>;
  15539. /**
  15540. * An event triggered when the postprocess changes its size.
  15541. */
  15542. onSizeChangedObservable: Observable<PostProcess>;
  15543. private _onSizeChangedObserver;
  15544. /**
  15545. * A function that is added to the onSizeChangedObservable
  15546. */
  15547. onSizeChanged: (postProcess: PostProcess) => void;
  15548. /**
  15549. * An event triggered when the postprocess applies its effect.
  15550. */
  15551. onApplyObservable: Observable<Effect>;
  15552. private _onApplyObserver;
  15553. /**
  15554. * A function that is added to the onApplyObservable
  15555. */
  15556. onApply: (effect: Effect) => void;
  15557. /**
  15558. * An event triggered before rendering the postprocess
  15559. */
  15560. onBeforeRenderObservable: Observable<Effect>;
  15561. private _onBeforeRenderObserver;
  15562. /**
  15563. * A function that is added to the onBeforeRenderObservable
  15564. */
  15565. onBeforeRender: (effect: Effect) => void;
  15566. /**
  15567. * An event triggered after rendering the postprocess
  15568. */
  15569. onAfterRenderObservable: Observable<Effect>;
  15570. private _onAfterRenderObserver;
  15571. /**
  15572. * A function that is added to the onAfterRenderObservable
  15573. */
  15574. onAfterRender: (efect: Effect) => void;
  15575. /**
  15576. * 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
  15577. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15578. */
  15579. inputTexture: InternalTexture;
  15580. /**
  15581. * Gets the camera which post process is applied to.
  15582. * @returns The camera the post process is applied to.
  15583. */
  15584. getCamera(): Camera;
  15585. /**
  15586. * Gets the texel size of the postprocess.
  15587. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15588. */
  15589. readonly texelSize: Vector2;
  15590. /**
  15591. * Creates a new instance PostProcess
  15592. * @param name The name of the PostProcess.
  15593. * @param fragmentUrl The url of the fragment shader to be used.
  15594. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15595. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15596. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15597. * @param camera The camera to apply the render pass to.
  15598. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15599. * @param engine The engine which the post process will be applied. (default: current engine)
  15600. * @param reusable If the post process can be reused on the same frame. (default: false)
  15601. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15602. * @param textureType Type of textures used when performing the post process. (default: 0)
  15603. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15604. * @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
  15605. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15606. */
  15607. constructor(
  15608. /** Name of the PostProcess. */
  15609. 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);
  15610. /**
  15611. * Gets a string idenfifying the name of the class
  15612. * @returns "PostProcess" string
  15613. */
  15614. getClassName(): string;
  15615. /**
  15616. * Gets the engine which this post process belongs to.
  15617. * @returns The engine the post process was enabled with.
  15618. */
  15619. getEngine(): Engine;
  15620. /**
  15621. * The effect that is created when initializing the post process.
  15622. * @returns The created effect corresponding the the postprocess.
  15623. */
  15624. getEffect(): Effect;
  15625. /**
  15626. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15627. * @param postProcess The post process to share the output with.
  15628. * @returns This post process.
  15629. */
  15630. shareOutputWith(postProcess: PostProcess): PostProcess;
  15631. /**
  15632. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15633. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15634. */
  15635. useOwnOutput(): void;
  15636. /**
  15637. * Updates the effect with the current post process compile time values and recompiles the shader.
  15638. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15639. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15640. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15641. * @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
  15642. * @param onCompiled Called when the shader has been compiled.
  15643. * @param onError Called if there is an error when compiling a shader.
  15644. */
  15645. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15646. /**
  15647. * The post process is reusable if it can be used multiple times within one frame.
  15648. * @returns If the post process is reusable
  15649. */
  15650. isReusable(): boolean;
  15651. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15652. markTextureDirty(): void;
  15653. /**
  15654. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15655. * 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.
  15656. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15657. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15658. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15659. * @returns The target texture that was bound to be written to.
  15660. */
  15661. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15662. /**
  15663. * If the post process is supported.
  15664. */
  15665. readonly isSupported: boolean;
  15666. /**
  15667. * The aspect ratio of the output texture.
  15668. */
  15669. readonly aspectRatio: number;
  15670. /**
  15671. * Get a value indicating if the post-process is ready to be used
  15672. * @returns true if the post-process is ready (shader is compiled)
  15673. */
  15674. isReady(): boolean;
  15675. /**
  15676. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15677. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15678. */
  15679. apply(): Nullable<Effect>;
  15680. private _disposeTextures;
  15681. /**
  15682. * Disposes the post process.
  15683. * @param camera The camera to dispose the post process on.
  15684. */
  15685. dispose(camera?: Camera): void;
  15686. }
  15687. }
  15688. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15689. /** @hidden */
  15690. export var kernelBlurVaryingDeclaration: {
  15691. name: string;
  15692. shader: string;
  15693. };
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15696. /** @hidden */
  15697. export var kernelBlurFragment: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment2: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15710. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15711. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15712. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15713. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15714. /** @hidden */
  15715. export var kernelBlurPixelShader: {
  15716. name: string;
  15717. shader: string;
  15718. };
  15719. }
  15720. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15721. /** @hidden */
  15722. export var kernelBlurVertex: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15728. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15729. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15730. /** @hidden */
  15731. export var kernelBlurVertexShader: {
  15732. name: string;
  15733. shader: string;
  15734. };
  15735. }
  15736. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15737. import { Vector2 } from "babylonjs/Maths/math.vector";
  15738. import { Nullable } from "babylonjs/types";
  15739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15740. import { Camera } from "babylonjs/Cameras/camera";
  15741. import { Effect } from "babylonjs/Materials/effect";
  15742. import { Engine } from "babylonjs/Engines/engine";
  15743. import "babylonjs/Shaders/kernelBlur.fragment";
  15744. import "babylonjs/Shaders/kernelBlur.vertex";
  15745. /**
  15746. * The Blur Post Process which blurs an image based on a kernel and direction.
  15747. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15748. */
  15749. export class BlurPostProcess extends PostProcess {
  15750. /** The direction in which to blur the image. */
  15751. direction: Vector2;
  15752. private blockCompilation;
  15753. protected _kernel: number;
  15754. protected _idealKernel: number;
  15755. protected _packedFloat: boolean;
  15756. private _staticDefines;
  15757. /**
  15758. * Sets the length in pixels of the blur sample region
  15759. */
  15760. /**
  15761. * Gets the length in pixels of the blur sample region
  15762. */
  15763. kernel: number;
  15764. /**
  15765. * Sets wether or not the blur needs to unpack/repack floats
  15766. */
  15767. /**
  15768. * Gets wether or not the blur is unpacking/repacking floats
  15769. */
  15770. packedFloat: boolean;
  15771. /**
  15772. * Creates a new instance BlurPostProcess
  15773. * @param name The name of the effect.
  15774. * @param direction The direction in which to blur the image.
  15775. * @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.
  15776. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15777. * @param camera The camera to apply the render pass to.
  15778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15779. * @param engine The engine which the post process will be applied. (default: current engine)
  15780. * @param reusable If the post process can be reused on the same frame. (default: false)
  15781. * @param textureType Type of textures used when performing the post process. (default: 0)
  15782. * @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)
  15783. */
  15784. constructor(name: string,
  15785. /** The direction in which to blur the image. */
  15786. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15787. /**
  15788. * Updates the effect with the current post process compile time values and recompiles the shader.
  15789. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15790. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15791. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15792. * @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
  15793. * @param onCompiled Called when the shader has been compiled.
  15794. * @param onError Called if there is an error when compiling a shader.
  15795. */
  15796. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15797. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15798. /**
  15799. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15800. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15801. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15802. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15803. * The gaps between physical kernels are compensated for in the weighting of the samples
  15804. * @param idealKernel Ideal blur kernel.
  15805. * @return Nearest best kernel.
  15806. */
  15807. protected _nearestBestKernel(idealKernel: number): number;
  15808. /**
  15809. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15810. * @param x The point on the Gaussian distribution to sample.
  15811. * @return the value of the Gaussian function at x.
  15812. */
  15813. protected _gaussianWeight(x: number): number;
  15814. /**
  15815. * Generates a string that can be used as a floating point number in GLSL.
  15816. * @param x Value to print.
  15817. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15818. * @return GLSL float string.
  15819. */
  15820. protected _glslFloat(x: number, decimalFigures?: number): string;
  15821. }
  15822. }
  15823. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15824. import { Scene } from "babylonjs/scene";
  15825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15826. import { Plane } from "babylonjs/Maths/math.plane";
  15827. /**
  15828. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15829. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15830. * You can then easily use it as a reflectionTexture on a flat surface.
  15831. * In case the surface is not a plane, please consider relying on reflection probes.
  15832. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15833. */
  15834. export class MirrorTexture extends RenderTargetTexture {
  15835. private scene;
  15836. /**
  15837. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15838. * 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.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. mirrorPlane: Plane;
  15842. /**
  15843. * Define the blur ratio used to blur the reflection if needed.
  15844. */
  15845. blurRatio: number;
  15846. /**
  15847. * Define the adaptive blur kernel used to blur the reflection if needed.
  15848. * This will autocompute the closest best match for the `blurKernel`
  15849. */
  15850. adaptiveBlurKernel: number;
  15851. /**
  15852. * Define the blur kernel used to blur the reflection if needed.
  15853. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15854. */
  15855. blurKernel: number;
  15856. /**
  15857. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15858. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15859. */
  15860. blurKernelX: number;
  15861. /**
  15862. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15863. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15864. */
  15865. blurKernelY: number;
  15866. private _autoComputeBlurKernel;
  15867. protected _onRatioRescale(): void;
  15868. private _updateGammaSpace;
  15869. private _imageProcessingConfigChangeObserver;
  15870. private _transformMatrix;
  15871. private _mirrorMatrix;
  15872. private _savedViewMatrix;
  15873. private _blurX;
  15874. private _blurY;
  15875. private _adaptiveBlurKernel;
  15876. private _blurKernelX;
  15877. private _blurKernelY;
  15878. private _blurRatio;
  15879. /**
  15880. * Instantiates a Mirror Texture.
  15881. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15882. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15883. * You can then easily use it as a reflectionTexture on a flat surface.
  15884. * In case the surface is not a plane, please consider relying on reflection probes.
  15885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15886. * @param name
  15887. * @param size
  15888. * @param scene
  15889. * @param generateMipMaps
  15890. * @param type
  15891. * @param samplingMode
  15892. * @param generateDepthBuffer
  15893. */
  15894. constructor(name: string, size: number | {
  15895. width: number;
  15896. height: number;
  15897. } | {
  15898. ratio: number;
  15899. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15900. private _preparePostProcesses;
  15901. /**
  15902. * Clone the mirror texture.
  15903. * @returns the cloned texture
  15904. */
  15905. clone(): MirrorTexture;
  15906. /**
  15907. * Serialize the texture to a JSON representation you could use in Parse later on
  15908. * @returns the serialized JSON representation
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Dispose the texture and release its associated resources.
  15913. */
  15914. dispose(): void;
  15915. }
  15916. }
  15917. declare module "babylonjs/Materials/Textures/texture" {
  15918. import { Observable } from "babylonjs/Misc/observable";
  15919. import { Nullable } from "babylonjs/types";
  15920. import { Scene } from "babylonjs/scene";
  15921. import { Matrix } from "babylonjs/Maths/math.vector";
  15922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15923. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15924. import { Engine } from "babylonjs/Engines/engine";
  15925. /**
  15926. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15927. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15928. */
  15929. export class Texture extends BaseTexture {
  15930. /** @hidden */
  15931. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15932. /** @hidden */
  15933. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15934. /** @hidden */
  15935. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15936. /** nearest is mag = nearest and min = nearest and mip = linear */
  15937. static readonly NEAREST_SAMPLINGMODE: number;
  15938. /** nearest is mag = nearest and min = nearest and mip = linear */
  15939. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15941. static readonly BILINEAR_SAMPLINGMODE: number;
  15942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15943. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15944. /** Trilinear is mag = linear and min = linear and mip = linear */
  15945. static readonly TRILINEAR_SAMPLINGMODE: number;
  15946. /** Trilinear is mag = linear and min = linear and mip = linear */
  15947. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15948. /** mag = nearest and min = nearest and mip = nearest */
  15949. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15950. /** mag = nearest and min = linear and mip = nearest */
  15951. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15952. /** mag = nearest and min = linear and mip = linear */
  15953. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15954. /** mag = nearest and min = linear and mip = none */
  15955. static readonly NEAREST_LINEAR: number;
  15956. /** mag = nearest and min = nearest and mip = none */
  15957. static readonly NEAREST_NEAREST: number;
  15958. /** mag = linear and min = nearest and mip = nearest */
  15959. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15960. /** mag = linear and min = nearest and mip = linear */
  15961. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15962. /** mag = linear and min = linear and mip = none */
  15963. static readonly LINEAR_LINEAR: number;
  15964. /** mag = linear and min = nearest and mip = none */
  15965. static readonly LINEAR_NEAREST: number;
  15966. /** Explicit coordinates mode */
  15967. static readonly EXPLICIT_MODE: number;
  15968. /** Spherical coordinates mode */
  15969. static readonly SPHERICAL_MODE: number;
  15970. /** Planar coordinates mode */
  15971. static readonly PLANAR_MODE: number;
  15972. /** Cubic coordinates mode */
  15973. static readonly CUBIC_MODE: number;
  15974. /** Projection coordinates mode */
  15975. static readonly PROJECTION_MODE: number;
  15976. /** Inverse Cubic coordinates mode */
  15977. static readonly SKYBOX_MODE: number;
  15978. /** Inverse Cubic coordinates mode */
  15979. static readonly INVCUBIC_MODE: number;
  15980. /** Equirectangular coordinates mode */
  15981. static readonly EQUIRECTANGULAR_MODE: number;
  15982. /** Equirectangular Fixed coordinates mode */
  15983. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15984. /** Equirectangular Fixed Mirrored coordinates mode */
  15985. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15986. /** Texture is not repeating outside of 0..1 UVs */
  15987. static readonly CLAMP_ADDRESSMODE: number;
  15988. /** Texture is repeating outside of 0..1 UVs */
  15989. static readonly WRAP_ADDRESSMODE: number;
  15990. /** Texture is repeating and mirrored */
  15991. static readonly MIRROR_ADDRESSMODE: number;
  15992. /**
  15993. * 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
  15994. */
  15995. static UseSerializedUrlIfAny: boolean;
  15996. /**
  15997. * Define the url of the texture.
  15998. */
  15999. url: Nullable<string>;
  16000. /**
  16001. * Define an offset on the texture to offset the u coordinates of the UVs
  16002. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16003. */
  16004. uOffset: number;
  16005. /**
  16006. * Define an offset on the texture to offset the v coordinates of the UVs
  16007. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16008. */
  16009. vOffset: number;
  16010. /**
  16011. * Define an offset on the texture to scale the u coordinates of the UVs
  16012. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16013. */
  16014. uScale: number;
  16015. /**
  16016. * Define an offset on the texture to scale the v coordinates of the UVs
  16017. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16018. */
  16019. vScale: number;
  16020. /**
  16021. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16022. * @see http://doc.babylonjs.com/how_to/more_materials
  16023. */
  16024. uAng: number;
  16025. /**
  16026. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16027. * @see http://doc.babylonjs.com/how_to/more_materials
  16028. */
  16029. vAng: number;
  16030. /**
  16031. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16032. * @see http://doc.babylonjs.com/how_to/more_materials
  16033. */
  16034. wAng: number;
  16035. /**
  16036. * Defines the center of rotation (U)
  16037. */
  16038. uRotationCenter: number;
  16039. /**
  16040. * Defines the center of rotation (V)
  16041. */
  16042. vRotationCenter: number;
  16043. /**
  16044. * Defines the center of rotation (W)
  16045. */
  16046. wRotationCenter: number;
  16047. /**
  16048. * Are mip maps generated for this texture or not.
  16049. */
  16050. readonly noMipmap: boolean;
  16051. /**
  16052. * List of inspectable custom properties (used by the Inspector)
  16053. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16054. */
  16055. inspectableCustomProperties: Nullable<IInspectable[]>;
  16056. private _noMipmap;
  16057. /** @hidden */
  16058. _invertY: boolean;
  16059. private _rowGenerationMatrix;
  16060. private _cachedTextureMatrix;
  16061. private _projectionModeMatrix;
  16062. private _t0;
  16063. private _t1;
  16064. private _t2;
  16065. private _cachedUOffset;
  16066. private _cachedVOffset;
  16067. private _cachedUScale;
  16068. private _cachedVScale;
  16069. private _cachedUAng;
  16070. private _cachedVAng;
  16071. private _cachedWAng;
  16072. private _cachedProjectionMatrixId;
  16073. private _cachedCoordinatesMode;
  16074. /** @hidden */
  16075. protected _initialSamplingMode: number;
  16076. /** @hidden */
  16077. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16078. private _deleteBuffer;
  16079. protected _format: Nullable<number>;
  16080. private _delayedOnLoad;
  16081. private _delayedOnError;
  16082. /**
  16083. * Observable triggered once the texture has been loaded.
  16084. */
  16085. onLoadObservable: Observable<Texture>;
  16086. protected _isBlocking: boolean;
  16087. /**
  16088. * Is the texture preventing material to render while loading.
  16089. * If false, a default texture will be used instead of the loading one during the preparation step.
  16090. */
  16091. isBlocking: boolean;
  16092. /**
  16093. * Get the current sampling mode associated with the texture.
  16094. */
  16095. readonly samplingMode: number;
  16096. /**
  16097. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16098. */
  16099. readonly invertY: boolean;
  16100. /**
  16101. * Instantiates a new texture.
  16102. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16103. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16104. * @param url define the url of the picture to load as a texture
  16105. * @param scene define the scene or engine the texture will belong to
  16106. * @param noMipmap define if the texture will require mip maps or not
  16107. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16108. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16109. * @param onLoad define a callback triggered when the texture has been loaded
  16110. * @param onError define a callback triggered when an error occurred during the loading session
  16111. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16112. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16113. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16114. */
  16115. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  16116. /**
  16117. * Update the url (and optional buffer) of this texture if url was null during construction.
  16118. * @param url the url of the texture
  16119. * @param buffer the buffer of the texture (defaults to null)
  16120. * @param onLoad callback called when the texture is loaded (defaults to null)
  16121. */
  16122. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16123. /**
  16124. * Finish the loading sequence of a texture flagged as delayed load.
  16125. * @hidden
  16126. */
  16127. delayLoad(): void;
  16128. private _prepareRowForTextureGeneration;
  16129. /**
  16130. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16131. * @returns the transform matrix of the texture.
  16132. */
  16133. getTextureMatrix(): Matrix;
  16134. /**
  16135. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16136. * @returns The reflection texture transform
  16137. */
  16138. getReflectionTextureMatrix(): Matrix;
  16139. /**
  16140. * Clones the texture.
  16141. * @returns the cloned texture
  16142. */
  16143. clone(): Texture;
  16144. /**
  16145. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16146. * @returns The JSON representation of the texture
  16147. */
  16148. serialize(): any;
  16149. /**
  16150. * Get the current class name of the texture useful for serialization or dynamic coding.
  16151. * @returns "Texture"
  16152. */
  16153. getClassName(): string;
  16154. /**
  16155. * Dispose the texture and release its associated resources.
  16156. */
  16157. dispose(): void;
  16158. /**
  16159. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16160. * @param parsedTexture Define the JSON representation of the texture
  16161. * @param scene Define the scene the parsed texture should be instantiated in
  16162. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16163. * @returns The parsed texture if successful
  16164. */
  16165. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16166. /**
  16167. * Creates a texture from its base 64 representation.
  16168. * @param data Define the base64 payload without the data: prefix
  16169. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16170. * @param scene Define the scene the texture should belong to
  16171. * @param noMipmap Forces the texture to not create mip map information if true
  16172. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16173. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16174. * @param onLoad define a callback triggered when the texture has been loaded
  16175. * @param onError define a callback triggered when an error occurred during the loading session
  16176. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16177. * @returns the created texture
  16178. */
  16179. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16180. /**
  16181. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16182. * @param data Define the base64 payload without the data: prefix
  16183. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16184. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16185. * @param scene Define the scene the texture should belong to
  16186. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16187. * @param noMipmap Forces the texture to not create mip map information if true
  16188. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16189. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16190. * @param onLoad define a callback triggered when the texture has been loaded
  16191. * @param onError define a callback triggered when an error occurred during the loading session
  16192. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16193. * @returns the created texture
  16194. */
  16195. 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;
  16196. }
  16197. }
  16198. declare module "babylonjs/PostProcesses/postProcessManager" {
  16199. import { Nullable } from "babylonjs/types";
  16200. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16201. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16202. import { Scene } from "babylonjs/scene";
  16203. /**
  16204. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16205. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16206. */
  16207. export class PostProcessManager {
  16208. private _scene;
  16209. private _indexBuffer;
  16210. private _vertexBuffers;
  16211. /**
  16212. * Creates a new instance PostProcess
  16213. * @param scene The scene that the post process is associated with.
  16214. */
  16215. constructor(scene: Scene);
  16216. private _prepareBuffers;
  16217. private _buildIndexBuffer;
  16218. /**
  16219. * Rebuilds the vertex buffers of the manager.
  16220. * @hidden
  16221. */
  16222. _rebuild(): void;
  16223. /**
  16224. * Prepares a frame to be run through a post process.
  16225. * @param sourceTexture The input texture to the post procesess. (default: null)
  16226. * @param postProcesses An array of post processes to be run. (default: null)
  16227. * @returns True if the post processes were able to be run.
  16228. * @hidden
  16229. */
  16230. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16231. /**
  16232. * Manually render a set of post processes to a texture.
  16233. * @param postProcesses An array of post processes to be run.
  16234. * @param targetTexture The target texture to render to.
  16235. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16236. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16237. * @param lodLevel defines which lod of the texture to render to
  16238. */
  16239. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16240. /**
  16241. * Finalize the result of the output of the postprocesses.
  16242. * @param doNotPresent If true the result will not be displayed to the screen.
  16243. * @param targetTexture The target texture to render to.
  16244. * @param faceIndex The index of the face to bind the target texture to.
  16245. * @param postProcesses The array of post processes to render.
  16246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16247. * @hidden
  16248. */
  16249. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16250. /**
  16251. * Disposes of the post process manager.
  16252. */
  16253. dispose(): void;
  16254. }
  16255. }
  16256. declare module "babylonjs/Misc/gradients" {
  16257. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16258. /** Interface used by value gradients (color, factor, ...) */
  16259. export interface IValueGradient {
  16260. /**
  16261. * Gets or sets the gradient value (between 0 and 1)
  16262. */
  16263. gradient: number;
  16264. }
  16265. /** Class used to store color4 gradient */
  16266. export class ColorGradient implements IValueGradient {
  16267. /**
  16268. * Gets or sets the gradient value (between 0 and 1)
  16269. */
  16270. gradient: number;
  16271. /**
  16272. * Gets or sets first associated color
  16273. */
  16274. color1: Color4;
  16275. /**
  16276. * Gets or sets second associated color
  16277. */
  16278. color2?: Color4;
  16279. /**
  16280. * Will get a color picked randomly between color1 and color2.
  16281. * If color2 is undefined then color1 will be used
  16282. * @param result defines the target Color4 to store the result in
  16283. */
  16284. getColorToRef(result: Color4): void;
  16285. }
  16286. /** Class used to store color 3 gradient */
  16287. export class Color3Gradient implements IValueGradient {
  16288. /**
  16289. * Gets or sets the gradient value (between 0 and 1)
  16290. */
  16291. gradient: number;
  16292. /**
  16293. * Gets or sets the associated color
  16294. */
  16295. color: Color3;
  16296. }
  16297. /** Class used to store factor gradient */
  16298. export class FactorGradient implements IValueGradient {
  16299. /**
  16300. * Gets or sets the gradient value (between 0 and 1)
  16301. */
  16302. gradient: number;
  16303. /**
  16304. * Gets or sets first associated factor
  16305. */
  16306. factor1: number;
  16307. /**
  16308. * Gets or sets second associated factor
  16309. */
  16310. factor2?: number;
  16311. /**
  16312. * Will get a number picked randomly between factor1 and factor2.
  16313. * If factor2 is undefined then factor1 will be used
  16314. * @returns the picked number
  16315. */
  16316. getFactor(): number;
  16317. }
  16318. /**
  16319. * Helper used to simplify some generic gradient tasks
  16320. */
  16321. export class GradientHelper {
  16322. /**
  16323. * Gets the current gradient from an array of IValueGradient
  16324. * @param ratio defines the current ratio to get
  16325. * @param gradients defines the array of IValueGradient
  16326. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16327. */
  16328. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16329. }
  16330. }
  16331. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16332. import { Scene } from "babylonjs/scene";
  16333. import { ISceneComponent } from "babylonjs/sceneComponent";
  16334. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16335. module "babylonjs/abstractScene" {
  16336. interface AbstractScene {
  16337. /**
  16338. * The list of procedural textures added to the scene
  16339. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16340. */
  16341. proceduralTextures: Array<ProceduralTexture>;
  16342. }
  16343. }
  16344. /**
  16345. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16346. * in a given scene.
  16347. */
  16348. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16349. /**
  16350. * The component name helpfull to identify the component in the list of scene components.
  16351. */
  16352. readonly name: string;
  16353. /**
  16354. * The scene the component belongs to.
  16355. */
  16356. scene: Scene;
  16357. /**
  16358. * Creates a new instance of the component for the given scene
  16359. * @param scene Defines the scene to register the component in
  16360. */
  16361. constructor(scene: Scene);
  16362. /**
  16363. * Registers the component in a given scene
  16364. */
  16365. register(): void;
  16366. /**
  16367. * Rebuilds the elements related to this component in case of
  16368. * context lost for instance.
  16369. */
  16370. rebuild(): void;
  16371. /**
  16372. * Disposes the component and the associated ressources.
  16373. */
  16374. dispose(): void;
  16375. private _beforeClear;
  16376. }
  16377. }
  16378. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16380. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16381. module "babylonjs/Engines/engine" {
  16382. interface Engine {
  16383. /**
  16384. * Creates a new render target cube texture
  16385. * @param size defines the size of the texture
  16386. * @param options defines the options used to create the texture
  16387. * @returns a new render target cube texture stored in an InternalTexture
  16388. */
  16389. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16390. }
  16391. }
  16392. }
  16393. declare module "babylonjs/Shaders/procedural.vertex" {
  16394. /** @hidden */
  16395. export var proceduralVertexShader: {
  16396. name: string;
  16397. shader: string;
  16398. };
  16399. }
  16400. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16401. import { Observable } from "babylonjs/Misc/observable";
  16402. import { Nullable } from "babylonjs/types";
  16403. import { Scene } from "babylonjs/scene";
  16404. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16405. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16406. import { Effect } from "babylonjs/Materials/effect";
  16407. import { Texture } from "babylonjs/Materials/Textures/texture";
  16408. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16409. import "babylonjs/Shaders/procedural.vertex";
  16410. /**
  16411. * 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.
  16412. * This is the base class of any Procedural texture and contains most of the shareable code.
  16413. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16414. */
  16415. export class ProceduralTexture extends Texture {
  16416. isCube: boolean;
  16417. /**
  16418. * Define if the texture is enabled or not (disabled texture will not render)
  16419. */
  16420. isEnabled: boolean;
  16421. /**
  16422. * Define if the texture must be cleared before rendering (default is true)
  16423. */
  16424. autoClear: boolean;
  16425. /**
  16426. * Callback called when the texture is generated
  16427. */
  16428. onGenerated: () => void;
  16429. /**
  16430. * Event raised when the texture is generated
  16431. */
  16432. onGeneratedObservable: Observable<ProceduralTexture>;
  16433. /** @hidden */
  16434. _generateMipMaps: boolean;
  16435. /** @hidden **/
  16436. _effect: Effect;
  16437. /** @hidden */
  16438. _textures: {
  16439. [key: string]: Texture;
  16440. };
  16441. private _size;
  16442. private _currentRefreshId;
  16443. private _refreshRate;
  16444. private _vertexBuffers;
  16445. private _indexBuffer;
  16446. private _uniforms;
  16447. private _samplers;
  16448. private _fragment;
  16449. private _floats;
  16450. private _ints;
  16451. private _floatsArrays;
  16452. private _colors3;
  16453. private _colors4;
  16454. private _vectors2;
  16455. private _vectors3;
  16456. private _matrices;
  16457. private _fallbackTexture;
  16458. private _fallbackTextureUsed;
  16459. private _engine;
  16460. private _cachedDefines;
  16461. private _contentUpdateId;
  16462. private _contentData;
  16463. /**
  16464. * Instantiates a new procedural texture.
  16465. * 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.
  16466. * This is the base class of any Procedural texture and contains most of the shareable code.
  16467. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16468. * @param name Define the name of the texture
  16469. * @param size Define the size of the texture to create
  16470. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16471. * @param scene Define the scene the texture belongs to
  16472. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16473. * @param generateMipMaps Define if the texture should creates mip maps or not
  16474. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16475. */
  16476. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16477. /**
  16478. * The effect that is created when initializing the post process.
  16479. * @returns The created effect corresponding the the postprocess.
  16480. */
  16481. getEffect(): Effect;
  16482. /**
  16483. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16484. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16485. */
  16486. getContent(): Nullable<ArrayBufferView>;
  16487. private _createIndexBuffer;
  16488. /** @hidden */
  16489. _rebuild(): void;
  16490. /**
  16491. * Resets the texture in order to recreate its associated resources.
  16492. * This can be called in case of context loss
  16493. */
  16494. reset(): void;
  16495. protected _getDefines(): string;
  16496. /**
  16497. * Is the texture ready to be used ? (rendered at least once)
  16498. * @returns true if ready, otherwise, false.
  16499. */
  16500. isReady(): boolean;
  16501. /**
  16502. * Resets the refresh counter of the texture and start bak from scratch.
  16503. * Could be useful to regenerate the texture if it is setup to render only once.
  16504. */
  16505. resetRefreshCounter(): void;
  16506. /**
  16507. * Set the fragment shader to use in order to render the texture.
  16508. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16509. */
  16510. setFragment(fragment: any): void;
  16511. /**
  16512. * Define the refresh rate of the texture or the rendering frequency.
  16513. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16514. */
  16515. refreshRate: number;
  16516. /** @hidden */
  16517. _shouldRender(): boolean;
  16518. /**
  16519. * Get the size the texture is rendering at.
  16520. * @returns the size (texture is always squared)
  16521. */
  16522. getRenderSize(): number;
  16523. /**
  16524. * Resize the texture to new value.
  16525. * @param size Define the new size the texture should have
  16526. * @param generateMipMaps Define whether the new texture should create mip maps
  16527. */
  16528. resize(size: number, generateMipMaps: boolean): void;
  16529. private _checkUniform;
  16530. /**
  16531. * Set a texture in the shader program used to render.
  16532. * @param name Define the name of the uniform samplers as defined in the shader
  16533. * @param texture Define the texture to bind to this sampler
  16534. * @return the texture itself allowing "fluent" like uniform updates
  16535. */
  16536. setTexture(name: string, texture: Texture): ProceduralTexture;
  16537. /**
  16538. * Set a float in the shader.
  16539. * @param name Define the name of the uniform as defined in the shader
  16540. * @param value Define the value to give to the uniform
  16541. * @return the texture itself allowing "fluent" like uniform updates
  16542. */
  16543. setFloat(name: string, value: number): ProceduralTexture;
  16544. /**
  16545. * Set a int in the shader.
  16546. * @param name Define the name of the uniform as defined in the shader
  16547. * @param value Define the value to give to the uniform
  16548. * @return the texture itself allowing "fluent" like uniform updates
  16549. */
  16550. setInt(name: string, value: number): ProceduralTexture;
  16551. /**
  16552. * Set an array of floats in the shader.
  16553. * @param name Define the name of the uniform as defined in the shader
  16554. * @param value Define the value to give to the uniform
  16555. * @return the texture itself allowing "fluent" like uniform updates
  16556. */
  16557. setFloats(name: string, value: number[]): ProceduralTexture;
  16558. /**
  16559. * Set a vec3 in the shader from a Color3.
  16560. * @param name Define the name of the uniform as defined in the shader
  16561. * @param value Define the value to give to the uniform
  16562. * @return the texture itself allowing "fluent" like uniform updates
  16563. */
  16564. setColor3(name: string, value: Color3): ProceduralTexture;
  16565. /**
  16566. * Set a vec4 in the shader from a Color4.
  16567. * @param name Define the name of the uniform as defined in the shader
  16568. * @param value Define the value to give to the uniform
  16569. * @return the texture itself allowing "fluent" like uniform updates
  16570. */
  16571. setColor4(name: string, value: Color4): ProceduralTexture;
  16572. /**
  16573. * Set a vec2 in the shader from a Vector2.
  16574. * @param name Define the name of the uniform as defined in the shader
  16575. * @param value Define the value to give to the uniform
  16576. * @return the texture itself allowing "fluent" like uniform updates
  16577. */
  16578. setVector2(name: string, value: Vector2): ProceduralTexture;
  16579. /**
  16580. * Set a vec3 in the shader from a Vector3.
  16581. * @param name Define the name of the uniform as defined in the shader
  16582. * @param value Define the value to give to the uniform
  16583. * @return the texture itself allowing "fluent" like uniform updates
  16584. */
  16585. setVector3(name: string, value: Vector3): ProceduralTexture;
  16586. /**
  16587. * Set a mat4 in the shader from a MAtrix.
  16588. * @param name Define the name of the uniform as defined in the shader
  16589. * @param value Define the value to give to the uniform
  16590. * @return the texture itself allowing "fluent" like uniform updates
  16591. */
  16592. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16593. /**
  16594. * Render the texture to its associated render target.
  16595. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16596. */
  16597. render(useCameraPostProcess?: boolean): void;
  16598. /**
  16599. * Clone the texture.
  16600. * @returns the cloned texture
  16601. */
  16602. clone(): ProceduralTexture;
  16603. /**
  16604. * Dispose the texture and release its asoociated resources.
  16605. */
  16606. dispose(): void;
  16607. }
  16608. }
  16609. declare module "babylonjs/Particles/baseParticleSystem" {
  16610. import { Nullable } from "babylonjs/types";
  16611. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16613. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16614. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16615. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16616. import { Scene } from "babylonjs/scene";
  16617. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16618. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16619. import { Texture } from "babylonjs/Materials/Textures/texture";
  16620. import { Color4 } from "babylonjs/Maths/math.color";
  16621. import { Animation } from "babylonjs/Animations/animation";
  16622. /**
  16623. * This represents the base class for particle system in Babylon.
  16624. * 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.
  16625. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16626. * @example https://doc.babylonjs.com/babylon101/particles
  16627. */
  16628. export class BaseParticleSystem {
  16629. /**
  16630. * Source color is added to the destination color without alpha affecting the result
  16631. */
  16632. static BLENDMODE_ONEONE: number;
  16633. /**
  16634. * Blend current color and particle color using particle’s alpha
  16635. */
  16636. static BLENDMODE_STANDARD: number;
  16637. /**
  16638. * Add current color and particle color multiplied by particle’s alpha
  16639. */
  16640. static BLENDMODE_ADD: number;
  16641. /**
  16642. * Multiply current color with particle color
  16643. */
  16644. static BLENDMODE_MULTIPLY: number;
  16645. /**
  16646. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16647. */
  16648. static BLENDMODE_MULTIPLYADD: number;
  16649. /**
  16650. * List of animations used by the particle system.
  16651. */
  16652. animations: Animation[];
  16653. /**
  16654. * The id of the Particle system.
  16655. */
  16656. id: string;
  16657. /**
  16658. * The friendly name of the Particle system.
  16659. */
  16660. name: string;
  16661. /**
  16662. * The rendering group used by the Particle system to chose when to render.
  16663. */
  16664. renderingGroupId: number;
  16665. /**
  16666. * The emitter represents the Mesh or position we are attaching the particle system to.
  16667. */
  16668. emitter: Nullable<AbstractMesh | Vector3>;
  16669. /**
  16670. * The maximum number of particles to emit per frame
  16671. */
  16672. emitRate: number;
  16673. /**
  16674. * If you want to launch only a few particles at once, that can be done, as well.
  16675. */
  16676. manualEmitCount: number;
  16677. /**
  16678. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16679. */
  16680. updateSpeed: number;
  16681. /**
  16682. * The amount of time the particle system is running (depends of the overall update speed).
  16683. */
  16684. targetStopDuration: number;
  16685. /**
  16686. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16687. */
  16688. disposeOnStop: boolean;
  16689. /**
  16690. * Minimum power of emitting particles.
  16691. */
  16692. minEmitPower: number;
  16693. /**
  16694. * Maximum power of emitting particles.
  16695. */
  16696. maxEmitPower: number;
  16697. /**
  16698. * Minimum life time of emitting particles.
  16699. */
  16700. minLifeTime: number;
  16701. /**
  16702. * Maximum life time of emitting particles.
  16703. */
  16704. maxLifeTime: number;
  16705. /**
  16706. * Minimum Size of emitting particles.
  16707. */
  16708. minSize: number;
  16709. /**
  16710. * Maximum Size of emitting particles.
  16711. */
  16712. maxSize: number;
  16713. /**
  16714. * Minimum scale of emitting particles on X axis.
  16715. */
  16716. minScaleX: number;
  16717. /**
  16718. * Maximum scale of emitting particles on X axis.
  16719. */
  16720. maxScaleX: number;
  16721. /**
  16722. * Minimum scale of emitting particles on Y axis.
  16723. */
  16724. minScaleY: number;
  16725. /**
  16726. * Maximum scale of emitting particles on Y axis.
  16727. */
  16728. maxScaleY: number;
  16729. /**
  16730. * Gets or sets the minimal initial rotation in radians.
  16731. */
  16732. minInitialRotation: number;
  16733. /**
  16734. * Gets or sets the maximal initial rotation in radians.
  16735. */
  16736. maxInitialRotation: number;
  16737. /**
  16738. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16739. */
  16740. minAngularSpeed: number;
  16741. /**
  16742. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16743. */
  16744. maxAngularSpeed: number;
  16745. /**
  16746. * The texture used to render each particle. (this can be a spritesheet)
  16747. */
  16748. particleTexture: Nullable<Texture>;
  16749. /**
  16750. * The layer mask we are rendering the particles through.
  16751. */
  16752. layerMask: number;
  16753. /**
  16754. * This can help using your own shader to render the particle system.
  16755. * The according effect will be created
  16756. */
  16757. customShader: any;
  16758. /**
  16759. * By default particle system starts as soon as they are created. This prevents the
  16760. * automatic start to happen and let you decide when to start emitting particles.
  16761. */
  16762. preventAutoStart: boolean;
  16763. private _noiseTexture;
  16764. /**
  16765. * Gets or sets a texture used to add random noise to particle positions
  16766. */
  16767. noiseTexture: Nullable<ProceduralTexture>;
  16768. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16769. noiseStrength: Vector3;
  16770. /**
  16771. * Callback triggered when the particle animation is ending.
  16772. */
  16773. onAnimationEnd: Nullable<() => void>;
  16774. /**
  16775. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16776. */
  16777. blendMode: number;
  16778. /**
  16779. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16780. * to override the particles.
  16781. */
  16782. forceDepthWrite: boolean;
  16783. /** 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 */
  16784. preWarmCycles: number;
  16785. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16786. preWarmStepOffset: number;
  16787. /**
  16788. * 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)
  16789. */
  16790. spriteCellChangeSpeed: number;
  16791. /**
  16792. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16793. */
  16794. startSpriteCellID: number;
  16795. /**
  16796. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16797. */
  16798. endSpriteCellID: number;
  16799. /**
  16800. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16801. */
  16802. spriteCellWidth: number;
  16803. /**
  16804. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16805. */
  16806. spriteCellHeight: number;
  16807. /**
  16808. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16809. */
  16810. spriteRandomStartCell: boolean;
  16811. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16812. translationPivot: Vector2;
  16813. /** @hidden */
  16814. protected _isAnimationSheetEnabled: boolean;
  16815. /**
  16816. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16817. */
  16818. beginAnimationOnStart: boolean;
  16819. /**
  16820. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16821. */
  16822. beginAnimationFrom: number;
  16823. /**
  16824. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16825. */
  16826. beginAnimationTo: number;
  16827. /**
  16828. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16829. */
  16830. beginAnimationLoop: boolean;
  16831. /**
  16832. * Gets or sets a world offset applied to all particles
  16833. */
  16834. worldOffset: Vector3;
  16835. /**
  16836. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16837. */
  16838. isAnimationSheetEnabled: boolean;
  16839. /**
  16840. * Get hosting scene
  16841. * @returns the scene
  16842. */
  16843. getScene(): Scene;
  16844. /**
  16845. * You can use gravity if you want to give an orientation to your particles.
  16846. */
  16847. gravity: Vector3;
  16848. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16849. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16850. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16851. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16852. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16853. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16854. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16855. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16856. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16857. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16858. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16859. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16860. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16861. /**
  16862. * Defines the delay in milliseconds before starting the system (0 by default)
  16863. */
  16864. startDelay: number;
  16865. /**
  16866. * Gets the current list of drag gradients.
  16867. * You must use addDragGradient and removeDragGradient to udpate this list
  16868. * @returns the list of drag gradients
  16869. */
  16870. getDragGradients(): Nullable<Array<FactorGradient>>;
  16871. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16872. limitVelocityDamping: number;
  16873. /**
  16874. * Gets the current list of limit velocity gradients.
  16875. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16876. * @returns the list of limit velocity gradients
  16877. */
  16878. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16879. /**
  16880. * Gets the current list of color gradients.
  16881. * You must use addColorGradient and removeColorGradient to udpate this list
  16882. * @returns the list of color gradients
  16883. */
  16884. getColorGradients(): Nullable<Array<ColorGradient>>;
  16885. /**
  16886. * Gets the current list of size gradients.
  16887. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16888. * @returns the list of size gradients
  16889. */
  16890. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16891. /**
  16892. * Gets the current list of color remap gradients.
  16893. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16894. * @returns the list of color remap gradients
  16895. */
  16896. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16897. /**
  16898. * Gets the current list of alpha remap gradients.
  16899. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16900. * @returns the list of alpha remap gradients
  16901. */
  16902. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16903. /**
  16904. * Gets the current list of life time gradients.
  16905. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16906. * @returns the list of life time gradients
  16907. */
  16908. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16909. /**
  16910. * Gets the current list of angular speed gradients.
  16911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16912. * @returns the list of angular speed gradients
  16913. */
  16914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16915. /**
  16916. * Gets the current list of velocity gradients.
  16917. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16918. * @returns the list of velocity gradients
  16919. */
  16920. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16921. /**
  16922. * Gets the current list of start size gradients.
  16923. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16924. * @returns the list of start size gradients
  16925. */
  16926. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16927. /**
  16928. * Gets the current list of emit rate gradients.
  16929. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16930. * @returns the list of emit rate gradients
  16931. */
  16932. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16933. /**
  16934. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16935. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16936. */
  16937. direction1: Vector3;
  16938. /**
  16939. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16940. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16941. */
  16942. direction2: Vector3;
  16943. /**
  16944. * 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.
  16945. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16946. */
  16947. minEmitBox: Vector3;
  16948. /**
  16949. * 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.
  16950. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16951. */
  16952. maxEmitBox: Vector3;
  16953. /**
  16954. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16955. */
  16956. color1: Color4;
  16957. /**
  16958. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16959. */
  16960. color2: Color4;
  16961. /**
  16962. * Color the particle will have at the end of its lifetime
  16963. */
  16964. colorDead: Color4;
  16965. /**
  16966. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16967. */
  16968. textureMask: Color4;
  16969. /**
  16970. * The particle emitter type defines the emitter used by the particle system.
  16971. * It can be for example box, sphere, or cone...
  16972. */
  16973. particleEmitterType: IParticleEmitterType;
  16974. /** @hidden */
  16975. _isSubEmitter: boolean;
  16976. /**
  16977. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16978. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16979. */
  16980. billboardMode: number;
  16981. protected _isBillboardBased: boolean;
  16982. /**
  16983. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16984. */
  16985. isBillboardBased: boolean;
  16986. /**
  16987. * The scene the particle system belongs to.
  16988. */
  16989. protected _scene: Scene;
  16990. /**
  16991. * Local cache of defines for image processing.
  16992. */
  16993. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16994. /**
  16995. * Default configuration related to image processing available in the standard Material.
  16996. */
  16997. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16998. /**
  16999. * Gets the image processing configuration used either in this material.
  17000. */
  17001. /**
  17002. * Sets the Default image processing configuration used either in the this material.
  17003. *
  17004. * If sets to null, the scene one is in use.
  17005. */
  17006. imageProcessingConfiguration: ImageProcessingConfiguration;
  17007. /**
  17008. * Attaches a new image processing configuration to the Standard Material.
  17009. * @param configuration
  17010. */
  17011. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17012. /** @hidden */
  17013. protected _reset(): void;
  17014. /** @hidden */
  17015. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17016. /**
  17017. * Instantiates a particle system.
  17018. * 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.
  17019. * @param name The name of the particle system
  17020. */
  17021. constructor(name: string);
  17022. /**
  17023. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17024. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17025. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17026. * @returns the emitter
  17027. */
  17028. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17029. /**
  17030. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17031. * @param radius The radius of the hemisphere to emit from
  17032. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17033. * @returns the emitter
  17034. */
  17035. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17036. /**
  17037. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17038. * @param radius The radius of the sphere to emit from
  17039. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17040. * @returns the emitter
  17041. */
  17042. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17043. /**
  17044. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17045. * @param radius The radius of the sphere to emit from
  17046. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17047. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17048. * @returns the emitter
  17049. */
  17050. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17051. /**
  17052. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17053. * @param radius The radius of the emission cylinder
  17054. * @param height The height of the emission cylinder
  17055. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17056. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17057. * @returns the emitter
  17058. */
  17059. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17060. /**
  17061. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17062. * @param radius The radius of the cylinder to emit from
  17063. * @param height The height of the emission cylinder
  17064. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17065. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17066. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17067. * @returns the emitter
  17068. */
  17069. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17070. /**
  17071. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17072. * @param radius The radius of the cone to emit from
  17073. * @param angle The base angle of the cone
  17074. * @returns the emitter
  17075. */
  17076. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17077. /**
  17078. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17079. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17080. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17081. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17082. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17083. * @returns the emitter
  17084. */
  17085. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17086. }
  17087. }
  17088. declare module "babylonjs/Particles/subEmitter" {
  17089. import { Scene } from "babylonjs/scene";
  17090. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17091. /**
  17092. * Type of sub emitter
  17093. */
  17094. export enum SubEmitterType {
  17095. /**
  17096. * Attached to the particle over it's lifetime
  17097. */
  17098. ATTACHED = 0,
  17099. /**
  17100. * Created when the particle dies
  17101. */
  17102. END = 1
  17103. }
  17104. /**
  17105. * Sub emitter class used to emit particles from an existing particle
  17106. */
  17107. export class SubEmitter {
  17108. /**
  17109. * the particle system to be used by the sub emitter
  17110. */
  17111. particleSystem: ParticleSystem;
  17112. /**
  17113. * Type of the submitter (Default: END)
  17114. */
  17115. type: SubEmitterType;
  17116. /**
  17117. * 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)
  17118. * Note: This only is supported when using an emitter of type Mesh
  17119. */
  17120. inheritDirection: boolean;
  17121. /**
  17122. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17123. */
  17124. inheritedVelocityAmount: number;
  17125. /**
  17126. * Creates a sub emitter
  17127. * @param particleSystem the particle system to be used by the sub emitter
  17128. */
  17129. constructor(
  17130. /**
  17131. * the particle system to be used by the sub emitter
  17132. */
  17133. particleSystem: ParticleSystem);
  17134. /**
  17135. * Clones the sub emitter
  17136. * @returns the cloned sub emitter
  17137. */
  17138. clone(): SubEmitter;
  17139. /**
  17140. * Serialize current object to a JSON object
  17141. * @returns the serialized object
  17142. */
  17143. serialize(): any;
  17144. /** @hidden */
  17145. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17146. /**
  17147. * Creates a new SubEmitter from a serialized JSON version
  17148. * @param serializationObject defines the JSON object to read from
  17149. * @param scene defines the hosting scene
  17150. * @param rootUrl defines the rootUrl for data loading
  17151. * @returns a new SubEmitter
  17152. */
  17153. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17154. /** Release associated resources */
  17155. dispose(): void;
  17156. }
  17157. }
  17158. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17159. /** @hidden */
  17160. export var clipPlaneFragmentDeclaration: {
  17161. name: string;
  17162. shader: string;
  17163. };
  17164. }
  17165. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17166. /** @hidden */
  17167. export var imageProcessingDeclaration: {
  17168. name: string;
  17169. shader: string;
  17170. };
  17171. }
  17172. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17173. /** @hidden */
  17174. export var imageProcessingFunctions: {
  17175. name: string;
  17176. shader: string;
  17177. };
  17178. }
  17179. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17180. /** @hidden */
  17181. export var clipPlaneFragment: {
  17182. name: string;
  17183. shader: string;
  17184. };
  17185. }
  17186. declare module "babylonjs/Shaders/particles.fragment" {
  17187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17188. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17189. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17190. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17191. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17192. /** @hidden */
  17193. export var particlesPixelShader: {
  17194. name: string;
  17195. shader: string;
  17196. };
  17197. }
  17198. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17199. /** @hidden */
  17200. export var clipPlaneVertexDeclaration: {
  17201. name: string;
  17202. shader: string;
  17203. };
  17204. }
  17205. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17206. /** @hidden */
  17207. export var clipPlaneVertex: {
  17208. name: string;
  17209. shader: string;
  17210. };
  17211. }
  17212. declare module "babylonjs/Shaders/particles.vertex" {
  17213. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17214. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17215. /** @hidden */
  17216. export var particlesVertexShader: {
  17217. name: string;
  17218. shader: string;
  17219. };
  17220. }
  17221. declare module "babylonjs/Particles/particleSystem" {
  17222. import { Nullable } from "babylonjs/types";
  17223. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17224. import { Observable } from "babylonjs/Misc/observable";
  17225. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17226. import { Effect } from "babylonjs/Materials/effect";
  17227. import { Scene, IDisposable } from "babylonjs/scene";
  17228. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17229. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17230. import { Particle } from "babylonjs/Particles/particle";
  17231. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17232. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17233. import "babylonjs/Shaders/particles.fragment";
  17234. import "babylonjs/Shaders/particles.vertex";
  17235. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17236. /**
  17237. * This represents a particle system in Babylon.
  17238. * 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.
  17239. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17240. * @example https://doc.babylonjs.com/babylon101/particles
  17241. */
  17242. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17243. /**
  17244. * Billboard mode will only apply to Y axis
  17245. */
  17246. static readonly BILLBOARDMODE_Y: number;
  17247. /**
  17248. * Billboard mode will apply to all axes
  17249. */
  17250. static readonly BILLBOARDMODE_ALL: number;
  17251. /**
  17252. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17253. */
  17254. static readonly BILLBOARDMODE_STRETCHED: number;
  17255. /**
  17256. * This function can be defined to provide custom update for active particles.
  17257. * This function will be called instead of regular update (age, position, color, etc.).
  17258. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17259. */
  17260. updateFunction: (particles: Particle[]) => void;
  17261. private _emitterWorldMatrix;
  17262. /**
  17263. * This function can be defined to specify initial direction for every new particle.
  17264. * It by default use the emitterType defined function
  17265. */
  17266. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17267. /**
  17268. * This function can be defined to specify initial position for every new particle.
  17269. * It by default use the emitterType defined function
  17270. */
  17271. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17272. /**
  17273. * @hidden
  17274. */
  17275. _inheritedVelocityOffset: Vector3;
  17276. /**
  17277. * An event triggered when the system is disposed
  17278. */
  17279. onDisposeObservable: Observable<ParticleSystem>;
  17280. private _onDisposeObserver;
  17281. /**
  17282. * Sets a callback that will be triggered when the system is disposed
  17283. */
  17284. onDispose: () => void;
  17285. private _particles;
  17286. private _epsilon;
  17287. private _capacity;
  17288. private _stockParticles;
  17289. private _newPartsExcess;
  17290. private _vertexData;
  17291. private _vertexBuffer;
  17292. private _vertexBuffers;
  17293. private _spriteBuffer;
  17294. private _indexBuffer;
  17295. private _effect;
  17296. private _customEffect;
  17297. private _cachedDefines;
  17298. private _scaledColorStep;
  17299. private _colorDiff;
  17300. private _scaledDirection;
  17301. private _scaledGravity;
  17302. private _currentRenderId;
  17303. private _alive;
  17304. private _useInstancing;
  17305. private _started;
  17306. private _stopped;
  17307. private _actualFrame;
  17308. private _scaledUpdateSpeed;
  17309. private _vertexBufferSize;
  17310. /** @hidden */
  17311. _currentEmitRateGradient: Nullable<FactorGradient>;
  17312. /** @hidden */
  17313. _currentEmitRate1: number;
  17314. /** @hidden */
  17315. _currentEmitRate2: number;
  17316. /** @hidden */
  17317. _currentStartSizeGradient: Nullable<FactorGradient>;
  17318. /** @hidden */
  17319. _currentStartSize1: number;
  17320. /** @hidden */
  17321. _currentStartSize2: number;
  17322. private readonly _rawTextureWidth;
  17323. private _rampGradientsTexture;
  17324. private _useRampGradients;
  17325. /** Gets or sets a boolean indicating that ramp gradients must be used
  17326. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17327. */
  17328. useRampGradients: boolean;
  17329. /**
  17330. * 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.
  17331. * 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: [])
  17332. */
  17333. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17334. private _subEmitters;
  17335. /**
  17336. * @hidden
  17337. * If the particle systems emitter should be disposed when the particle system is disposed
  17338. */
  17339. _disposeEmitterOnDispose: boolean;
  17340. /**
  17341. * The current active Sub-systems, this property is used by the root particle system only.
  17342. */
  17343. activeSubSystems: Array<ParticleSystem>;
  17344. private _rootParticleSystem;
  17345. /**
  17346. * Gets the current list of active particles
  17347. */
  17348. readonly particles: Particle[];
  17349. /**
  17350. * Returns the string "ParticleSystem"
  17351. * @returns a string containing the class name
  17352. */
  17353. getClassName(): string;
  17354. /**
  17355. * Instantiates a particle system.
  17356. * 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.
  17357. * @param name The name of the particle system
  17358. * @param capacity The max number of particles alive at the same time
  17359. * @param scene The scene the particle system belongs to
  17360. * @param customEffect a custom effect used to change the way particles are rendered by default
  17361. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17362. * @param epsilon Offset used to render the particles
  17363. */
  17364. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17365. private _addFactorGradient;
  17366. private _removeFactorGradient;
  17367. /**
  17368. * Adds a new life time gradient
  17369. * @param gradient defines the gradient to use (between 0 and 1)
  17370. * @param factor defines the life time factor to affect to the specified gradient
  17371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17372. * @returns the current particle system
  17373. */
  17374. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17375. /**
  17376. * Remove a specific life time gradient
  17377. * @param gradient defines the gradient to remove
  17378. * @returns the current particle system
  17379. */
  17380. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17381. /**
  17382. * Adds a new size gradient
  17383. * @param gradient defines the gradient to use (between 0 and 1)
  17384. * @param factor defines the size factor to affect to the specified gradient
  17385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17386. * @returns the current particle system
  17387. */
  17388. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17389. /**
  17390. * Remove a specific size gradient
  17391. * @param gradient defines the gradient to remove
  17392. * @returns the current particle system
  17393. */
  17394. removeSizeGradient(gradient: number): IParticleSystem;
  17395. /**
  17396. * Adds a new color remap gradient
  17397. * @param gradient defines the gradient to use (between 0 and 1)
  17398. * @param min defines the color remap minimal range
  17399. * @param max defines the color remap maximal range
  17400. * @returns the current particle system
  17401. */
  17402. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17403. /**
  17404. * Remove a specific color remap gradient
  17405. * @param gradient defines the gradient to remove
  17406. * @returns the current particle system
  17407. */
  17408. removeColorRemapGradient(gradient: number): IParticleSystem;
  17409. /**
  17410. * Adds a new alpha remap gradient
  17411. * @param gradient defines the gradient to use (between 0 and 1)
  17412. * @param min defines the alpha remap minimal range
  17413. * @param max defines the alpha remap maximal range
  17414. * @returns the current particle system
  17415. */
  17416. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17417. /**
  17418. * Remove a specific alpha remap gradient
  17419. * @param gradient defines the gradient to remove
  17420. * @returns the current particle system
  17421. */
  17422. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17423. /**
  17424. * Adds a new angular speed gradient
  17425. * @param gradient defines the gradient to use (between 0 and 1)
  17426. * @param factor defines the angular speed to affect to the specified gradient
  17427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17428. * @returns the current particle system
  17429. */
  17430. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17431. /**
  17432. * Remove a specific angular speed gradient
  17433. * @param gradient defines the gradient to remove
  17434. * @returns the current particle system
  17435. */
  17436. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17437. /**
  17438. * Adds a new velocity gradient
  17439. * @param gradient defines the gradient to use (between 0 and 1)
  17440. * @param factor defines the velocity to affect to the specified gradient
  17441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17442. * @returns the current particle system
  17443. */
  17444. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17445. /**
  17446. * Remove a specific velocity gradient
  17447. * @param gradient defines the gradient to remove
  17448. * @returns the current particle system
  17449. */
  17450. removeVelocityGradient(gradient: number): IParticleSystem;
  17451. /**
  17452. * Adds a new limit velocity gradient
  17453. * @param gradient defines the gradient to use (between 0 and 1)
  17454. * @param factor defines the limit velocity value to affect to the specified gradient
  17455. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17456. * @returns the current particle system
  17457. */
  17458. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17459. /**
  17460. * Remove a specific limit velocity gradient
  17461. * @param gradient defines the gradient to remove
  17462. * @returns the current particle system
  17463. */
  17464. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17465. /**
  17466. * Adds a new drag gradient
  17467. * @param gradient defines the gradient to use (between 0 and 1)
  17468. * @param factor defines the drag value to affect to the specified gradient
  17469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17470. * @returns the current particle system
  17471. */
  17472. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17473. /**
  17474. * Remove a specific drag gradient
  17475. * @param gradient defines the gradient to remove
  17476. * @returns the current particle system
  17477. */
  17478. removeDragGradient(gradient: number): IParticleSystem;
  17479. /**
  17480. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17481. * @param gradient defines the gradient to use (between 0 and 1)
  17482. * @param factor defines the emit rate value to affect to the specified gradient
  17483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17484. * @returns the current particle system
  17485. */
  17486. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17487. /**
  17488. * Remove a specific emit rate gradient
  17489. * @param gradient defines the gradient to remove
  17490. * @returns the current particle system
  17491. */
  17492. removeEmitRateGradient(gradient: number): IParticleSystem;
  17493. /**
  17494. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17495. * @param gradient defines the gradient to use (between 0 and 1)
  17496. * @param factor defines the start size value to affect to the specified gradient
  17497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17498. * @returns the current particle system
  17499. */
  17500. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17501. /**
  17502. * Remove a specific start size gradient
  17503. * @param gradient defines the gradient to remove
  17504. * @returns the current particle system
  17505. */
  17506. removeStartSizeGradient(gradient: number): IParticleSystem;
  17507. private _createRampGradientTexture;
  17508. /**
  17509. * Gets the current list of ramp gradients.
  17510. * You must use addRampGradient and removeRampGradient to udpate this list
  17511. * @returns the list of ramp gradients
  17512. */
  17513. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17514. /**
  17515. * Adds a new ramp gradient used to remap particle colors
  17516. * @param gradient defines the gradient to use (between 0 and 1)
  17517. * @param color defines the color to affect to the specified gradient
  17518. * @returns the current particle system
  17519. */
  17520. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17521. /**
  17522. * Remove a specific ramp gradient
  17523. * @param gradient defines the gradient to remove
  17524. * @returns the current particle system
  17525. */
  17526. removeRampGradient(gradient: number): ParticleSystem;
  17527. /**
  17528. * Adds a new color gradient
  17529. * @param gradient defines the gradient to use (between 0 and 1)
  17530. * @param color1 defines the color to affect to the specified gradient
  17531. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17532. * @returns this particle system
  17533. */
  17534. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17535. /**
  17536. * Remove a specific color gradient
  17537. * @param gradient defines the gradient to remove
  17538. * @returns this particle system
  17539. */
  17540. removeColorGradient(gradient: number): IParticleSystem;
  17541. private _fetchR;
  17542. protected _reset(): void;
  17543. private _resetEffect;
  17544. private _createVertexBuffers;
  17545. private _createIndexBuffer;
  17546. /**
  17547. * Gets the maximum number of particles active at the same time.
  17548. * @returns The max number of active particles.
  17549. */
  17550. getCapacity(): number;
  17551. /**
  17552. * Gets whether there are still active particles in the system.
  17553. * @returns True if it is alive, otherwise false.
  17554. */
  17555. isAlive(): boolean;
  17556. /**
  17557. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17558. * @returns True if it has been started, otherwise false.
  17559. */
  17560. isStarted(): boolean;
  17561. private _prepareSubEmitterInternalArray;
  17562. /**
  17563. * Starts the particle system and begins to emit
  17564. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17565. */
  17566. start(delay?: number): void;
  17567. /**
  17568. * Stops the particle system.
  17569. * @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.
  17570. */
  17571. stop(stopSubEmitters?: boolean): void;
  17572. /**
  17573. * Remove all active particles
  17574. */
  17575. reset(): void;
  17576. /**
  17577. * @hidden (for internal use only)
  17578. */
  17579. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17580. /**
  17581. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17582. * Its lifetime will start back at 0.
  17583. */
  17584. recycleParticle: (particle: Particle) => void;
  17585. private _stopSubEmitters;
  17586. private _createParticle;
  17587. private _removeFromRoot;
  17588. private _emitFromParticle;
  17589. private _update;
  17590. /** @hidden */
  17591. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17592. /** @hidden */
  17593. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17594. /** @hidden */
  17595. private _getEffect;
  17596. /**
  17597. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17598. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17599. */
  17600. animate(preWarmOnly?: boolean): void;
  17601. private _appendParticleVertices;
  17602. /**
  17603. * Rebuilds the particle system.
  17604. */
  17605. rebuild(): void;
  17606. /**
  17607. * Is this system ready to be used/rendered
  17608. * @return true if the system is ready
  17609. */
  17610. isReady(): boolean;
  17611. private _render;
  17612. /**
  17613. * Renders the particle system in its current state.
  17614. * @returns the current number of particles
  17615. */
  17616. render(): number;
  17617. /**
  17618. * Disposes the particle system and free the associated resources
  17619. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17620. */
  17621. dispose(disposeTexture?: boolean): void;
  17622. /**
  17623. * Clones the particle system.
  17624. * @param name The name of the cloned object
  17625. * @param newEmitter The new emitter to use
  17626. * @returns the cloned particle system
  17627. */
  17628. clone(name: string, newEmitter: any): ParticleSystem;
  17629. /**
  17630. * Serializes the particle system to a JSON object.
  17631. * @returns the JSON object
  17632. */
  17633. serialize(): any;
  17634. /** @hidden */
  17635. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17636. /** @hidden */
  17637. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17638. /**
  17639. * Parses a JSON object to create a particle system.
  17640. * @param parsedParticleSystem The JSON object to parse
  17641. * @param scene The scene to create the particle system in
  17642. * @param rootUrl The root url to use to load external dependencies like texture
  17643. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17644. * @returns the Parsed particle system
  17645. */
  17646. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17647. }
  17648. }
  17649. declare module "babylonjs/Particles/particle" {
  17650. import { Nullable } from "babylonjs/types";
  17651. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17652. import { Color4 } from "babylonjs/Maths/math.color";
  17653. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17654. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17655. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17656. /**
  17657. * A particle represents one of the element emitted by a particle system.
  17658. * This is mainly define by its coordinates, direction, velocity and age.
  17659. */
  17660. export class Particle {
  17661. /**
  17662. * The particle system the particle belongs to.
  17663. */
  17664. particleSystem: ParticleSystem;
  17665. private static _Count;
  17666. /**
  17667. * Unique ID of the particle
  17668. */
  17669. id: number;
  17670. /**
  17671. * The world position of the particle in the scene.
  17672. */
  17673. position: Vector3;
  17674. /**
  17675. * The world direction of the particle in the scene.
  17676. */
  17677. direction: Vector3;
  17678. /**
  17679. * The color of the particle.
  17680. */
  17681. color: Color4;
  17682. /**
  17683. * The color change of the particle per step.
  17684. */
  17685. colorStep: Color4;
  17686. /**
  17687. * Defines how long will the life of the particle be.
  17688. */
  17689. lifeTime: number;
  17690. /**
  17691. * The current age of the particle.
  17692. */
  17693. age: number;
  17694. /**
  17695. * The current size of the particle.
  17696. */
  17697. size: number;
  17698. /**
  17699. * The current scale of the particle.
  17700. */
  17701. scale: Vector2;
  17702. /**
  17703. * The current angle of the particle.
  17704. */
  17705. angle: number;
  17706. /**
  17707. * Defines how fast is the angle changing.
  17708. */
  17709. angularSpeed: number;
  17710. /**
  17711. * Defines the cell index used by the particle to be rendered from a sprite.
  17712. */
  17713. cellIndex: number;
  17714. /**
  17715. * The information required to support color remapping
  17716. */
  17717. remapData: Vector4;
  17718. /** @hidden */
  17719. _randomCellOffset?: number;
  17720. /** @hidden */
  17721. _initialDirection: Nullable<Vector3>;
  17722. /** @hidden */
  17723. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17724. /** @hidden */
  17725. _initialStartSpriteCellID: number;
  17726. /** @hidden */
  17727. _initialEndSpriteCellID: number;
  17728. /** @hidden */
  17729. _currentColorGradient: Nullable<ColorGradient>;
  17730. /** @hidden */
  17731. _currentColor1: Color4;
  17732. /** @hidden */
  17733. _currentColor2: Color4;
  17734. /** @hidden */
  17735. _currentSizeGradient: Nullable<FactorGradient>;
  17736. /** @hidden */
  17737. _currentSize1: number;
  17738. /** @hidden */
  17739. _currentSize2: number;
  17740. /** @hidden */
  17741. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17742. /** @hidden */
  17743. _currentAngularSpeed1: number;
  17744. /** @hidden */
  17745. _currentAngularSpeed2: number;
  17746. /** @hidden */
  17747. _currentVelocityGradient: Nullable<FactorGradient>;
  17748. /** @hidden */
  17749. _currentVelocity1: number;
  17750. /** @hidden */
  17751. _currentVelocity2: number;
  17752. /** @hidden */
  17753. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17754. /** @hidden */
  17755. _currentLimitVelocity1: number;
  17756. /** @hidden */
  17757. _currentLimitVelocity2: number;
  17758. /** @hidden */
  17759. _currentDragGradient: Nullable<FactorGradient>;
  17760. /** @hidden */
  17761. _currentDrag1: number;
  17762. /** @hidden */
  17763. _currentDrag2: number;
  17764. /** @hidden */
  17765. _randomNoiseCoordinates1: Vector3;
  17766. /** @hidden */
  17767. _randomNoiseCoordinates2: Vector3;
  17768. /**
  17769. * Creates a new instance Particle
  17770. * @param particleSystem the particle system the particle belongs to
  17771. */
  17772. constructor(
  17773. /**
  17774. * The particle system the particle belongs to.
  17775. */
  17776. particleSystem: ParticleSystem);
  17777. private updateCellInfoFromSystem;
  17778. /**
  17779. * Defines how the sprite cell index is updated for the particle
  17780. */
  17781. updateCellIndex(): void;
  17782. /** @hidden */
  17783. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17784. /** @hidden */
  17785. _inheritParticleInfoToSubEmitters(): void;
  17786. /** @hidden */
  17787. _reset(): void;
  17788. /**
  17789. * Copy the properties of particle to another one.
  17790. * @param other the particle to copy the information to.
  17791. */
  17792. copyTo(other: Particle): void;
  17793. }
  17794. }
  17795. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17796. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17797. import { Effect } from "babylonjs/Materials/effect";
  17798. import { Particle } from "babylonjs/Particles/particle";
  17799. /**
  17800. * Particle emitter represents a volume emitting particles.
  17801. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17802. */
  17803. export interface IParticleEmitterType {
  17804. /**
  17805. * Called by the particle System when the direction is computed for the created particle.
  17806. * @param worldMatrix is the world matrix of the particle system
  17807. * @param directionToUpdate is the direction vector to update with the result
  17808. * @param particle is the particle we are computed the direction for
  17809. */
  17810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17811. /**
  17812. * Called by the particle System when the position is computed for the created particle.
  17813. * @param worldMatrix is the world matrix of the particle system
  17814. * @param positionToUpdate is the position vector to update with the result
  17815. * @param particle is the particle we are computed the position for
  17816. */
  17817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17818. /**
  17819. * Clones the current emitter and returns a copy of it
  17820. * @returns the new emitter
  17821. */
  17822. clone(): IParticleEmitterType;
  17823. /**
  17824. * Called by the GPUParticleSystem to setup the update shader
  17825. * @param effect defines the update shader
  17826. */
  17827. applyToShader(effect: Effect): void;
  17828. /**
  17829. * Returns a string to use to update the GPU particles update shader
  17830. * @returns the effect defines string
  17831. */
  17832. getEffectDefines(): string;
  17833. /**
  17834. * Returns a string representing the class name
  17835. * @returns a string containing the class name
  17836. */
  17837. getClassName(): string;
  17838. /**
  17839. * Serializes the particle system to a JSON object.
  17840. * @returns the JSON object
  17841. */
  17842. serialize(): any;
  17843. /**
  17844. * Parse properties from a JSON object
  17845. * @param serializationObject defines the JSON object
  17846. */
  17847. parse(serializationObject: any): void;
  17848. }
  17849. }
  17850. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17851. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17852. import { Effect } from "babylonjs/Materials/effect";
  17853. import { Particle } from "babylonjs/Particles/particle";
  17854. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17855. /**
  17856. * Particle emitter emitting particles from the inside of a box.
  17857. * It emits the particles randomly between 2 given directions.
  17858. */
  17859. export class BoxParticleEmitter implements IParticleEmitterType {
  17860. /**
  17861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17862. */
  17863. direction1: Vector3;
  17864. /**
  17865. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17866. */
  17867. direction2: Vector3;
  17868. /**
  17869. * 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.
  17870. */
  17871. minEmitBox: Vector3;
  17872. /**
  17873. * 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.
  17874. */
  17875. maxEmitBox: Vector3;
  17876. /**
  17877. * Creates a new instance BoxParticleEmitter
  17878. */
  17879. constructor();
  17880. /**
  17881. * Called by the particle System when the direction is computed for the created particle.
  17882. * @param worldMatrix is the world matrix of the particle system
  17883. * @param directionToUpdate is the direction vector to update with the result
  17884. * @param particle is the particle we are computed the direction for
  17885. */
  17886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17887. /**
  17888. * Called by the particle System when the position is computed for the created particle.
  17889. * @param worldMatrix is the world matrix of the particle system
  17890. * @param positionToUpdate is the position vector to update with the result
  17891. * @param particle is the particle we are computed the position for
  17892. */
  17893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17894. /**
  17895. * Clones the current emitter and returns a copy of it
  17896. * @returns the new emitter
  17897. */
  17898. clone(): BoxParticleEmitter;
  17899. /**
  17900. * Called by the GPUParticleSystem to setup the update shader
  17901. * @param effect defines the update shader
  17902. */
  17903. applyToShader(effect: Effect): void;
  17904. /**
  17905. * Returns a string to use to update the GPU particles update shader
  17906. * @returns a string containng the defines string
  17907. */
  17908. getEffectDefines(): string;
  17909. /**
  17910. * Returns the string "BoxParticleEmitter"
  17911. * @returns a string containing the class name
  17912. */
  17913. getClassName(): string;
  17914. /**
  17915. * Serializes the particle system to a JSON object.
  17916. * @returns the JSON object
  17917. */
  17918. serialize(): any;
  17919. /**
  17920. * Parse properties from a JSON object
  17921. * @param serializationObject defines the JSON object
  17922. */
  17923. parse(serializationObject: any): void;
  17924. }
  17925. }
  17926. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17927. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17928. import { Effect } from "babylonjs/Materials/effect";
  17929. import { Particle } from "babylonjs/Particles/particle";
  17930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17931. /**
  17932. * Particle emitter emitting particles from the inside of a cone.
  17933. * It emits the particles alongside the cone volume from the base to the particle.
  17934. * The emission direction might be randomized.
  17935. */
  17936. export class ConeParticleEmitter implements IParticleEmitterType {
  17937. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17938. directionRandomizer: number;
  17939. private _radius;
  17940. private _angle;
  17941. private _height;
  17942. /**
  17943. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17944. */
  17945. radiusRange: number;
  17946. /**
  17947. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17948. */
  17949. heightRange: number;
  17950. /**
  17951. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17952. */
  17953. emitFromSpawnPointOnly: boolean;
  17954. /**
  17955. * Gets or sets the radius of the emission cone
  17956. */
  17957. radius: number;
  17958. /**
  17959. * Gets or sets the angle of the emission cone
  17960. */
  17961. angle: number;
  17962. private _buildHeight;
  17963. /**
  17964. * Creates a new instance ConeParticleEmitter
  17965. * @param radius the radius of the emission cone (1 by default)
  17966. * @param angle the cone base angle (PI by default)
  17967. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17968. */
  17969. constructor(radius?: number, angle?: number,
  17970. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17971. directionRandomizer?: number);
  17972. /**
  17973. * Called by the particle System when the direction is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param directionToUpdate is the direction vector to update with the result
  17976. * @param particle is the particle we are computed the direction for
  17977. */
  17978. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Called by the particle System when the position is computed for the created particle.
  17981. * @param worldMatrix is the world matrix of the particle system
  17982. * @param positionToUpdate is the position vector to update with the result
  17983. * @param particle is the particle we are computed the position for
  17984. */
  17985. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17986. /**
  17987. * Clones the current emitter and returns a copy of it
  17988. * @returns the new emitter
  17989. */
  17990. clone(): ConeParticleEmitter;
  17991. /**
  17992. * Called by the GPUParticleSystem to setup the update shader
  17993. * @param effect defines the update shader
  17994. */
  17995. applyToShader(effect: Effect): void;
  17996. /**
  17997. * Returns a string to use to update the GPU particles update shader
  17998. * @returns a string containng the defines string
  17999. */
  18000. getEffectDefines(): string;
  18001. /**
  18002. * Returns the string "ConeParticleEmitter"
  18003. * @returns a string containing the class name
  18004. */
  18005. getClassName(): string;
  18006. /**
  18007. * Serializes the particle system to a JSON object.
  18008. * @returns the JSON object
  18009. */
  18010. serialize(): any;
  18011. /**
  18012. * Parse properties from a JSON object
  18013. * @param serializationObject defines the JSON object
  18014. */
  18015. parse(serializationObject: any): void;
  18016. }
  18017. }
  18018. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18019. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18020. import { Effect } from "babylonjs/Materials/effect";
  18021. import { Particle } from "babylonjs/Particles/particle";
  18022. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18023. /**
  18024. * Particle emitter emitting particles from the inside of a cylinder.
  18025. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18026. */
  18027. export class CylinderParticleEmitter implements IParticleEmitterType {
  18028. /**
  18029. * The radius of the emission cylinder.
  18030. */
  18031. radius: number;
  18032. /**
  18033. * The height of the emission cylinder.
  18034. */
  18035. height: number;
  18036. /**
  18037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18038. */
  18039. radiusRange: number;
  18040. /**
  18041. * How much to randomize the particle direction [0-1].
  18042. */
  18043. directionRandomizer: number;
  18044. /**
  18045. * Creates a new instance CylinderParticleEmitter
  18046. * @param radius the radius of the emission cylinder (1 by default)
  18047. * @param height the height of the emission cylinder (1 by default)
  18048. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18049. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18050. */
  18051. constructor(
  18052. /**
  18053. * The radius of the emission cylinder.
  18054. */
  18055. radius?: number,
  18056. /**
  18057. * The height of the emission cylinder.
  18058. */
  18059. height?: number,
  18060. /**
  18061. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18062. */
  18063. radiusRange?: number,
  18064. /**
  18065. * How much to randomize the particle direction [0-1].
  18066. */
  18067. directionRandomizer?: number);
  18068. /**
  18069. * Called by the particle System when the direction is computed for the created particle.
  18070. * @param worldMatrix is the world matrix of the particle system
  18071. * @param directionToUpdate is the direction vector to update with the result
  18072. * @param particle is the particle we are computed the direction for
  18073. */
  18074. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18075. /**
  18076. * Called by the particle System when the position is computed for the created particle.
  18077. * @param worldMatrix is the world matrix of the particle system
  18078. * @param positionToUpdate is the position vector to update with the result
  18079. * @param particle is the particle we are computed the position for
  18080. */
  18081. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18082. /**
  18083. * Clones the current emitter and returns a copy of it
  18084. * @returns the new emitter
  18085. */
  18086. clone(): CylinderParticleEmitter;
  18087. /**
  18088. * Called by the GPUParticleSystem to setup the update shader
  18089. * @param effect defines the update shader
  18090. */
  18091. applyToShader(effect: Effect): void;
  18092. /**
  18093. * Returns a string to use to update the GPU particles update shader
  18094. * @returns a string containng the defines string
  18095. */
  18096. getEffectDefines(): string;
  18097. /**
  18098. * Returns the string "CylinderParticleEmitter"
  18099. * @returns a string containing the class name
  18100. */
  18101. getClassName(): string;
  18102. /**
  18103. * Serializes the particle system to a JSON object.
  18104. * @returns the JSON object
  18105. */
  18106. serialize(): any;
  18107. /**
  18108. * Parse properties from a JSON object
  18109. * @param serializationObject defines the JSON object
  18110. */
  18111. parse(serializationObject: any): void;
  18112. }
  18113. /**
  18114. * Particle emitter emitting particles from the inside of a cylinder.
  18115. * It emits the particles randomly between two vectors.
  18116. */
  18117. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18118. /**
  18119. * The min limit of the emission direction.
  18120. */
  18121. direction1: Vector3;
  18122. /**
  18123. * The max limit of the emission direction.
  18124. */
  18125. direction2: Vector3;
  18126. /**
  18127. * Creates a new instance CylinderDirectedParticleEmitter
  18128. * @param radius the radius of the emission cylinder (1 by default)
  18129. * @param height the height of the emission cylinder (1 by default)
  18130. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18131. * @param direction1 the min limit of the emission direction (up vector by default)
  18132. * @param direction2 the max limit of the emission direction (up vector by default)
  18133. */
  18134. constructor(radius?: number, height?: number, radiusRange?: number,
  18135. /**
  18136. * The min limit of the emission direction.
  18137. */
  18138. direction1?: Vector3,
  18139. /**
  18140. * The max limit of the emission direction.
  18141. */
  18142. direction2?: Vector3);
  18143. /**
  18144. * Called by the particle System when the direction is computed for the created particle.
  18145. * @param worldMatrix is the world matrix of the particle system
  18146. * @param directionToUpdate is the direction vector to update with the result
  18147. * @param particle is the particle we are computed the direction for
  18148. */
  18149. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18150. /**
  18151. * Clones the current emitter and returns a copy of it
  18152. * @returns the new emitter
  18153. */
  18154. clone(): CylinderDirectedParticleEmitter;
  18155. /**
  18156. * Called by the GPUParticleSystem to setup the update shader
  18157. * @param effect defines the update shader
  18158. */
  18159. applyToShader(effect: Effect): void;
  18160. /**
  18161. * Returns a string to use to update the GPU particles update shader
  18162. * @returns a string containng the defines string
  18163. */
  18164. getEffectDefines(): string;
  18165. /**
  18166. * Returns the string "CylinderDirectedParticleEmitter"
  18167. * @returns a string containing the class name
  18168. */
  18169. getClassName(): string;
  18170. /**
  18171. * Serializes the particle system to a JSON object.
  18172. * @returns the JSON object
  18173. */
  18174. serialize(): any;
  18175. /**
  18176. * Parse properties from a JSON object
  18177. * @param serializationObject defines the JSON object
  18178. */
  18179. parse(serializationObject: any): void;
  18180. }
  18181. }
  18182. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18183. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18184. import { Effect } from "babylonjs/Materials/effect";
  18185. import { Particle } from "babylonjs/Particles/particle";
  18186. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18187. /**
  18188. * Particle emitter emitting particles from the inside of a hemisphere.
  18189. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18190. */
  18191. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18192. /**
  18193. * The radius of the emission hemisphere.
  18194. */
  18195. radius: number;
  18196. /**
  18197. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18198. */
  18199. radiusRange: number;
  18200. /**
  18201. * How much to randomize the particle direction [0-1].
  18202. */
  18203. directionRandomizer: number;
  18204. /**
  18205. * Creates a new instance HemisphericParticleEmitter
  18206. * @param radius the radius of the emission hemisphere (1 by default)
  18207. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18208. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18209. */
  18210. constructor(
  18211. /**
  18212. * The radius of the emission hemisphere.
  18213. */
  18214. radius?: number,
  18215. /**
  18216. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18217. */
  18218. radiusRange?: number,
  18219. /**
  18220. * How much to randomize the particle direction [0-1].
  18221. */
  18222. directionRandomizer?: number);
  18223. /**
  18224. * Called by the particle System when the direction is computed for the created particle.
  18225. * @param worldMatrix is the world matrix of the particle system
  18226. * @param directionToUpdate is the direction vector to update with the result
  18227. * @param particle is the particle we are computed the direction for
  18228. */
  18229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18230. /**
  18231. * Called by the particle System when the position is computed for the created particle.
  18232. * @param worldMatrix is the world matrix of the particle system
  18233. * @param positionToUpdate is the position vector to update with the result
  18234. * @param particle is the particle we are computed the position for
  18235. */
  18236. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18237. /**
  18238. * Clones the current emitter and returns a copy of it
  18239. * @returns the new emitter
  18240. */
  18241. clone(): HemisphericParticleEmitter;
  18242. /**
  18243. * Called by the GPUParticleSystem to setup the update shader
  18244. * @param effect defines the update shader
  18245. */
  18246. applyToShader(effect: Effect): void;
  18247. /**
  18248. * Returns a string to use to update the GPU particles update shader
  18249. * @returns a string containng the defines string
  18250. */
  18251. getEffectDefines(): string;
  18252. /**
  18253. * Returns the string "HemisphericParticleEmitter"
  18254. * @returns a string containing the class name
  18255. */
  18256. getClassName(): string;
  18257. /**
  18258. * Serializes the particle system to a JSON object.
  18259. * @returns the JSON object
  18260. */
  18261. serialize(): any;
  18262. /**
  18263. * Parse properties from a JSON object
  18264. * @param serializationObject defines the JSON object
  18265. */
  18266. parse(serializationObject: any): void;
  18267. }
  18268. }
  18269. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18270. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18271. import { Effect } from "babylonjs/Materials/effect";
  18272. import { Particle } from "babylonjs/Particles/particle";
  18273. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18274. /**
  18275. * Particle emitter emitting particles from a point.
  18276. * It emits the particles randomly between 2 given directions.
  18277. */
  18278. export class PointParticleEmitter implements IParticleEmitterType {
  18279. /**
  18280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18281. */
  18282. direction1: Vector3;
  18283. /**
  18284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18285. */
  18286. direction2: Vector3;
  18287. /**
  18288. * Creates a new instance PointParticleEmitter
  18289. */
  18290. constructor();
  18291. /**
  18292. * Called by the particle System when the direction is computed for the created particle.
  18293. * @param worldMatrix is the world matrix of the particle system
  18294. * @param directionToUpdate is the direction vector to update with the result
  18295. * @param particle is the particle we are computed the direction for
  18296. */
  18297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18298. /**
  18299. * Called by the particle System when the position is computed for the created particle.
  18300. * @param worldMatrix is the world matrix of the particle system
  18301. * @param positionToUpdate is the position vector to update with the result
  18302. * @param particle is the particle we are computed the position for
  18303. */
  18304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18305. /**
  18306. * Clones the current emitter and returns a copy of it
  18307. * @returns the new emitter
  18308. */
  18309. clone(): PointParticleEmitter;
  18310. /**
  18311. * Called by the GPUParticleSystem to setup the update shader
  18312. * @param effect defines the update shader
  18313. */
  18314. applyToShader(effect: Effect): void;
  18315. /**
  18316. * Returns a string to use to update the GPU particles update shader
  18317. * @returns a string containng the defines string
  18318. */
  18319. getEffectDefines(): string;
  18320. /**
  18321. * Returns the string "PointParticleEmitter"
  18322. * @returns a string containing the class name
  18323. */
  18324. getClassName(): string;
  18325. /**
  18326. * Serializes the particle system to a JSON object.
  18327. * @returns the JSON object
  18328. */
  18329. serialize(): any;
  18330. /**
  18331. * Parse properties from a JSON object
  18332. * @param serializationObject defines the JSON object
  18333. */
  18334. parse(serializationObject: any): void;
  18335. }
  18336. }
  18337. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18338. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18339. import { Effect } from "babylonjs/Materials/effect";
  18340. import { Particle } from "babylonjs/Particles/particle";
  18341. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18342. /**
  18343. * Particle emitter emitting particles from the inside of a sphere.
  18344. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18345. */
  18346. export class SphereParticleEmitter implements IParticleEmitterType {
  18347. /**
  18348. * The radius of the emission sphere.
  18349. */
  18350. radius: number;
  18351. /**
  18352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18353. */
  18354. radiusRange: number;
  18355. /**
  18356. * How much to randomize the particle direction [0-1].
  18357. */
  18358. directionRandomizer: number;
  18359. /**
  18360. * Creates a new instance SphereParticleEmitter
  18361. * @param radius the radius of the emission sphere (1 by default)
  18362. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18363. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18364. */
  18365. constructor(
  18366. /**
  18367. * The radius of the emission sphere.
  18368. */
  18369. radius?: number,
  18370. /**
  18371. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18372. */
  18373. radiusRange?: number,
  18374. /**
  18375. * How much to randomize the particle direction [0-1].
  18376. */
  18377. directionRandomizer?: number);
  18378. /**
  18379. * Called by the particle System when the direction is computed for the created particle.
  18380. * @param worldMatrix is the world matrix of the particle system
  18381. * @param directionToUpdate is the direction vector to update with the result
  18382. * @param particle is the particle we are computed the direction for
  18383. */
  18384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18385. /**
  18386. * Called by the particle System when the position is computed for the created particle.
  18387. * @param worldMatrix is the world matrix of the particle system
  18388. * @param positionToUpdate is the position vector to update with the result
  18389. * @param particle is the particle we are computed the position for
  18390. */
  18391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18392. /**
  18393. * Clones the current emitter and returns a copy of it
  18394. * @returns the new emitter
  18395. */
  18396. clone(): SphereParticleEmitter;
  18397. /**
  18398. * Called by the GPUParticleSystem to setup the update shader
  18399. * @param effect defines the update shader
  18400. */
  18401. applyToShader(effect: Effect): void;
  18402. /**
  18403. * Returns a string to use to update the GPU particles update shader
  18404. * @returns a string containng the defines string
  18405. */
  18406. getEffectDefines(): string;
  18407. /**
  18408. * Returns the string "SphereParticleEmitter"
  18409. * @returns a string containing the class name
  18410. */
  18411. getClassName(): string;
  18412. /**
  18413. * Serializes the particle system to a JSON object.
  18414. * @returns the JSON object
  18415. */
  18416. serialize(): any;
  18417. /**
  18418. * Parse properties from a JSON object
  18419. * @param serializationObject defines the JSON object
  18420. */
  18421. parse(serializationObject: any): void;
  18422. }
  18423. /**
  18424. * Particle emitter emitting particles from the inside of a sphere.
  18425. * It emits the particles randomly between two vectors.
  18426. */
  18427. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18428. /**
  18429. * The min limit of the emission direction.
  18430. */
  18431. direction1: Vector3;
  18432. /**
  18433. * The max limit of the emission direction.
  18434. */
  18435. direction2: Vector3;
  18436. /**
  18437. * Creates a new instance SphereDirectedParticleEmitter
  18438. * @param radius the radius of the emission sphere (1 by default)
  18439. * @param direction1 the min limit of the emission direction (up vector by default)
  18440. * @param direction2 the max limit of the emission direction (up vector by default)
  18441. */
  18442. constructor(radius?: number,
  18443. /**
  18444. * The min limit of the emission direction.
  18445. */
  18446. direction1?: Vector3,
  18447. /**
  18448. * The max limit of the emission direction.
  18449. */
  18450. direction2?: Vector3);
  18451. /**
  18452. * Called by the particle System when the direction is computed for the created particle.
  18453. * @param worldMatrix is the world matrix of the particle system
  18454. * @param directionToUpdate is the direction vector to update with the result
  18455. * @param particle is the particle we are computed the direction for
  18456. */
  18457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18458. /**
  18459. * Clones the current emitter and returns a copy of it
  18460. * @returns the new emitter
  18461. */
  18462. clone(): SphereDirectedParticleEmitter;
  18463. /**
  18464. * Called by the GPUParticleSystem to setup the update shader
  18465. * @param effect defines the update shader
  18466. */
  18467. applyToShader(effect: Effect): void;
  18468. /**
  18469. * Returns a string to use to update the GPU particles update shader
  18470. * @returns a string containng the defines string
  18471. */
  18472. getEffectDefines(): string;
  18473. /**
  18474. * Returns the string "SphereDirectedParticleEmitter"
  18475. * @returns a string containing the class name
  18476. */
  18477. getClassName(): string;
  18478. /**
  18479. * Serializes the particle system to a JSON object.
  18480. * @returns the JSON object
  18481. */
  18482. serialize(): any;
  18483. /**
  18484. * Parse properties from a JSON object
  18485. * @param serializationObject defines the JSON object
  18486. */
  18487. parse(serializationObject: any): void;
  18488. }
  18489. }
  18490. declare module "babylonjs/Particles/EmitterTypes/index" {
  18491. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18492. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18493. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18494. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18495. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18496. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18497. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18498. }
  18499. declare module "babylonjs/Particles/IParticleSystem" {
  18500. import { Nullable } from "babylonjs/types";
  18501. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18502. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18505. import { Texture } from "babylonjs/Materials/Textures/texture";
  18506. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18507. import { Scene } from "babylonjs/scene";
  18508. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18509. import { Animation } from "babylonjs/Animations/animation";
  18510. /**
  18511. * Interface representing a particle system in Babylon.js.
  18512. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18513. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18514. */
  18515. export interface IParticleSystem {
  18516. /**
  18517. * List of animations used by the particle system.
  18518. */
  18519. animations: Animation[];
  18520. /**
  18521. * The id of the Particle system.
  18522. */
  18523. id: string;
  18524. /**
  18525. * The name of the Particle system.
  18526. */
  18527. name: string;
  18528. /**
  18529. * The emitter represents the Mesh or position we are attaching the particle system to.
  18530. */
  18531. emitter: Nullable<AbstractMesh | Vector3>;
  18532. /**
  18533. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18534. */
  18535. isBillboardBased: boolean;
  18536. /**
  18537. * The rendering group used by the Particle system to chose when to render.
  18538. */
  18539. renderingGroupId: number;
  18540. /**
  18541. * The layer mask we are rendering the particles through.
  18542. */
  18543. layerMask: number;
  18544. /**
  18545. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18546. */
  18547. updateSpeed: number;
  18548. /**
  18549. * The amount of time the particle system is running (depends of the overall update speed).
  18550. */
  18551. targetStopDuration: number;
  18552. /**
  18553. * The texture used to render each particle. (this can be a spritesheet)
  18554. */
  18555. particleTexture: Nullable<Texture>;
  18556. /**
  18557. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18558. */
  18559. blendMode: number;
  18560. /**
  18561. * Minimum life time of emitting particles.
  18562. */
  18563. minLifeTime: number;
  18564. /**
  18565. * Maximum life time of emitting particles.
  18566. */
  18567. maxLifeTime: number;
  18568. /**
  18569. * Minimum Size of emitting particles.
  18570. */
  18571. minSize: number;
  18572. /**
  18573. * Maximum Size of emitting particles.
  18574. */
  18575. maxSize: number;
  18576. /**
  18577. * Minimum scale of emitting particles on X axis.
  18578. */
  18579. minScaleX: number;
  18580. /**
  18581. * Maximum scale of emitting particles on X axis.
  18582. */
  18583. maxScaleX: number;
  18584. /**
  18585. * Minimum scale of emitting particles on Y axis.
  18586. */
  18587. minScaleY: number;
  18588. /**
  18589. * Maximum scale of emitting particles on Y axis.
  18590. */
  18591. maxScaleY: number;
  18592. /**
  18593. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18594. */
  18595. color1: Color4;
  18596. /**
  18597. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18598. */
  18599. color2: Color4;
  18600. /**
  18601. * Color the particle will have at the end of its lifetime.
  18602. */
  18603. colorDead: Color4;
  18604. /**
  18605. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18606. */
  18607. emitRate: number;
  18608. /**
  18609. * You can use gravity if you want to give an orientation to your particles.
  18610. */
  18611. gravity: Vector3;
  18612. /**
  18613. * Minimum power of emitting particles.
  18614. */
  18615. minEmitPower: number;
  18616. /**
  18617. * Maximum power of emitting particles.
  18618. */
  18619. maxEmitPower: number;
  18620. /**
  18621. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18622. */
  18623. minAngularSpeed: number;
  18624. /**
  18625. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18626. */
  18627. maxAngularSpeed: number;
  18628. /**
  18629. * Gets or sets the minimal initial rotation in radians.
  18630. */
  18631. minInitialRotation: number;
  18632. /**
  18633. * Gets or sets the maximal initial rotation in radians.
  18634. */
  18635. maxInitialRotation: number;
  18636. /**
  18637. * The particle emitter type defines the emitter used by the particle system.
  18638. * It can be for example box, sphere, or cone...
  18639. */
  18640. particleEmitterType: Nullable<IParticleEmitterType>;
  18641. /**
  18642. * Defines the delay in milliseconds before starting the system (0 by default)
  18643. */
  18644. startDelay: number;
  18645. /**
  18646. * 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
  18647. */
  18648. preWarmCycles: number;
  18649. /**
  18650. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18651. */
  18652. preWarmStepOffset: number;
  18653. /**
  18654. * 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)
  18655. */
  18656. spriteCellChangeSpeed: number;
  18657. /**
  18658. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18659. */
  18660. startSpriteCellID: number;
  18661. /**
  18662. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18663. */
  18664. endSpriteCellID: number;
  18665. /**
  18666. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18667. */
  18668. spriteCellWidth: number;
  18669. /**
  18670. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18671. */
  18672. spriteCellHeight: number;
  18673. /**
  18674. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18675. */
  18676. spriteRandomStartCell: boolean;
  18677. /**
  18678. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18679. */
  18680. isAnimationSheetEnabled: boolean;
  18681. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18682. translationPivot: Vector2;
  18683. /**
  18684. * Gets or sets a texture used to add random noise to particle positions
  18685. */
  18686. noiseTexture: Nullable<BaseTexture>;
  18687. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18688. noiseStrength: Vector3;
  18689. /**
  18690. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18691. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18692. */
  18693. billboardMode: number;
  18694. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18695. limitVelocityDamping: number;
  18696. /**
  18697. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18698. */
  18699. beginAnimationOnStart: boolean;
  18700. /**
  18701. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18702. */
  18703. beginAnimationFrom: number;
  18704. /**
  18705. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18706. */
  18707. beginAnimationTo: number;
  18708. /**
  18709. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18710. */
  18711. beginAnimationLoop: boolean;
  18712. /**
  18713. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18714. */
  18715. disposeOnStop: boolean;
  18716. /**
  18717. * Gets the maximum number of particles active at the same time.
  18718. * @returns The max number of active particles.
  18719. */
  18720. getCapacity(): number;
  18721. /**
  18722. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18723. * @returns True if it has been started, otherwise false.
  18724. */
  18725. isStarted(): boolean;
  18726. /**
  18727. * Animates the particle system for this frame.
  18728. */
  18729. animate(): void;
  18730. /**
  18731. * Renders the particle system in its current state.
  18732. * @returns the current number of particles
  18733. */
  18734. render(): number;
  18735. /**
  18736. * Dispose the particle system and frees its associated resources.
  18737. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18738. */
  18739. dispose(disposeTexture?: boolean): void;
  18740. /**
  18741. * Clones the particle system.
  18742. * @param name The name of the cloned object
  18743. * @param newEmitter The new emitter to use
  18744. * @returns the cloned particle system
  18745. */
  18746. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18747. /**
  18748. * Serializes the particle system to a JSON object.
  18749. * @returns the JSON object
  18750. */
  18751. serialize(): any;
  18752. /**
  18753. * Rebuild the particle system
  18754. */
  18755. rebuild(): void;
  18756. /**
  18757. * Starts the particle system and begins to emit
  18758. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18759. */
  18760. start(delay?: number): void;
  18761. /**
  18762. * Stops the particle system.
  18763. */
  18764. stop(): void;
  18765. /**
  18766. * Remove all active particles
  18767. */
  18768. reset(): void;
  18769. /**
  18770. * Is this system ready to be used/rendered
  18771. * @return true if the system is ready
  18772. */
  18773. isReady(): boolean;
  18774. /**
  18775. * Adds a new color gradient
  18776. * @param gradient defines the gradient to use (between 0 and 1)
  18777. * @param color1 defines the color to affect to the specified gradient
  18778. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18779. * @returns the current particle system
  18780. */
  18781. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18782. /**
  18783. * Remove a specific color gradient
  18784. * @param gradient defines the gradient to remove
  18785. * @returns the current particle system
  18786. */
  18787. removeColorGradient(gradient: number): IParticleSystem;
  18788. /**
  18789. * Adds a new size gradient
  18790. * @param gradient defines the gradient to use (between 0 and 1)
  18791. * @param factor defines the size factor to affect to the specified gradient
  18792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18793. * @returns the current particle system
  18794. */
  18795. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18796. /**
  18797. * Remove a specific size gradient
  18798. * @param gradient defines the gradient to remove
  18799. * @returns the current particle system
  18800. */
  18801. removeSizeGradient(gradient: number): IParticleSystem;
  18802. /**
  18803. * Gets the current list of color gradients.
  18804. * You must use addColorGradient and removeColorGradient to udpate this list
  18805. * @returns the list of color gradients
  18806. */
  18807. getColorGradients(): Nullable<Array<ColorGradient>>;
  18808. /**
  18809. * Gets the current list of size gradients.
  18810. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18811. * @returns the list of size gradients
  18812. */
  18813. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18814. /**
  18815. * Gets the current list of angular speed gradients.
  18816. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18817. * @returns the list of angular speed gradients
  18818. */
  18819. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18820. /**
  18821. * Adds a new angular speed gradient
  18822. * @param gradient defines the gradient to use (between 0 and 1)
  18823. * @param factor defines the angular speed to affect to the specified gradient
  18824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18825. * @returns the current particle system
  18826. */
  18827. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18828. /**
  18829. * Remove a specific angular speed gradient
  18830. * @param gradient defines the gradient to remove
  18831. * @returns the current particle system
  18832. */
  18833. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18834. /**
  18835. * Gets the current list of velocity gradients.
  18836. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18837. * @returns the list of velocity gradients
  18838. */
  18839. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18840. /**
  18841. * Adds a new velocity gradient
  18842. * @param gradient defines the gradient to use (between 0 and 1)
  18843. * @param factor defines the velocity to affect to the specified gradient
  18844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18845. * @returns the current particle system
  18846. */
  18847. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18848. /**
  18849. * Remove a specific velocity gradient
  18850. * @param gradient defines the gradient to remove
  18851. * @returns the current particle system
  18852. */
  18853. removeVelocityGradient(gradient: number): IParticleSystem;
  18854. /**
  18855. * Gets the current list of limit velocity gradients.
  18856. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18857. * @returns the list of limit velocity gradients
  18858. */
  18859. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18860. /**
  18861. * Adds a new limit velocity gradient
  18862. * @param gradient defines the gradient to use (between 0 and 1)
  18863. * @param factor defines the limit velocity to affect to the specified gradient
  18864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18865. * @returns the current particle system
  18866. */
  18867. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18868. /**
  18869. * Remove a specific limit velocity gradient
  18870. * @param gradient defines the gradient to remove
  18871. * @returns the current particle system
  18872. */
  18873. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18874. /**
  18875. * Adds a new drag gradient
  18876. * @param gradient defines the gradient to use (between 0 and 1)
  18877. * @param factor defines the drag to affect to the specified gradient
  18878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18879. * @returns the current particle system
  18880. */
  18881. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18882. /**
  18883. * Remove a specific drag gradient
  18884. * @param gradient defines the gradient to remove
  18885. * @returns the current particle system
  18886. */
  18887. removeDragGradient(gradient: number): IParticleSystem;
  18888. /**
  18889. * Gets the current list of drag gradients.
  18890. * You must use addDragGradient and removeDragGradient to udpate this list
  18891. * @returns the list of drag gradients
  18892. */
  18893. getDragGradients(): Nullable<Array<FactorGradient>>;
  18894. /**
  18895. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18896. * @param gradient defines the gradient to use (between 0 and 1)
  18897. * @param factor defines the emit rate to affect to the specified gradient
  18898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18899. * @returns the current particle system
  18900. */
  18901. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18902. /**
  18903. * Remove a specific emit rate gradient
  18904. * @param gradient defines the gradient to remove
  18905. * @returns the current particle system
  18906. */
  18907. removeEmitRateGradient(gradient: number): IParticleSystem;
  18908. /**
  18909. * Gets the current list of emit rate gradients.
  18910. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18911. * @returns the list of emit rate gradients
  18912. */
  18913. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18914. /**
  18915. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18916. * @param gradient defines the gradient to use (between 0 and 1)
  18917. * @param factor defines the start size to affect to the specified gradient
  18918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18919. * @returns the current particle system
  18920. */
  18921. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18922. /**
  18923. * Remove a specific start size gradient
  18924. * @param gradient defines the gradient to remove
  18925. * @returns the current particle system
  18926. */
  18927. removeStartSizeGradient(gradient: number): IParticleSystem;
  18928. /**
  18929. * Gets the current list of start size gradients.
  18930. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18931. * @returns the list of start size gradients
  18932. */
  18933. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18934. /**
  18935. * Adds a new life time gradient
  18936. * @param gradient defines the gradient to use (between 0 and 1)
  18937. * @param factor defines the life time factor to affect to the specified gradient
  18938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18939. * @returns the current particle system
  18940. */
  18941. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18942. /**
  18943. * Remove a specific life time gradient
  18944. * @param gradient defines the gradient to remove
  18945. * @returns the current particle system
  18946. */
  18947. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18948. /**
  18949. * Gets the current list of life time gradients.
  18950. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18951. * @returns the list of life time gradients
  18952. */
  18953. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18954. /**
  18955. * Gets the current list of color gradients.
  18956. * You must use addColorGradient and removeColorGradient to udpate this list
  18957. * @returns the list of color gradients
  18958. */
  18959. getColorGradients(): Nullable<Array<ColorGradient>>;
  18960. /**
  18961. * Adds a new ramp gradient used to remap particle colors
  18962. * @param gradient defines the gradient to use (between 0 and 1)
  18963. * @param color defines the color to affect to the specified gradient
  18964. * @returns the current particle system
  18965. */
  18966. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18967. /**
  18968. * Gets the current list of ramp gradients.
  18969. * You must use addRampGradient and removeRampGradient to udpate this list
  18970. * @returns the list of ramp gradients
  18971. */
  18972. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18973. /** Gets or sets a boolean indicating that ramp gradients must be used
  18974. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18975. */
  18976. useRampGradients: boolean;
  18977. /**
  18978. * Adds a new color remap gradient
  18979. * @param gradient defines the gradient to use (between 0 and 1)
  18980. * @param min defines the color remap minimal range
  18981. * @param max defines the color remap maximal range
  18982. * @returns the current particle system
  18983. */
  18984. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18985. /**
  18986. * Gets the current list of color remap gradients.
  18987. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18988. * @returns the list of color remap gradients
  18989. */
  18990. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18991. /**
  18992. * Adds a new alpha remap gradient
  18993. * @param gradient defines the gradient to use (between 0 and 1)
  18994. * @param min defines the alpha remap minimal range
  18995. * @param max defines the alpha remap maximal range
  18996. * @returns the current particle system
  18997. */
  18998. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18999. /**
  19000. * Gets the current list of alpha remap gradients.
  19001. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19002. * @returns the list of alpha remap gradients
  19003. */
  19004. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19007. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19008. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19009. * @returns the emitter
  19010. */
  19011. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19012. /**
  19013. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19014. * @param radius The radius of the hemisphere to emit from
  19015. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19016. * @returns the emitter
  19017. */
  19018. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19019. /**
  19020. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19021. * @param radius The radius of the sphere to emit from
  19022. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19023. * @returns the emitter
  19024. */
  19025. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19026. /**
  19027. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19028. * @param radius The radius of the sphere to emit from
  19029. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19030. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19031. * @returns the emitter
  19032. */
  19033. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19034. /**
  19035. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19036. * @param radius The radius of the emission cylinder
  19037. * @param height The height of the emission cylinder
  19038. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19039. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19040. * @returns the emitter
  19041. */
  19042. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19043. /**
  19044. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19045. * @param radius The radius of the cylinder to emit from
  19046. * @param height The height of the emission cylinder
  19047. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19048. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19049. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19050. * @returns the emitter
  19051. */
  19052. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19053. /**
  19054. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19055. * @param radius The radius of the cone to emit from
  19056. * @param angle The base angle of the cone
  19057. * @returns the emitter
  19058. */
  19059. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19060. /**
  19061. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19062. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19063. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19064. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19065. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19066. * @returns the emitter
  19067. */
  19068. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19069. /**
  19070. * Get hosting scene
  19071. * @returns the scene
  19072. */
  19073. getScene(): Scene;
  19074. }
  19075. }
  19076. declare module "babylonjs/Meshes/instancedMesh" {
  19077. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19078. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19079. import { Camera } from "babylonjs/Cameras/camera";
  19080. import { Node } from "babylonjs/node";
  19081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19082. import { Mesh } from "babylonjs/Meshes/mesh";
  19083. import { Material } from "babylonjs/Materials/material";
  19084. import { Skeleton } from "babylonjs/Bones/skeleton";
  19085. import { Light } from "babylonjs/Lights/light";
  19086. /**
  19087. * Creates an instance based on a source mesh.
  19088. */
  19089. export class InstancedMesh extends AbstractMesh {
  19090. private _sourceMesh;
  19091. private _currentLOD;
  19092. /** @hidden */
  19093. _indexInSourceMeshInstanceArray: number;
  19094. constructor(name: string, source: Mesh);
  19095. /**
  19096. * Returns the string "InstancedMesh".
  19097. */
  19098. getClassName(): string;
  19099. /** Gets the list of lights affecting that mesh */
  19100. readonly lightSources: Light[];
  19101. _resyncLightSources(): void;
  19102. _resyncLighSource(light: Light): void;
  19103. _removeLightSource(light: Light, dispose: boolean): void;
  19104. /**
  19105. * If the source mesh receives shadows
  19106. */
  19107. readonly receiveShadows: boolean;
  19108. /**
  19109. * The material of the source mesh
  19110. */
  19111. readonly material: Nullable<Material>;
  19112. /**
  19113. * Visibility of the source mesh
  19114. */
  19115. readonly visibility: number;
  19116. /**
  19117. * Skeleton of the source mesh
  19118. */
  19119. readonly skeleton: Nullable<Skeleton>;
  19120. /**
  19121. * Rendering ground id of the source mesh
  19122. */
  19123. renderingGroupId: number;
  19124. /**
  19125. * Returns the total number of vertices (integer).
  19126. */
  19127. getTotalVertices(): number;
  19128. /**
  19129. * Returns a positive integer : the total number of indices in this mesh geometry.
  19130. * @returns the numner of indices or zero if the mesh has no geometry.
  19131. */
  19132. getTotalIndices(): number;
  19133. /**
  19134. * The source mesh of the instance
  19135. */
  19136. readonly sourceMesh: Mesh;
  19137. /**
  19138. * Is this node ready to be used/rendered
  19139. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19140. * @return {boolean} is it ready
  19141. */
  19142. isReady(completeCheck?: boolean): boolean;
  19143. /**
  19144. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19145. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19146. * @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.
  19147. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19148. */
  19149. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19150. /**
  19151. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19152. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19153. * The `data` are either a numeric array either a Float32Array.
  19154. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19155. * 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).
  19156. * Note that a new underlying VertexBuffer object is created each call.
  19157. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19158. *
  19159. * Possible `kind` values :
  19160. * - VertexBuffer.PositionKind
  19161. * - VertexBuffer.UVKind
  19162. * - VertexBuffer.UV2Kind
  19163. * - VertexBuffer.UV3Kind
  19164. * - VertexBuffer.UV4Kind
  19165. * - VertexBuffer.UV5Kind
  19166. * - VertexBuffer.UV6Kind
  19167. * - VertexBuffer.ColorKind
  19168. * - VertexBuffer.MatricesIndicesKind
  19169. * - VertexBuffer.MatricesIndicesExtraKind
  19170. * - VertexBuffer.MatricesWeightsKind
  19171. * - VertexBuffer.MatricesWeightsExtraKind
  19172. *
  19173. * Returns the Mesh.
  19174. */
  19175. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19176. /**
  19177. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19178. * If the mesh has no geometry, it is simply returned as it is.
  19179. * The `data` are either a numeric array either a Float32Array.
  19180. * No new underlying VertexBuffer object is created.
  19181. * 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.
  19182. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19183. *
  19184. * Possible `kind` values :
  19185. * - VertexBuffer.PositionKind
  19186. * - VertexBuffer.UVKind
  19187. * - VertexBuffer.UV2Kind
  19188. * - VertexBuffer.UV3Kind
  19189. * - VertexBuffer.UV4Kind
  19190. * - VertexBuffer.UV5Kind
  19191. * - VertexBuffer.UV6Kind
  19192. * - VertexBuffer.ColorKind
  19193. * - VertexBuffer.MatricesIndicesKind
  19194. * - VertexBuffer.MatricesIndicesExtraKind
  19195. * - VertexBuffer.MatricesWeightsKind
  19196. * - VertexBuffer.MatricesWeightsExtraKind
  19197. *
  19198. * Returns the Mesh.
  19199. */
  19200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19201. /**
  19202. * Sets the mesh indices.
  19203. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19204. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19205. * This method creates a new index buffer each call.
  19206. * Returns the Mesh.
  19207. */
  19208. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19209. /**
  19210. * Boolean : True if the mesh owns the requested kind of data.
  19211. */
  19212. isVerticesDataPresent(kind: string): boolean;
  19213. /**
  19214. * Returns an array of indices (IndicesArray).
  19215. */
  19216. getIndices(): Nullable<IndicesArray>;
  19217. readonly _positions: Nullable<Vector3[]>;
  19218. /**
  19219. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19220. * This means the mesh underlying bounding box and sphere are recomputed.
  19221. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19222. * @returns the current mesh
  19223. */
  19224. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19225. /** @hidden */
  19226. _preActivate(): InstancedMesh;
  19227. /** @hidden */
  19228. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19229. /** @hidden */
  19230. _postActivate(): void;
  19231. getWorldMatrix(): Matrix;
  19232. readonly isAnInstance: boolean;
  19233. /**
  19234. * Returns the current associated LOD AbstractMesh.
  19235. */
  19236. getLOD(camera: Camera): AbstractMesh;
  19237. /** @hidden */
  19238. _syncSubMeshes(): InstancedMesh;
  19239. /** @hidden */
  19240. _generatePointsArray(): boolean;
  19241. /**
  19242. * Creates a new InstancedMesh from the current mesh.
  19243. * - name (string) : the cloned mesh name
  19244. * - newParent (optional Node) : the optional Node to parent the clone to.
  19245. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19246. *
  19247. * Returns the clone.
  19248. */
  19249. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19250. /**
  19251. * Disposes the InstancedMesh.
  19252. * Returns nothing.
  19253. */
  19254. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19255. }
  19256. }
  19257. declare module "babylonjs/Materials/shaderMaterial" {
  19258. import { Scene } from "babylonjs/scene";
  19259. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19261. import { Mesh } from "babylonjs/Meshes/mesh";
  19262. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19264. import { Texture } from "babylonjs/Materials/Textures/texture";
  19265. import { Material } from "babylonjs/Materials/material";
  19266. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19267. /**
  19268. * Defines the options associated with the creation of a shader material.
  19269. */
  19270. export interface IShaderMaterialOptions {
  19271. /**
  19272. * Does the material work in alpha blend mode
  19273. */
  19274. needAlphaBlending: boolean;
  19275. /**
  19276. * Does the material work in alpha test mode
  19277. */
  19278. needAlphaTesting: boolean;
  19279. /**
  19280. * The list of attribute names used in the shader
  19281. */
  19282. attributes: string[];
  19283. /**
  19284. * The list of unifrom names used in the shader
  19285. */
  19286. uniforms: string[];
  19287. /**
  19288. * The list of UBO names used in the shader
  19289. */
  19290. uniformBuffers: string[];
  19291. /**
  19292. * The list of sampler names used in the shader
  19293. */
  19294. samplers: string[];
  19295. /**
  19296. * The list of defines used in the shader
  19297. */
  19298. defines: string[];
  19299. }
  19300. /**
  19301. * 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.
  19302. *
  19303. * This returned material effects how the mesh will look based on the code in the shaders.
  19304. *
  19305. * @see http://doc.babylonjs.com/how_to/shader_material
  19306. */
  19307. export class ShaderMaterial extends Material {
  19308. private _shaderPath;
  19309. private _options;
  19310. private _textures;
  19311. private _textureArrays;
  19312. private _floats;
  19313. private _ints;
  19314. private _floatsArrays;
  19315. private _colors3;
  19316. private _colors3Arrays;
  19317. private _colors4;
  19318. private _colors4Arrays;
  19319. private _vectors2;
  19320. private _vectors3;
  19321. private _vectors4;
  19322. private _matrices;
  19323. private _matrices3x3;
  19324. private _matrices2x2;
  19325. private _vectors2Arrays;
  19326. private _vectors3Arrays;
  19327. private _vectors4Arrays;
  19328. private _cachedWorldViewMatrix;
  19329. private _cachedWorldViewProjectionMatrix;
  19330. private _renderId;
  19331. /**
  19332. * Instantiate a new shader material.
  19333. * 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.
  19334. * This returned material effects how the mesh will look based on the code in the shaders.
  19335. * @see http://doc.babylonjs.com/how_to/shader_material
  19336. * @param name Define the name of the material in the scene
  19337. * @param scene Define the scene the material belongs to
  19338. * @param shaderPath Defines the route to the shader code in one of three ways:
  19339. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19340. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19341. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19342. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19343. * @param options Define the options used to create the shader
  19344. */
  19345. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19346. /**
  19347. * Gets the options used to compile the shader.
  19348. * They can be modified to trigger a new compilation
  19349. */
  19350. readonly options: IShaderMaterialOptions;
  19351. /**
  19352. * Gets the current class name of the material e.g. "ShaderMaterial"
  19353. * Mainly use in serialization.
  19354. * @returns the class name
  19355. */
  19356. getClassName(): string;
  19357. /**
  19358. * Specifies if the material will require alpha blending
  19359. * @returns a boolean specifying if alpha blending is needed
  19360. */
  19361. needAlphaBlending(): boolean;
  19362. /**
  19363. * Specifies if this material should be rendered in alpha test mode
  19364. * @returns a boolean specifying if an alpha test is needed.
  19365. */
  19366. needAlphaTesting(): boolean;
  19367. private _checkUniform;
  19368. /**
  19369. * Set a texture in the shader.
  19370. * @param name Define the name of the uniform samplers as defined in the shader
  19371. * @param texture Define the texture to bind to this sampler
  19372. * @return the material itself allowing "fluent" like uniform updates
  19373. */
  19374. setTexture(name: string, texture: Texture): ShaderMaterial;
  19375. /**
  19376. * Set a texture array in the shader.
  19377. * @param name Define the name of the uniform sampler array as defined in the shader
  19378. * @param textures Define the list of textures to bind to this sampler
  19379. * @return the material itself allowing "fluent" like uniform updates
  19380. */
  19381. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19382. /**
  19383. * Set a float in the shader.
  19384. * @param name Define the name of the uniform as defined in the shader
  19385. * @param value Define the value to give to the uniform
  19386. * @return the material itself allowing "fluent" like uniform updates
  19387. */
  19388. setFloat(name: string, value: number): ShaderMaterial;
  19389. /**
  19390. * Set a int in the shader.
  19391. * @param name Define the name of the uniform as defined in the shader
  19392. * @param value Define the value to give to the uniform
  19393. * @return the material itself allowing "fluent" like uniform updates
  19394. */
  19395. setInt(name: string, value: number): ShaderMaterial;
  19396. /**
  19397. * Set an array of floats in the shader.
  19398. * @param name Define the name of the uniform as defined in the shader
  19399. * @param value Define the value to give to the uniform
  19400. * @return the material itself allowing "fluent" like uniform updates
  19401. */
  19402. setFloats(name: string, value: number[]): ShaderMaterial;
  19403. /**
  19404. * Set a vec3 in the shader from a Color3.
  19405. * @param name Define the name of the uniform as defined in the shader
  19406. * @param value Define the value to give to the uniform
  19407. * @return the material itself allowing "fluent" like uniform updates
  19408. */
  19409. setColor3(name: string, value: Color3): ShaderMaterial;
  19410. /**
  19411. * Set a vec3 array in the shader from a Color3 array.
  19412. * @param name Define the name of the uniform as defined in the shader
  19413. * @param value Define the value to give to the uniform
  19414. * @return the material itself allowing "fluent" like uniform updates
  19415. */
  19416. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19417. /**
  19418. * Set a vec4 in the shader from a Color4.
  19419. * @param name Define the name of the uniform as defined in the shader
  19420. * @param value Define the value to give to the uniform
  19421. * @return the material itself allowing "fluent" like uniform updates
  19422. */
  19423. setColor4(name: string, value: Color4): ShaderMaterial;
  19424. /**
  19425. * Set a vec4 array in the shader from a Color4 array.
  19426. * @param name Define the name of the uniform as defined in the shader
  19427. * @param value Define the value to give to the uniform
  19428. * @return the material itself allowing "fluent" like uniform updates
  19429. */
  19430. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19431. /**
  19432. * Set a vec2 in the shader from a Vector2.
  19433. * @param name Define the name of the uniform as defined in the shader
  19434. * @param value Define the value to give to the uniform
  19435. * @return the material itself allowing "fluent" like uniform updates
  19436. */
  19437. setVector2(name: string, value: Vector2): ShaderMaterial;
  19438. /**
  19439. * Set a vec3 in the shader from a Vector3.
  19440. * @param name Define the name of the uniform as defined in the shader
  19441. * @param value Define the value to give to the uniform
  19442. * @return the material itself allowing "fluent" like uniform updates
  19443. */
  19444. setVector3(name: string, value: Vector3): ShaderMaterial;
  19445. /**
  19446. * Set a vec4 in the shader from a Vector4.
  19447. * @param name Define the name of the uniform as defined in the shader
  19448. * @param value Define the value to give to the uniform
  19449. * @return the material itself allowing "fluent" like uniform updates
  19450. */
  19451. setVector4(name: string, value: Vector4): ShaderMaterial;
  19452. /**
  19453. * Set a mat4 in the shader from a Matrix.
  19454. * @param name Define the name of the uniform as defined in the shader
  19455. * @param value Define the value to give to the uniform
  19456. * @return the material itself allowing "fluent" like uniform updates
  19457. */
  19458. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19459. /**
  19460. * Set a mat3 in the shader from a Float32Array.
  19461. * @param name Define the name of the uniform as defined in the shader
  19462. * @param value Define the value to give to the uniform
  19463. * @return the material itself allowing "fluent" like uniform updates
  19464. */
  19465. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19466. /**
  19467. * Set a mat2 in the shader from a Float32Array.
  19468. * @param name Define the name of the uniform as defined in the shader
  19469. * @param value Define the value to give to the uniform
  19470. * @return the material itself allowing "fluent" like uniform updates
  19471. */
  19472. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19473. /**
  19474. * Set a vec2 array in the shader from a number array.
  19475. * @param name Define the name of the uniform as defined in the shader
  19476. * @param value Define the value to give to the uniform
  19477. * @return the material itself allowing "fluent" like uniform updates
  19478. */
  19479. setArray2(name: string, value: number[]): ShaderMaterial;
  19480. /**
  19481. * Set a vec3 array in the shader from a number array.
  19482. * @param name Define the name of the uniform as defined in the shader
  19483. * @param value Define the value to give to the uniform
  19484. * @return the material itself allowing "fluent" like uniform updates
  19485. */
  19486. setArray3(name: string, value: number[]): ShaderMaterial;
  19487. /**
  19488. * Set a vec4 array in the shader from a number array.
  19489. * @param name Define the name of the uniform as defined in the shader
  19490. * @param value Define the value to give to the uniform
  19491. * @return the material itself allowing "fluent" like uniform updates
  19492. */
  19493. setArray4(name: string, value: number[]): ShaderMaterial;
  19494. private _checkCache;
  19495. /**
  19496. * Specifies that the submesh is ready to be used
  19497. * @param mesh defines the mesh to check
  19498. * @param subMesh defines which submesh to check
  19499. * @param useInstances specifies that instances should be used
  19500. * @returns a boolean indicating that the submesh is ready or not
  19501. */
  19502. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19503. /**
  19504. * Checks if the material is ready to render the requested mesh
  19505. * @param mesh Define the mesh to render
  19506. * @param useInstances Define whether or not the material is used with instances
  19507. * @returns true if ready, otherwise false
  19508. */
  19509. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19510. /**
  19511. * Binds the world matrix to the material
  19512. * @param world defines the world transformation matrix
  19513. */
  19514. bindOnlyWorldMatrix(world: Matrix): void;
  19515. /**
  19516. * Binds the material to the mesh
  19517. * @param world defines the world transformation matrix
  19518. * @param mesh defines the mesh to bind the material to
  19519. */
  19520. bind(world: Matrix, mesh?: Mesh): void;
  19521. /**
  19522. * Gets the active textures from the material
  19523. * @returns an array of textures
  19524. */
  19525. getActiveTextures(): BaseTexture[];
  19526. /**
  19527. * Specifies if the material uses a texture
  19528. * @param texture defines the texture to check against the material
  19529. * @returns a boolean specifying if the material uses the texture
  19530. */
  19531. hasTexture(texture: BaseTexture): boolean;
  19532. /**
  19533. * Makes a duplicate of the material, and gives it a new name
  19534. * @param name defines the new name for the duplicated material
  19535. * @returns the cloned material
  19536. */
  19537. clone(name: string): ShaderMaterial;
  19538. /**
  19539. * Disposes the material
  19540. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19541. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19542. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19543. */
  19544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19545. /**
  19546. * Serializes this material in a JSON representation
  19547. * @returns the serialized material object
  19548. */
  19549. serialize(): any;
  19550. /**
  19551. * Creates a shader material from parsed shader material data
  19552. * @param source defines the JSON represnetation of the material
  19553. * @param scene defines the hosting scene
  19554. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19555. * @returns a new material
  19556. */
  19557. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19558. }
  19559. }
  19560. declare module "babylonjs/Shaders/color.fragment" {
  19561. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19562. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19563. /** @hidden */
  19564. export var colorPixelShader: {
  19565. name: string;
  19566. shader: string;
  19567. };
  19568. }
  19569. declare module "babylonjs/Shaders/color.vertex" {
  19570. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19572. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19573. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19574. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19575. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19576. /** @hidden */
  19577. export var colorVertexShader: {
  19578. name: string;
  19579. shader: string;
  19580. };
  19581. }
  19582. declare module "babylonjs/Meshes/linesMesh" {
  19583. import { Nullable } from "babylonjs/types";
  19584. import { Scene } from "babylonjs/scene";
  19585. import { Color3 } from "babylonjs/Maths/math.color";
  19586. import { Node } from "babylonjs/node";
  19587. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19588. import { Mesh } from "babylonjs/Meshes/mesh";
  19589. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19590. import { Effect } from "babylonjs/Materials/effect";
  19591. import { Material } from "babylonjs/Materials/material";
  19592. import "babylonjs/Shaders/color.fragment";
  19593. import "babylonjs/Shaders/color.vertex";
  19594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19595. /**
  19596. * Line mesh
  19597. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19598. */
  19599. export class LinesMesh extends Mesh {
  19600. /**
  19601. * If vertex color should be applied to the mesh
  19602. */
  19603. readonly useVertexColor?: boolean | undefined;
  19604. /**
  19605. * If vertex alpha should be applied to the mesh
  19606. */
  19607. readonly useVertexAlpha?: boolean | undefined;
  19608. /**
  19609. * Color of the line (Default: White)
  19610. */
  19611. color: Color3;
  19612. /**
  19613. * Alpha of the line (Default: 1)
  19614. */
  19615. alpha: number;
  19616. /**
  19617. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19618. * This margin is expressed in world space coordinates, so its value may vary.
  19619. * Default value is 0.1
  19620. */
  19621. intersectionThreshold: number;
  19622. private _colorShader;
  19623. private color4;
  19624. /**
  19625. * Creates a new LinesMesh
  19626. * @param name defines the name
  19627. * @param scene defines the hosting scene
  19628. * @param parent defines the parent mesh if any
  19629. * @param source defines the optional source LinesMesh used to clone data from
  19630. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19631. * When false, achieved by calling a clone(), also passing False.
  19632. * This will make creation of children, recursive.
  19633. * @param useVertexColor defines if this LinesMesh supports vertex color
  19634. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19635. */
  19636. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19637. /**
  19638. * If vertex color should be applied to the mesh
  19639. */
  19640. useVertexColor?: boolean | undefined,
  19641. /**
  19642. * If vertex alpha should be applied to the mesh
  19643. */
  19644. useVertexAlpha?: boolean | undefined);
  19645. private _addClipPlaneDefine;
  19646. private _removeClipPlaneDefine;
  19647. isReady(): boolean;
  19648. /**
  19649. * Returns the string "LineMesh"
  19650. */
  19651. getClassName(): string;
  19652. /**
  19653. * @hidden
  19654. */
  19655. /**
  19656. * @hidden
  19657. */
  19658. material: Material;
  19659. /**
  19660. * @hidden
  19661. */
  19662. readonly checkCollisions: boolean;
  19663. /** @hidden */
  19664. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19665. /** @hidden */
  19666. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19667. /**
  19668. * Disposes of the line mesh
  19669. * @param doNotRecurse If children should be disposed
  19670. */
  19671. dispose(doNotRecurse?: boolean): void;
  19672. /**
  19673. * Returns a new LineMesh object cloned from the current one.
  19674. */
  19675. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19676. /**
  19677. * Creates a new InstancedLinesMesh object from the mesh model.
  19678. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19679. * @param name defines the name of the new instance
  19680. * @returns a new InstancedLinesMesh
  19681. */
  19682. createInstance(name: string): InstancedLinesMesh;
  19683. }
  19684. /**
  19685. * Creates an instance based on a source LinesMesh
  19686. */
  19687. export class InstancedLinesMesh extends InstancedMesh {
  19688. /**
  19689. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19690. * This margin is expressed in world space coordinates, so its value may vary.
  19691. * Initilized with the intersectionThreshold value of the source LinesMesh
  19692. */
  19693. intersectionThreshold: number;
  19694. constructor(name: string, source: LinesMesh);
  19695. /**
  19696. * Returns the string "InstancedLinesMesh".
  19697. */
  19698. getClassName(): string;
  19699. }
  19700. }
  19701. declare module "babylonjs/Shaders/line.fragment" {
  19702. /** @hidden */
  19703. export var linePixelShader: {
  19704. name: string;
  19705. shader: string;
  19706. };
  19707. }
  19708. declare module "babylonjs/Shaders/line.vertex" {
  19709. /** @hidden */
  19710. export var lineVertexShader: {
  19711. name: string;
  19712. shader: string;
  19713. };
  19714. }
  19715. declare module "babylonjs/Rendering/edgesRenderer" {
  19716. import { Nullable } from "babylonjs/types";
  19717. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19719. import { Vector3 } from "babylonjs/Maths/math.vector";
  19720. import { IDisposable } from "babylonjs/scene";
  19721. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19722. import "babylonjs/Shaders/line.fragment";
  19723. import "babylonjs/Shaders/line.vertex";
  19724. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19725. module "babylonjs/Meshes/abstractMesh" {
  19726. interface AbstractMesh {
  19727. /**
  19728. * Gets the edgesRenderer associated with the mesh
  19729. */
  19730. edgesRenderer: Nullable<EdgesRenderer>;
  19731. }
  19732. }
  19733. module "babylonjs/Meshes/linesMesh" {
  19734. interface LinesMesh {
  19735. /**
  19736. * Enables the edge rendering mode on the mesh.
  19737. * This mode makes the mesh edges visible
  19738. * @param epsilon defines the maximal distance between two angles to detect a face
  19739. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19740. * @returns the currentAbstractMesh
  19741. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19742. */
  19743. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19744. }
  19745. }
  19746. module "babylonjs/Meshes/linesMesh" {
  19747. interface InstancedLinesMesh {
  19748. /**
  19749. * Enables the edge rendering mode on the mesh.
  19750. * This mode makes the mesh edges visible
  19751. * @param epsilon defines the maximal distance between two angles to detect a face
  19752. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19753. * @returns the current InstancedLinesMesh
  19754. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19755. */
  19756. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19757. }
  19758. }
  19759. /**
  19760. * Defines the minimum contract an Edges renderer should follow.
  19761. */
  19762. export interface IEdgesRenderer extends IDisposable {
  19763. /**
  19764. * Gets or sets a boolean indicating if the edgesRenderer is active
  19765. */
  19766. isEnabled: boolean;
  19767. /**
  19768. * Renders the edges of the attached mesh,
  19769. */
  19770. render(): void;
  19771. /**
  19772. * Checks wether or not the edges renderer is ready to render.
  19773. * @return true if ready, otherwise false.
  19774. */
  19775. isReady(): boolean;
  19776. }
  19777. /**
  19778. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19779. */
  19780. export class EdgesRenderer implements IEdgesRenderer {
  19781. /**
  19782. * Define the size of the edges with an orthographic camera
  19783. */
  19784. edgesWidthScalerForOrthographic: number;
  19785. /**
  19786. * Define the size of the edges with a perspective camera
  19787. */
  19788. edgesWidthScalerForPerspective: number;
  19789. protected _source: AbstractMesh;
  19790. protected _linesPositions: number[];
  19791. protected _linesNormals: number[];
  19792. protected _linesIndices: number[];
  19793. protected _epsilon: number;
  19794. protected _indicesCount: number;
  19795. protected _lineShader: ShaderMaterial;
  19796. protected _ib: DataBuffer;
  19797. protected _buffers: {
  19798. [key: string]: Nullable<VertexBuffer>;
  19799. };
  19800. protected _checkVerticesInsteadOfIndices: boolean;
  19801. private _meshRebuildObserver;
  19802. private _meshDisposeObserver;
  19803. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19804. isEnabled: boolean;
  19805. /**
  19806. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19807. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19808. * @param source Mesh used to create edges
  19809. * @param epsilon sum of angles in adjacency to check for edge
  19810. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19811. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19812. */
  19813. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19814. protected _prepareRessources(): void;
  19815. /** @hidden */
  19816. _rebuild(): void;
  19817. /**
  19818. * Releases the required resources for the edges renderer
  19819. */
  19820. dispose(): void;
  19821. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19822. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19823. /**
  19824. * Checks if the pair of p0 and p1 is en edge
  19825. * @param faceIndex
  19826. * @param edge
  19827. * @param faceNormals
  19828. * @param p0
  19829. * @param p1
  19830. * @private
  19831. */
  19832. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19833. /**
  19834. * push line into the position, normal and index buffer
  19835. * @protected
  19836. */
  19837. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19838. /**
  19839. * Generates lines edges from adjacencjes
  19840. * @private
  19841. */
  19842. _generateEdgesLines(): void;
  19843. /**
  19844. * Checks wether or not the edges renderer is ready to render.
  19845. * @return true if ready, otherwise false.
  19846. */
  19847. isReady(): boolean;
  19848. /**
  19849. * Renders the edges of the attached mesh,
  19850. */
  19851. render(): void;
  19852. }
  19853. /**
  19854. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19855. */
  19856. export class LineEdgesRenderer extends EdgesRenderer {
  19857. /**
  19858. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19859. * @param source LineMesh used to generate edges
  19860. * @param epsilon not important (specified angle for edge detection)
  19861. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19862. */
  19863. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19864. /**
  19865. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19866. */
  19867. _generateEdgesLines(): void;
  19868. }
  19869. }
  19870. declare module "babylonjs/Rendering/renderingGroup" {
  19871. import { SmartArray } from "babylonjs/Misc/smartArray";
  19872. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19874. import { Nullable } from "babylonjs/types";
  19875. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19876. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19877. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19878. import { Material } from "babylonjs/Materials/material";
  19879. import { Scene } from "babylonjs/scene";
  19880. /**
  19881. * This represents the object necessary to create a rendering group.
  19882. * This is exclusively used and created by the rendering manager.
  19883. * To modify the behavior, you use the available helpers in your scene or meshes.
  19884. * @hidden
  19885. */
  19886. export class RenderingGroup {
  19887. index: number;
  19888. private static _zeroVector;
  19889. private _scene;
  19890. private _opaqueSubMeshes;
  19891. private _transparentSubMeshes;
  19892. private _alphaTestSubMeshes;
  19893. private _depthOnlySubMeshes;
  19894. private _particleSystems;
  19895. private _spriteManagers;
  19896. private _opaqueSortCompareFn;
  19897. private _alphaTestSortCompareFn;
  19898. private _transparentSortCompareFn;
  19899. private _renderOpaque;
  19900. private _renderAlphaTest;
  19901. private _renderTransparent;
  19902. /** @hidden */
  19903. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19904. onBeforeTransparentRendering: () => void;
  19905. /**
  19906. * Set the opaque sort comparison function.
  19907. * If null the sub meshes will be render in the order they were created
  19908. */
  19909. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19910. /**
  19911. * Set the alpha test sort comparison function.
  19912. * If null the sub meshes will be render in the order they were created
  19913. */
  19914. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19915. /**
  19916. * Set the transparent sort comparison function.
  19917. * If null the sub meshes will be render in the order they were created
  19918. */
  19919. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19920. /**
  19921. * Creates a new rendering group.
  19922. * @param index The rendering group index
  19923. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19924. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19925. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19926. */
  19927. 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>);
  19928. /**
  19929. * Render all the sub meshes contained in the group.
  19930. * @param customRenderFunction Used to override the default render behaviour of the group.
  19931. * @returns true if rendered some submeshes.
  19932. */
  19933. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19934. /**
  19935. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19936. * @param subMeshes The submeshes to render
  19937. */
  19938. private renderOpaqueSorted;
  19939. /**
  19940. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19941. * @param subMeshes The submeshes to render
  19942. */
  19943. private renderAlphaTestSorted;
  19944. /**
  19945. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19946. * @param subMeshes The submeshes to render
  19947. */
  19948. private renderTransparentSorted;
  19949. /**
  19950. * Renders the submeshes in a specified order.
  19951. * @param subMeshes The submeshes to sort before render
  19952. * @param sortCompareFn The comparison function use to sort
  19953. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19954. * @param transparent Specifies to activate blending if true
  19955. */
  19956. private static renderSorted;
  19957. /**
  19958. * Renders the submeshes in the order they were dispatched (no sort applied).
  19959. * @param subMeshes The submeshes to render
  19960. */
  19961. private static renderUnsorted;
  19962. /**
  19963. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19964. * are rendered back to front if in the same alpha index.
  19965. *
  19966. * @param a The first submesh
  19967. * @param b The second submesh
  19968. * @returns The result of the comparison
  19969. */
  19970. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19971. /**
  19972. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19973. * are rendered back to front.
  19974. *
  19975. * @param a The first submesh
  19976. * @param b The second submesh
  19977. * @returns The result of the comparison
  19978. */
  19979. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19980. /**
  19981. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19982. * are rendered front to back (prevent overdraw).
  19983. *
  19984. * @param a The first submesh
  19985. * @param b The second submesh
  19986. * @returns The result of the comparison
  19987. */
  19988. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19989. /**
  19990. * Resets the different lists of submeshes to prepare a new frame.
  19991. */
  19992. prepare(): void;
  19993. dispose(): void;
  19994. /**
  19995. * Inserts the submesh in its correct queue depending on its material.
  19996. * @param subMesh The submesh to dispatch
  19997. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19998. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19999. */
  20000. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20001. dispatchSprites(spriteManager: ISpriteManager): void;
  20002. dispatchParticles(particleSystem: IParticleSystem): void;
  20003. private _renderParticles;
  20004. private _renderSprites;
  20005. }
  20006. }
  20007. declare module "babylonjs/Rendering/renderingManager" {
  20008. import { Nullable } from "babylonjs/types";
  20009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20011. import { SmartArray } from "babylonjs/Misc/smartArray";
  20012. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20013. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20014. import { Material } from "babylonjs/Materials/material";
  20015. import { Scene } from "babylonjs/scene";
  20016. import { Camera } from "babylonjs/Cameras/camera";
  20017. /**
  20018. * Interface describing the different options available in the rendering manager
  20019. * regarding Auto Clear between groups.
  20020. */
  20021. export interface IRenderingManagerAutoClearSetup {
  20022. /**
  20023. * Defines whether or not autoclear is enable.
  20024. */
  20025. autoClear: boolean;
  20026. /**
  20027. * Defines whether or not to autoclear the depth buffer.
  20028. */
  20029. depth: boolean;
  20030. /**
  20031. * Defines whether or not to autoclear the stencil buffer.
  20032. */
  20033. stencil: boolean;
  20034. }
  20035. /**
  20036. * This class is used by the onRenderingGroupObservable
  20037. */
  20038. export class RenderingGroupInfo {
  20039. /**
  20040. * The Scene that being rendered
  20041. */
  20042. scene: Scene;
  20043. /**
  20044. * The camera currently used for the rendering pass
  20045. */
  20046. camera: Nullable<Camera>;
  20047. /**
  20048. * The ID of the renderingGroup being processed
  20049. */
  20050. renderingGroupId: number;
  20051. }
  20052. /**
  20053. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20054. * It is enable to manage the different groups as well as the different necessary sort functions.
  20055. * This should not be used directly aside of the few static configurations
  20056. */
  20057. export class RenderingManager {
  20058. /**
  20059. * The max id used for rendering groups (not included)
  20060. */
  20061. static MAX_RENDERINGGROUPS: number;
  20062. /**
  20063. * The min id used for rendering groups (included)
  20064. */
  20065. static MIN_RENDERINGGROUPS: number;
  20066. /**
  20067. * Used to globally prevent autoclearing scenes.
  20068. */
  20069. static AUTOCLEAR: boolean;
  20070. /**
  20071. * @hidden
  20072. */
  20073. _useSceneAutoClearSetup: boolean;
  20074. private _scene;
  20075. private _renderingGroups;
  20076. private _depthStencilBufferAlreadyCleaned;
  20077. private _autoClearDepthStencil;
  20078. private _customOpaqueSortCompareFn;
  20079. private _customAlphaTestSortCompareFn;
  20080. private _customTransparentSortCompareFn;
  20081. private _renderingGroupInfo;
  20082. /**
  20083. * Instantiates a new rendering group for a particular scene
  20084. * @param scene Defines the scene the groups belongs to
  20085. */
  20086. constructor(scene: Scene);
  20087. private _clearDepthStencilBuffer;
  20088. /**
  20089. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20090. * @hidden
  20091. */
  20092. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20093. /**
  20094. * Resets the different information of the group to prepare a new frame
  20095. * @hidden
  20096. */
  20097. reset(): void;
  20098. /**
  20099. * Dispose and release the group and its associated resources.
  20100. * @hidden
  20101. */
  20102. dispose(): void;
  20103. /**
  20104. * Clear the info related to rendering groups preventing retention points during dispose.
  20105. */
  20106. freeRenderingGroups(): void;
  20107. private _prepareRenderingGroup;
  20108. /**
  20109. * Add a sprite manager to the rendering manager in order to render it this frame.
  20110. * @param spriteManager Define the sprite manager to render
  20111. */
  20112. dispatchSprites(spriteManager: ISpriteManager): void;
  20113. /**
  20114. * Add a particle system to the rendering manager in order to render it this frame.
  20115. * @param particleSystem Define the particle system to render
  20116. */
  20117. dispatchParticles(particleSystem: IParticleSystem): void;
  20118. /**
  20119. * Add a submesh to the manager in order to render it this frame
  20120. * @param subMesh The submesh to dispatch
  20121. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20122. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20123. */
  20124. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20125. /**
  20126. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20127. * This allowed control for front to back rendering or reversly depending of the special needs.
  20128. *
  20129. * @param renderingGroupId The rendering group id corresponding to its index
  20130. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20131. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20132. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20133. */
  20134. 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;
  20135. /**
  20136. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20137. *
  20138. * @param renderingGroupId The rendering group id corresponding to its index
  20139. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20140. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20141. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20142. */
  20143. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20144. /**
  20145. * Gets the current auto clear configuration for one rendering group of the rendering
  20146. * manager.
  20147. * @param index the rendering group index to get the information for
  20148. * @returns The auto clear setup for the requested rendering group
  20149. */
  20150. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20151. }
  20152. }
  20153. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20154. import { Observable } from "babylonjs/Misc/observable";
  20155. import { SmartArray } from "babylonjs/Misc/smartArray";
  20156. import { Nullable } from "babylonjs/types";
  20157. import { Camera } from "babylonjs/Cameras/camera";
  20158. import { Scene } from "babylonjs/scene";
  20159. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20160. import { Color4 } from "babylonjs/Maths/math.color";
  20161. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20164. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20165. import { Texture } from "babylonjs/Materials/Textures/texture";
  20166. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20167. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20168. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20169. import { Engine } from "babylonjs/Engines/engine";
  20170. /**
  20171. * This Helps creating a texture that will be created from a camera in your scene.
  20172. * It is basically a dynamic texture that could be used to create special effects for instance.
  20173. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20174. */
  20175. export class RenderTargetTexture extends Texture {
  20176. isCube: boolean;
  20177. /**
  20178. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20179. */
  20180. static readonly REFRESHRATE_RENDER_ONCE: number;
  20181. /**
  20182. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20183. */
  20184. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20185. /**
  20186. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20187. * the central point of your effect and can save a lot of performances.
  20188. */
  20189. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20190. /**
  20191. * Use this predicate to dynamically define the list of mesh you want to render.
  20192. * If set, the renderList property will be overwritten.
  20193. */
  20194. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20195. private _renderList;
  20196. /**
  20197. * Use this list to define the list of mesh you want to render.
  20198. */
  20199. renderList: Nullable<Array<AbstractMesh>>;
  20200. private _hookArray;
  20201. /**
  20202. * Define if particles should be rendered in your texture.
  20203. */
  20204. renderParticles: boolean;
  20205. /**
  20206. * Define if sprites should be rendered in your texture.
  20207. */
  20208. renderSprites: boolean;
  20209. /**
  20210. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20211. */
  20212. coordinatesMode: number;
  20213. /**
  20214. * Define the camera used to render the texture.
  20215. */
  20216. activeCamera: Nullable<Camera>;
  20217. /**
  20218. * Override the render function of the texture with your own one.
  20219. */
  20220. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20221. /**
  20222. * Define if camera post processes should be use while rendering the texture.
  20223. */
  20224. useCameraPostProcesses: boolean;
  20225. /**
  20226. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20227. */
  20228. ignoreCameraViewport: boolean;
  20229. private _postProcessManager;
  20230. private _postProcesses;
  20231. private _resizeObserver;
  20232. /**
  20233. * An event triggered when the texture is unbind.
  20234. */
  20235. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20236. /**
  20237. * An event triggered when the texture is unbind.
  20238. */
  20239. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20240. private _onAfterUnbindObserver;
  20241. /**
  20242. * Set a after unbind callback in the texture.
  20243. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20244. */
  20245. onAfterUnbind: () => void;
  20246. /**
  20247. * An event triggered before rendering the texture
  20248. */
  20249. onBeforeRenderObservable: Observable<number>;
  20250. private _onBeforeRenderObserver;
  20251. /**
  20252. * Set a before render callback in the texture.
  20253. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20254. */
  20255. onBeforeRender: (faceIndex: number) => void;
  20256. /**
  20257. * An event triggered after rendering the texture
  20258. */
  20259. onAfterRenderObservable: Observable<number>;
  20260. private _onAfterRenderObserver;
  20261. /**
  20262. * Set a after render callback in the texture.
  20263. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20264. */
  20265. onAfterRender: (faceIndex: number) => void;
  20266. /**
  20267. * An event triggered after the texture clear
  20268. */
  20269. onClearObservable: Observable<Engine>;
  20270. private _onClearObserver;
  20271. /**
  20272. * Set a clear callback in the texture.
  20273. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20274. */
  20275. onClear: (Engine: Engine) => void;
  20276. /**
  20277. * An event triggered when the texture is resized.
  20278. */
  20279. onResizeObservable: Observable<RenderTargetTexture>;
  20280. /**
  20281. * Define the clear color of the Render Target if it should be different from the scene.
  20282. */
  20283. clearColor: Color4;
  20284. protected _size: number | {
  20285. width: number;
  20286. height: number;
  20287. };
  20288. protected _initialSizeParameter: number | {
  20289. width: number;
  20290. height: number;
  20291. } | {
  20292. ratio: number;
  20293. };
  20294. protected _sizeRatio: Nullable<number>;
  20295. /** @hidden */
  20296. _generateMipMaps: boolean;
  20297. protected _renderingManager: RenderingManager;
  20298. /** @hidden */
  20299. _waitingRenderList: string[];
  20300. protected _doNotChangeAspectRatio: boolean;
  20301. protected _currentRefreshId: number;
  20302. protected _refreshRate: number;
  20303. protected _textureMatrix: Matrix;
  20304. protected _samples: number;
  20305. protected _renderTargetOptions: RenderTargetCreationOptions;
  20306. /**
  20307. * Gets render target creation options that were used.
  20308. */
  20309. readonly renderTargetOptions: RenderTargetCreationOptions;
  20310. protected _engine: Engine;
  20311. protected _onRatioRescale(): void;
  20312. /**
  20313. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20314. * It must define where the camera used to render the texture is set
  20315. */
  20316. boundingBoxPosition: Vector3;
  20317. private _boundingBoxSize;
  20318. /**
  20319. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20320. * When defined, the cubemap will switch to local mode
  20321. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20322. * @example https://www.babylonjs-playground.com/#RNASML
  20323. */
  20324. boundingBoxSize: Vector3;
  20325. /**
  20326. * In case the RTT has been created with a depth texture, get the associated
  20327. * depth texture.
  20328. * Otherwise, return null.
  20329. */
  20330. depthStencilTexture: Nullable<InternalTexture>;
  20331. /**
  20332. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20333. * or used a shadow, depth texture...
  20334. * @param name The friendly name of the texture
  20335. * @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)
  20336. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20337. * @param generateMipMaps True if mip maps need to be generated after render.
  20338. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20339. * @param type The type of the buffer in the RTT (int, half float, float...)
  20340. * @param isCube True if a cube texture needs to be created
  20341. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20342. * @param generateDepthBuffer True to generate a depth buffer
  20343. * @param generateStencilBuffer True to generate a stencil buffer
  20344. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20345. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20346. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20347. */
  20348. constructor(name: string, size: number | {
  20349. width: number;
  20350. height: number;
  20351. } | {
  20352. ratio: number;
  20353. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20354. /**
  20355. * Creates a depth stencil texture.
  20356. * This is only available in WebGL 2 or with the depth texture extension available.
  20357. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20358. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20359. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20360. */
  20361. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20362. private _processSizeParameter;
  20363. /**
  20364. * Define the number of samples to use in case of MSAA.
  20365. * It defaults to one meaning no MSAA has been enabled.
  20366. */
  20367. samples: number;
  20368. /**
  20369. * Resets the refresh counter of the texture and start bak from scratch.
  20370. * Could be useful to regenerate the texture if it is setup to render only once.
  20371. */
  20372. resetRefreshCounter(): void;
  20373. /**
  20374. * Define the refresh rate of the texture or the rendering frequency.
  20375. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20376. */
  20377. refreshRate: number;
  20378. /**
  20379. * Adds a post process to the render target rendering passes.
  20380. * @param postProcess define the post process to add
  20381. */
  20382. addPostProcess(postProcess: PostProcess): void;
  20383. /**
  20384. * Clear all the post processes attached to the render target
  20385. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20386. */
  20387. clearPostProcesses(dispose?: boolean): void;
  20388. /**
  20389. * Remove one of the post process from the list of attached post processes to the texture
  20390. * @param postProcess define the post process to remove from the list
  20391. */
  20392. removePostProcess(postProcess: PostProcess): void;
  20393. /** @hidden */
  20394. _shouldRender(): boolean;
  20395. /**
  20396. * Gets the actual render size of the texture.
  20397. * @returns the width of the render size
  20398. */
  20399. getRenderSize(): number;
  20400. /**
  20401. * Gets the actual render width of the texture.
  20402. * @returns the width of the render size
  20403. */
  20404. getRenderWidth(): number;
  20405. /**
  20406. * Gets the actual render height of the texture.
  20407. * @returns the height of the render size
  20408. */
  20409. getRenderHeight(): number;
  20410. /**
  20411. * Get if the texture can be rescaled or not.
  20412. */
  20413. readonly canRescale: boolean;
  20414. /**
  20415. * Resize the texture using a ratio.
  20416. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20417. */
  20418. scale(ratio: number): void;
  20419. /**
  20420. * Get the texture reflection matrix used to rotate/transform the reflection.
  20421. * @returns the reflection matrix
  20422. */
  20423. getReflectionTextureMatrix(): Matrix;
  20424. /**
  20425. * Resize the texture to a new desired size.
  20426. * Be carrefull as it will recreate all the data in the new texture.
  20427. * @param size Define the new size. It can be:
  20428. * - a number for squared texture,
  20429. * - an object containing { width: number, height: number }
  20430. * - or an object containing a ratio { ratio: number }
  20431. */
  20432. resize(size: number | {
  20433. width: number;
  20434. height: number;
  20435. } | {
  20436. ratio: number;
  20437. }): void;
  20438. /**
  20439. * Renders all the objects from the render list into the texture.
  20440. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20441. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20442. */
  20443. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20444. private _bestReflectionRenderTargetDimension;
  20445. /**
  20446. * @hidden
  20447. * @param faceIndex face index to bind to if this is a cubetexture
  20448. */
  20449. _bindFrameBuffer(faceIndex?: number): void;
  20450. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20451. private renderToTarget;
  20452. /**
  20453. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20454. * This allowed control for front to back rendering or reversly depending of the special needs.
  20455. *
  20456. * @param renderingGroupId The rendering group id corresponding to its index
  20457. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20458. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20459. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20460. */
  20461. 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;
  20462. /**
  20463. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20464. *
  20465. * @param renderingGroupId The rendering group id corresponding to its index
  20466. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20467. */
  20468. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20469. /**
  20470. * Clones the texture.
  20471. * @returns the cloned texture
  20472. */
  20473. clone(): RenderTargetTexture;
  20474. /**
  20475. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20476. * @returns The JSON representation of the texture
  20477. */
  20478. serialize(): any;
  20479. /**
  20480. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20481. */
  20482. disposeFramebufferObjects(): void;
  20483. /**
  20484. * Dispose the texture and release its associated resources.
  20485. */
  20486. dispose(): void;
  20487. /** @hidden */
  20488. _rebuild(): void;
  20489. /**
  20490. * Clear the info related to rendering groups preventing retention point in material dispose.
  20491. */
  20492. freeRenderingGroups(): void;
  20493. /**
  20494. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20495. * @returns the view count
  20496. */
  20497. getViewCount(): number;
  20498. }
  20499. }
  20500. declare module "babylonjs/Materials/material" {
  20501. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20502. import { SmartArray } from "babylonjs/Misc/smartArray";
  20503. import { Observable } from "babylonjs/Misc/observable";
  20504. import { Nullable } from "babylonjs/types";
  20505. import { Scene } from "babylonjs/scene";
  20506. import { Matrix } from "babylonjs/Maths/math.vector";
  20507. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20509. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20510. import { Effect } from "babylonjs/Materials/effect";
  20511. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20512. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20513. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20514. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20515. import { Mesh } from "babylonjs/Meshes/mesh";
  20516. import { Animation } from "babylonjs/Animations/animation";
  20517. /**
  20518. * Base class for the main features of a material in Babylon.js
  20519. */
  20520. export class Material implements IAnimatable {
  20521. /**
  20522. * Returns the triangle fill mode
  20523. */
  20524. static readonly TriangleFillMode: number;
  20525. /**
  20526. * Returns the wireframe mode
  20527. */
  20528. static readonly WireFrameFillMode: number;
  20529. /**
  20530. * Returns the point fill mode
  20531. */
  20532. static readonly PointFillMode: number;
  20533. /**
  20534. * Returns the point list draw mode
  20535. */
  20536. static readonly PointListDrawMode: number;
  20537. /**
  20538. * Returns the line list draw mode
  20539. */
  20540. static readonly LineListDrawMode: number;
  20541. /**
  20542. * Returns the line loop draw mode
  20543. */
  20544. static readonly LineLoopDrawMode: number;
  20545. /**
  20546. * Returns the line strip draw mode
  20547. */
  20548. static readonly LineStripDrawMode: number;
  20549. /**
  20550. * Returns the triangle strip draw mode
  20551. */
  20552. static readonly TriangleStripDrawMode: number;
  20553. /**
  20554. * Returns the triangle fan draw mode
  20555. */
  20556. static readonly TriangleFanDrawMode: number;
  20557. /**
  20558. * Stores the clock-wise side orientation
  20559. */
  20560. static readonly ClockWiseSideOrientation: number;
  20561. /**
  20562. * Stores the counter clock-wise side orientation
  20563. */
  20564. static readonly CounterClockWiseSideOrientation: number;
  20565. /**
  20566. * The dirty texture flag value
  20567. */
  20568. static readonly TextureDirtyFlag: number;
  20569. /**
  20570. * The dirty light flag value
  20571. */
  20572. static readonly LightDirtyFlag: number;
  20573. /**
  20574. * The dirty fresnel flag value
  20575. */
  20576. static readonly FresnelDirtyFlag: number;
  20577. /**
  20578. * The dirty attribute flag value
  20579. */
  20580. static readonly AttributesDirtyFlag: number;
  20581. /**
  20582. * The dirty misc flag value
  20583. */
  20584. static readonly MiscDirtyFlag: number;
  20585. /**
  20586. * The all dirty flag value
  20587. */
  20588. static readonly AllDirtyFlag: number;
  20589. /**
  20590. * The ID of the material
  20591. */
  20592. id: string;
  20593. /**
  20594. * Gets or sets the unique id of the material
  20595. */
  20596. uniqueId: number;
  20597. /**
  20598. * The name of the material
  20599. */
  20600. name: string;
  20601. /**
  20602. * Gets or sets user defined metadata
  20603. */
  20604. metadata: any;
  20605. /**
  20606. * For internal use only. Please do not use.
  20607. */
  20608. reservedDataStore: any;
  20609. /**
  20610. * Specifies if the ready state should be checked on each call
  20611. */
  20612. checkReadyOnEveryCall: boolean;
  20613. /**
  20614. * Specifies if the ready state should be checked once
  20615. */
  20616. checkReadyOnlyOnce: boolean;
  20617. /**
  20618. * The state of the material
  20619. */
  20620. state: string;
  20621. /**
  20622. * The alpha value of the material
  20623. */
  20624. protected _alpha: number;
  20625. /**
  20626. * List of inspectable custom properties (used by the Inspector)
  20627. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20628. */
  20629. inspectableCustomProperties: IInspectable[];
  20630. /**
  20631. * Sets the alpha value of the material
  20632. */
  20633. /**
  20634. * Gets the alpha value of the material
  20635. */
  20636. alpha: number;
  20637. /**
  20638. * Specifies if back face culling is enabled
  20639. */
  20640. protected _backFaceCulling: boolean;
  20641. /**
  20642. * Sets the back-face culling state
  20643. */
  20644. /**
  20645. * Gets the back-face culling state
  20646. */
  20647. backFaceCulling: boolean;
  20648. /**
  20649. * Stores the value for side orientation
  20650. */
  20651. sideOrientation: number;
  20652. /**
  20653. * Callback triggered when the material is compiled
  20654. */
  20655. onCompiled: Nullable<(effect: Effect) => void>;
  20656. /**
  20657. * Callback triggered when an error occurs
  20658. */
  20659. onError: Nullable<(effect: Effect, errors: string) => void>;
  20660. /**
  20661. * Callback triggered to get the render target textures
  20662. */
  20663. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20664. /**
  20665. * Gets a boolean indicating that current material needs to register RTT
  20666. */
  20667. readonly hasRenderTargetTextures: boolean;
  20668. /**
  20669. * Specifies if the material should be serialized
  20670. */
  20671. doNotSerialize: boolean;
  20672. /**
  20673. * @hidden
  20674. */
  20675. _storeEffectOnSubMeshes: boolean;
  20676. /**
  20677. * Stores the animations for the material
  20678. */
  20679. animations: Nullable<Array<Animation>>;
  20680. /**
  20681. * An event triggered when the material is disposed
  20682. */
  20683. onDisposeObservable: Observable<Material>;
  20684. /**
  20685. * An observer which watches for dispose events
  20686. */
  20687. private _onDisposeObserver;
  20688. private _onUnBindObservable;
  20689. /**
  20690. * Called during a dispose event
  20691. */
  20692. onDispose: () => void;
  20693. private _onBindObservable;
  20694. /**
  20695. * An event triggered when the material is bound
  20696. */
  20697. readonly onBindObservable: Observable<AbstractMesh>;
  20698. /**
  20699. * An observer which watches for bind events
  20700. */
  20701. private _onBindObserver;
  20702. /**
  20703. * Called during a bind event
  20704. */
  20705. onBind: (Mesh: AbstractMesh) => void;
  20706. /**
  20707. * An event triggered when the material is unbound
  20708. */
  20709. readonly onUnBindObservable: Observable<Material>;
  20710. /**
  20711. * Stores the value of the alpha mode
  20712. */
  20713. private _alphaMode;
  20714. /**
  20715. * Sets the value of the alpha mode.
  20716. *
  20717. * | Value | Type | Description |
  20718. * | --- | --- | --- |
  20719. * | 0 | ALPHA_DISABLE | |
  20720. * | 1 | ALPHA_ADD | |
  20721. * | 2 | ALPHA_COMBINE | |
  20722. * | 3 | ALPHA_SUBTRACT | |
  20723. * | 4 | ALPHA_MULTIPLY | |
  20724. * | 5 | ALPHA_MAXIMIZED | |
  20725. * | 6 | ALPHA_ONEONE | |
  20726. * | 7 | ALPHA_PREMULTIPLIED | |
  20727. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20728. * | 9 | ALPHA_INTERPOLATE | |
  20729. * | 10 | ALPHA_SCREENMODE | |
  20730. *
  20731. */
  20732. /**
  20733. * Gets the value of the alpha mode
  20734. */
  20735. alphaMode: number;
  20736. /**
  20737. * Stores the state of the need depth pre-pass value
  20738. */
  20739. private _needDepthPrePass;
  20740. /**
  20741. * Sets the need depth pre-pass value
  20742. */
  20743. /**
  20744. * Gets the depth pre-pass value
  20745. */
  20746. needDepthPrePass: boolean;
  20747. /**
  20748. * Specifies if depth writing should be disabled
  20749. */
  20750. disableDepthWrite: boolean;
  20751. /**
  20752. * Specifies if depth writing should be forced
  20753. */
  20754. forceDepthWrite: boolean;
  20755. /**
  20756. * Specifies if there should be a separate pass for culling
  20757. */
  20758. separateCullingPass: boolean;
  20759. /**
  20760. * Stores the state specifing if fog should be enabled
  20761. */
  20762. private _fogEnabled;
  20763. /**
  20764. * Sets the state for enabling fog
  20765. */
  20766. /**
  20767. * Gets the value of the fog enabled state
  20768. */
  20769. fogEnabled: boolean;
  20770. /**
  20771. * Stores the size of points
  20772. */
  20773. pointSize: number;
  20774. /**
  20775. * Stores the z offset value
  20776. */
  20777. zOffset: number;
  20778. /**
  20779. * Gets a value specifying if wireframe mode is enabled
  20780. */
  20781. /**
  20782. * Sets the state of wireframe mode
  20783. */
  20784. wireframe: boolean;
  20785. /**
  20786. * Gets the value specifying if point clouds are enabled
  20787. */
  20788. /**
  20789. * Sets the state of point cloud mode
  20790. */
  20791. pointsCloud: boolean;
  20792. /**
  20793. * Gets the material fill mode
  20794. */
  20795. /**
  20796. * Sets the material fill mode
  20797. */
  20798. fillMode: number;
  20799. /**
  20800. * @hidden
  20801. * Stores the effects for the material
  20802. */
  20803. _effect: Nullable<Effect>;
  20804. /**
  20805. * @hidden
  20806. * Specifies if the material was previously ready
  20807. */
  20808. _wasPreviouslyReady: boolean;
  20809. /**
  20810. * Specifies if uniform buffers should be used
  20811. */
  20812. private _useUBO;
  20813. /**
  20814. * Stores a reference to the scene
  20815. */
  20816. private _scene;
  20817. /**
  20818. * Stores the fill mode state
  20819. */
  20820. private _fillMode;
  20821. /**
  20822. * Specifies if the depth write state should be cached
  20823. */
  20824. private _cachedDepthWriteState;
  20825. /**
  20826. * Stores the uniform buffer
  20827. */
  20828. protected _uniformBuffer: UniformBuffer;
  20829. /** @hidden */
  20830. _indexInSceneMaterialArray: number;
  20831. /** @hidden */
  20832. meshMap: Nullable<{
  20833. [id: string]: AbstractMesh | undefined;
  20834. }>;
  20835. /**
  20836. * Creates a material instance
  20837. * @param name defines the name of the material
  20838. * @param scene defines the scene to reference
  20839. * @param doNotAdd specifies if the material should be added to the scene
  20840. */
  20841. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20842. /**
  20843. * Returns a string representation of the current material
  20844. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20845. * @returns a string with material information
  20846. */
  20847. toString(fullDetails?: boolean): string;
  20848. /**
  20849. * Gets the class name of the material
  20850. * @returns a string with the class name of the material
  20851. */
  20852. getClassName(): string;
  20853. /**
  20854. * Specifies if updates for the material been locked
  20855. */
  20856. readonly isFrozen: boolean;
  20857. /**
  20858. * Locks updates for the material
  20859. */
  20860. freeze(): void;
  20861. /**
  20862. * Unlocks updates for the material
  20863. */
  20864. unfreeze(): void;
  20865. /**
  20866. * Specifies if the material is ready to be used
  20867. * @param mesh defines the mesh to check
  20868. * @param useInstances specifies if instances should be used
  20869. * @returns a boolean indicating if the material is ready to be used
  20870. */
  20871. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20872. /**
  20873. * Specifies that the submesh is ready to be used
  20874. * @param mesh defines the mesh to check
  20875. * @param subMesh defines which submesh to check
  20876. * @param useInstances specifies that instances should be used
  20877. * @returns a boolean indicating that the submesh is ready or not
  20878. */
  20879. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20880. /**
  20881. * Returns the material effect
  20882. * @returns the effect associated with the material
  20883. */
  20884. getEffect(): Nullable<Effect>;
  20885. /**
  20886. * Returns the current scene
  20887. * @returns a Scene
  20888. */
  20889. getScene(): Scene;
  20890. /**
  20891. * Specifies if the material will require alpha blending
  20892. * @returns a boolean specifying if alpha blending is needed
  20893. */
  20894. needAlphaBlending(): boolean;
  20895. /**
  20896. * Specifies if the mesh will require alpha blending
  20897. * @param mesh defines the mesh to check
  20898. * @returns a boolean specifying if alpha blending is needed for the mesh
  20899. */
  20900. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20901. /**
  20902. * Specifies if this material should be rendered in alpha test mode
  20903. * @returns a boolean specifying if an alpha test is needed.
  20904. */
  20905. needAlphaTesting(): boolean;
  20906. /**
  20907. * Gets the texture used for the alpha test
  20908. * @returns the texture to use for alpha testing
  20909. */
  20910. getAlphaTestTexture(): Nullable<BaseTexture>;
  20911. /**
  20912. * Marks the material to indicate that it needs to be re-calculated
  20913. */
  20914. markDirty(): void;
  20915. /** @hidden */
  20916. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20917. /**
  20918. * Binds the material to the mesh
  20919. * @param world defines the world transformation matrix
  20920. * @param mesh defines the mesh to bind the material to
  20921. */
  20922. bind(world: Matrix, mesh?: Mesh): void;
  20923. /**
  20924. * Binds the submesh to the material
  20925. * @param world defines the world transformation matrix
  20926. * @param mesh defines the mesh containing the submesh
  20927. * @param subMesh defines the submesh to bind the material to
  20928. */
  20929. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20930. /**
  20931. * Binds the world matrix to the material
  20932. * @param world defines the world transformation matrix
  20933. */
  20934. bindOnlyWorldMatrix(world: Matrix): void;
  20935. /**
  20936. * Binds the scene's uniform buffer to the effect.
  20937. * @param effect defines the effect to bind to the scene uniform buffer
  20938. * @param sceneUbo defines the uniform buffer storing scene data
  20939. */
  20940. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20941. /**
  20942. * Binds the view matrix to the effect
  20943. * @param effect defines the effect to bind the view matrix to
  20944. */
  20945. bindView(effect: Effect): void;
  20946. /**
  20947. * Binds the view projection matrix to the effect
  20948. * @param effect defines the effect to bind the view projection matrix to
  20949. */
  20950. bindViewProjection(effect: Effect): void;
  20951. /**
  20952. * Specifies if material alpha testing should be turned on for the mesh
  20953. * @param mesh defines the mesh to check
  20954. */
  20955. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20956. /**
  20957. * Processes to execute after binding the material to a mesh
  20958. * @param mesh defines the rendered mesh
  20959. */
  20960. protected _afterBind(mesh?: Mesh): void;
  20961. /**
  20962. * Unbinds the material from the mesh
  20963. */
  20964. unbind(): void;
  20965. /**
  20966. * Gets the active textures from the material
  20967. * @returns an array of textures
  20968. */
  20969. getActiveTextures(): BaseTexture[];
  20970. /**
  20971. * Specifies if the material uses a texture
  20972. * @param texture defines the texture to check against the material
  20973. * @returns a boolean specifying if the material uses the texture
  20974. */
  20975. hasTexture(texture: BaseTexture): boolean;
  20976. /**
  20977. * Makes a duplicate of the material, and gives it a new name
  20978. * @param name defines the new name for the duplicated material
  20979. * @returns the cloned material
  20980. */
  20981. clone(name: string): Nullable<Material>;
  20982. /**
  20983. * Gets the meshes bound to the material
  20984. * @returns an array of meshes bound to the material
  20985. */
  20986. getBindedMeshes(): AbstractMesh[];
  20987. /**
  20988. * Force shader compilation
  20989. * @param mesh defines the mesh associated with this material
  20990. * @param onCompiled defines a function to execute once the material is compiled
  20991. * @param options defines the options to configure the compilation
  20992. */
  20993. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20994. clipPlane: boolean;
  20995. }>): void;
  20996. /**
  20997. * Force shader compilation
  20998. * @param mesh defines the mesh that will use this material
  20999. * @param options defines additional options for compiling the shaders
  21000. * @returns a promise that resolves when the compilation completes
  21001. */
  21002. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21003. clipPlane: boolean;
  21004. }>): Promise<void>;
  21005. private static readonly _AllDirtyCallBack;
  21006. private static readonly _ImageProcessingDirtyCallBack;
  21007. private static readonly _TextureDirtyCallBack;
  21008. private static readonly _FresnelDirtyCallBack;
  21009. private static readonly _MiscDirtyCallBack;
  21010. private static readonly _LightsDirtyCallBack;
  21011. private static readonly _AttributeDirtyCallBack;
  21012. private static _FresnelAndMiscDirtyCallBack;
  21013. private static _TextureAndMiscDirtyCallBack;
  21014. private static readonly _DirtyCallbackArray;
  21015. private static readonly _RunDirtyCallBacks;
  21016. /**
  21017. * Marks a define in the material to indicate that it needs to be re-computed
  21018. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21019. */
  21020. markAsDirty(flag: number): void;
  21021. /**
  21022. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21023. * @param func defines a function which checks material defines against the submeshes
  21024. */
  21025. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21026. /**
  21027. * Indicates that we need to re-calculated for all submeshes
  21028. */
  21029. protected _markAllSubMeshesAsAllDirty(): void;
  21030. /**
  21031. * Indicates that image processing needs to be re-calculated for all submeshes
  21032. */
  21033. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21034. /**
  21035. * Indicates that textures need to be re-calculated for all submeshes
  21036. */
  21037. protected _markAllSubMeshesAsTexturesDirty(): void;
  21038. /**
  21039. * Indicates that fresnel needs to be re-calculated for all submeshes
  21040. */
  21041. protected _markAllSubMeshesAsFresnelDirty(): void;
  21042. /**
  21043. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21044. */
  21045. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21046. /**
  21047. * Indicates that lights need to be re-calculated for all submeshes
  21048. */
  21049. protected _markAllSubMeshesAsLightsDirty(): void;
  21050. /**
  21051. * Indicates that attributes need to be re-calculated for all submeshes
  21052. */
  21053. protected _markAllSubMeshesAsAttributesDirty(): void;
  21054. /**
  21055. * Indicates that misc needs to be re-calculated for all submeshes
  21056. */
  21057. protected _markAllSubMeshesAsMiscDirty(): void;
  21058. /**
  21059. * Indicates that textures and misc need to be re-calculated for all submeshes
  21060. */
  21061. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21062. /**
  21063. * Disposes the material
  21064. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21065. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21066. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21067. */
  21068. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21069. /** @hidden */
  21070. private releaseVertexArrayObject;
  21071. /**
  21072. * Serializes this material
  21073. * @returns the serialized material object
  21074. */
  21075. serialize(): any;
  21076. /**
  21077. * Creates a material from parsed material data
  21078. * @param parsedMaterial defines parsed material data
  21079. * @param scene defines the hosting scene
  21080. * @param rootUrl defines the root URL to use to load textures
  21081. * @returns a new material
  21082. */
  21083. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21084. }
  21085. }
  21086. declare module "babylonjs/Materials/multiMaterial" {
  21087. import { Nullable } from "babylonjs/types";
  21088. import { Scene } from "babylonjs/scene";
  21089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21090. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21092. import { Material } from "babylonjs/Materials/material";
  21093. /**
  21094. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21095. * separate meshes. This can be use to improve performances.
  21096. * @see http://doc.babylonjs.com/how_to/multi_materials
  21097. */
  21098. export class MultiMaterial extends Material {
  21099. private _subMaterials;
  21100. /**
  21101. * Gets or Sets the list of Materials used within the multi material.
  21102. * They need to be ordered according to the submeshes order in the associated mesh
  21103. */
  21104. subMaterials: Nullable<Material>[];
  21105. /**
  21106. * Function used to align with Node.getChildren()
  21107. * @returns the list of Materials used within the multi material
  21108. */
  21109. getChildren(): Nullable<Material>[];
  21110. /**
  21111. * Instantiates a new Multi Material
  21112. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21113. * separate meshes. This can be use to improve performances.
  21114. * @see http://doc.babylonjs.com/how_to/multi_materials
  21115. * @param name Define the name in the scene
  21116. * @param scene Define the scene the material belongs to
  21117. */
  21118. constructor(name: string, scene: Scene);
  21119. private _hookArray;
  21120. /**
  21121. * Get one of the submaterial by its index in the submaterials array
  21122. * @param index The index to look the sub material at
  21123. * @returns The Material if the index has been defined
  21124. */
  21125. getSubMaterial(index: number): Nullable<Material>;
  21126. /**
  21127. * Get the list of active textures for the whole sub materials list.
  21128. * @returns All the textures that will be used during the rendering
  21129. */
  21130. getActiveTextures(): BaseTexture[];
  21131. /**
  21132. * Gets the current class name of the material e.g. "MultiMaterial"
  21133. * Mainly use in serialization.
  21134. * @returns the class name
  21135. */
  21136. getClassName(): string;
  21137. /**
  21138. * Checks if the material is ready to render the requested sub mesh
  21139. * @param mesh Define the mesh the submesh belongs to
  21140. * @param subMesh Define the sub mesh to look readyness for
  21141. * @param useInstances Define whether or not the material is used with instances
  21142. * @returns true if ready, otherwise false
  21143. */
  21144. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21145. /**
  21146. * Clones the current material and its related sub materials
  21147. * @param name Define the name of the newly cloned material
  21148. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21149. * @returns the cloned material
  21150. */
  21151. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21152. /**
  21153. * Serializes the materials into a JSON representation.
  21154. * @returns the JSON representation
  21155. */
  21156. serialize(): any;
  21157. /**
  21158. * Dispose the material and release its associated resources
  21159. * @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)
  21160. * @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)
  21161. * @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)
  21162. */
  21163. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21164. /**
  21165. * Creates a MultiMaterial from parsed MultiMaterial data.
  21166. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21167. * @param scene defines the hosting scene
  21168. * @returns a new MultiMaterial
  21169. */
  21170. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21171. }
  21172. }
  21173. declare module "babylonjs/Meshes/subMesh" {
  21174. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21175. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21176. import { Engine } from "babylonjs/Engines/engine";
  21177. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21178. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21179. import { Effect } from "babylonjs/Materials/effect";
  21180. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21181. import { Plane } from "babylonjs/Maths/math.plane";
  21182. import { Collider } from "babylonjs/Collisions/collider";
  21183. import { Material } from "babylonjs/Materials/material";
  21184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21186. import { Mesh } from "babylonjs/Meshes/mesh";
  21187. import { Ray } from "babylonjs/Culling/ray";
  21188. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21189. /**
  21190. * Base class for submeshes
  21191. */
  21192. export class BaseSubMesh {
  21193. /** @hidden */
  21194. _materialDefines: Nullable<MaterialDefines>;
  21195. /** @hidden */
  21196. _materialEffect: Nullable<Effect>;
  21197. /**
  21198. * Gets associated effect
  21199. */
  21200. readonly effect: Nullable<Effect>;
  21201. /**
  21202. * Sets associated effect (effect used to render this submesh)
  21203. * @param effect defines the effect to associate with
  21204. * @param defines defines the set of defines used to compile this effect
  21205. */
  21206. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21207. }
  21208. /**
  21209. * Defines a subdivision inside a mesh
  21210. */
  21211. export class SubMesh extends BaseSubMesh implements ICullable {
  21212. /** the material index to use */
  21213. materialIndex: number;
  21214. /** vertex index start */
  21215. verticesStart: number;
  21216. /** vertices count */
  21217. verticesCount: number;
  21218. /** index start */
  21219. indexStart: number;
  21220. /** indices count */
  21221. indexCount: number;
  21222. /** @hidden */
  21223. _linesIndexCount: number;
  21224. private _mesh;
  21225. private _renderingMesh;
  21226. private _boundingInfo;
  21227. private _linesIndexBuffer;
  21228. /** @hidden */
  21229. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21230. /** @hidden */
  21231. _trianglePlanes: Plane[];
  21232. /** @hidden */
  21233. _lastColliderTransformMatrix: Nullable<Matrix>;
  21234. /** @hidden */
  21235. _renderId: number;
  21236. /** @hidden */
  21237. _alphaIndex: number;
  21238. /** @hidden */
  21239. _distanceToCamera: number;
  21240. /** @hidden */
  21241. _id: number;
  21242. private _currentMaterial;
  21243. /**
  21244. * Add a new submesh to a mesh
  21245. * @param materialIndex defines the material index to use
  21246. * @param verticesStart defines vertex index start
  21247. * @param verticesCount defines vertices count
  21248. * @param indexStart defines index start
  21249. * @param indexCount defines indices count
  21250. * @param mesh defines the parent mesh
  21251. * @param renderingMesh defines an optional rendering mesh
  21252. * @param createBoundingBox defines if bounding box should be created for this submesh
  21253. * @returns the new submesh
  21254. */
  21255. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21256. /**
  21257. * Creates a new submesh
  21258. * @param materialIndex defines the material index to use
  21259. * @param verticesStart defines vertex index start
  21260. * @param verticesCount defines vertices count
  21261. * @param indexStart defines index start
  21262. * @param indexCount defines indices count
  21263. * @param mesh defines the parent mesh
  21264. * @param renderingMesh defines an optional rendering mesh
  21265. * @param createBoundingBox defines if bounding box should be created for this submesh
  21266. */
  21267. constructor(
  21268. /** the material index to use */
  21269. materialIndex: number,
  21270. /** vertex index start */
  21271. verticesStart: number,
  21272. /** vertices count */
  21273. verticesCount: number,
  21274. /** index start */
  21275. indexStart: number,
  21276. /** indices count */
  21277. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21278. /**
  21279. * Returns true if this submesh covers the entire parent mesh
  21280. * @ignorenaming
  21281. */
  21282. readonly IsGlobal: boolean;
  21283. /**
  21284. * Returns the submesh BoudingInfo object
  21285. * @returns current bounding info (or mesh's one if the submesh is global)
  21286. */
  21287. getBoundingInfo(): BoundingInfo;
  21288. /**
  21289. * Sets the submesh BoundingInfo
  21290. * @param boundingInfo defines the new bounding info to use
  21291. * @returns the SubMesh
  21292. */
  21293. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21294. /**
  21295. * Returns the mesh of the current submesh
  21296. * @return the parent mesh
  21297. */
  21298. getMesh(): AbstractMesh;
  21299. /**
  21300. * Returns the rendering mesh of the submesh
  21301. * @returns the rendering mesh (could be different from parent mesh)
  21302. */
  21303. getRenderingMesh(): Mesh;
  21304. /**
  21305. * Returns the submesh material
  21306. * @returns null or the current material
  21307. */
  21308. getMaterial(): Nullable<Material>;
  21309. /**
  21310. * Sets a new updated BoundingInfo object to the submesh
  21311. * @param data defines an optional position array to use to determine the bounding info
  21312. * @returns the SubMesh
  21313. */
  21314. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21315. /** @hidden */
  21316. _checkCollision(collider: Collider): boolean;
  21317. /**
  21318. * Updates the submesh BoundingInfo
  21319. * @param world defines the world matrix to use to update the bounding info
  21320. * @returns the submesh
  21321. */
  21322. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21323. /**
  21324. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21325. * @param frustumPlanes defines the frustum planes
  21326. * @returns true if the submesh is intersecting with the frustum
  21327. */
  21328. isInFrustum(frustumPlanes: Plane[]): boolean;
  21329. /**
  21330. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21331. * @param frustumPlanes defines the frustum planes
  21332. * @returns true if the submesh is inside the frustum
  21333. */
  21334. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21335. /**
  21336. * Renders the submesh
  21337. * @param enableAlphaMode defines if alpha needs to be used
  21338. * @returns the submesh
  21339. */
  21340. render(enableAlphaMode: boolean): SubMesh;
  21341. /**
  21342. * @hidden
  21343. */
  21344. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21345. /**
  21346. * Checks if the submesh intersects with a ray
  21347. * @param ray defines the ray to test
  21348. * @returns true is the passed ray intersects the submesh bounding box
  21349. */
  21350. canIntersects(ray: Ray): boolean;
  21351. /**
  21352. * Intersects current submesh with a ray
  21353. * @param ray defines the ray to test
  21354. * @param positions defines mesh's positions array
  21355. * @param indices defines mesh's indices array
  21356. * @param fastCheck defines if only bounding info should be used
  21357. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21358. * @returns intersection info or null if no intersection
  21359. */
  21360. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21361. /** @hidden */
  21362. private _intersectLines;
  21363. /** @hidden */
  21364. private _intersectUnIndexedLines;
  21365. /** @hidden */
  21366. private _intersectTriangles;
  21367. /** @hidden */
  21368. private _intersectUnIndexedTriangles;
  21369. /** @hidden */
  21370. _rebuild(): void;
  21371. /**
  21372. * Creates a new submesh from the passed mesh
  21373. * @param newMesh defines the new hosting mesh
  21374. * @param newRenderingMesh defines an optional rendering mesh
  21375. * @returns the new submesh
  21376. */
  21377. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21378. /**
  21379. * Release associated resources
  21380. */
  21381. dispose(): void;
  21382. /**
  21383. * Gets the class name
  21384. * @returns the string "SubMesh".
  21385. */
  21386. getClassName(): string;
  21387. /**
  21388. * Creates a new submesh from indices data
  21389. * @param materialIndex the index of the main mesh material
  21390. * @param startIndex the index where to start the copy in the mesh indices array
  21391. * @param indexCount the number of indices to copy then from the startIndex
  21392. * @param mesh the main mesh to create the submesh from
  21393. * @param renderingMesh the optional rendering mesh
  21394. * @returns a new submesh
  21395. */
  21396. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21397. }
  21398. }
  21399. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21400. /**
  21401. * Class used to represent data loading progression
  21402. */
  21403. export class SceneLoaderFlags {
  21404. private static _ForceFullSceneLoadingForIncremental;
  21405. private static _ShowLoadingScreen;
  21406. private static _CleanBoneMatrixWeights;
  21407. private static _loggingLevel;
  21408. /**
  21409. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21410. */
  21411. static ForceFullSceneLoadingForIncremental: boolean;
  21412. /**
  21413. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21414. */
  21415. static ShowLoadingScreen: boolean;
  21416. /**
  21417. * Defines the current logging level (while loading the scene)
  21418. * @ignorenaming
  21419. */
  21420. static loggingLevel: number;
  21421. /**
  21422. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21423. */
  21424. static CleanBoneMatrixWeights: boolean;
  21425. }
  21426. }
  21427. declare module "babylonjs/Meshes/geometry" {
  21428. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21429. import { Scene } from "babylonjs/scene";
  21430. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21431. import { Engine } from "babylonjs/Engines/engine";
  21432. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21433. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21434. import { Effect } from "babylonjs/Materials/effect";
  21435. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21436. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21437. import { Mesh } from "babylonjs/Meshes/mesh";
  21438. /**
  21439. * Class used to store geometry data (vertex buffers + index buffer)
  21440. */
  21441. export class Geometry implements IGetSetVerticesData {
  21442. /**
  21443. * Gets or sets the ID of the geometry
  21444. */
  21445. id: string;
  21446. /**
  21447. * Gets or sets the unique ID of the geometry
  21448. */
  21449. uniqueId: number;
  21450. /**
  21451. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21452. */
  21453. delayLoadState: number;
  21454. /**
  21455. * Gets the file containing the data to load when running in delay load state
  21456. */
  21457. delayLoadingFile: Nullable<string>;
  21458. /**
  21459. * Callback called when the geometry is updated
  21460. */
  21461. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21462. private _scene;
  21463. private _engine;
  21464. private _meshes;
  21465. private _totalVertices;
  21466. /** @hidden */
  21467. _indices: IndicesArray;
  21468. /** @hidden */
  21469. _vertexBuffers: {
  21470. [key: string]: VertexBuffer;
  21471. };
  21472. private _isDisposed;
  21473. private _extend;
  21474. private _boundingBias;
  21475. /** @hidden */
  21476. _delayInfo: Array<string>;
  21477. private _indexBuffer;
  21478. private _indexBufferIsUpdatable;
  21479. /** @hidden */
  21480. _boundingInfo: Nullable<BoundingInfo>;
  21481. /** @hidden */
  21482. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21483. /** @hidden */
  21484. _softwareSkinningFrameId: number;
  21485. private _vertexArrayObjects;
  21486. private _updatable;
  21487. /** @hidden */
  21488. _positions: Nullable<Vector3[]>;
  21489. /**
  21490. * 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
  21491. */
  21492. /**
  21493. * 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
  21494. */
  21495. boundingBias: Vector2;
  21496. /**
  21497. * Static function used to attach a new empty geometry to a mesh
  21498. * @param mesh defines the mesh to attach the geometry to
  21499. * @returns the new Geometry
  21500. */
  21501. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21502. /**
  21503. * Creates a new geometry
  21504. * @param id defines the unique ID
  21505. * @param scene defines the hosting scene
  21506. * @param vertexData defines the VertexData used to get geometry data
  21507. * @param updatable defines if geometry must be updatable (false by default)
  21508. * @param mesh defines the mesh that will be associated with the geometry
  21509. */
  21510. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21511. /**
  21512. * Gets the current extend of the geometry
  21513. */
  21514. readonly extend: {
  21515. minimum: Vector3;
  21516. maximum: Vector3;
  21517. };
  21518. /**
  21519. * Gets the hosting scene
  21520. * @returns the hosting Scene
  21521. */
  21522. getScene(): Scene;
  21523. /**
  21524. * Gets the hosting engine
  21525. * @returns the hosting Engine
  21526. */
  21527. getEngine(): Engine;
  21528. /**
  21529. * Defines if the geometry is ready to use
  21530. * @returns true if the geometry is ready to be used
  21531. */
  21532. isReady(): boolean;
  21533. /**
  21534. * Gets a value indicating that the geometry should not be serialized
  21535. */
  21536. readonly doNotSerialize: boolean;
  21537. /** @hidden */
  21538. _rebuild(): void;
  21539. /**
  21540. * Affects all geometry data in one call
  21541. * @param vertexData defines the geometry data
  21542. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21543. */
  21544. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21545. /**
  21546. * Set specific vertex data
  21547. * @param kind defines the data kind (Position, normal, etc...)
  21548. * @param data defines the vertex data to use
  21549. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21550. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21551. */
  21552. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21553. /**
  21554. * Removes a specific vertex data
  21555. * @param kind defines the data kind (Position, normal, etc...)
  21556. */
  21557. removeVerticesData(kind: string): void;
  21558. /**
  21559. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21560. * @param buffer defines the vertex buffer to use
  21561. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21562. */
  21563. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21564. /**
  21565. * Update a specific vertex buffer
  21566. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21567. * It will do nothing if the buffer is not updatable
  21568. * @param kind defines the data kind (Position, normal, etc...)
  21569. * @param data defines the data to use
  21570. * @param offset defines the offset in the target buffer where to store the data
  21571. * @param useBytes set to true if the offset is in bytes
  21572. */
  21573. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21574. /**
  21575. * Update a specific vertex buffer
  21576. * This function will create a new buffer if the current one is not updatable
  21577. * @param kind defines the data kind (Position, normal, etc...)
  21578. * @param data defines the data to use
  21579. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21580. */
  21581. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21582. private _updateBoundingInfo;
  21583. /** @hidden */
  21584. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21585. /**
  21586. * Gets total number of vertices
  21587. * @returns the total number of vertices
  21588. */
  21589. getTotalVertices(): number;
  21590. /**
  21591. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21592. * @param kind defines the data kind (Position, normal, etc...)
  21593. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21594. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21595. * @returns a float array containing vertex data
  21596. */
  21597. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21598. /**
  21599. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21600. * @param kind defines the data kind (Position, normal, etc...)
  21601. * @returns true if the vertex buffer with the specified kind is updatable
  21602. */
  21603. isVertexBufferUpdatable(kind: string): boolean;
  21604. /**
  21605. * Gets a specific vertex buffer
  21606. * @param kind defines the data kind (Position, normal, etc...)
  21607. * @returns a VertexBuffer
  21608. */
  21609. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21610. /**
  21611. * Returns all vertex buffers
  21612. * @return an object holding all vertex buffers indexed by kind
  21613. */
  21614. getVertexBuffers(): Nullable<{
  21615. [key: string]: VertexBuffer;
  21616. }>;
  21617. /**
  21618. * Gets a boolean indicating if specific vertex buffer is present
  21619. * @param kind defines the data kind (Position, normal, etc...)
  21620. * @returns true if data is present
  21621. */
  21622. isVerticesDataPresent(kind: string): boolean;
  21623. /**
  21624. * Gets a list of all attached data kinds (Position, normal, etc...)
  21625. * @returns a list of string containing all kinds
  21626. */
  21627. getVerticesDataKinds(): string[];
  21628. /**
  21629. * Update index buffer
  21630. * @param indices defines the indices to store in the index buffer
  21631. * @param offset defines the offset in the target buffer where to store the data
  21632. * @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)
  21633. */
  21634. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21635. /**
  21636. * Creates a new index buffer
  21637. * @param indices defines the indices to store in the index buffer
  21638. * @param totalVertices defines the total number of vertices (could be null)
  21639. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21640. */
  21641. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21642. /**
  21643. * Return the total number of indices
  21644. * @returns the total number of indices
  21645. */
  21646. getTotalIndices(): number;
  21647. /**
  21648. * Gets the index buffer array
  21649. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21651. * @returns the index buffer array
  21652. */
  21653. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21654. /**
  21655. * Gets the index buffer
  21656. * @return the index buffer
  21657. */
  21658. getIndexBuffer(): Nullable<DataBuffer>;
  21659. /** @hidden */
  21660. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21661. /**
  21662. * Release the associated resources for a specific mesh
  21663. * @param mesh defines the source mesh
  21664. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21665. */
  21666. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21667. /**
  21668. * Apply current geometry to a given mesh
  21669. * @param mesh defines the mesh to apply geometry to
  21670. */
  21671. applyToMesh(mesh: Mesh): void;
  21672. private _updateExtend;
  21673. private _applyToMesh;
  21674. private notifyUpdate;
  21675. /**
  21676. * Load the geometry if it was flagged as delay loaded
  21677. * @param scene defines the hosting scene
  21678. * @param onLoaded defines a callback called when the geometry is loaded
  21679. */
  21680. load(scene: Scene, onLoaded?: () => void): void;
  21681. private _queueLoad;
  21682. /**
  21683. * Invert the geometry to move from a right handed system to a left handed one.
  21684. */
  21685. toLeftHanded(): void;
  21686. /** @hidden */
  21687. _resetPointsArrayCache(): void;
  21688. /** @hidden */
  21689. _generatePointsArray(): boolean;
  21690. /**
  21691. * Gets a value indicating if the geometry is disposed
  21692. * @returns true if the geometry was disposed
  21693. */
  21694. isDisposed(): boolean;
  21695. private _disposeVertexArrayObjects;
  21696. /**
  21697. * Free all associated resources
  21698. */
  21699. dispose(): void;
  21700. /**
  21701. * Clone the current geometry into a new geometry
  21702. * @param id defines the unique ID of the new geometry
  21703. * @returns a new geometry object
  21704. */
  21705. copy(id: string): Geometry;
  21706. /**
  21707. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21708. * @return a JSON representation of the current geometry data (without the vertices data)
  21709. */
  21710. serialize(): any;
  21711. private toNumberArray;
  21712. /**
  21713. * Serialize all vertices data into a JSON oject
  21714. * @returns a JSON representation of the current geometry data
  21715. */
  21716. serializeVerticeData(): any;
  21717. /**
  21718. * Extracts a clone of a mesh geometry
  21719. * @param mesh defines the source mesh
  21720. * @param id defines the unique ID of the new geometry object
  21721. * @returns the new geometry object
  21722. */
  21723. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21724. /**
  21725. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21726. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21727. * Be aware Math.random() could cause collisions, but:
  21728. * "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"
  21729. * @returns a string containing a new GUID
  21730. */
  21731. static RandomId(): string;
  21732. /** @hidden */
  21733. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21734. private static _CleanMatricesWeights;
  21735. /**
  21736. * Create a new geometry from persisted data (Using .babylon file format)
  21737. * @param parsedVertexData defines the persisted data
  21738. * @param scene defines the hosting scene
  21739. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21740. * @returns the new geometry object
  21741. */
  21742. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21743. }
  21744. }
  21745. declare module "babylonjs/Meshes/mesh.vertexData" {
  21746. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21747. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21748. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21749. import { Geometry } from "babylonjs/Meshes/geometry";
  21750. import { Mesh } from "babylonjs/Meshes/mesh";
  21751. /**
  21752. * Define an interface for all classes that will get and set the data on vertices
  21753. */
  21754. export interface IGetSetVerticesData {
  21755. /**
  21756. * Gets a boolean indicating if specific vertex data is present
  21757. * @param kind defines the vertex data kind to use
  21758. * @returns true is data kind is present
  21759. */
  21760. isVerticesDataPresent(kind: string): boolean;
  21761. /**
  21762. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21763. * @param kind defines the data kind (Position, normal, etc...)
  21764. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21765. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21766. * @returns a float array containing vertex data
  21767. */
  21768. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21769. /**
  21770. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21771. * @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.
  21772. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21773. * @returns the indices array or an empty array if the mesh has no geometry
  21774. */
  21775. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21776. /**
  21777. * Set specific vertex data
  21778. * @param kind defines the data kind (Position, normal, etc...)
  21779. * @param data defines the vertex data to use
  21780. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21781. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21782. */
  21783. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21784. /**
  21785. * Update a specific associated vertex buffer
  21786. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21787. * - VertexBuffer.PositionKind
  21788. * - VertexBuffer.UVKind
  21789. * - VertexBuffer.UV2Kind
  21790. * - VertexBuffer.UV3Kind
  21791. * - VertexBuffer.UV4Kind
  21792. * - VertexBuffer.UV5Kind
  21793. * - VertexBuffer.UV6Kind
  21794. * - VertexBuffer.ColorKind
  21795. * - VertexBuffer.MatricesIndicesKind
  21796. * - VertexBuffer.MatricesIndicesExtraKind
  21797. * - VertexBuffer.MatricesWeightsKind
  21798. * - VertexBuffer.MatricesWeightsExtraKind
  21799. * @param data defines the data source
  21800. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21801. * @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)
  21802. */
  21803. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21804. /**
  21805. * Creates a new index buffer
  21806. * @param indices defines the indices to store in the index buffer
  21807. * @param totalVertices defines the total number of vertices (could be null)
  21808. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21809. */
  21810. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21811. }
  21812. /**
  21813. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21814. */
  21815. export class VertexData {
  21816. /**
  21817. * Mesh side orientation : usually the external or front surface
  21818. */
  21819. static readonly FRONTSIDE: number;
  21820. /**
  21821. * Mesh side orientation : usually the internal or back surface
  21822. */
  21823. static readonly BACKSIDE: number;
  21824. /**
  21825. * Mesh side orientation : both internal and external or front and back surfaces
  21826. */
  21827. static readonly DOUBLESIDE: number;
  21828. /**
  21829. * Mesh side orientation : by default, `FRONTSIDE`
  21830. */
  21831. static readonly DEFAULTSIDE: number;
  21832. /**
  21833. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21834. */
  21835. positions: Nullable<FloatArray>;
  21836. /**
  21837. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21838. */
  21839. normals: Nullable<FloatArray>;
  21840. /**
  21841. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21842. */
  21843. tangents: Nullable<FloatArray>;
  21844. /**
  21845. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21846. */
  21847. uvs: Nullable<FloatArray>;
  21848. /**
  21849. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21850. */
  21851. uvs2: Nullable<FloatArray>;
  21852. /**
  21853. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21854. */
  21855. uvs3: Nullable<FloatArray>;
  21856. /**
  21857. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21858. */
  21859. uvs4: Nullable<FloatArray>;
  21860. /**
  21861. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21862. */
  21863. uvs5: Nullable<FloatArray>;
  21864. /**
  21865. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21866. */
  21867. uvs6: Nullable<FloatArray>;
  21868. /**
  21869. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21870. */
  21871. colors: Nullable<FloatArray>;
  21872. /**
  21873. * 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).
  21874. */
  21875. matricesIndices: Nullable<FloatArray>;
  21876. /**
  21877. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21878. */
  21879. matricesWeights: Nullable<FloatArray>;
  21880. /**
  21881. * An array extending the number of possible indices
  21882. */
  21883. matricesIndicesExtra: Nullable<FloatArray>;
  21884. /**
  21885. * An array extending the number of possible weights when the number of indices is extended
  21886. */
  21887. matricesWeightsExtra: Nullable<FloatArray>;
  21888. /**
  21889. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21890. */
  21891. indices: Nullable<IndicesArray>;
  21892. /**
  21893. * Uses the passed data array to set the set the values for the specified kind of data
  21894. * @param data a linear array of floating numbers
  21895. * @param kind the type of data that is being set, eg positions, colors etc
  21896. */
  21897. set(data: FloatArray, kind: string): void;
  21898. /**
  21899. * Associates the vertexData to the passed Mesh.
  21900. * Sets it as updatable or not (default `false`)
  21901. * @param mesh the mesh the vertexData is applied to
  21902. * @param updatable when used and having the value true allows new data to update the vertexData
  21903. * @returns the VertexData
  21904. */
  21905. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21906. /**
  21907. * Associates the vertexData to the passed Geometry.
  21908. * Sets it as updatable or not (default `false`)
  21909. * @param geometry the geometry the vertexData is applied to
  21910. * @param updatable when used and having the value true allows new data to update the vertexData
  21911. * @returns VertexData
  21912. */
  21913. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21914. /**
  21915. * Updates the associated mesh
  21916. * @param mesh the mesh to be updated
  21917. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21918. * @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
  21919. * @returns VertexData
  21920. */
  21921. updateMesh(mesh: Mesh): VertexData;
  21922. /**
  21923. * Updates the associated geometry
  21924. * @param geometry the geometry to be updated
  21925. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21926. * @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
  21927. * @returns VertexData.
  21928. */
  21929. updateGeometry(geometry: Geometry): VertexData;
  21930. private _applyTo;
  21931. private _update;
  21932. /**
  21933. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21934. * @param matrix the transforming matrix
  21935. * @returns the VertexData
  21936. */
  21937. transform(matrix: Matrix): VertexData;
  21938. /**
  21939. * Merges the passed VertexData into the current one
  21940. * @param other the VertexData to be merged into the current one
  21941. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21942. * @returns the modified VertexData
  21943. */
  21944. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21945. private _mergeElement;
  21946. private _validate;
  21947. /**
  21948. * Serializes the VertexData
  21949. * @returns a serialized object
  21950. */
  21951. serialize(): any;
  21952. /**
  21953. * Extracts the vertexData from a mesh
  21954. * @param mesh the mesh from which to extract the VertexData
  21955. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21956. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21957. * @returns the object VertexData associated to the passed mesh
  21958. */
  21959. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21960. /**
  21961. * Extracts the vertexData from the geometry
  21962. * @param geometry the geometry from which to extract the VertexData
  21963. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21964. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21965. * @returns the object VertexData associated to the passed mesh
  21966. */
  21967. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21968. private static _ExtractFrom;
  21969. /**
  21970. * Creates the VertexData for a Ribbon
  21971. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21972. * * pathArray array of paths, each of which an array of successive Vector3
  21973. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21974. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21975. * * 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
  21976. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21977. * * 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)
  21978. * * 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)
  21979. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21980. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21981. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21982. * @returns the VertexData of the ribbon
  21983. */
  21984. static CreateRibbon(options: {
  21985. pathArray: Vector3[][];
  21986. closeArray?: boolean;
  21987. closePath?: boolean;
  21988. offset?: number;
  21989. sideOrientation?: number;
  21990. frontUVs?: Vector4;
  21991. backUVs?: Vector4;
  21992. invertUV?: boolean;
  21993. uvs?: Vector2[];
  21994. colors?: Color4[];
  21995. }): VertexData;
  21996. /**
  21997. * Creates the VertexData for a box
  21998. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21999. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22000. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22001. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22002. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22003. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22004. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22006. * * 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)
  22007. * * 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)
  22008. * @returns the VertexData of the box
  22009. */
  22010. static CreateBox(options: {
  22011. size?: number;
  22012. width?: number;
  22013. height?: number;
  22014. depth?: number;
  22015. faceUV?: Vector4[];
  22016. faceColors?: Color4[];
  22017. sideOrientation?: number;
  22018. frontUVs?: Vector4;
  22019. backUVs?: Vector4;
  22020. }): VertexData;
  22021. /**
  22022. * Creates the VertexData for a tiled box
  22023. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22024. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22025. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22026. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22028. * @returns the VertexData of the box
  22029. */
  22030. static CreateTiledBox(options: {
  22031. pattern?: number;
  22032. width?: number;
  22033. height?: number;
  22034. depth?: number;
  22035. tileSize?: number;
  22036. tileWidth?: number;
  22037. tileHeight?: number;
  22038. alignHorizontal?: number;
  22039. alignVertical?: number;
  22040. faceUV?: Vector4[];
  22041. faceColors?: Color4[];
  22042. sideOrientation?: number;
  22043. }): VertexData;
  22044. /**
  22045. * Creates the VertexData for a tiled plane
  22046. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22047. * * pattern a limited pattern arrangement depending on the number
  22048. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22049. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22050. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22052. * * 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)
  22053. * * 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)
  22054. * @returns the VertexData of the tiled plane
  22055. */
  22056. static CreateTiledPlane(options: {
  22057. pattern?: number;
  22058. tileSize?: number;
  22059. tileWidth?: number;
  22060. tileHeight?: number;
  22061. size?: number;
  22062. width?: number;
  22063. height?: number;
  22064. alignHorizontal?: number;
  22065. alignVertical?: number;
  22066. sideOrientation?: number;
  22067. frontUVs?: Vector4;
  22068. backUVs?: Vector4;
  22069. }): VertexData;
  22070. /**
  22071. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22072. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22073. * * segments sets the number of horizontal strips optional, default 32
  22074. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22075. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22076. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22077. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22078. * * 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
  22079. * * 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
  22080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22081. * * 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)
  22082. * * 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)
  22083. * @returns the VertexData of the ellipsoid
  22084. */
  22085. static CreateSphere(options: {
  22086. segments?: number;
  22087. diameter?: number;
  22088. diameterX?: number;
  22089. diameterY?: number;
  22090. diameterZ?: number;
  22091. arc?: number;
  22092. slice?: number;
  22093. sideOrientation?: number;
  22094. frontUVs?: Vector4;
  22095. backUVs?: Vector4;
  22096. }): VertexData;
  22097. /**
  22098. * Creates the VertexData for a cylinder, cone or prism
  22099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22100. * * height sets the height (y direction) of the cylinder, optional, default 2
  22101. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22102. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22103. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22104. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22105. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22106. * * 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
  22107. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22108. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22109. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22110. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22112. * * 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)
  22113. * * 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)
  22114. * @returns the VertexData of the cylinder, cone or prism
  22115. */
  22116. static CreateCylinder(options: {
  22117. height?: number;
  22118. diameterTop?: number;
  22119. diameterBottom?: number;
  22120. diameter?: number;
  22121. tessellation?: number;
  22122. subdivisions?: number;
  22123. arc?: number;
  22124. faceColors?: Color4[];
  22125. faceUV?: Vector4[];
  22126. hasRings?: boolean;
  22127. enclose?: boolean;
  22128. sideOrientation?: number;
  22129. frontUVs?: Vector4;
  22130. backUVs?: Vector4;
  22131. }): VertexData;
  22132. /**
  22133. * Creates the VertexData for a torus
  22134. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22135. * * diameter the diameter of the torus, optional default 1
  22136. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22137. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22138. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22139. * * 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)
  22140. * * 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)
  22141. * @returns the VertexData of the torus
  22142. */
  22143. static CreateTorus(options: {
  22144. diameter?: number;
  22145. thickness?: number;
  22146. tessellation?: number;
  22147. sideOrientation?: number;
  22148. frontUVs?: Vector4;
  22149. backUVs?: Vector4;
  22150. }): VertexData;
  22151. /**
  22152. * Creates the VertexData of the LineSystem
  22153. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22154. * - lines an array of lines, each line being an array of successive Vector3
  22155. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22156. * @returns the VertexData of the LineSystem
  22157. */
  22158. static CreateLineSystem(options: {
  22159. lines: Vector3[][];
  22160. colors?: Nullable<Color4[][]>;
  22161. }): VertexData;
  22162. /**
  22163. * Create the VertexData for a DashedLines
  22164. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22165. * - points an array successive Vector3
  22166. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22167. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22168. * - dashNb the intended total number of dashes, optional, default 200
  22169. * @returns the VertexData for the DashedLines
  22170. */
  22171. static CreateDashedLines(options: {
  22172. points: Vector3[];
  22173. dashSize?: number;
  22174. gapSize?: number;
  22175. dashNb?: number;
  22176. }): VertexData;
  22177. /**
  22178. * Creates the VertexData for a Ground
  22179. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22180. * - width the width (x direction) of the ground, optional, default 1
  22181. * - height the height (z direction) of the ground, optional, default 1
  22182. * - subdivisions the number of subdivisions per side, optional, default 1
  22183. * @returns the VertexData of the Ground
  22184. */
  22185. static CreateGround(options: {
  22186. width?: number;
  22187. height?: number;
  22188. subdivisions?: number;
  22189. subdivisionsX?: number;
  22190. subdivisionsY?: number;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22194. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22195. * * xmin the ground minimum X coordinate, optional, default -1
  22196. * * zmin the ground minimum Z coordinate, optional, default -1
  22197. * * xmax the ground maximum X coordinate, optional, default 1
  22198. * * zmax the ground maximum Z coordinate, optional, default 1
  22199. * * 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}
  22200. * * 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}
  22201. * @returns the VertexData of the TiledGround
  22202. */
  22203. static CreateTiledGround(options: {
  22204. xmin: number;
  22205. zmin: number;
  22206. xmax: number;
  22207. zmax: number;
  22208. subdivisions?: {
  22209. w: number;
  22210. h: number;
  22211. };
  22212. precision?: {
  22213. w: number;
  22214. h: number;
  22215. };
  22216. }): VertexData;
  22217. /**
  22218. * Creates the VertexData of the Ground designed from a heightmap
  22219. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22220. * * width the width (x direction) of the ground
  22221. * * height the height (z direction) of the ground
  22222. * * subdivisions the number of subdivisions per side
  22223. * * minHeight the minimum altitude on the ground, optional, default 0
  22224. * * maxHeight the maximum altitude on the ground, optional default 1
  22225. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22226. * * buffer the array holding the image color data
  22227. * * bufferWidth the width of image
  22228. * * bufferHeight the height of image
  22229. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22230. * @returns the VertexData of the Ground designed from a heightmap
  22231. */
  22232. static CreateGroundFromHeightMap(options: {
  22233. width: number;
  22234. height: number;
  22235. subdivisions: number;
  22236. minHeight: number;
  22237. maxHeight: number;
  22238. colorFilter: Color3;
  22239. buffer: Uint8Array;
  22240. bufferWidth: number;
  22241. bufferHeight: number;
  22242. alphaFilter: number;
  22243. }): VertexData;
  22244. /**
  22245. * Creates the VertexData for a Plane
  22246. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22247. * * size sets the width and height of the plane to the value of size, optional default 1
  22248. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22249. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22251. * * 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)
  22252. * * 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)
  22253. * @returns the VertexData of the box
  22254. */
  22255. static CreatePlane(options: {
  22256. size?: number;
  22257. width?: number;
  22258. height?: number;
  22259. sideOrientation?: number;
  22260. frontUVs?: Vector4;
  22261. backUVs?: Vector4;
  22262. }): VertexData;
  22263. /**
  22264. * Creates the VertexData of the Disc or regular Polygon
  22265. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22266. * * radius the radius of the disc, optional default 0.5
  22267. * * tessellation the number of polygon sides, optional, default 64
  22268. * * 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
  22269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22270. * * 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)
  22271. * * 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)
  22272. * @returns the VertexData of the box
  22273. */
  22274. static CreateDisc(options: {
  22275. radius?: number;
  22276. tessellation?: number;
  22277. arc?: number;
  22278. sideOrientation?: number;
  22279. frontUVs?: Vector4;
  22280. backUVs?: Vector4;
  22281. }): VertexData;
  22282. /**
  22283. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22284. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22285. * @param polygon a mesh built from polygonTriangulation.build()
  22286. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22287. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22288. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22289. * @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)
  22290. * @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)
  22291. * @returns the VertexData of the Polygon
  22292. */
  22293. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22294. /**
  22295. * Creates the VertexData of the IcoSphere
  22296. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22297. * * radius the radius of the IcoSphere, optional default 1
  22298. * * radiusX allows stretching in the x direction, optional, default radius
  22299. * * radiusY allows stretching in the y direction, optional, default radius
  22300. * * radiusZ allows stretching in the z direction, optional, default radius
  22301. * * flat when true creates a flat shaded mesh, optional, default true
  22302. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22304. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22305. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22306. * @returns the VertexData of the IcoSphere
  22307. */
  22308. static CreateIcoSphere(options: {
  22309. radius?: number;
  22310. radiusX?: number;
  22311. radiusY?: number;
  22312. radiusZ?: number;
  22313. flat?: boolean;
  22314. subdivisions?: number;
  22315. sideOrientation?: number;
  22316. frontUVs?: Vector4;
  22317. backUVs?: Vector4;
  22318. }): VertexData;
  22319. /**
  22320. * Creates the VertexData for a Polyhedron
  22321. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22322. * * type provided types are:
  22323. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22324. * * 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)
  22325. * * size the size of the IcoSphere, optional default 1
  22326. * * sizeX allows stretching in the x direction, optional, default size
  22327. * * sizeY allows stretching in the y direction, optional, default size
  22328. * * sizeZ allows stretching in the z direction, optional, default size
  22329. * * 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
  22330. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22331. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22332. * * flat when true creates a flat shaded mesh, optional, default true
  22333. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22335. * * 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)
  22336. * * 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)
  22337. * @returns the VertexData of the Polyhedron
  22338. */
  22339. static CreatePolyhedron(options: {
  22340. type?: number;
  22341. size?: number;
  22342. sizeX?: number;
  22343. sizeY?: number;
  22344. sizeZ?: number;
  22345. custom?: any;
  22346. faceUV?: Vector4[];
  22347. faceColors?: Color4[];
  22348. flat?: boolean;
  22349. sideOrientation?: number;
  22350. frontUVs?: Vector4;
  22351. backUVs?: Vector4;
  22352. }): VertexData;
  22353. /**
  22354. * Creates the VertexData for a TorusKnot
  22355. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22356. * * radius the radius of the torus knot, optional, default 2
  22357. * * tube the thickness of the tube, optional, default 0.5
  22358. * * radialSegments the number of sides on each tube segments, optional, default 32
  22359. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22360. * * p the number of windings around the z axis, optional, default 2
  22361. * * q the number of windings around the x axis, optional, default 3
  22362. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22363. * * 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)
  22364. * * 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)
  22365. * @returns the VertexData of the Torus Knot
  22366. */
  22367. static CreateTorusKnot(options: {
  22368. radius?: number;
  22369. tube?: number;
  22370. radialSegments?: number;
  22371. tubularSegments?: number;
  22372. p?: number;
  22373. q?: number;
  22374. sideOrientation?: number;
  22375. frontUVs?: Vector4;
  22376. backUVs?: Vector4;
  22377. }): VertexData;
  22378. /**
  22379. * Compute normals for given positions and indices
  22380. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22381. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22382. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22383. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22384. * * facetNormals : optional array of facet normals (vector3)
  22385. * * facetPositions : optional array of facet positions (vector3)
  22386. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22387. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22388. * * bInfo : optional bounding info, required for facetPartitioning computation
  22389. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22390. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22391. * * useRightHandedSystem: optional boolean to for right handed system computation
  22392. * * depthSort : optional boolean to enable the facet depth sort computation
  22393. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22394. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22395. */
  22396. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22397. facetNormals?: any;
  22398. facetPositions?: any;
  22399. facetPartitioning?: any;
  22400. ratio?: number;
  22401. bInfo?: any;
  22402. bbSize?: Vector3;
  22403. subDiv?: any;
  22404. useRightHandedSystem?: boolean;
  22405. depthSort?: boolean;
  22406. distanceTo?: Vector3;
  22407. depthSortedFacets?: any;
  22408. }): void;
  22409. /** @hidden */
  22410. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22411. /**
  22412. * Applies VertexData created from the imported parameters to the geometry
  22413. * @param parsedVertexData the parsed data from an imported file
  22414. * @param geometry the geometry to apply the VertexData to
  22415. */
  22416. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22417. }
  22418. }
  22419. declare module "babylonjs/Morph/morphTarget" {
  22420. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22421. import { Observable } from "babylonjs/Misc/observable";
  22422. import { Nullable, FloatArray } from "babylonjs/types";
  22423. import { Scene } from "babylonjs/scene";
  22424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22425. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22426. /**
  22427. * Defines a target to use with MorphTargetManager
  22428. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22429. */
  22430. export class MorphTarget implements IAnimatable {
  22431. /** defines the name of the target */
  22432. name: string;
  22433. /**
  22434. * Gets or sets the list of animations
  22435. */
  22436. animations: import("babylonjs/Animations/animation").Animation[];
  22437. private _scene;
  22438. private _positions;
  22439. private _normals;
  22440. private _tangents;
  22441. private _uvs;
  22442. private _influence;
  22443. /**
  22444. * Observable raised when the influence changes
  22445. */
  22446. onInfluenceChanged: Observable<boolean>;
  22447. /** @hidden */
  22448. _onDataLayoutChanged: Observable<void>;
  22449. /**
  22450. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22451. */
  22452. influence: number;
  22453. /**
  22454. * Gets or sets the id of the morph Target
  22455. */
  22456. id: string;
  22457. private _animationPropertiesOverride;
  22458. /**
  22459. * Gets or sets the animation properties override
  22460. */
  22461. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22462. /**
  22463. * Creates a new MorphTarget
  22464. * @param name defines the name of the target
  22465. * @param influence defines the influence to use
  22466. * @param scene defines the scene the morphtarget belongs to
  22467. */
  22468. constructor(
  22469. /** defines the name of the target */
  22470. name: string, influence?: number, scene?: Nullable<Scene>);
  22471. /**
  22472. * Gets a boolean defining if the target contains position data
  22473. */
  22474. readonly hasPositions: boolean;
  22475. /**
  22476. * Gets a boolean defining if the target contains normal data
  22477. */
  22478. readonly hasNormals: boolean;
  22479. /**
  22480. * Gets a boolean defining if the target contains tangent data
  22481. */
  22482. readonly hasTangents: boolean;
  22483. /**
  22484. * Gets a boolean defining if the target contains texture coordinates data
  22485. */
  22486. readonly hasUVs: boolean;
  22487. /**
  22488. * Affects position data to this target
  22489. * @param data defines the position data to use
  22490. */
  22491. setPositions(data: Nullable<FloatArray>): void;
  22492. /**
  22493. * Gets the position data stored in this target
  22494. * @returns a FloatArray containing the position data (or null if not present)
  22495. */
  22496. getPositions(): Nullable<FloatArray>;
  22497. /**
  22498. * Affects normal data to this target
  22499. * @param data defines the normal data to use
  22500. */
  22501. setNormals(data: Nullable<FloatArray>): void;
  22502. /**
  22503. * Gets the normal data stored in this target
  22504. * @returns a FloatArray containing the normal data (or null if not present)
  22505. */
  22506. getNormals(): Nullable<FloatArray>;
  22507. /**
  22508. * Affects tangent data to this target
  22509. * @param data defines the tangent data to use
  22510. */
  22511. setTangents(data: Nullable<FloatArray>): void;
  22512. /**
  22513. * Gets the tangent data stored in this target
  22514. * @returns a FloatArray containing the tangent data (or null if not present)
  22515. */
  22516. getTangents(): Nullable<FloatArray>;
  22517. /**
  22518. * Affects texture coordinates data to this target
  22519. * @param data defines the texture coordinates data to use
  22520. */
  22521. setUVs(data: Nullable<FloatArray>): void;
  22522. /**
  22523. * Gets the texture coordinates data stored in this target
  22524. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22525. */
  22526. getUVs(): Nullable<FloatArray>;
  22527. /**
  22528. * Serializes the current target into a Serialization object
  22529. * @returns the serialized object
  22530. */
  22531. serialize(): any;
  22532. /**
  22533. * Returns the string "MorphTarget"
  22534. * @returns "MorphTarget"
  22535. */
  22536. getClassName(): string;
  22537. /**
  22538. * Creates a new target from serialized data
  22539. * @param serializationObject defines the serialized data to use
  22540. * @returns a new MorphTarget
  22541. */
  22542. static Parse(serializationObject: any): MorphTarget;
  22543. /**
  22544. * Creates a MorphTarget from mesh data
  22545. * @param mesh defines the source mesh
  22546. * @param name defines the name to use for the new target
  22547. * @param influence defines the influence to attach to the target
  22548. * @returns a new MorphTarget
  22549. */
  22550. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22551. }
  22552. }
  22553. declare module "babylonjs/Morph/morphTargetManager" {
  22554. import { Nullable } from "babylonjs/types";
  22555. import { Scene } from "babylonjs/scene";
  22556. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22557. /**
  22558. * This class is used to deform meshes using morphing between different targets
  22559. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22560. */
  22561. export class MorphTargetManager {
  22562. private _targets;
  22563. private _targetInfluenceChangedObservers;
  22564. private _targetDataLayoutChangedObservers;
  22565. private _activeTargets;
  22566. private _scene;
  22567. private _influences;
  22568. private _supportsNormals;
  22569. private _supportsTangents;
  22570. private _supportsUVs;
  22571. private _vertexCount;
  22572. private _uniqueId;
  22573. private _tempInfluences;
  22574. /**
  22575. * Gets or sets a boolean indicating if normals must be morphed
  22576. */
  22577. enableNormalMorphing: boolean;
  22578. /**
  22579. * Gets or sets a boolean indicating if tangents must be morphed
  22580. */
  22581. enableTangentMorphing: boolean;
  22582. /**
  22583. * Gets or sets a boolean indicating if UV must be morphed
  22584. */
  22585. enableUVMorphing: boolean;
  22586. /**
  22587. * Creates a new MorphTargetManager
  22588. * @param scene defines the current scene
  22589. */
  22590. constructor(scene?: Nullable<Scene>);
  22591. /**
  22592. * Gets the unique ID of this manager
  22593. */
  22594. readonly uniqueId: number;
  22595. /**
  22596. * Gets the number of vertices handled by this manager
  22597. */
  22598. readonly vertexCount: number;
  22599. /**
  22600. * Gets a boolean indicating if this manager supports morphing of normals
  22601. */
  22602. readonly supportsNormals: boolean;
  22603. /**
  22604. * Gets a boolean indicating if this manager supports morphing of tangents
  22605. */
  22606. readonly supportsTangents: boolean;
  22607. /**
  22608. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22609. */
  22610. readonly supportsUVs: boolean;
  22611. /**
  22612. * Gets the number of targets stored in this manager
  22613. */
  22614. readonly numTargets: number;
  22615. /**
  22616. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22617. */
  22618. readonly numInfluencers: number;
  22619. /**
  22620. * Gets the list of influences (one per target)
  22621. */
  22622. readonly influences: Float32Array;
  22623. /**
  22624. * Gets the active target at specified index. An active target is a target with an influence > 0
  22625. * @param index defines the index to check
  22626. * @returns the requested target
  22627. */
  22628. getActiveTarget(index: number): MorphTarget;
  22629. /**
  22630. * Gets the target at specified index
  22631. * @param index defines the index to check
  22632. * @returns the requested target
  22633. */
  22634. getTarget(index: number): MorphTarget;
  22635. /**
  22636. * Add a new target to this manager
  22637. * @param target defines the target to add
  22638. */
  22639. addTarget(target: MorphTarget): void;
  22640. /**
  22641. * Removes a target from the manager
  22642. * @param target defines the target to remove
  22643. */
  22644. removeTarget(target: MorphTarget): void;
  22645. /**
  22646. * Serializes the current manager into a Serialization object
  22647. * @returns the serialized object
  22648. */
  22649. serialize(): any;
  22650. private _syncActiveTargets;
  22651. /**
  22652. * Syncrhonize the targets with all the meshes using this morph target manager
  22653. */
  22654. synchronize(): void;
  22655. /**
  22656. * Creates a new MorphTargetManager from serialized data
  22657. * @param serializationObject defines the serialized data
  22658. * @param scene defines the hosting scene
  22659. * @returns the new MorphTargetManager
  22660. */
  22661. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22662. }
  22663. }
  22664. declare module "babylonjs/Meshes/meshLODLevel" {
  22665. import { Mesh } from "babylonjs/Meshes/mesh";
  22666. import { Nullable } from "babylonjs/types";
  22667. /**
  22668. * Class used to represent a specific level of detail of a mesh
  22669. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22670. */
  22671. export class MeshLODLevel {
  22672. /** Defines the distance where this level should start being displayed */
  22673. distance: number;
  22674. /** Defines the mesh to use to render this level */
  22675. mesh: Nullable<Mesh>;
  22676. /**
  22677. * Creates a new LOD level
  22678. * @param distance defines the distance where this level should star being displayed
  22679. * @param mesh defines the mesh to use to render this level
  22680. */
  22681. constructor(
  22682. /** Defines the distance where this level should start being displayed */
  22683. distance: number,
  22684. /** Defines the mesh to use to render this level */
  22685. mesh: Nullable<Mesh>);
  22686. }
  22687. }
  22688. declare module "babylonjs/Meshes/groundMesh" {
  22689. import { Scene } from "babylonjs/scene";
  22690. import { Vector3 } from "babylonjs/Maths/math.vector";
  22691. import { Mesh } from "babylonjs/Meshes/mesh";
  22692. /**
  22693. * Mesh representing the gorund
  22694. */
  22695. export class GroundMesh extends Mesh {
  22696. /** If octree should be generated */
  22697. generateOctree: boolean;
  22698. private _heightQuads;
  22699. /** @hidden */
  22700. _subdivisionsX: number;
  22701. /** @hidden */
  22702. _subdivisionsY: number;
  22703. /** @hidden */
  22704. _width: number;
  22705. /** @hidden */
  22706. _height: number;
  22707. /** @hidden */
  22708. _minX: number;
  22709. /** @hidden */
  22710. _maxX: number;
  22711. /** @hidden */
  22712. _minZ: number;
  22713. /** @hidden */
  22714. _maxZ: number;
  22715. constructor(name: string, scene: Scene);
  22716. /**
  22717. * "GroundMesh"
  22718. * @returns "GroundMesh"
  22719. */
  22720. getClassName(): string;
  22721. /**
  22722. * The minimum of x and y subdivisions
  22723. */
  22724. readonly subdivisions: number;
  22725. /**
  22726. * X subdivisions
  22727. */
  22728. readonly subdivisionsX: number;
  22729. /**
  22730. * Y subdivisions
  22731. */
  22732. readonly subdivisionsY: number;
  22733. /**
  22734. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22735. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22736. * @param chunksCount the number of subdivisions for x and y
  22737. * @param octreeBlocksSize (Default: 32)
  22738. */
  22739. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22740. /**
  22741. * Returns a height (y) value in the Worl system :
  22742. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22743. * @param x x coordinate
  22744. * @param z z coordinate
  22745. * @returns the ground y position if (x, z) are outside the ground surface.
  22746. */
  22747. getHeightAtCoordinates(x: number, z: number): number;
  22748. /**
  22749. * Returns a normalized vector (Vector3) orthogonal to the ground
  22750. * at the ground coordinates (x, z) expressed in the World system.
  22751. * @param x x coordinate
  22752. * @param z z coordinate
  22753. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22754. */
  22755. getNormalAtCoordinates(x: number, z: number): Vector3;
  22756. /**
  22757. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22758. * at the ground coordinates (x, z) expressed in the World system.
  22759. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22760. * @param x x coordinate
  22761. * @param z z coordinate
  22762. * @param ref vector to store the result
  22763. * @returns the GroundMesh.
  22764. */
  22765. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22766. /**
  22767. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22768. * if the ground has been updated.
  22769. * This can be used in the render loop.
  22770. * @returns the GroundMesh.
  22771. */
  22772. updateCoordinateHeights(): GroundMesh;
  22773. private _getFacetAt;
  22774. private _initHeightQuads;
  22775. private _computeHeightQuads;
  22776. /**
  22777. * Serializes this ground mesh
  22778. * @param serializationObject object to write serialization to
  22779. */
  22780. serialize(serializationObject: any): void;
  22781. /**
  22782. * Parses a serialized ground mesh
  22783. * @param parsedMesh the serialized mesh
  22784. * @param scene the scene to create the ground mesh in
  22785. * @returns the created ground mesh
  22786. */
  22787. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22788. }
  22789. }
  22790. declare module "babylonjs/Physics/physicsJoint" {
  22791. import { Vector3 } from "babylonjs/Maths/math.vector";
  22792. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22793. /**
  22794. * Interface for Physics-Joint data
  22795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22796. */
  22797. export interface PhysicsJointData {
  22798. /**
  22799. * The main pivot of the joint
  22800. */
  22801. mainPivot?: Vector3;
  22802. /**
  22803. * The connected pivot of the joint
  22804. */
  22805. connectedPivot?: Vector3;
  22806. /**
  22807. * The main axis of the joint
  22808. */
  22809. mainAxis?: Vector3;
  22810. /**
  22811. * The connected axis of the joint
  22812. */
  22813. connectedAxis?: Vector3;
  22814. /**
  22815. * The collision of the joint
  22816. */
  22817. collision?: boolean;
  22818. /**
  22819. * Native Oimo/Cannon/Energy data
  22820. */
  22821. nativeParams?: any;
  22822. }
  22823. /**
  22824. * This is a holder class for the physics joint created by the physics plugin
  22825. * It holds a set of functions to control the underlying joint
  22826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22827. */
  22828. export class PhysicsJoint {
  22829. /**
  22830. * The type of the physics joint
  22831. */
  22832. type: number;
  22833. /**
  22834. * The data for the physics joint
  22835. */
  22836. jointData: PhysicsJointData;
  22837. private _physicsJoint;
  22838. protected _physicsPlugin: IPhysicsEnginePlugin;
  22839. /**
  22840. * Initializes the physics joint
  22841. * @param type The type of the physics joint
  22842. * @param jointData The data for the physics joint
  22843. */
  22844. constructor(
  22845. /**
  22846. * The type of the physics joint
  22847. */
  22848. type: number,
  22849. /**
  22850. * The data for the physics joint
  22851. */
  22852. jointData: PhysicsJointData);
  22853. /**
  22854. * Gets the physics joint
  22855. */
  22856. /**
  22857. * Sets the physics joint
  22858. */
  22859. physicsJoint: any;
  22860. /**
  22861. * Sets the physics plugin
  22862. */
  22863. physicsPlugin: IPhysicsEnginePlugin;
  22864. /**
  22865. * Execute a function that is physics-plugin specific.
  22866. * @param {Function} func the function that will be executed.
  22867. * It accepts two parameters: the physics world and the physics joint
  22868. */
  22869. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22870. /**
  22871. * Distance-Joint type
  22872. */
  22873. static DistanceJoint: number;
  22874. /**
  22875. * Hinge-Joint type
  22876. */
  22877. static HingeJoint: number;
  22878. /**
  22879. * Ball-and-Socket joint type
  22880. */
  22881. static BallAndSocketJoint: number;
  22882. /**
  22883. * Wheel-Joint type
  22884. */
  22885. static WheelJoint: number;
  22886. /**
  22887. * Slider-Joint type
  22888. */
  22889. static SliderJoint: number;
  22890. /**
  22891. * Prismatic-Joint type
  22892. */
  22893. static PrismaticJoint: number;
  22894. /**
  22895. * Universal-Joint type
  22896. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22897. */
  22898. static UniversalJoint: number;
  22899. /**
  22900. * Hinge-Joint 2 type
  22901. */
  22902. static Hinge2Joint: number;
  22903. /**
  22904. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22905. */
  22906. static PointToPointJoint: number;
  22907. /**
  22908. * Spring-Joint type
  22909. */
  22910. static SpringJoint: number;
  22911. /**
  22912. * Lock-Joint type
  22913. */
  22914. static LockJoint: number;
  22915. }
  22916. /**
  22917. * A class representing a physics distance joint
  22918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22919. */
  22920. export class DistanceJoint extends PhysicsJoint {
  22921. /**
  22922. *
  22923. * @param jointData The data for the Distance-Joint
  22924. */
  22925. constructor(jointData: DistanceJointData);
  22926. /**
  22927. * Update the predefined distance.
  22928. * @param maxDistance The maximum preferred distance
  22929. * @param minDistance The minimum preferred distance
  22930. */
  22931. updateDistance(maxDistance: number, minDistance?: number): void;
  22932. }
  22933. /**
  22934. * Represents a Motor-Enabled Joint
  22935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22936. */
  22937. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22938. /**
  22939. * Initializes the Motor-Enabled Joint
  22940. * @param type The type of the joint
  22941. * @param jointData The physica joint data for the joint
  22942. */
  22943. constructor(type: number, jointData: PhysicsJointData);
  22944. /**
  22945. * Set the motor values.
  22946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22947. * @param force the force to apply
  22948. * @param maxForce max force for this motor.
  22949. */
  22950. setMotor(force?: number, maxForce?: number): void;
  22951. /**
  22952. * Set the motor's limits.
  22953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22954. * @param upperLimit The upper limit of the motor
  22955. * @param lowerLimit The lower limit of the motor
  22956. */
  22957. setLimit(upperLimit: number, lowerLimit?: number): void;
  22958. }
  22959. /**
  22960. * This class represents a single physics Hinge-Joint
  22961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22962. */
  22963. export class HingeJoint extends MotorEnabledJoint {
  22964. /**
  22965. * Initializes the Hinge-Joint
  22966. * @param jointData The joint data for the Hinge-Joint
  22967. */
  22968. constructor(jointData: PhysicsJointData);
  22969. /**
  22970. * Set the motor values.
  22971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22972. * @param {number} force the force to apply
  22973. * @param {number} maxForce max force for this motor.
  22974. */
  22975. setMotor(force?: number, maxForce?: number): void;
  22976. /**
  22977. * Set the motor's limits.
  22978. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22979. * @param upperLimit The upper limit of the motor
  22980. * @param lowerLimit The lower limit of the motor
  22981. */
  22982. setLimit(upperLimit: number, lowerLimit?: number): void;
  22983. }
  22984. /**
  22985. * This class represents a dual hinge physics joint (same as wheel joint)
  22986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22987. */
  22988. export class Hinge2Joint extends MotorEnabledJoint {
  22989. /**
  22990. * Initializes the Hinge2-Joint
  22991. * @param jointData The joint data for the Hinge2-Joint
  22992. */
  22993. constructor(jointData: PhysicsJointData);
  22994. /**
  22995. * Set the motor values.
  22996. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22997. * @param {number} targetSpeed the speed the motor is to reach
  22998. * @param {number} maxForce max force for this motor.
  22999. * @param {motorIndex} the motor's index, 0 or 1.
  23000. */
  23001. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23002. /**
  23003. * Set the motor limits.
  23004. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23005. * @param {number} upperLimit the upper limit
  23006. * @param {number} lowerLimit lower limit
  23007. * @param {motorIndex} the motor's index, 0 or 1.
  23008. */
  23009. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23010. }
  23011. /**
  23012. * Interface for a motor enabled joint
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export interface IMotorEnabledJoint {
  23016. /**
  23017. * Physics joint
  23018. */
  23019. physicsJoint: any;
  23020. /**
  23021. * Sets the motor of the motor-enabled joint
  23022. * @param force The force of the motor
  23023. * @param maxForce The maximum force of the motor
  23024. * @param motorIndex The index of the motor
  23025. */
  23026. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23027. /**
  23028. * Sets the limit of the motor
  23029. * @param upperLimit The upper limit of the motor
  23030. * @param lowerLimit The lower limit of the motor
  23031. * @param motorIndex The index of the motor
  23032. */
  23033. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23034. }
  23035. /**
  23036. * Joint data for a Distance-Joint
  23037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23038. */
  23039. export interface DistanceJointData extends PhysicsJointData {
  23040. /**
  23041. * Max distance the 2 joint objects can be apart
  23042. */
  23043. maxDistance: number;
  23044. }
  23045. /**
  23046. * Joint data from a spring joint
  23047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23048. */
  23049. export interface SpringJointData extends PhysicsJointData {
  23050. /**
  23051. * Length of the spring
  23052. */
  23053. length: number;
  23054. /**
  23055. * Stiffness of the spring
  23056. */
  23057. stiffness: number;
  23058. /**
  23059. * Damping of the spring
  23060. */
  23061. damping: number;
  23062. /** this callback will be called when applying the force to the impostors. */
  23063. forceApplicationCallback: () => void;
  23064. }
  23065. }
  23066. declare module "babylonjs/Physics/physicsRaycastResult" {
  23067. import { Vector3 } from "babylonjs/Maths/math.vector";
  23068. /**
  23069. * Holds the data for the raycast result
  23070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23071. */
  23072. export class PhysicsRaycastResult {
  23073. private _hasHit;
  23074. private _hitDistance;
  23075. private _hitNormalWorld;
  23076. private _hitPointWorld;
  23077. private _rayFromWorld;
  23078. private _rayToWorld;
  23079. /**
  23080. * Gets if there was a hit
  23081. */
  23082. readonly hasHit: boolean;
  23083. /**
  23084. * Gets the distance from the hit
  23085. */
  23086. readonly hitDistance: number;
  23087. /**
  23088. * Gets the hit normal/direction in the world
  23089. */
  23090. readonly hitNormalWorld: Vector3;
  23091. /**
  23092. * Gets the hit point in the world
  23093. */
  23094. readonly hitPointWorld: Vector3;
  23095. /**
  23096. * Gets the ray "start point" of the ray in the world
  23097. */
  23098. readonly rayFromWorld: Vector3;
  23099. /**
  23100. * Gets the ray "end point" of the ray in the world
  23101. */
  23102. readonly rayToWorld: Vector3;
  23103. /**
  23104. * Sets the hit data (normal & point in world space)
  23105. * @param hitNormalWorld defines the normal in world space
  23106. * @param hitPointWorld defines the point in world space
  23107. */
  23108. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23109. /**
  23110. * Sets the distance from the start point to the hit point
  23111. * @param distance
  23112. */
  23113. setHitDistance(distance: number): void;
  23114. /**
  23115. * Calculates the distance manually
  23116. */
  23117. calculateHitDistance(): void;
  23118. /**
  23119. * Resets all the values to default
  23120. * @param from The from point on world space
  23121. * @param to The to point on world space
  23122. */
  23123. reset(from?: Vector3, to?: Vector3): void;
  23124. }
  23125. /**
  23126. * Interface for the size containing width and height
  23127. */
  23128. interface IXYZ {
  23129. /**
  23130. * X
  23131. */
  23132. x: number;
  23133. /**
  23134. * Y
  23135. */
  23136. y: number;
  23137. /**
  23138. * Z
  23139. */
  23140. z: number;
  23141. }
  23142. }
  23143. declare module "babylonjs/Physics/IPhysicsEngine" {
  23144. import { Nullable } from "babylonjs/types";
  23145. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23147. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23148. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23149. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23150. /**
  23151. * Interface used to describe a physics joint
  23152. */
  23153. export interface PhysicsImpostorJoint {
  23154. /** Defines the main impostor to which the joint is linked */
  23155. mainImpostor: PhysicsImpostor;
  23156. /** Defines the impostor that is connected to the main impostor using this joint */
  23157. connectedImpostor: PhysicsImpostor;
  23158. /** Defines the joint itself */
  23159. joint: PhysicsJoint;
  23160. }
  23161. /** @hidden */
  23162. export interface IPhysicsEnginePlugin {
  23163. world: any;
  23164. name: string;
  23165. setGravity(gravity: Vector3): void;
  23166. setTimeStep(timeStep: number): void;
  23167. getTimeStep(): number;
  23168. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23169. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23170. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23171. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23172. removePhysicsBody(impostor: PhysicsImpostor): void;
  23173. generateJoint(joint: PhysicsImpostorJoint): void;
  23174. removeJoint(joint: PhysicsImpostorJoint): void;
  23175. isSupported(): boolean;
  23176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23177. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23178. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23179. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23180. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23181. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23182. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23183. getBodyMass(impostor: PhysicsImpostor): number;
  23184. getBodyFriction(impostor: PhysicsImpostor): number;
  23185. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23186. getBodyRestitution(impostor: PhysicsImpostor): number;
  23187. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23188. getBodyPressure?(impostor: PhysicsImpostor): number;
  23189. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23190. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23191. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23192. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23193. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23194. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23195. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23196. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23197. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23198. sleepBody(impostor: PhysicsImpostor): void;
  23199. wakeUpBody(impostor: PhysicsImpostor): void;
  23200. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23201. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23202. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23203. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23204. getRadius(impostor: PhysicsImpostor): number;
  23205. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23206. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23207. dispose(): void;
  23208. }
  23209. /**
  23210. * Interface used to define a physics engine
  23211. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23212. */
  23213. export interface IPhysicsEngine {
  23214. /**
  23215. * Gets the gravity vector used by the simulation
  23216. */
  23217. gravity: Vector3;
  23218. /**
  23219. * Sets the gravity vector used by the simulation
  23220. * @param gravity defines the gravity vector to use
  23221. */
  23222. setGravity(gravity: Vector3): void;
  23223. /**
  23224. * Set the time step of the physics engine.
  23225. * Default is 1/60.
  23226. * To slow it down, enter 1/600 for example.
  23227. * To speed it up, 1/30
  23228. * @param newTimeStep the new timestep to apply to this world.
  23229. */
  23230. setTimeStep(newTimeStep: number): void;
  23231. /**
  23232. * Get the time step of the physics engine.
  23233. * @returns the current time step
  23234. */
  23235. getTimeStep(): number;
  23236. /**
  23237. * Release all resources
  23238. */
  23239. dispose(): void;
  23240. /**
  23241. * Gets the name of the current physics plugin
  23242. * @returns the name of the plugin
  23243. */
  23244. getPhysicsPluginName(): string;
  23245. /**
  23246. * Adding a new impostor for the impostor tracking.
  23247. * This will be done by the impostor itself.
  23248. * @param impostor the impostor to add
  23249. */
  23250. addImpostor(impostor: PhysicsImpostor): void;
  23251. /**
  23252. * Remove an impostor from the engine.
  23253. * This impostor and its mesh will not longer be updated by the physics engine.
  23254. * @param impostor the impostor to remove
  23255. */
  23256. removeImpostor(impostor: PhysicsImpostor): void;
  23257. /**
  23258. * Add a joint to the physics engine
  23259. * @param mainImpostor defines the main impostor to which the joint is added.
  23260. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23261. * @param joint defines the joint that will connect both impostors.
  23262. */
  23263. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23264. /**
  23265. * Removes a joint from the simulation
  23266. * @param mainImpostor defines the impostor used with the joint
  23267. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23268. * @param joint defines the joint to remove
  23269. */
  23270. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23271. /**
  23272. * Gets the current plugin used to run the simulation
  23273. * @returns current plugin
  23274. */
  23275. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23276. /**
  23277. * Gets the list of physic impostors
  23278. * @returns an array of PhysicsImpostor
  23279. */
  23280. getImpostors(): Array<PhysicsImpostor>;
  23281. /**
  23282. * Gets the impostor for a physics enabled object
  23283. * @param object defines the object impersonated by the impostor
  23284. * @returns the PhysicsImpostor or null if not found
  23285. */
  23286. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23287. /**
  23288. * Gets the impostor for a physics body object
  23289. * @param body defines physics body used by the impostor
  23290. * @returns the PhysicsImpostor or null if not found
  23291. */
  23292. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23293. /**
  23294. * Does a raycast in the physics world
  23295. * @param from when should the ray start?
  23296. * @param to when should the ray end?
  23297. * @returns PhysicsRaycastResult
  23298. */
  23299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23300. /**
  23301. * Called by the scene. No need to call it.
  23302. * @param delta defines the timespam between frames
  23303. */
  23304. _step(delta: number): void;
  23305. }
  23306. }
  23307. declare module "babylonjs/Physics/physicsImpostor" {
  23308. import { Nullable, IndicesArray } from "babylonjs/types";
  23309. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23310. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23312. import { Scene } from "babylonjs/scene";
  23313. import { Bone } from "babylonjs/Bones/bone";
  23314. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23315. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23316. import { Space } from "babylonjs/Maths/math.axis";
  23317. /**
  23318. * The interface for the physics imposter parameters
  23319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23320. */
  23321. export interface PhysicsImpostorParameters {
  23322. /**
  23323. * The mass of the physics imposter
  23324. */
  23325. mass: number;
  23326. /**
  23327. * The friction of the physics imposter
  23328. */
  23329. friction?: number;
  23330. /**
  23331. * The coefficient of restitution of the physics imposter
  23332. */
  23333. restitution?: number;
  23334. /**
  23335. * The native options of the physics imposter
  23336. */
  23337. nativeOptions?: any;
  23338. /**
  23339. * Specifies if the parent should be ignored
  23340. */
  23341. ignoreParent?: boolean;
  23342. /**
  23343. * Specifies if bi-directional transformations should be disabled
  23344. */
  23345. disableBidirectionalTransformation?: boolean;
  23346. /**
  23347. * The pressure inside the physics imposter, soft object only
  23348. */
  23349. pressure?: number;
  23350. /**
  23351. * The stiffness the physics imposter, soft object only
  23352. */
  23353. stiffness?: number;
  23354. /**
  23355. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23356. */
  23357. velocityIterations?: number;
  23358. /**
  23359. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23360. */
  23361. positionIterations?: number;
  23362. /**
  23363. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23364. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23365. * Add to fix multiple points
  23366. */
  23367. fixedPoints?: number;
  23368. /**
  23369. * The collision margin around a soft object
  23370. */
  23371. margin?: number;
  23372. /**
  23373. * The collision margin around a soft object
  23374. */
  23375. damping?: number;
  23376. /**
  23377. * The path for a rope based on an extrusion
  23378. */
  23379. path?: any;
  23380. /**
  23381. * The shape of an extrusion used for a rope based on an extrusion
  23382. */
  23383. shape?: any;
  23384. }
  23385. /**
  23386. * Interface for a physics-enabled object
  23387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23388. */
  23389. export interface IPhysicsEnabledObject {
  23390. /**
  23391. * The position of the physics-enabled object
  23392. */
  23393. position: Vector3;
  23394. /**
  23395. * The rotation of the physics-enabled object
  23396. */
  23397. rotationQuaternion: Nullable<Quaternion>;
  23398. /**
  23399. * The scale of the physics-enabled object
  23400. */
  23401. scaling: Vector3;
  23402. /**
  23403. * The rotation of the physics-enabled object
  23404. */
  23405. rotation?: Vector3;
  23406. /**
  23407. * The parent of the physics-enabled object
  23408. */
  23409. parent?: any;
  23410. /**
  23411. * The bounding info of the physics-enabled object
  23412. * @returns The bounding info of the physics-enabled object
  23413. */
  23414. getBoundingInfo(): BoundingInfo;
  23415. /**
  23416. * Computes the world matrix
  23417. * @param force Specifies if the world matrix should be computed by force
  23418. * @returns A world matrix
  23419. */
  23420. computeWorldMatrix(force: boolean): Matrix;
  23421. /**
  23422. * Gets the world matrix
  23423. * @returns A world matrix
  23424. */
  23425. getWorldMatrix?(): Matrix;
  23426. /**
  23427. * Gets the child meshes
  23428. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23429. * @returns An array of abstract meshes
  23430. */
  23431. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23432. /**
  23433. * Gets the vertex data
  23434. * @param kind The type of vertex data
  23435. * @returns A nullable array of numbers, or a float32 array
  23436. */
  23437. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23438. /**
  23439. * Gets the indices from the mesh
  23440. * @returns A nullable array of index arrays
  23441. */
  23442. getIndices?(): Nullable<IndicesArray>;
  23443. /**
  23444. * Gets the scene from the mesh
  23445. * @returns the indices array or null
  23446. */
  23447. getScene?(): Scene;
  23448. /**
  23449. * Gets the absolute position from the mesh
  23450. * @returns the absolute position
  23451. */
  23452. getAbsolutePosition(): Vector3;
  23453. /**
  23454. * Gets the absolute pivot point from the mesh
  23455. * @returns the absolute pivot point
  23456. */
  23457. getAbsolutePivotPoint(): Vector3;
  23458. /**
  23459. * Rotates the mesh
  23460. * @param axis The axis of rotation
  23461. * @param amount The amount of rotation
  23462. * @param space The space of the rotation
  23463. * @returns The rotation transform node
  23464. */
  23465. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23466. /**
  23467. * Translates the mesh
  23468. * @param axis The axis of translation
  23469. * @param distance The distance of translation
  23470. * @param space The space of the translation
  23471. * @returns The transform node
  23472. */
  23473. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23474. /**
  23475. * Sets the absolute position of the mesh
  23476. * @param absolutePosition The absolute position of the mesh
  23477. * @returns The transform node
  23478. */
  23479. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23480. /**
  23481. * Gets the class name of the mesh
  23482. * @returns The class name
  23483. */
  23484. getClassName(): string;
  23485. }
  23486. /**
  23487. * Represents a physics imposter
  23488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23489. */
  23490. export class PhysicsImpostor {
  23491. /**
  23492. * The physics-enabled object used as the physics imposter
  23493. */
  23494. object: IPhysicsEnabledObject;
  23495. /**
  23496. * The type of the physics imposter
  23497. */
  23498. type: number;
  23499. private _options;
  23500. private _scene?;
  23501. /**
  23502. * The default object size of the imposter
  23503. */
  23504. static DEFAULT_OBJECT_SIZE: Vector3;
  23505. /**
  23506. * The identity quaternion of the imposter
  23507. */
  23508. static IDENTITY_QUATERNION: Quaternion;
  23509. /** @hidden */
  23510. _pluginData: any;
  23511. private _physicsEngine;
  23512. private _physicsBody;
  23513. private _bodyUpdateRequired;
  23514. private _onBeforePhysicsStepCallbacks;
  23515. private _onAfterPhysicsStepCallbacks;
  23516. /** @hidden */
  23517. _onPhysicsCollideCallbacks: Array<{
  23518. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23519. otherImpostors: Array<PhysicsImpostor>;
  23520. }>;
  23521. private _deltaPosition;
  23522. private _deltaRotation;
  23523. private _deltaRotationConjugated;
  23524. /** @hidden */
  23525. _isFromLine: boolean;
  23526. private _parent;
  23527. private _isDisposed;
  23528. private static _tmpVecs;
  23529. private static _tmpQuat;
  23530. /**
  23531. * Specifies if the physics imposter is disposed
  23532. */
  23533. readonly isDisposed: boolean;
  23534. /**
  23535. * Gets the mass of the physics imposter
  23536. */
  23537. mass: number;
  23538. /**
  23539. * Gets the coefficient of friction
  23540. */
  23541. /**
  23542. * Sets the coefficient of friction
  23543. */
  23544. friction: number;
  23545. /**
  23546. * Gets the coefficient of restitution
  23547. */
  23548. /**
  23549. * Sets the coefficient of restitution
  23550. */
  23551. restitution: number;
  23552. /**
  23553. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23554. */
  23555. /**
  23556. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23557. */
  23558. pressure: number;
  23559. /**
  23560. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23561. */
  23562. /**
  23563. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23564. */
  23565. stiffness: number;
  23566. /**
  23567. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23568. */
  23569. /**
  23570. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23571. */
  23572. velocityIterations: number;
  23573. /**
  23574. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23575. */
  23576. /**
  23577. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23578. */
  23579. positionIterations: number;
  23580. /**
  23581. * The unique id of the physics imposter
  23582. * set by the physics engine when adding this impostor to the array
  23583. */
  23584. uniqueId: number;
  23585. /**
  23586. * @hidden
  23587. */
  23588. soft: boolean;
  23589. /**
  23590. * @hidden
  23591. */
  23592. segments: number;
  23593. private _joints;
  23594. /**
  23595. * Initializes the physics imposter
  23596. * @param object The physics-enabled object used as the physics imposter
  23597. * @param type The type of the physics imposter
  23598. * @param _options The options for the physics imposter
  23599. * @param _scene The Babylon scene
  23600. */
  23601. constructor(
  23602. /**
  23603. * The physics-enabled object used as the physics imposter
  23604. */
  23605. object: IPhysicsEnabledObject,
  23606. /**
  23607. * The type of the physics imposter
  23608. */
  23609. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23610. /**
  23611. * This function will completly initialize this impostor.
  23612. * It will create a new body - but only if this mesh has no parent.
  23613. * If it has, this impostor will not be used other than to define the impostor
  23614. * of the child mesh.
  23615. * @hidden
  23616. */
  23617. _init(): void;
  23618. private _getPhysicsParent;
  23619. /**
  23620. * Should a new body be generated.
  23621. * @returns boolean specifying if body initialization is required
  23622. */
  23623. isBodyInitRequired(): boolean;
  23624. /**
  23625. * Sets the updated scaling
  23626. * @param updated Specifies if the scaling is updated
  23627. */
  23628. setScalingUpdated(): void;
  23629. /**
  23630. * Force a regeneration of this or the parent's impostor's body.
  23631. * Use under cautious - This will remove all joints already implemented.
  23632. */
  23633. forceUpdate(): void;
  23634. /**
  23635. * Gets the body that holds this impostor. Either its own, or its parent.
  23636. */
  23637. /**
  23638. * Set the physics body. Used mainly by the physics engine/plugin
  23639. */
  23640. physicsBody: any;
  23641. /**
  23642. * Get the parent of the physics imposter
  23643. * @returns Physics imposter or null
  23644. */
  23645. /**
  23646. * Sets the parent of the physics imposter
  23647. */
  23648. parent: Nullable<PhysicsImpostor>;
  23649. /**
  23650. * Resets the update flags
  23651. */
  23652. resetUpdateFlags(): void;
  23653. /**
  23654. * Gets the object extend size
  23655. * @returns the object extend size
  23656. */
  23657. getObjectExtendSize(): Vector3;
  23658. /**
  23659. * Gets the object center
  23660. * @returns The object center
  23661. */
  23662. getObjectCenter(): Vector3;
  23663. /**
  23664. * Get a specific parametes from the options parameter
  23665. * @param paramName The object parameter name
  23666. * @returns The object parameter
  23667. */
  23668. getParam(paramName: string): any;
  23669. /**
  23670. * Sets a specific parameter in the options given to the physics plugin
  23671. * @param paramName The parameter name
  23672. * @param value The value of the parameter
  23673. */
  23674. setParam(paramName: string, value: number): void;
  23675. /**
  23676. * Specifically change the body's mass option. Won't recreate the physics body object
  23677. * @param mass The mass of the physics imposter
  23678. */
  23679. setMass(mass: number): void;
  23680. /**
  23681. * Gets the linear velocity
  23682. * @returns linear velocity or null
  23683. */
  23684. getLinearVelocity(): Nullable<Vector3>;
  23685. /**
  23686. * Sets the linear velocity
  23687. * @param velocity linear velocity or null
  23688. */
  23689. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23690. /**
  23691. * Gets the angular velocity
  23692. * @returns angular velocity or null
  23693. */
  23694. getAngularVelocity(): Nullable<Vector3>;
  23695. /**
  23696. * Sets the angular velocity
  23697. * @param velocity The velocity or null
  23698. */
  23699. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23700. /**
  23701. * Execute a function with the physics plugin native code
  23702. * Provide a function the will have two variables - the world object and the physics body object
  23703. * @param func The function to execute with the physics plugin native code
  23704. */
  23705. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23706. /**
  23707. * Register a function that will be executed before the physics world is stepping forward
  23708. * @param func The function to execute before the physics world is stepped forward
  23709. */
  23710. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23711. /**
  23712. * Unregister a function that will be executed before the physics world is stepping forward
  23713. * @param func The function to execute before the physics world is stepped forward
  23714. */
  23715. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23716. /**
  23717. * Register a function that will be executed after the physics step
  23718. * @param func The function to execute after physics step
  23719. */
  23720. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23721. /**
  23722. * Unregisters a function that will be executed after the physics step
  23723. * @param func The function to execute after physics step
  23724. */
  23725. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23726. /**
  23727. * register a function that will be executed when this impostor collides against a different body
  23728. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23729. * @param func Callback that is executed on collision
  23730. */
  23731. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23732. /**
  23733. * Unregisters the physics imposter on contact
  23734. * @param collideAgainst The physics object to collide against
  23735. * @param func Callback to execute on collision
  23736. */
  23737. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23738. private _tmpQuat;
  23739. private _tmpQuat2;
  23740. /**
  23741. * Get the parent rotation
  23742. * @returns The parent rotation
  23743. */
  23744. getParentsRotation(): Quaternion;
  23745. /**
  23746. * this function is executed by the physics engine.
  23747. */
  23748. beforeStep: () => void;
  23749. /**
  23750. * this function is executed by the physics engine
  23751. */
  23752. afterStep: () => void;
  23753. /**
  23754. * Legacy collision detection event support
  23755. */
  23756. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23757. /**
  23758. * event and body object due to cannon's event-based architecture.
  23759. */
  23760. onCollide: (e: {
  23761. body: any;
  23762. }) => void;
  23763. /**
  23764. * Apply a force
  23765. * @param force The force to apply
  23766. * @param contactPoint The contact point for the force
  23767. * @returns The physics imposter
  23768. */
  23769. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23770. /**
  23771. * Apply an impulse
  23772. * @param force The impulse force
  23773. * @param contactPoint The contact point for the impulse force
  23774. * @returns The physics imposter
  23775. */
  23776. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23777. /**
  23778. * A help function to create a joint
  23779. * @param otherImpostor A physics imposter used to create a joint
  23780. * @param jointType The type of joint
  23781. * @param jointData The data for the joint
  23782. * @returns The physics imposter
  23783. */
  23784. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23785. /**
  23786. * Add a joint to this impostor with a different impostor
  23787. * @param otherImpostor A physics imposter used to add a joint
  23788. * @param joint The joint to add
  23789. * @returns The physics imposter
  23790. */
  23791. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23792. /**
  23793. * Add an anchor to a cloth impostor
  23794. * @param otherImpostor rigid impostor to anchor to
  23795. * @param width ratio across width from 0 to 1
  23796. * @param height ratio up height from 0 to 1
  23797. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23798. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23799. * @returns impostor the soft imposter
  23800. */
  23801. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23802. /**
  23803. * Add a hook to a rope impostor
  23804. * @param otherImpostor rigid impostor to anchor to
  23805. * @param length ratio across rope from 0 to 1
  23806. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23807. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23808. * @returns impostor the rope imposter
  23809. */
  23810. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23811. /**
  23812. * Will keep this body still, in a sleep mode.
  23813. * @returns the physics imposter
  23814. */
  23815. sleep(): PhysicsImpostor;
  23816. /**
  23817. * Wake the body up.
  23818. * @returns The physics imposter
  23819. */
  23820. wakeUp(): PhysicsImpostor;
  23821. /**
  23822. * Clones the physics imposter
  23823. * @param newObject The physics imposter clones to this physics-enabled object
  23824. * @returns A nullable physics imposter
  23825. */
  23826. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23827. /**
  23828. * Disposes the physics imposter
  23829. */
  23830. dispose(): void;
  23831. /**
  23832. * Sets the delta position
  23833. * @param position The delta position amount
  23834. */
  23835. setDeltaPosition(position: Vector3): void;
  23836. /**
  23837. * Sets the delta rotation
  23838. * @param rotation The delta rotation amount
  23839. */
  23840. setDeltaRotation(rotation: Quaternion): void;
  23841. /**
  23842. * Gets the box size of the physics imposter and stores the result in the input parameter
  23843. * @param result Stores the box size
  23844. * @returns The physics imposter
  23845. */
  23846. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23847. /**
  23848. * Gets the radius of the physics imposter
  23849. * @returns Radius of the physics imposter
  23850. */
  23851. getRadius(): number;
  23852. /**
  23853. * Sync a bone with this impostor
  23854. * @param bone The bone to sync to the impostor.
  23855. * @param boneMesh The mesh that the bone is influencing.
  23856. * @param jointPivot The pivot of the joint / bone in local space.
  23857. * @param distToJoint Optional distance from the impostor to the joint.
  23858. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23859. */
  23860. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23861. /**
  23862. * Sync impostor to a bone
  23863. * @param bone The bone that the impostor will be synced to.
  23864. * @param boneMesh The mesh that the bone is influencing.
  23865. * @param jointPivot The pivot of the joint / bone in local space.
  23866. * @param distToJoint Optional distance from the impostor to the joint.
  23867. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23868. * @param boneAxis Optional vector3 axis the bone is aligned with
  23869. */
  23870. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23871. /**
  23872. * No-Imposter type
  23873. */
  23874. static NoImpostor: number;
  23875. /**
  23876. * Sphere-Imposter type
  23877. */
  23878. static SphereImpostor: number;
  23879. /**
  23880. * Box-Imposter type
  23881. */
  23882. static BoxImpostor: number;
  23883. /**
  23884. * Plane-Imposter type
  23885. */
  23886. static PlaneImpostor: number;
  23887. /**
  23888. * Mesh-imposter type
  23889. */
  23890. static MeshImpostor: number;
  23891. /**
  23892. * Capsule-Impostor type (Ammo.js plugin only)
  23893. */
  23894. static CapsuleImpostor: number;
  23895. /**
  23896. * Cylinder-Imposter type
  23897. */
  23898. static CylinderImpostor: number;
  23899. /**
  23900. * Particle-Imposter type
  23901. */
  23902. static ParticleImpostor: number;
  23903. /**
  23904. * Heightmap-Imposter type
  23905. */
  23906. static HeightmapImpostor: number;
  23907. /**
  23908. * ConvexHull-Impostor type (Ammo.js plugin only)
  23909. */
  23910. static ConvexHullImpostor: number;
  23911. /**
  23912. * Rope-Imposter type
  23913. */
  23914. static RopeImpostor: number;
  23915. /**
  23916. * Cloth-Imposter type
  23917. */
  23918. static ClothImpostor: number;
  23919. /**
  23920. * Softbody-Imposter type
  23921. */
  23922. static SoftbodyImpostor: number;
  23923. }
  23924. }
  23925. declare module "babylonjs/Meshes/mesh" {
  23926. import { Observable } from "babylonjs/Misc/observable";
  23927. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23928. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23929. import { Camera } from "babylonjs/Cameras/camera";
  23930. import { Scene } from "babylonjs/scene";
  23931. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23932. import { Color4 } from "babylonjs/Maths/math.color";
  23933. import { Engine } from "babylonjs/Engines/engine";
  23934. import { Node } from "babylonjs/node";
  23935. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23936. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23937. import { Buffer } from "babylonjs/Meshes/buffer";
  23938. import { Geometry } from "babylonjs/Meshes/geometry";
  23939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23941. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23942. import { Effect } from "babylonjs/Materials/effect";
  23943. import { Material } from "babylonjs/Materials/material";
  23944. import { Skeleton } from "babylonjs/Bones/skeleton";
  23945. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23946. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23947. import { Path3D } from "babylonjs/Maths/math.path";
  23948. import { Plane } from "babylonjs/Maths/math.plane";
  23949. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23950. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23951. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23952. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23953. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23954. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23955. /**
  23956. * @hidden
  23957. **/
  23958. export class _CreationDataStorage {
  23959. closePath?: boolean;
  23960. closeArray?: boolean;
  23961. idx: number[];
  23962. dashSize: number;
  23963. gapSize: number;
  23964. path3D: Path3D;
  23965. pathArray: Vector3[][];
  23966. arc: number;
  23967. radius: number;
  23968. cap: number;
  23969. tessellation: number;
  23970. }
  23971. /**
  23972. * @hidden
  23973. **/
  23974. class _InstanceDataStorage {
  23975. visibleInstances: any;
  23976. batchCache: _InstancesBatch;
  23977. instancesBufferSize: number;
  23978. instancesBuffer: Nullable<Buffer>;
  23979. instancesData: Float32Array;
  23980. overridenInstanceCount: number;
  23981. isFrozen: boolean;
  23982. previousBatch: Nullable<_InstancesBatch>;
  23983. hardwareInstancedRendering: boolean;
  23984. sideOrientation: number;
  23985. }
  23986. /**
  23987. * @hidden
  23988. **/
  23989. export class _InstancesBatch {
  23990. mustReturn: boolean;
  23991. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23992. renderSelf: boolean[];
  23993. hardwareInstancedRendering: boolean[];
  23994. }
  23995. /**
  23996. * Class used to represent renderable models
  23997. */
  23998. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23999. /**
  24000. * Mesh side orientation : usually the external or front surface
  24001. */
  24002. static readonly FRONTSIDE: number;
  24003. /**
  24004. * Mesh side orientation : usually the internal or back surface
  24005. */
  24006. static readonly BACKSIDE: number;
  24007. /**
  24008. * Mesh side orientation : both internal and external or front and back surfaces
  24009. */
  24010. static readonly DOUBLESIDE: number;
  24011. /**
  24012. * Mesh side orientation : by default, `FRONTSIDE`
  24013. */
  24014. static readonly DEFAULTSIDE: number;
  24015. /**
  24016. * Mesh cap setting : no cap
  24017. */
  24018. static readonly NO_CAP: number;
  24019. /**
  24020. * Mesh cap setting : one cap at the beginning of the mesh
  24021. */
  24022. static readonly CAP_START: number;
  24023. /**
  24024. * Mesh cap setting : one cap at the end of the mesh
  24025. */
  24026. static readonly CAP_END: number;
  24027. /**
  24028. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24029. */
  24030. static readonly CAP_ALL: number;
  24031. /**
  24032. * Mesh pattern setting : no flip or rotate
  24033. */
  24034. static readonly NO_FLIP: number;
  24035. /**
  24036. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24037. */
  24038. static readonly FLIP_TILE: number;
  24039. /**
  24040. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24041. */
  24042. static readonly ROTATE_TILE: number;
  24043. /**
  24044. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24045. */
  24046. static readonly FLIP_ROW: number;
  24047. /**
  24048. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24049. */
  24050. static readonly ROTATE_ROW: number;
  24051. /**
  24052. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24053. */
  24054. static readonly FLIP_N_ROTATE_TILE: number;
  24055. /**
  24056. * Mesh pattern setting : rotate pattern and rotate
  24057. */
  24058. static readonly FLIP_N_ROTATE_ROW: number;
  24059. /**
  24060. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24061. */
  24062. static readonly CENTER: number;
  24063. /**
  24064. * Mesh tile positioning : part tiles on left
  24065. */
  24066. static readonly LEFT: number;
  24067. /**
  24068. * Mesh tile positioning : part tiles on right
  24069. */
  24070. static readonly RIGHT: number;
  24071. /**
  24072. * Mesh tile positioning : part tiles on top
  24073. */
  24074. static readonly TOP: number;
  24075. /**
  24076. * Mesh tile positioning : part tiles on bottom
  24077. */
  24078. static readonly BOTTOM: number;
  24079. /**
  24080. * Gets the default side orientation.
  24081. * @param orientation the orientation to value to attempt to get
  24082. * @returns the default orientation
  24083. * @hidden
  24084. */
  24085. static _GetDefaultSideOrientation(orientation?: number): number;
  24086. private _internalMeshDataInfo;
  24087. /**
  24088. * An event triggered before rendering the mesh
  24089. */
  24090. readonly onBeforeRenderObservable: Observable<Mesh>;
  24091. /**
  24092. * An event triggered before binding the mesh
  24093. */
  24094. readonly onBeforeBindObservable: Observable<Mesh>;
  24095. /**
  24096. * An event triggered after rendering the mesh
  24097. */
  24098. readonly onAfterRenderObservable: Observable<Mesh>;
  24099. /**
  24100. * An event triggered before drawing the mesh
  24101. */
  24102. readonly onBeforeDrawObservable: Observable<Mesh>;
  24103. private _onBeforeDrawObserver;
  24104. /**
  24105. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24106. */
  24107. onBeforeDraw: () => void;
  24108. readonly hasInstances: boolean;
  24109. /**
  24110. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24111. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24112. */
  24113. delayLoadState: number;
  24114. /**
  24115. * Gets the list of instances created from this mesh
  24116. * it is not supposed to be modified manually.
  24117. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24118. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24119. */
  24120. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24121. /**
  24122. * Gets the file containing delay loading data for this mesh
  24123. */
  24124. delayLoadingFile: string;
  24125. /** @hidden */
  24126. _binaryInfo: any;
  24127. /**
  24128. * User defined function used to change how LOD level selection is done
  24129. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24130. */
  24131. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24132. /**
  24133. * Gets or sets the morph target manager
  24134. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24135. */
  24136. morphTargetManager: Nullable<MorphTargetManager>;
  24137. /** @hidden */
  24138. _creationDataStorage: Nullable<_CreationDataStorage>;
  24139. /** @hidden */
  24140. _geometry: Nullable<Geometry>;
  24141. /** @hidden */
  24142. _delayInfo: Array<string>;
  24143. /** @hidden */
  24144. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24145. /** @hidden */
  24146. _instanceDataStorage: _InstanceDataStorage;
  24147. private _effectiveMaterial;
  24148. /** @hidden */
  24149. _shouldGenerateFlatShading: boolean;
  24150. /** @hidden */
  24151. _originalBuilderSideOrientation: number;
  24152. /**
  24153. * Use this property to change the original side orientation defined at construction time
  24154. */
  24155. overrideMaterialSideOrientation: Nullable<number>;
  24156. /**
  24157. * Gets the source mesh (the one used to clone this one from)
  24158. */
  24159. readonly source: Nullable<Mesh>;
  24160. /**
  24161. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24162. */
  24163. isUnIndexed: boolean;
  24164. /**
  24165. * @constructor
  24166. * @param name The value used by scene.getMeshByName() to do a lookup.
  24167. * @param scene The scene to add this mesh to.
  24168. * @param parent The parent of this mesh, if it has one
  24169. * @param source An optional Mesh from which geometry is shared, cloned.
  24170. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24171. * When false, achieved by calling a clone(), also passing False.
  24172. * This will make creation of children, recursive.
  24173. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24174. */
  24175. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24176. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24177. /**
  24178. * Gets the class name
  24179. * @returns the string "Mesh".
  24180. */
  24181. getClassName(): string;
  24182. /** @hidden */
  24183. readonly _isMesh: boolean;
  24184. /**
  24185. * Returns a description of this mesh
  24186. * @param fullDetails define if full details about this mesh must be used
  24187. * @returns a descriptive string representing this mesh
  24188. */
  24189. toString(fullDetails?: boolean): string;
  24190. /** @hidden */
  24191. _unBindEffect(): void;
  24192. /**
  24193. * Gets a boolean indicating if this mesh has LOD
  24194. */
  24195. readonly hasLODLevels: boolean;
  24196. /**
  24197. * Gets the list of MeshLODLevel associated with the current mesh
  24198. * @returns an array of MeshLODLevel
  24199. */
  24200. getLODLevels(): MeshLODLevel[];
  24201. private _sortLODLevels;
  24202. /**
  24203. * Add a mesh as LOD level triggered at the given distance.
  24204. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24205. * @param distance The distance from the center of the object to show this level
  24206. * @param mesh The mesh to be added as LOD level (can be null)
  24207. * @return This mesh (for chaining)
  24208. */
  24209. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24210. /**
  24211. * Returns the LOD level mesh at the passed distance or null if not found.
  24212. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24213. * @param distance The distance from the center of the object to show this level
  24214. * @returns a Mesh or `null`
  24215. */
  24216. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24217. /**
  24218. * Remove a mesh from the LOD array
  24219. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24220. * @param mesh defines the mesh to be removed
  24221. * @return This mesh (for chaining)
  24222. */
  24223. removeLODLevel(mesh: Mesh): Mesh;
  24224. /**
  24225. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24226. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24227. * @param camera defines the camera to use to compute distance
  24228. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24229. * @return This mesh (for chaining)
  24230. */
  24231. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24232. /**
  24233. * Gets the mesh internal Geometry object
  24234. */
  24235. readonly geometry: Nullable<Geometry>;
  24236. /**
  24237. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24238. * @returns the total number of vertices
  24239. */
  24240. getTotalVertices(): number;
  24241. /**
  24242. * Returns the content of an associated vertex buffer
  24243. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24244. * - VertexBuffer.PositionKind
  24245. * - VertexBuffer.UVKind
  24246. * - VertexBuffer.UV2Kind
  24247. * - VertexBuffer.UV3Kind
  24248. * - VertexBuffer.UV4Kind
  24249. * - VertexBuffer.UV5Kind
  24250. * - VertexBuffer.UV6Kind
  24251. * - VertexBuffer.ColorKind
  24252. * - VertexBuffer.MatricesIndicesKind
  24253. * - VertexBuffer.MatricesIndicesExtraKind
  24254. * - VertexBuffer.MatricesWeightsKind
  24255. * - VertexBuffer.MatricesWeightsExtraKind
  24256. * @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
  24257. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24258. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24259. */
  24260. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24261. /**
  24262. * Returns the mesh VertexBuffer object from the requested `kind`
  24263. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24264. * - VertexBuffer.PositionKind
  24265. * - VertexBuffer.NormalKind
  24266. * - VertexBuffer.UVKind
  24267. * - VertexBuffer.UV2Kind
  24268. * - VertexBuffer.UV3Kind
  24269. * - VertexBuffer.UV4Kind
  24270. * - VertexBuffer.UV5Kind
  24271. * - VertexBuffer.UV6Kind
  24272. * - VertexBuffer.ColorKind
  24273. * - VertexBuffer.MatricesIndicesKind
  24274. * - VertexBuffer.MatricesIndicesExtraKind
  24275. * - VertexBuffer.MatricesWeightsKind
  24276. * - VertexBuffer.MatricesWeightsExtraKind
  24277. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24278. */
  24279. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24280. /**
  24281. * Tests if a specific vertex buffer is associated with this mesh
  24282. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24283. * - VertexBuffer.PositionKind
  24284. * - VertexBuffer.NormalKind
  24285. * - VertexBuffer.UVKind
  24286. * - VertexBuffer.UV2Kind
  24287. * - VertexBuffer.UV3Kind
  24288. * - VertexBuffer.UV4Kind
  24289. * - VertexBuffer.UV5Kind
  24290. * - VertexBuffer.UV6Kind
  24291. * - VertexBuffer.ColorKind
  24292. * - VertexBuffer.MatricesIndicesKind
  24293. * - VertexBuffer.MatricesIndicesExtraKind
  24294. * - VertexBuffer.MatricesWeightsKind
  24295. * - VertexBuffer.MatricesWeightsExtraKind
  24296. * @returns a boolean
  24297. */
  24298. isVerticesDataPresent(kind: string): boolean;
  24299. /**
  24300. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24301. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24302. * - VertexBuffer.PositionKind
  24303. * - VertexBuffer.UVKind
  24304. * - VertexBuffer.UV2Kind
  24305. * - VertexBuffer.UV3Kind
  24306. * - VertexBuffer.UV4Kind
  24307. * - VertexBuffer.UV5Kind
  24308. * - VertexBuffer.UV6Kind
  24309. * - VertexBuffer.ColorKind
  24310. * - VertexBuffer.MatricesIndicesKind
  24311. * - VertexBuffer.MatricesIndicesExtraKind
  24312. * - VertexBuffer.MatricesWeightsKind
  24313. * - VertexBuffer.MatricesWeightsExtraKind
  24314. * @returns a boolean
  24315. */
  24316. isVertexBufferUpdatable(kind: string): boolean;
  24317. /**
  24318. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24319. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24320. * - VertexBuffer.PositionKind
  24321. * - VertexBuffer.NormalKind
  24322. * - VertexBuffer.UVKind
  24323. * - VertexBuffer.UV2Kind
  24324. * - VertexBuffer.UV3Kind
  24325. * - VertexBuffer.UV4Kind
  24326. * - VertexBuffer.UV5Kind
  24327. * - VertexBuffer.UV6Kind
  24328. * - VertexBuffer.ColorKind
  24329. * - VertexBuffer.MatricesIndicesKind
  24330. * - VertexBuffer.MatricesIndicesExtraKind
  24331. * - VertexBuffer.MatricesWeightsKind
  24332. * - VertexBuffer.MatricesWeightsExtraKind
  24333. * @returns an array of strings
  24334. */
  24335. getVerticesDataKinds(): string[];
  24336. /**
  24337. * Returns a positive integer : the total number of indices in this mesh geometry.
  24338. * @returns the numner of indices or zero if the mesh has no geometry.
  24339. */
  24340. getTotalIndices(): number;
  24341. /**
  24342. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24343. * @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.
  24344. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24345. * @returns the indices array or an empty array if the mesh has no geometry
  24346. */
  24347. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24348. readonly isBlocked: boolean;
  24349. /**
  24350. * Determine if the current mesh is ready to be rendered
  24351. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24352. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24353. * @returns true if all associated assets are ready (material, textures, shaders)
  24354. */
  24355. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24356. /**
  24357. * 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.
  24358. */
  24359. readonly areNormalsFrozen: boolean;
  24360. /**
  24361. * 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.
  24362. * @returns the current mesh
  24363. */
  24364. freezeNormals(): Mesh;
  24365. /**
  24366. * 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
  24367. * @returns the current mesh
  24368. */
  24369. unfreezeNormals(): Mesh;
  24370. /**
  24371. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24372. */
  24373. overridenInstanceCount: number;
  24374. /** @hidden */
  24375. _preActivate(): Mesh;
  24376. /** @hidden */
  24377. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24378. /** @hidden */
  24379. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24380. /**
  24381. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24382. * This means the mesh underlying bounding box and sphere are recomputed.
  24383. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24384. * @returns the current mesh
  24385. */
  24386. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24387. /** @hidden */
  24388. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24389. /**
  24390. * This function will subdivide the mesh into multiple submeshes
  24391. * @param count defines the expected number of submeshes
  24392. */
  24393. subdivide(count: number): void;
  24394. /**
  24395. * Copy a FloatArray into a specific associated vertex buffer
  24396. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24397. * - VertexBuffer.PositionKind
  24398. * - VertexBuffer.UVKind
  24399. * - VertexBuffer.UV2Kind
  24400. * - VertexBuffer.UV3Kind
  24401. * - VertexBuffer.UV4Kind
  24402. * - VertexBuffer.UV5Kind
  24403. * - VertexBuffer.UV6Kind
  24404. * - VertexBuffer.ColorKind
  24405. * - VertexBuffer.MatricesIndicesKind
  24406. * - VertexBuffer.MatricesIndicesExtraKind
  24407. * - VertexBuffer.MatricesWeightsKind
  24408. * - VertexBuffer.MatricesWeightsExtraKind
  24409. * @param data defines the data source
  24410. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24411. * @param stride defines the data stride size (can be null)
  24412. * @returns the current mesh
  24413. */
  24414. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24415. /**
  24416. * Flags an associated vertex buffer as updatable
  24417. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24418. * - VertexBuffer.PositionKind
  24419. * - VertexBuffer.UVKind
  24420. * - VertexBuffer.UV2Kind
  24421. * - VertexBuffer.UV3Kind
  24422. * - VertexBuffer.UV4Kind
  24423. * - VertexBuffer.UV5Kind
  24424. * - VertexBuffer.UV6Kind
  24425. * - VertexBuffer.ColorKind
  24426. * - VertexBuffer.MatricesIndicesKind
  24427. * - VertexBuffer.MatricesIndicesExtraKind
  24428. * - VertexBuffer.MatricesWeightsKind
  24429. * - VertexBuffer.MatricesWeightsExtraKind
  24430. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24431. */
  24432. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24433. /**
  24434. * Sets the mesh global Vertex Buffer
  24435. * @param buffer defines the buffer to use
  24436. * @returns the current mesh
  24437. */
  24438. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24439. /**
  24440. * Update a specific associated vertex buffer
  24441. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24442. * - VertexBuffer.PositionKind
  24443. * - VertexBuffer.UVKind
  24444. * - VertexBuffer.UV2Kind
  24445. * - VertexBuffer.UV3Kind
  24446. * - VertexBuffer.UV4Kind
  24447. * - VertexBuffer.UV5Kind
  24448. * - VertexBuffer.UV6Kind
  24449. * - VertexBuffer.ColorKind
  24450. * - VertexBuffer.MatricesIndicesKind
  24451. * - VertexBuffer.MatricesIndicesExtraKind
  24452. * - VertexBuffer.MatricesWeightsKind
  24453. * - VertexBuffer.MatricesWeightsExtraKind
  24454. * @param data defines the data source
  24455. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24456. * @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)
  24457. * @returns the current mesh
  24458. */
  24459. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24460. /**
  24461. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24462. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24463. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24464. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24465. * @returns the current mesh
  24466. */
  24467. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24468. /**
  24469. * Creates a un-shared specific occurence of the geometry for the mesh.
  24470. * @returns the current mesh
  24471. */
  24472. makeGeometryUnique(): Mesh;
  24473. /**
  24474. * Set the index buffer of this mesh
  24475. * @param indices defines the source data
  24476. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24477. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24478. * @returns the current mesh
  24479. */
  24480. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24481. /**
  24482. * Update the current index buffer
  24483. * @param indices defines the source data
  24484. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24485. * @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)
  24486. * @returns the current mesh
  24487. */
  24488. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24489. /**
  24490. * Invert the geometry to move from a right handed system to a left handed one.
  24491. * @returns the current mesh
  24492. */
  24493. toLeftHanded(): Mesh;
  24494. /** @hidden */
  24495. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24496. /** @hidden */
  24497. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24498. /**
  24499. * Registers for this mesh a javascript function called just before the rendering process
  24500. * @param func defines the function to call before rendering this mesh
  24501. * @returns the current mesh
  24502. */
  24503. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24504. /**
  24505. * Disposes a previously registered javascript function called before the rendering
  24506. * @param func defines the function to remove
  24507. * @returns the current mesh
  24508. */
  24509. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24510. /**
  24511. * Registers for this mesh a javascript function called just after the rendering is complete
  24512. * @param func defines the function to call after rendering this mesh
  24513. * @returns the current mesh
  24514. */
  24515. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24516. /**
  24517. * Disposes a previously registered javascript function called after the rendering.
  24518. * @param func defines the function to remove
  24519. * @returns the current mesh
  24520. */
  24521. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24522. /** @hidden */
  24523. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24524. /** @hidden */
  24525. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24526. /** @hidden */
  24527. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24528. /** @hidden */
  24529. _rebuild(): void;
  24530. /** @hidden */
  24531. _freeze(): void;
  24532. /** @hidden */
  24533. _unFreeze(): void;
  24534. /**
  24535. * 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
  24536. * @param subMesh defines the subMesh to render
  24537. * @param enableAlphaMode defines if alpha mode can be changed
  24538. * @returns the current mesh
  24539. */
  24540. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24541. private _onBeforeDraw;
  24542. /**
  24543. * Renormalize the mesh and patch it up if there are no weights
  24544. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24545. * However in the case of zero weights then we set just a single influence to 1.
  24546. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24547. */
  24548. cleanMatrixWeights(): void;
  24549. private normalizeSkinFourWeights;
  24550. private normalizeSkinWeightsAndExtra;
  24551. /**
  24552. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24553. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24554. * the user know there was an issue with importing the mesh
  24555. * @returns a validation object with skinned, valid and report string
  24556. */
  24557. validateSkinning(): {
  24558. skinned: boolean;
  24559. valid: boolean;
  24560. report: string;
  24561. };
  24562. /** @hidden */
  24563. _checkDelayState(): Mesh;
  24564. private _queueLoad;
  24565. /**
  24566. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24567. * A mesh is in the frustum if its bounding box intersects the frustum
  24568. * @param frustumPlanes defines the frustum to test
  24569. * @returns true if the mesh is in the frustum planes
  24570. */
  24571. isInFrustum(frustumPlanes: Plane[]): boolean;
  24572. /**
  24573. * Sets the mesh material by the material or multiMaterial `id` property
  24574. * @param id is a string identifying the material or the multiMaterial
  24575. * @returns the current mesh
  24576. */
  24577. setMaterialByID(id: string): Mesh;
  24578. /**
  24579. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24580. * @returns an array of IAnimatable
  24581. */
  24582. getAnimatables(): IAnimatable[];
  24583. /**
  24584. * Modifies the mesh geometry according to the passed transformation matrix.
  24585. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24586. * The mesh normals are modified using the same transformation.
  24587. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24588. * @param transform defines the transform matrix to use
  24589. * @see http://doc.babylonjs.com/resources/baking_transformations
  24590. * @returns the current mesh
  24591. */
  24592. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24593. /**
  24594. * Modifies the mesh geometry according to its own current World Matrix.
  24595. * The mesh World Matrix is then reset.
  24596. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24597. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24598. * @see http://doc.babylonjs.com/resources/baking_transformations
  24599. * @returns the current mesh
  24600. */
  24601. bakeCurrentTransformIntoVertices(): Mesh;
  24602. /** @hidden */
  24603. readonly _positions: Nullable<Vector3[]>;
  24604. /** @hidden */
  24605. _resetPointsArrayCache(): Mesh;
  24606. /** @hidden */
  24607. _generatePointsArray(): boolean;
  24608. /**
  24609. * Returns a new Mesh object generated from the current mesh properties.
  24610. * This method must not get confused with createInstance()
  24611. * @param name is a string, the name given to the new mesh
  24612. * @param newParent can be any Node object (default `null`)
  24613. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24614. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24615. * @returns a new mesh
  24616. */
  24617. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24618. /**
  24619. * Releases resources associated with this mesh.
  24620. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24621. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24622. */
  24623. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24624. /**
  24625. * Modifies the mesh geometry according to a displacement map.
  24626. * 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.
  24627. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24628. * @param url is a string, the URL from the image file is to be downloaded.
  24629. * @param minHeight is the lower limit of the displacement.
  24630. * @param maxHeight is the upper limit of the displacement.
  24631. * @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.
  24632. * @param uvOffset is an optional vector2 used to offset UV.
  24633. * @param uvScale is an optional vector2 used to scale UV.
  24634. * @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.
  24635. * @returns the Mesh.
  24636. */
  24637. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24638. /**
  24639. * Modifies the mesh geometry according to a displacementMap buffer.
  24640. * 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.
  24641. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24642. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24643. * @param heightMapWidth is the width of the buffer image.
  24644. * @param heightMapHeight is the height of the buffer image.
  24645. * @param minHeight is the lower limit of the displacement.
  24646. * @param maxHeight is the upper limit of the displacement.
  24647. * @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.
  24648. * @param uvOffset is an optional vector2 used to offset UV.
  24649. * @param uvScale is an optional vector2 used to scale UV.
  24650. * @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.
  24651. * @returns the Mesh.
  24652. */
  24653. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24654. /**
  24655. * Modify the mesh to get a flat shading rendering.
  24656. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24657. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24658. * @returns current mesh
  24659. */
  24660. convertToFlatShadedMesh(): Mesh;
  24661. /**
  24662. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24663. * In other words, more vertices, no more indices and a single bigger VBO.
  24664. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24665. * @returns current mesh
  24666. */
  24667. convertToUnIndexedMesh(): Mesh;
  24668. /**
  24669. * Inverses facet orientations.
  24670. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24671. * @param flipNormals will also inverts the normals
  24672. * @returns current mesh
  24673. */
  24674. flipFaces(flipNormals?: boolean): Mesh;
  24675. /**
  24676. * Increase the number of facets and hence vertices in a mesh
  24677. * Vertex normals are interpolated from existing vertex normals
  24678. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24679. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24680. */
  24681. increaseVertices(numberPerEdge: number): void;
  24682. /**
  24683. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24684. * This will undo any application of covertToFlatShadedMesh
  24685. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24686. */
  24687. forceSharedVertices(): void;
  24688. /** @hidden */
  24689. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24690. /** @hidden */
  24691. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24692. /**
  24693. * Creates a new InstancedMesh object from the mesh model.
  24694. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24695. * @param name defines the name of the new instance
  24696. * @returns a new InstancedMesh
  24697. */
  24698. createInstance(name: string): InstancedMesh;
  24699. /**
  24700. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24701. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24702. * @returns the current mesh
  24703. */
  24704. synchronizeInstances(): Mesh;
  24705. /**
  24706. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24707. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24708. * This should be used together with the simplification to avoid disappearing triangles.
  24709. * @param successCallback an optional success callback to be called after the optimization finished.
  24710. * @returns the current mesh
  24711. */
  24712. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24713. /**
  24714. * Serialize current mesh
  24715. * @param serializationObject defines the object which will receive the serialization data
  24716. */
  24717. serialize(serializationObject: any): void;
  24718. /** @hidden */
  24719. _syncGeometryWithMorphTargetManager(): void;
  24720. /** @hidden */
  24721. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24722. /**
  24723. * Returns a new Mesh object parsed from the source provided.
  24724. * @param parsedMesh is the source
  24725. * @param scene defines the hosting scene
  24726. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24727. * @returns a new Mesh
  24728. */
  24729. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24730. /**
  24731. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24732. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24733. * @param name defines the name of the mesh to create
  24734. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24735. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24736. * @param closePath creates a seam between the first and the last points of each path of the path array
  24737. * @param offset is taken in account only if the `pathArray` is containing a single path
  24738. * @param scene defines the hosting scene
  24739. * @param updatable defines if the mesh must be flagged as updatable
  24740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24741. * @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)
  24742. * @returns a new Mesh
  24743. */
  24744. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24745. /**
  24746. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24747. * @param name defines the name of the mesh to create
  24748. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24749. * @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
  24750. * @param scene defines the hosting scene
  24751. * @param updatable defines if the mesh must be flagged as updatable
  24752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24753. * @returns a new Mesh
  24754. */
  24755. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24756. /**
  24757. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24758. * @param name defines the name of the mesh to create
  24759. * @param size sets the size (float) of each box side (default 1)
  24760. * @param scene defines the hosting scene
  24761. * @param updatable defines if the mesh must be flagged as updatable
  24762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24763. * @returns a new Mesh
  24764. */
  24765. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24766. /**
  24767. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24768. * @param name defines the name of the mesh to create
  24769. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24770. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24771. * @param scene defines the hosting scene
  24772. * @param updatable defines if the mesh must be flagged as updatable
  24773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24774. * @returns a new Mesh
  24775. */
  24776. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24777. /**
  24778. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24779. * @param name defines the name of the mesh to create
  24780. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24781. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24782. * @param scene defines the hosting scene
  24783. * @returns a new Mesh
  24784. */
  24785. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24786. /**
  24787. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24788. * @param name defines the name of the mesh to create
  24789. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24790. * @param diameterTop set the top cap diameter (floats, default 1)
  24791. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24792. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24793. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24794. * @param scene defines the hosting scene
  24795. * @param updatable defines if the mesh must be flagged as updatable
  24796. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24797. * @returns a new Mesh
  24798. */
  24799. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24800. /**
  24801. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24802. * @param name defines the name of the mesh to create
  24803. * @param diameter sets the diameter size (float) of the torus (default 1)
  24804. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24805. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24806. * @param scene defines the hosting scene
  24807. * @param updatable defines if the mesh must be flagged as updatable
  24808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24809. * @returns a new Mesh
  24810. */
  24811. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24812. /**
  24813. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24814. * @param name defines the name of the mesh to create
  24815. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24816. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24817. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24818. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24819. * @param p the number of windings on X axis (positive integers, default 2)
  24820. * @param q the number of windings on Y axis (positive integers, default 3)
  24821. * @param scene defines the hosting scene
  24822. * @param updatable defines if the mesh must be flagged as updatable
  24823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24824. * @returns a new Mesh
  24825. */
  24826. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24827. /**
  24828. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24829. * @param name defines the name of the mesh to create
  24830. * @param points is an array successive Vector3
  24831. * @param scene defines the hosting scene
  24832. * @param updatable defines if the mesh must be flagged as updatable
  24833. * @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).
  24834. * @returns a new Mesh
  24835. */
  24836. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24837. /**
  24838. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24839. * @param name defines the name of the mesh to create
  24840. * @param points is an array successive Vector3
  24841. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24842. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24843. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24844. * @param scene defines the hosting scene
  24845. * @param updatable defines if the mesh must be flagged as updatable
  24846. * @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)
  24847. * @returns a new Mesh
  24848. */
  24849. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24850. /**
  24851. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24852. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24853. * 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.
  24854. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24855. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24856. * Remember you can only change the shape positions, not their number when updating a polygon.
  24857. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24858. * @param name defines the name of the mesh to create
  24859. * @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
  24860. * @param scene defines the hosting scene
  24861. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24862. * @param updatable defines if the mesh must be flagged as updatable
  24863. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24864. * @param earcutInjection can be used to inject your own earcut reference
  24865. * @returns a new Mesh
  24866. */
  24867. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24868. /**
  24869. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24870. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24871. * @param name defines the name of the mesh to create
  24872. * @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
  24873. * @param depth defines the height of extrusion
  24874. * @param scene defines the hosting scene
  24875. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24876. * @param updatable defines if the mesh must be flagged as updatable
  24877. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24878. * @param earcutInjection can be used to inject your own earcut reference
  24879. * @returns a new Mesh
  24880. */
  24881. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24882. /**
  24883. * Creates an extruded shape mesh.
  24884. * 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
  24885. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24886. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24887. * @param name defines the name of the mesh to create
  24888. * @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
  24889. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24890. * @param scale is the value to scale the shape
  24891. * @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
  24892. * @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
  24893. * @param scene defines the hosting scene
  24894. * @param updatable defines if the mesh must be flagged as updatable
  24895. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24896. * @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)
  24897. * @returns a new Mesh
  24898. */
  24899. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24900. /**
  24901. * Creates an custom extruded shape mesh.
  24902. * The custom extrusion is a parametric shape.
  24903. * It has no predefined shape. Its final shape will depend on the input parameters.
  24904. * Please consider using the same method from the MeshBuilder class instead
  24905. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24906. * @param name defines the name of the mesh to create
  24907. * @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
  24908. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24909. * @param scaleFunction is a custom Javascript function called on each path point
  24910. * @param rotationFunction is a custom Javascript function called on each path point
  24911. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24912. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24913. * @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
  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. * @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)
  24918. * @returns a new Mesh
  24919. */
  24920. 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;
  24921. /**
  24922. * Creates lathe mesh.
  24923. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24924. * Please consider using the same method from the MeshBuilder class instead
  24925. * @param name defines the name of the mesh to create
  24926. * @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
  24927. * @param radius is the radius value of the lathe
  24928. * @param tessellation is the side number of the lathe.
  24929. * @param scene defines the hosting scene
  24930. * @param updatable defines if the mesh must be flagged as updatable
  24931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24932. * @returns a new Mesh
  24933. */
  24934. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24935. /**
  24936. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24937. * @param name defines the name of the mesh to create
  24938. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24945. /**
  24946. * Creates a ground mesh.
  24947. * Please consider using the same method from the MeshBuilder class instead
  24948. * @param name defines the name of the mesh to create
  24949. * @param width set the width of the ground
  24950. * @param height set the height of the ground
  24951. * @param subdivisions sets the number of subdivisions per side
  24952. * @param scene defines the hosting scene
  24953. * @param updatable defines if the mesh must be flagged as updatable
  24954. * @returns a new Mesh
  24955. */
  24956. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24957. /**
  24958. * Creates a tiled ground mesh.
  24959. * Please consider using the same method from the MeshBuilder class instead
  24960. * @param name defines the name of the mesh to create
  24961. * @param xmin set the ground minimum X coordinate
  24962. * @param zmin set the ground minimum Y coordinate
  24963. * @param xmax set the ground maximum X coordinate
  24964. * @param zmax set the ground maximum Z coordinate
  24965. * @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
  24966. * @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
  24967. * @param scene defines the hosting scene
  24968. * @param updatable defines if the mesh must be flagged as updatable
  24969. * @returns a new Mesh
  24970. */
  24971. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24972. w: number;
  24973. h: number;
  24974. }, precision: {
  24975. w: number;
  24976. h: number;
  24977. }, scene: Scene, updatable?: boolean): Mesh;
  24978. /**
  24979. * Creates a ground mesh from a height map.
  24980. * Please consider using the same method from the MeshBuilder class instead
  24981. * @see http://doc.babylonjs.com/babylon101/height_map
  24982. * @param name defines the name of the mesh to create
  24983. * @param url sets the URL of the height map image resource
  24984. * @param width set the ground width size
  24985. * @param height set the ground height size
  24986. * @param subdivisions sets the number of subdivision per side
  24987. * @param minHeight is the minimum altitude on the ground
  24988. * @param maxHeight is the maximum altitude on the ground
  24989. * @param scene defines the hosting scene
  24990. * @param updatable defines if the mesh must be flagged as updatable
  24991. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24992. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24993. * @returns a new Mesh
  24994. */
  24995. 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;
  24996. /**
  24997. * Creates a tube mesh.
  24998. * The tube is a parametric shape.
  24999. * It has no predefined shape. Its final shape will depend on the input parameters.
  25000. * Please consider using the same method from the MeshBuilder class instead
  25001. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25002. * @param name defines the name of the mesh to create
  25003. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25004. * @param radius sets the tube radius size
  25005. * @param tessellation is the number of sides on the tubular surface
  25006. * @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
  25007. * @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
  25008. * @param scene defines the hosting scene
  25009. * @param updatable defines if the mesh must be flagged as updatable
  25010. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25011. * @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)
  25012. * @returns a new Mesh
  25013. */
  25014. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25015. (i: number, distance: number): number;
  25016. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25017. /**
  25018. * Creates a polyhedron mesh.
  25019. * Please consider using the same method from the MeshBuilder class instead.
  25020. * * 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
  25021. * * The parameter `size` (positive float, default 1) sets the polygon size
  25022. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25023. * * 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`
  25024. * * 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
  25025. * * 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)`)
  25026. * * 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
  25027. * * 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
  25028. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25029. * * 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
  25030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25031. * @param name defines the name of the mesh to create
  25032. * @param options defines the options used to create the mesh
  25033. * @param scene defines the hosting scene
  25034. * @returns a new Mesh
  25035. */
  25036. static CreatePolyhedron(name: string, options: {
  25037. type?: number;
  25038. size?: number;
  25039. sizeX?: number;
  25040. sizeY?: number;
  25041. sizeZ?: number;
  25042. custom?: any;
  25043. faceUV?: Vector4[];
  25044. faceColors?: Color4[];
  25045. updatable?: boolean;
  25046. sideOrientation?: number;
  25047. }, scene: Scene): Mesh;
  25048. /**
  25049. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25050. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25051. * * 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`)
  25052. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25053. * * 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
  25054. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25055. * * 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
  25056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25057. * @param name defines the name of the mesh
  25058. * @param options defines the options used to create the mesh
  25059. * @param scene defines the hosting scene
  25060. * @returns a new Mesh
  25061. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25062. */
  25063. static CreateIcoSphere(name: string, options: {
  25064. radius?: number;
  25065. flat?: boolean;
  25066. subdivisions?: number;
  25067. sideOrientation?: number;
  25068. updatable?: boolean;
  25069. }, scene: Scene): Mesh;
  25070. /**
  25071. * Creates a decal mesh.
  25072. * Please consider using the same method from the MeshBuilder class instead.
  25073. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25074. * @param name defines the name of the mesh
  25075. * @param sourceMesh defines the mesh receiving the decal
  25076. * @param position sets the position of the decal in world coordinates
  25077. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25078. * @param size sets the decal scaling
  25079. * @param angle sets the angle to rotate the decal
  25080. * @returns a new Mesh
  25081. */
  25082. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25083. /**
  25084. * Prepare internal position array for software CPU skinning
  25085. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25086. */
  25087. setPositionsForCPUSkinning(): Float32Array;
  25088. /**
  25089. * Prepare internal normal array for software CPU skinning
  25090. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25091. */
  25092. setNormalsForCPUSkinning(): Float32Array;
  25093. /**
  25094. * Updates the vertex buffer by applying transformation from the bones
  25095. * @param skeleton defines the skeleton to apply to current mesh
  25096. * @returns the current mesh
  25097. */
  25098. applySkeleton(skeleton: Skeleton): Mesh;
  25099. /**
  25100. * 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
  25101. * @param meshes defines the list of meshes to scan
  25102. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25103. */
  25104. static MinMax(meshes: AbstractMesh[]): {
  25105. min: Vector3;
  25106. max: Vector3;
  25107. };
  25108. /**
  25109. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25110. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25111. * @returns a vector3
  25112. */
  25113. static Center(meshesOrMinMaxVector: {
  25114. min: Vector3;
  25115. max: Vector3;
  25116. } | AbstractMesh[]): Vector3;
  25117. /**
  25118. * Merge the array of meshes into a single mesh for performance reasons.
  25119. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25120. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25121. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25122. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25123. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25124. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25125. * @returns a new mesh
  25126. */
  25127. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25128. /** @hidden */
  25129. addInstance(instance: InstancedMesh): void;
  25130. /** @hidden */
  25131. removeInstance(instance: InstancedMesh): void;
  25132. }
  25133. }
  25134. declare module "babylonjs/Cameras/camera" {
  25135. import { SmartArray } from "babylonjs/Misc/smartArray";
  25136. import { Observable } from "babylonjs/Misc/observable";
  25137. import { Nullable } from "babylonjs/types";
  25138. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25139. import { Scene } from "babylonjs/scene";
  25140. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25141. import { Node } from "babylonjs/node";
  25142. import { Mesh } from "babylonjs/Meshes/mesh";
  25143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25144. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25145. import { Viewport } from "babylonjs/Maths/math.viewport";
  25146. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25147. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25148. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25149. import { Ray } from "babylonjs/Culling/ray";
  25150. /**
  25151. * This is the base class of all the camera used in the application.
  25152. * @see http://doc.babylonjs.com/features/cameras
  25153. */
  25154. export class Camera extends Node {
  25155. /** @hidden */
  25156. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25157. /**
  25158. * This is the default projection mode used by the cameras.
  25159. * It helps recreating a feeling of perspective and better appreciate depth.
  25160. * This is the best way to simulate real life cameras.
  25161. */
  25162. static readonly PERSPECTIVE_CAMERA: number;
  25163. /**
  25164. * This helps creating camera with an orthographic mode.
  25165. * 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.
  25166. */
  25167. static readonly ORTHOGRAPHIC_CAMERA: number;
  25168. /**
  25169. * This is the default FOV mode for perspective cameras.
  25170. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25171. */
  25172. static readonly FOVMODE_VERTICAL_FIXED: number;
  25173. /**
  25174. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25175. */
  25176. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25177. /**
  25178. * This specifies ther is no need for a camera rig.
  25179. * Basically only one eye is rendered corresponding to the camera.
  25180. */
  25181. static readonly RIG_MODE_NONE: number;
  25182. /**
  25183. * Simulates a camera Rig with one blue eye and one red eye.
  25184. * This can be use with 3d blue and red glasses.
  25185. */
  25186. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25187. /**
  25188. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25189. */
  25190. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25191. /**
  25192. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25193. */
  25194. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25195. /**
  25196. * Defines that both eyes of the camera will be rendered over under each other.
  25197. */
  25198. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25199. /**
  25200. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25201. */
  25202. static readonly RIG_MODE_VR: number;
  25203. /**
  25204. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25205. */
  25206. static readonly RIG_MODE_WEBVR: number;
  25207. /**
  25208. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25209. */
  25210. static readonly RIG_MODE_CUSTOM: number;
  25211. /**
  25212. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25213. */
  25214. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25215. /**
  25216. * Define the input manager associated with the camera.
  25217. */
  25218. inputs: CameraInputsManager<Camera>;
  25219. /** @hidden */
  25220. _position: Vector3;
  25221. /**
  25222. * Define the current local position of the camera in the scene
  25223. */
  25224. position: Vector3;
  25225. /**
  25226. * The vector the camera should consider as up.
  25227. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25228. */
  25229. upVector: Vector3;
  25230. /**
  25231. * Define the current limit on the left side for an orthographic camera
  25232. * In scene unit
  25233. */
  25234. orthoLeft: Nullable<number>;
  25235. /**
  25236. * Define the current limit on the right side for an orthographic camera
  25237. * In scene unit
  25238. */
  25239. orthoRight: Nullable<number>;
  25240. /**
  25241. * Define the current limit on the bottom side for an orthographic camera
  25242. * In scene unit
  25243. */
  25244. orthoBottom: Nullable<number>;
  25245. /**
  25246. * Define the current limit on the top side for an orthographic camera
  25247. * In scene unit
  25248. */
  25249. orthoTop: Nullable<number>;
  25250. /**
  25251. * Field Of View is set in Radians. (default is 0.8)
  25252. */
  25253. fov: number;
  25254. /**
  25255. * Define the minimum distance the camera can see from.
  25256. * This is important to note that the depth buffer are not infinite and the closer it starts
  25257. * the more your scene might encounter depth fighting issue.
  25258. */
  25259. minZ: number;
  25260. /**
  25261. * Define the maximum distance the camera can see to.
  25262. * This is important to note that the depth buffer are not infinite and the further it end
  25263. * the more your scene might encounter depth fighting issue.
  25264. */
  25265. maxZ: number;
  25266. /**
  25267. * Define the default inertia of the camera.
  25268. * This helps giving a smooth feeling to the camera movement.
  25269. */
  25270. inertia: number;
  25271. /**
  25272. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25273. */
  25274. mode: number;
  25275. /**
  25276. * Define wether the camera is intermediate.
  25277. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25278. */
  25279. isIntermediate: boolean;
  25280. /**
  25281. * Define the viewport of the camera.
  25282. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25283. */
  25284. viewport: Viewport;
  25285. /**
  25286. * Restricts the camera to viewing objects with the same layerMask.
  25287. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25288. */
  25289. layerMask: number;
  25290. /**
  25291. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25292. */
  25293. fovMode: number;
  25294. /**
  25295. * Rig mode of the camera.
  25296. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25297. * This is normally controlled byt the camera themselves as internal use.
  25298. */
  25299. cameraRigMode: number;
  25300. /**
  25301. * Defines the distance between both "eyes" in case of a RIG
  25302. */
  25303. interaxialDistance: number;
  25304. /**
  25305. * Defines if stereoscopic rendering is done side by side or over under.
  25306. */
  25307. isStereoscopicSideBySide: boolean;
  25308. /**
  25309. * 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
  25310. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25311. * else in the scene. (Eg. security camera)
  25312. *
  25313. * 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)
  25314. */
  25315. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25316. /**
  25317. * When set, the camera will render to this render target instead of the default canvas
  25318. *
  25319. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25320. */
  25321. outputRenderTarget: Nullable<RenderTargetTexture>;
  25322. /**
  25323. * Observable triggered when the camera view matrix has changed.
  25324. */
  25325. onViewMatrixChangedObservable: Observable<Camera>;
  25326. /**
  25327. * Observable triggered when the camera Projection matrix has changed.
  25328. */
  25329. onProjectionMatrixChangedObservable: Observable<Camera>;
  25330. /**
  25331. * Observable triggered when the inputs have been processed.
  25332. */
  25333. onAfterCheckInputsObservable: Observable<Camera>;
  25334. /**
  25335. * Observable triggered when reset has been called and applied to the camera.
  25336. */
  25337. onRestoreStateObservable: Observable<Camera>;
  25338. /** @hidden */
  25339. _cameraRigParams: any;
  25340. /** @hidden */
  25341. _rigCameras: Camera[];
  25342. /** @hidden */
  25343. _rigPostProcess: Nullable<PostProcess>;
  25344. protected _webvrViewMatrix: Matrix;
  25345. /** @hidden */
  25346. _skipRendering: boolean;
  25347. /** @hidden */
  25348. _projectionMatrix: Matrix;
  25349. /** @hidden */
  25350. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25351. /** @hidden */
  25352. _activeMeshes: SmartArray<AbstractMesh>;
  25353. protected _globalPosition: Vector3;
  25354. /** @hidden */
  25355. _computedViewMatrix: Matrix;
  25356. private _doNotComputeProjectionMatrix;
  25357. private _transformMatrix;
  25358. private _frustumPlanes;
  25359. private _refreshFrustumPlanes;
  25360. private _storedFov;
  25361. private _stateStored;
  25362. /**
  25363. * Instantiates a new camera object.
  25364. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25365. * @see http://doc.babylonjs.com/features/cameras
  25366. * @param name Defines the name of the camera in the scene
  25367. * @param position Defines the position of the camera
  25368. * @param scene Defines the scene the camera belongs too
  25369. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25370. */
  25371. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25372. /**
  25373. * Store current camera state (fov, position, etc..)
  25374. * @returns the camera
  25375. */
  25376. storeState(): Camera;
  25377. /**
  25378. * Restores the camera state values if it has been stored. You must call storeState() first
  25379. */
  25380. protected _restoreStateValues(): boolean;
  25381. /**
  25382. * Restored camera state. You must call storeState() first.
  25383. * @returns true if restored and false otherwise
  25384. */
  25385. restoreState(): boolean;
  25386. /**
  25387. * Gets the class name of the camera.
  25388. * @returns the class name
  25389. */
  25390. getClassName(): string;
  25391. /** @hidden */
  25392. readonly _isCamera: boolean;
  25393. /**
  25394. * Gets a string representation of the camera useful for debug purpose.
  25395. * @param fullDetails Defines that a more verboe level of logging is required
  25396. * @returns the string representation
  25397. */
  25398. toString(fullDetails?: boolean): string;
  25399. /**
  25400. * Gets the current world space position of the camera.
  25401. */
  25402. readonly globalPosition: Vector3;
  25403. /**
  25404. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25405. * @returns the active meshe list
  25406. */
  25407. getActiveMeshes(): SmartArray<AbstractMesh>;
  25408. /**
  25409. * Check wether a mesh is part of the current active mesh list of the camera
  25410. * @param mesh Defines the mesh to check
  25411. * @returns true if active, false otherwise
  25412. */
  25413. isActiveMesh(mesh: Mesh): boolean;
  25414. /**
  25415. * Is this camera ready to be used/rendered
  25416. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25417. * @return true if the camera is ready
  25418. */
  25419. isReady(completeCheck?: boolean): boolean;
  25420. /** @hidden */
  25421. _initCache(): void;
  25422. /** @hidden */
  25423. _updateCache(ignoreParentClass?: boolean): void;
  25424. /** @hidden */
  25425. _isSynchronized(): boolean;
  25426. /** @hidden */
  25427. _isSynchronizedViewMatrix(): boolean;
  25428. /** @hidden */
  25429. _isSynchronizedProjectionMatrix(): boolean;
  25430. /**
  25431. * Attach the input controls to a specific dom element to get the input from.
  25432. * @param element Defines the element the controls should be listened from
  25433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25434. */
  25435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25436. /**
  25437. * Detach the current controls from the specified dom element.
  25438. * @param element Defines the element to stop listening the inputs from
  25439. */
  25440. detachControl(element: HTMLElement): void;
  25441. /**
  25442. * Update the camera state according to the different inputs gathered during the frame.
  25443. */
  25444. update(): void;
  25445. /** @hidden */
  25446. _checkInputs(): void;
  25447. /** @hidden */
  25448. readonly rigCameras: Camera[];
  25449. /**
  25450. * Gets the post process used by the rig cameras
  25451. */
  25452. readonly rigPostProcess: Nullable<PostProcess>;
  25453. /**
  25454. * Internal, gets the first post proces.
  25455. * @returns the first post process to be run on this camera.
  25456. */
  25457. _getFirstPostProcess(): Nullable<PostProcess>;
  25458. private _cascadePostProcessesToRigCams;
  25459. /**
  25460. * Attach a post process to the camera.
  25461. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25462. * @param postProcess The post process to attach to the camera
  25463. * @param insertAt The position of the post process in case several of them are in use in the scene
  25464. * @returns the position the post process has been inserted at
  25465. */
  25466. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25467. /**
  25468. * Detach a post process to the camera.
  25469. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25470. * @param postProcess The post process to detach from the camera
  25471. */
  25472. detachPostProcess(postProcess: PostProcess): void;
  25473. /**
  25474. * Gets the current world matrix of the camera
  25475. */
  25476. getWorldMatrix(): Matrix;
  25477. /** @hidden */
  25478. _getViewMatrix(): Matrix;
  25479. /**
  25480. * Gets the current view matrix of the camera.
  25481. * @param force forces the camera to recompute the matrix without looking at the cached state
  25482. * @returns the view matrix
  25483. */
  25484. getViewMatrix(force?: boolean): Matrix;
  25485. /**
  25486. * Freeze the projection matrix.
  25487. * It will prevent the cache check of the camera projection compute and can speed up perf
  25488. * if no parameter of the camera are meant to change
  25489. * @param projection Defines manually a projection if necessary
  25490. */
  25491. freezeProjectionMatrix(projection?: Matrix): void;
  25492. /**
  25493. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25494. */
  25495. unfreezeProjectionMatrix(): void;
  25496. /**
  25497. * Gets the current projection matrix of the camera.
  25498. * @param force forces the camera to recompute the matrix without looking at the cached state
  25499. * @returns the projection matrix
  25500. */
  25501. getProjectionMatrix(force?: boolean): Matrix;
  25502. /**
  25503. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25504. * @returns a Matrix
  25505. */
  25506. getTransformationMatrix(): Matrix;
  25507. private _updateFrustumPlanes;
  25508. /**
  25509. * Checks if a cullable object (mesh...) is in the camera frustum
  25510. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25511. * @param target The object to check
  25512. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25513. * @returns true if the object is in frustum otherwise false
  25514. */
  25515. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25516. /**
  25517. * Checks if a cullable object (mesh...) is in the camera frustum
  25518. * Unlike isInFrustum this cheks the full bounding box
  25519. * @param target The object to check
  25520. * @returns true if the object is in frustum otherwise false
  25521. */
  25522. isCompletelyInFrustum(target: ICullable): boolean;
  25523. /**
  25524. * Gets a ray in the forward direction from the camera.
  25525. * @param length Defines the length of the ray to create
  25526. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25527. * @param origin Defines the start point of the ray which defaults to the camera position
  25528. * @returns the forward ray
  25529. */
  25530. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25531. /**
  25532. * Releases resources associated with this node.
  25533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25535. */
  25536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25537. /** @hidden */
  25538. _isLeftCamera: boolean;
  25539. /**
  25540. * Gets the left camera of a rig setup in case of Rigged Camera
  25541. */
  25542. readonly isLeftCamera: boolean;
  25543. /** @hidden */
  25544. _isRightCamera: boolean;
  25545. /**
  25546. * Gets the right camera of a rig setup in case of Rigged Camera
  25547. */
  25548. readonly isRightCamera: boolean;
  25549. /**
  25550. * Gets the left camera of a rig setup in case of Rigged Camera
  25551. */
  25552. readonly leftCamera: Nullable<FreeCamera>;
  25553. /**
  25554. * Gets the right camera of a rig setup in case of Rigged Camera
  25555. */
  25556. readonly rightCamera: Nullable<FreeCamera>;
  25557. /**
  25558. * Gets the left camera target of a rig setup in case of Rigged Camera
  25559. * @returns the target position
  25560. */
  25561. getLeftTarget(): Nullable<Vector3>;
  25562. /**
  25563. * Gets the right camera target of a rig setup in case of Rigged Camera
  25564. * @returns the target position
  25565. */
  25566. getRightTarget(): Nullable<Vector3>;
  25567. /**
  25568. * @hidden
  25569. */
  25570. setCameraRigMode(mode: number, rigParams: any): void;
  25571. /** @hidden */
  25572. static _setStereoscopicRigMode(camera: Camera): void;
  25573. /** @hidden */
  25574. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25575. /** @hidden */
  25576. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25577. /** @hidden */
  25578. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25579. /** @hidden */
  25580. _getVRProjectionMatrix(): Matrix;
  25581. protected _updateCameraRotationMatrix(): void;
  25582. protected _updateWebVRCameraRotationMatrix(): void;
  25583. /**
  25584. * This function MUST be overwritten by the different WebVR cameras available.
  25585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25586. * @hidden
  25587. */
  25588. _getWebVRProjectionMatrix(): Matrix;
  25589. /**
  25590. * This function MUST be overwritten by the different WebVR cameras available.
  25591. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25592. * @hidden
  25593. */
  25594. _getWebVRViewMatrix(): Matrix;
  25595. /** @hidden */
  25596. setCameraRigParameter(name: string, value: any): void;
  25597. /**
  25598. * needs to be overridden by children so sub has required properties to be copied
  25599. * @hidden
  25600. */
  25601. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25602. /**
  25603. * May need to be overridden by children
  25604. * @hidden
  25605. */
  25606. _updateRigCameras(): void;
  25607. /** @hidden */
  25608. _setupInputs(): void;
  25609. /**
  25610. * Serialiaze the camera setup to a json represention
  25611. * @returns the JSON representation
  25612. */
  25613. serialize(): any;
  25614. /**
  25615. * Clones the current camera.
  25616. * @param name The cloned camera name
  25617. * @returns the cloned camera
  25618. */
  25619. clone(name: string): Camera;
  25620. /**
  25621. * Gets the direction of the camera relative to a given local axis.
  25622. * @param localAxis Defines the reference axis to provide a relative direction.
  25623. * @return the direction
  25624. */
  25625. getDirection(localAxis: Vector3): Vector3;
  25626. /**
  25627. * Returns the current camera absolute rotation
  25628. */
  25629. readonly absoluteRotation: Quaternion;
  25630. /**
  25631. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25632. * @param localAxis Defines the reference axis to provide a relative direction.
  25633. * @param result Defines the vector to store the result in
  25634. */
  25635. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25636. /**
  25637. * Gets a camera constructor for a given camera type
  25638. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25639. * @param name The name of the camera the result will be able to instantiate
  25640. * @param scene The scene the result will construct the camera in
  25641. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25642. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25643. * @returns a factory method to construc the camera
  25644. */
  25645. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25646. /**
  25647. * Compute the world matrix of the camera.
  25648. * @returns the camera workd matrix
  25649. */
  25650. computeWorldMatrix(): Matrix;
  25651. /**
  25652. * Parse a JSON and creates the camera from the parsed information
  25653. * @param parsedCamera The JSON to parse
  25654. * @param scene The scene to instantiate the camera in
  25655. * @returns the newly constructed camera
  25656. */
  25657. static Parse(parsedCamera: any, scene: Scene): Camera;
  25658. }
  25659. }
  25660. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25661. import { Nullable } from "babylonjs/types";
  25662. import { Scene } from "babylonjs/scene";
  25663. import { Vector4 } from "babylonjs/Maths/math.vector";
  25664. import { Mesh } from "babylonjs/Meshes/mesh";
  25665. /**
  25666. * Class containing static functions to help procedurally build meshes
  25667. */
  25668. export class DiscBuilder {
  25669. /**
  25670. * Creates a plane polygonal mesh. By default, this is a disc
  25671. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25672. * * 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
  25673. * * 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
  25674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25675. * * 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
  25676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25677. * @param name defines the name of the mesh
  25678. * @param options defines the options used to create the mesh
  25679. * @param scene defines the hosting scene
  25680. * @returns the plane polygonal mesh
  25681. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25682. */
  25683. static CreateDisc(name: string, options: {
  25684. radius?: number;
  25685. tessellation?: number;
  25686. arc?: number;
  25687. updatable?: boolean;
  25688. sideOrientation?: number;
  25689. frontUVs?: Vector4;
  25690. backUVs?: Vector4;
  25691. }, scene?: Nullable<Scene>): Mesh;
  25692. }
  25693. }
  25694. declare module "babylonjs/Particles/solidParticleSystem" {
  25695. import { Vector3 } from "babylonjs/Maths/math.vector";
  25696. import { Mesh } from "babylonjs/Meshes/mesh";
  25697. import { Scene, IDisposable } from "babylonjs/scene";
  25698. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25699. /**
  25700. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25701. *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.
  25702. * The SPS is also a particle system. It provides some methods to manage the particles.
  25703. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25704. *
  25705. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25706. */
  25707. export class SolidParticleSystem implements IDisposable {
  25708. /**
  25709. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25710. * Example : var p = SPS.particles[i];
  25711. */
  25712. particles: SolidParticle[];
  25713. /**
  25714. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25715. */
  25716. nbParticles: number;
  25717. /**
  25718. * If the particles must ever face the camera (default false). Useful for planar particles.
  25719. */
  25720. billboard: boolean;
  25721. /**
  25722. * Recompute normals when adding a shape
  25723. */
  25724. recomputeNormals: boolean;
  25725. /**
  25726. * This a counter ofr your own usage. It's not set by any SPS functions.
  25727. */
  25728. counter: number;
  25729. /**
  25730. * The SPS name. This name is also given to the underlying mesh.
  25731. */
  25732. name: string;
  25733. /**
  25734. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25735. */
  25736. mesh: Mesh;
  25737. /**
  25738. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25739. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25740. */
  25741. vars: any;
  25742. /**
  25743. * This array is populated when the SPS is set as 'pickable'.
  25744. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25745. * Each element of this array is an object `{idx: int, faceId: int}`.
  25746. * `idx` is the picked particle index in the `SPS.particles` array
  25747. * `faceId` is the picked face index counted within this particle.
  25748. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25749. */
  25750. pickedParticles: {
  25751. idx: number;
  25752. faceId: number;
  25753. }[];
  25754. /**
  25755. * This array is populated when `enableDepthSort` is set to true.
  25756. * Each element of this array is an instance of the class DepthSortedParticle.
  25757. */
  25758. depthSortedParticles: DepthSortedParticle[];
  25759. /**
  25760. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25761. * @hidden
  25762. */
  25763. _bSphereOnly: boolean;
  25764. /**
  25765. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25766. * @hidden
  25767. */
  25768. _bSphereRadiusFactor: number;
  25769. private _scene;
  25770. private _positions;
  25771. private _indices;
  25772. private _normals;
  25773. private _colors;
  25774. private _uvs;
  25775. private _indices32;
  25776. private _positions32;
  25777. private _normals32;
  25778. private _fixedNormal32;
  25779. private _colors32;
  25780. private _uvs32;
  25781. private _index;
  25782. private _updatable;
  25783. private _pickable;
  25784. private _isVisibilityBoxLocked;
  25785. private _alwaysVisible;
  25786. private _depthSort;
  25787. private _shapeCounter;
  25788. private _copy;
  25789. private _color;
  25790. private _computeParticleColor;
  25791. private _computeParticleTexture;
  25792. private _computeParticleRotation;
  25793. private _computeParticleVertex;
  25794. private _computeBoundingBox;
  25795. private _depthSortParticles;
  25796. private _camera;
  25797. private _mustUnrotateFixedNormals;
  25798. private _particlesIntersect;
  25799. private _needs32Bits;
  25800. /**
  25801. * Creates a SPS (Solid Particle System) object.
  25802. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25803. * @param scene (Scene) is the scene in which the SPS is added.
  25804. * @param options defines the options of the sps e.g.
  25805. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25806. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25807. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25808. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25809. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25810. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25811. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25812. */
  25813. constructor(name: string, scene: Scene, options?: {
  25814. updatable?: boolean;
  25815. isPickable?: boolean;
  25816. enableDepthSort?: boolean;
  25817. particleIntersection?: boolean;
  25818. boundingSphereOnly?: boolean;
  25819. bSphereRadiusFactor?: number;
  25820. });
  25821. /**
  25822. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25823. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25824. * @returns the created mesh
  25825. */
  25826. buildMesh(): Mesh;
  25827. /**
  25828. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25829. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25830. * Thus the particles generated from `digest()` have their property `position` set yet.
  25831. * @param mesh ( Mesh ) is the mesh to be digested
  25832. * @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
  25833. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25834. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25835. * @returns the current SPS
  25836. */
  25837. digest(mesh: Mesh, options?: {
  25838. facetNb?: number;
  25839. number?: number;
  25840. delta?: number;
  25841. }): SolidParticleSystem;
  25842. private _unrotateFixedNormals;
  25843. private _resetCopy;
  25844. private _meshBuilder;
  25845. private _posToShape;
  25846. private _uvsToShapeUV;
  25847. private _addParticle;
  25848. /**
  25849. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25850. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25851. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25852. * @param nb (positive integer) the number of particles to be created from this model
  25853. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25854. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25855. * @returns the number of shapes in the system
  25856. */
  25857. addShape(mesh: Mesh, nb: number, options?: {
  25858. positionFunction?: any;
  25859. vertexFunction?: any;
  25860. }): number;
  25861. private _rebuildParticle;
  25862. /**
  25863. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25864. * @returns the SPS.
  25865. */
  25866. rebuildMesh(): SolidParticleSystem;
  25867. /**
  25868. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25869. * This method calls `updateParticle()` for each particle of the SPS.
  25870. * For an animated SPS, it is usually called within the render loop.
  25871. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25872. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25873. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25874. * @returns the SPS.
  25875. */
  25876. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25877. /**
  25878. * Disposes the SPS.
  25879. */
  25880. dispose(): void;
  25881. /**
  25882. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25883. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25884. * @returns the SPS.
  25885. */
  25886. refreshVisibleSize(): SolidParticleSystem;
  25887. /**
  25888. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25889. * @param size the size (float) of the visibility box
  25890. * note : this doesn't lock the SPS mesh bounding box.
  25891. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25892. */
  25893. setVisibilityBox(size: number): void;
  25894. /**
  25895. * Gets whether the SPS as always visible or not
  25896. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25897. */
  25898. /**
  25899. * Sets the SPS as always visible or not
  25900. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25901. */
  25902. isAlwaysVisible: boolean;
  25903. /**
  25904. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25905. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25906. */
  25907. /**
  25908. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25909. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25910. */
  25911. isVisibilityBoxLocked: boolean;
  25912. /**
  25913. * Tells to `setParticles()` to compute the particle rotations or not.
  25914. * Default value : true. The SPS is faster when it's set to false.
  25915. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25916. */
  25917. /**
  25918. * Gets if `setParticles()` computes the particle rotations or not.
  25919. * Default value : true. The SPS is faster when it's set to false.
  25920. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25921. */
  25922. computeParticleRotation: boolean;
  25923. /**
  25924. * Tells to `setParticles()` to compute the particle colors or not.
  25925. * Default value : true. The SPS is faster when it's set to false.
  25926. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25927. */
  25928. /**
  25929. * Gets if `setParticles()` computes the particle colors or not.
  25930. * Default value : true. The SPS is faster when it's set to false.
  25931. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25932. */
  25933. computeParticleColor: boolean;
  25934. /**
  25935. * Gets if `setParticles()` computes the particle textures or not.
  25936. * Default value : true. The SPS is faster when it's set to false.
  25937. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25938. */
  25939. computeParticleTexture: boolean;
  25940. /**
  25941. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25942. * Default value : false. The SPS is faster when it's set to false.
  25943. * Note : the particle custom vertex positions aren't stored values.
  25944. */
  25945. /**
  25946. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25947. * Default value : false. The SPS is faster when it's set to false.
  25948. * Note : the particle custom vertex positions aren't stored values.
  25949. */
  25950. computeParticleVertex: boolean;
  25951. /**
  25952. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25953. */
  25954. /**
  25955. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25956. */
  25957. computeBoundingBox: boolean;
  25958. /**
  25959. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25960. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25961. * Default : `true`
  25962. */
  25963. /**
  25964. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25965. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25966. * Default : `true`
  25967. */
  25968. depthSortParticles: boolean;
  25969. /**
  25970. * This function does nothing. It may be overwritten to set all the particle first values.
  25971. * The SPS doesn't call this function, you may have to call it by your own.
  25972. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25973. */
  25974. initParticles(): void;
  25975. /**
  25976. * This function does nothing. It may be overwritten to recycle a particle.
  25977. * The SPS doesn't call this function, you may have to call it by your own.
  25978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25979. * @param particle The particle to recycle
  25980. * @returns the recycled particle
  25981. */
  25982. recycleParticle(particle: SolidParticle): SolidParticle;
  25983. /**
  25984. * Updates a particle : this function should be overwritten by the user.
  25985. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25987. * @example : just set a particle position or velocity and recycle conditions
  25988. * @param particle The particle to update
  25989. * @returns the updated particle
  25990. */
  25991. updateParticle(particle: SolidParticle): SolidParticle;
  25992. /**
  25993. * Updates a vertex of a particle : it can be overwritten by the user.
  25994. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25995. * @param particle the current particle
  25996. * @param vertex the current index of the current particle
  25997. * @param pt the index of the current vertex in the particle shape
  25998. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25999. * @example : just set a vertex particle position
  26000. * @returns the updated vertex
  26001. */
  26002. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26003. /**
  26004. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26005. * This does nothing and may be overwritten by the user.
  26006. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26007. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26008. * @param update the boolean update value actually passed to setParticles()
  26009. */
  26010. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26011. /**
  26012. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26013. * This will be passed three parameters.
  26014. * This does nothing and may be overwritten by the user.
  26015. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26016. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26017. * @param update the boolean update value actually passed to setParticles()
  26018. */
  26019. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26020. }
  26021. }
  26022. declare module "babylonjs/Particles/solidParticle" {
  26023. import { Nullable } from "babylonjs/types";
  26024. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26025. import { Color4 } from "babylonjs/Maths/math.color";
  26026. import { Mesh } from "babylonjs/Meshes/mesh";
  26027. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26028. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26029. import { Plane } from "babylonjs/Maths/math.plane";
  26030. /**
  26031. * Represents one particle of a solid particle system.
  26032. */
  26033. export class SolidParticle {
  26034. /**
  26035. * particle global index
  26036. */
  26037. idx: number;
  26038. /**
  26039. * The color of the particle
  26040. */
  26041. color: Nullable<Color4>;
  26042. /**
  26043. * The world space position of the particle.
  26044. */
  26045. position: Vector3;
  26046. /**
  26047. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26048. */
  26049. rotation: Vector3;
  26050. /**
  26051. * The world space rotation quaternion of the particle.
  26052. */
  26053. rotationQuaternion: Nullable<Quaternion>;
  26054. /**
  26055. * The scaling of the particle.
  26056. */
  26057. scaling: Vector3;
  26058. /**
  26059. * The uvs of the particle.
  26060. */
  26061. uvs: Vector4;
  26062. /**
  26063. * The current speed of the particle.
  26064. */
  26065. velocity: Vector3;
  26066. /**
  26067. * The pivot point in the particle local space.
  26068. */
  26069. pivot: Vector3;
  26070. /**
  26071. * Must the particle be translated from its pivot point in its local space ?
  26072. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26073. * Default : false
  26074. */
  26075. translateFromPivot: boolean;
  26076. /**
  26077. * Is the particle active or not ?
  26078. */
  26079. alive: boolean;
  26080. /**
  26081. * Is the particle visible or not ?
  26082. */
  26083. isVisible: boolean;
  26084. /**
  26085. * Index of this particle in the global "positions" array (Internal use)
  26086. * @hidden
  26087. */
  26088. _pos: number;
  26089. /**
  26090. * @hidden Index of this particle in the global "indices" array (Internal use)
  26091. */
  26092. _ind: number;
  26093. /**
  26094. * @hidden ModelShape of this particle (Internal use)
  26095. */
  26096. _model: ModelShape;
  26097. /**
  26098. * ModelShape id of this particle
  26099. */
  26100. shapeId: number;
  26101. /**
  26102. * Index of the particle in its shape id
  26103. */
  26104. idxInShape: number;
  26105. /**
  26106. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26107. */
  26108. _modelBoundingInfo: BoundingInfo;
  26109. /**
  26110. * @hidden Particle BoundingInfo object (Internal use)
  26111. */
  26112. _boundingInfo: BoundingInfo;
  26113. /**
  26114. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26115. */
  26116. _sps: SolidParticleSystem;
  26117. /**
  26118. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26119. */
  26120. _stillInvisible: boolean;
  26121. /**
  26122. * @hidden Last computed particle rotation matrix
  26123. */
  26124. _rotationMatrix: number[];
  26125. /**
  26126. * Parent particle Id, if any.
  26127. * Default null.
  26128. */
  26129. parentId: Nullable<number>;
  26130. /**
  26131. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26132. * The possible values are :
  26133. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26134. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26135. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26136. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26137. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26138. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26139. * */
  26140. cullingStrategy: number;
  26141. /**
  26142. * @hidden Internal global position in the SPS.
  26143. */
  26144. _globalPosition: Vector3;
  26145. /**
  26146. * Creates a Solid Particle object.
  26147. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26148. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26149. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26150. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26151. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26152. * @param shapeId (integer) is the model shape identifier in the SPS.
  26153. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26154. * @param sps defines the sps it is associated to
  26155. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26156. */
  26157. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26158. /**
  26159. * Legacy support, changed scale to scaling
  26160. */
  26161. /**
  26162. * Legacy support, changed scale to scaling
  26163. */
  26164. scale: Vector3;
  26165. /**
  26166. * Legacy support, changed quaternion to rotationQuaternion
  26167. */
  26168. /**
  26169. * Legacy support, changed quaternion to rotationQuaternion
  26170. */
  26171. quaternion: Nullable<Quaternion>;
  26172. /**
  26173. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26174. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26175. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26176. * @returns true if it intersects
  26177. */
  26178. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26179. /**
  26180. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26181. * A particle is in the frustum if its bounding box intersects the frustum
  26182. * @param frustumPlanes defines the frustum to test
  26183. * @returns true if the particle is in the frustum planes
  26184. */
  26185. isInFrustum(frustumPlanes: Plane[]): boolean;
  26186. /**
  26187. * get the rotation matrix of the particle
  26188. * @hidden
  26189. */
  26190. getRotationMatrix(m: Matrix): void;
  26191. }
  26192. /**
  26193. * Represents the shape of the model used by one particle of a solid particle system.
  26194. * SPS internal tool, don't use it manually.
  26195. */
  26196. export class ModelShape {
  26197. /**
  26198. * The shape id
  26199. * @hidden
  26200. */
  26201. shapeID: number;
  26202. /**
  26203. * flat array of model positions (internal use)
  26204. * @hidden
  26205. */
  26206. _shape: Vector3[];
  26207. /**
  26208. * flat array of model UVs (internal use)
  26209. * @hidden
  26210. */
  26211. _shapeUV: number[];
  26212. /**
  26213. * length of the shape in the model indices array (internal use)
  26214. * @hidden
  26215. */
  26216. _indicesLength: number;
  26217. /**
  26218. * Custom position function (internal use)
  26219. * @hidden
  26220. */
  26221. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26222. /**
  26223. * Custom vertex function (internal use)
  26224. * @hidden
  26225. */
  26226. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26227. /**
  26228. * 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.
  26229. * SPS internal tool, don't use it manually.
  26230. * @hidden
  26231. */
  26232. 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>);
  26233. }
  26234. /**
  26235. * Represents a Depth Sorted Particle in the solid particle system.
  26236. */
  26237. export class DepthSortedParticle {
  26238. /**
  26239. * Index of the particle in the "indices" array
  26240. */
  26241. ind: number;
  26242. /**
  26243. * Length of the particle shape in the "indices" array
  26244. */
  26245. indicesLength: number;
  26246. /**
  26247. * Squared distance from the particle to the camera
  26248. */
  26249. sqDistance: number;
  26250. }
  26251. }
  26252. declare module "babylonjs/Collisions/meshCollisionData" {
  26253. import { Collider } from "babylonjs/Collisions/collider";
  26254. import { Vector3 } from "babylonjs/Maths/math.vector";
  26255. import { Nullable } from "babylonjs/types";
  26256. import { Observer } from "babylonjs/Misc/observable";
  26257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26258. /**
  26259. * @hidden
  26260. */
  26261. export class _MeshCollisionData {
  26262. _checkCollisions: boolean;
  26263. _collisionMask: number;
  26264. _collisionGroup: number;
  26265. _collider: Nullable<Collider>;
  26266. _oldPositionForCollisions: Vector3;
  26267. _diffPositionForCollisions: Vector3;
  26268. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26269. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26270. }
  26271. }
  26272. declare module "babylonjs/Meshes/abstractMesh" {
  26273. import { Observable } from "babylonjs/Misc/observable";
  26274. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26275. import { Camera } from "babylonjs/Cameras/camera";
  26276. import { Scene, IDisposable } from "babylonjs/scene";
  26277. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26278. import { Node } from "babylonjs/node";
  26279. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26280. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26281. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26282. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26283. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26284. import { Material } from "babylonjs/Materials/material";
  26285. import { Light } from "babylonjs/Lights/light";
  26286. import { Skeleton } from "babylonjs/Bones/skeleton";
  26287. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26288. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26289. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26290. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26291. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26292. import { Plane } from "babylonjs/Maths/math.plane";
  26293. import { Ray } from "babylonjs/Culling/ray";
  26294. import { Collider } from "babylonjs/Collisions/collider";
  26295. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26296. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26297. /** @hidden */
  26298. class _FacetDataStorage {
  26299. facetPositions: Vector3[];
  26300. facetNormals: Vector3[];
  26301. facetPartitioning: number[][];
  26302. facetNb: number;
  26303. partitioningSubdivisions: number;
  26304. partitioningBBoxRatio: number;
  26305. facetDataEnabled: boolean;
  26306. facetParameters: any;
  26307. bbSize: Vector3;
  26308. subDiv: {
  26309. max: number;
  26310. X: number;
  26311. Y: number;
  26312. Z: number;
  26313. };
  26314. facetDepthSort: boolean;
  26315. facetDepthSortEnabled: boolean;
  26316. depthSortedIndices: IndicesArray;
  26317. depthSortedFacets: {
  26318. ind: number;
  26319. sqDistance: number;
  26320. }[];
  26321. facetDepthSortFunction: (f1: {
  26322. ind: number;
  26323. sqDistance: number;
  26324. }, f2: {
  26325. ind: number;
  26326. sqDistance: number;
  26327. }) => number;
  26328. facetDepthSortFrom: Vector3;
  26329. facetDepthSortOrigin: Vector3;
  26330. invertedMatrix: Matrix;
  26331. }
  26332. /**
  26333. * @hidden
  26334. **/
  26335. class _InternalAbstractMeshDataInfo {
  26336. _hasVertexAlpha: boolean;
  26337. _useVertexColors: boolean;
  26338. _numBoneInfluencers: number;
  26339. _applyFog: boolean;
  26340. _receiveShadows: boolean;
  26341. _facetData: _FacetDataStorage;
  26342. _visibility: number;
  26343. _skeleton: Nullable<Skeleton>;
  26344. _layerMask: number;
  26345. _computeBonesUsingShaders: boolean;
  26346. _isActive: boolean;
  26347. _onlyForInstances: boolean;
  26348. _isActiveIntermediate: boolean;
  26349. _onlyForInstancesIntermediate: boolean;
  26350. }
  26351. /**
  26352. * Class used to store all common mesh properties
  26353. */
  26354. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26355. /** No occlusion */
  26356. static OCCLUSION_TYPE_NONE: number;
  26357. /** Occlusion set to optimisitic */
  26358. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26359. /** Occlusion set to strict */
  26360. static OCCLUSION_TYPE_STRICT: number;
  26361. /** Use an accurante occlusion algorithm */
  26362. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26363. /** Use a conservative occlusion algorithm */
  26364. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26365. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26366. * Test order :
  26367. * Is the bounding sphere outside the frustum ?
  26368. * If not, are the bounding box vertices outside the frustum ?
  26369. * It not, then the cullable object is in the frustum.
  26370. */
  26371. static readonly CULLINGSTRATEGY_STANDARD: number;
  26372. /** Culling strategy : Bounding Sphere Only.
  26373. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26374. * It's also less accurate than the standard because some not visible objects can still be selected.
  26375. * Test : is the bounding sphere outside the frustum ?
  26376. * If not, then the cullable object is in the frustum.
  26377. */
  26378. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26379. /** Culling strategy : Optimistic Inclusion.
  26380. * This in an inclusion test first, then the standard exclusion test.
  26381. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26382. * 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.
  26383. * Anyway, it's as accurate as the standard strategy.
  26384. * Test :
  26385. * Is the cullable object bounding sphere center in the frustum ?
  26386. * If not, apply the default culling strategy.
  26387. */
  26388. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26389. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26390. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26391. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26392. * 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.
  26393. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26394. * Test :
  26395. * Is the cullable object bounding sphere center in the frustum ?
  26396. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26397. */
  26398. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26399. /**
  26400. * No billboard
  26401. */
  26402. static readonly BILLBOARDMODE_NONE: number;
  26403. /** Billboard on X axis */
  26404. static readonly BILLBOARDMODE_X: number;
  26405. /** Billboard on Y axis */
  26406. static readonly BILLBOARDMODE_Y: number;
  26407. /** Billboard on Z axis */
  26408. static readonly BILLBOARDMODE_Z: number;
  26409. /** Billboard on all axes */
  26410. static readonly BILLBOARDMODE_ALL: number;
  26411. /** Billboard on using position instead of orientation */
  26412. static readonly BILLBOARDMODE_USE_POSITION: number;
  26413. /** @hidden */
  26414. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26415. /**
  26416. * The culling strategy to use to check whether the mesh must be rendered or not.
  26417. * This value can be changed at any time and will be used on the next render mesh selection.
  26418. * The possible values are :
  26419. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26420. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26421. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26422. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26423. * Please read each static variable documentation to get details about the culling process.
  26424. * */
  26425. cullingStrategy: number;
  26426. /**
  26427. * Gets the number of facets in the mesh
  26428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26429. */
  26430. readonly facetNb: number;
  26431. /**
  26432. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26433. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26434. */
  26435. partitioningSubdivisions: number;
  26436. /**
  26437. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26438. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26440. */
  26441. partitioningBBoxRatio: number;
  26442. /**
  26443. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26444. * Works only for updatable meshes.
  26445. * Doesn't work with multi-materials
  26446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26447. */
  26448. mustDepthSortFacets: boolean;
  26449. /**
  26450. * The location (Vector3) where the facet depth sort must be computed from.
  26451. * By default, the active camera position.
  26452. * Used only when facet depth sort is enabled
  26453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26454. */
  26455. facetDepthSortFrom: Vector3;
  26456. /**
  26457. * gets a boolean indicating if facetData is enabled
  26458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26459. */
  26460. readonly isFacetDataEnabled: boolean;
  26461. /** @hidden */
  26462. _updateNonUniformScalingState(value: boolean): boolean;
  26463. /**
  26464. * An event triggered when this mesh collides with another one
  26465. */
  26466. onCollideObservable: Observable<AbstractMesh>;
  26467. /** Set a function to call when this mesh collides with another one */
  26468. onCollide: () => void;
  26469. /**
  26470. * An event triggered when the collision's position changes
  26471. */
  26472. onCollisionPositionChangeObservable: Observable<Vector3>;
  26473. /** Set a function to call when the collision's position changes */
  26474. onCollisionPositionChange: () => void;
  26475. /**
  26476. * An event triggered when material is changed
  26477. */
  26478. onMaterialChangedObservable: Observable<AbstractMesh>;
  26479. /**
  26480. * Gets or sets the orientation for POV movement & rotation
  26481. */
  26482. definedFacingForward: boolean;
  26483. /** @hidden */
  26484. _occlusionQuery: Nullable<WebGLQuery>;
  26485. /** @hidden */
  26486. _renderingGroup: Nullable<RenderingGroup>;
  26487. /**
  26488. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26489. */
  26490. /**
  26491. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26492. */
  26493. visibility: number;
  26494. /** Gets or sets the alpha index used to sort transparent meshes
  26495. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26496. */
  26497. alphaIndex: number;
  26498. /**
  26499. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26500. */
  26501. isVisible: boolean;
  26502. /**
  26503. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26504. */
  26505. isPickable: boolean;
  26506. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26507. showSubMeshesBoundingBox: boolean;
  26508. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26509. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26510. */
  26511. isBlocker: boolean;
  26512. /**
  26513. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26514. */
  26515. enablePointerMoveEvents: boolean;
  26516. /**
  26517. * Specifies the rendering group id for this mesh (0 by default)
  26518. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26519. */
  26520. renderingGroupId: number;
  26521. private _material;
  26522. /** Gets or sets current material */
  26523. material: Nullable<Material>;
  26524. /**
  26525. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26526. * @see http://doc.babylonjs.com/babylon101/shadows
  26527. */
  26528. receiveShadows: boolean;
  26529. /** Defines color to use when rendering outline */
  26530. outlineColor: Color3;
  26531. /** Define width to use when rendering outline */
  26532. outlineWidth: number;
  26533. /** Defines color to use when rendering overlay */
  26534. overlayColor: Color3;
  26535. /** Defines alpha to use when rendering overlay */
  26536. overlayAlpha: number;
  26537. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26538. hasVertexAlpha: boolean;
  26539. /** 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) */
  26540. useVertexColors: boolean;
  26541. /**
  26542. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26543. */
  26544. computeBonesUsingShaders: boolean;
  26545. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26546. numBoneInfluencers: number;
  26547. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26548. applyFog: boolean;
  26549. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26550. useOctreeForRenderingSelection: boolean;
  26551. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26552. useOctreeForPicking: boolean;
  26553. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26554. useOctreeForCollisions: boolean;
  26555. /**
  26556. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26557. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26558. */
  26559. layerMask: number;
  26560. /**
  26561. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26562. */
  26563. alwaysSelectAsActiveMesh: boolean;
  26564. /**
  26565. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26566. */
  26567. doNotSyncBoundingInfo: boolean;
  26568. /**
  26569. * Gets or sets the current action manager
  26570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26571. */
  26572. actionManager: Nullable<AbstractActionManager>;
  26573. private _meshCollisionData;
  26574. /**
  26575. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26576. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26577. */
  26578. ellipsoid: Vector3;
  26579. /**
  26580. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26581. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26582. */
  26583. ellipsoidOffset: Vector3;
  26584. /**
  26585. * Gets or sets a collision mask used to mask collisions (default is -1).
  26586. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26587. */
  26588. collisionMask: number;
  26589. /**
  26590. * Gets or sets the current collision group mask (-1 by default).
  26591. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26592. */
  26593. collisionGroup: number;
  26594. /**
  26595. * Defines edge width used when edgesRenderer is enabled
  26596. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26597. */
  26598. edgesWidth: number;
  26599. /**
  26600. * Defines edge color used when edgesRenderer is enabled
  26601. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26602. */
  26603. edgesColor: Color4;
  26604. /** @hidden */
  26605. _edgesRenderer: Nullable<IEdgesRenderer>;
  26606. /** @hidden */
  26607. _masterMesh: Nullable<AbstractMesh>;
  26608. /** @hidden */
  26609. _boundingInfo: Nullable<BoundingInfo>;
  26610. /** @hidden */
  26611. _renderId: number;
  26612. /**
  26613. * Gets or sets the list of subMeshes
  26614. * @see http://doc.babylonjs.com/how_to/multi_materials
  26615. */
  26616. subMeshes: SubMesh[];
  26617. /** @hidden */
  26618. _intersectionsInProgress: AbstractMesh[];
  26619. /** @hidden */
  26620. _unIndexed: boolean;
  26621. /** @hidden */
  26622. _lightSources: Light[];
  26623. /** Gets the list of lights affecting that mesh */
  26624. readonly lightSources: Light[];
  26625. /** @hidden */
  26626. readonly _positions: Nullable<Vector3[]>;
  26627. /** @hidden */
  26628. _waitingData: {
  26629. lods: Nullable<any>;
  26630. actions: Nullable<any>;
  26631. freezeWorldMatrix: Nullable<boolean>;
  26632. };
  26633. /** @hidden */
  26634. _bonesTransformMatrices: Nullable<Float32Array>;
  26635. /** @hidden */
  26636. _transformMatrixTexture: Nullable<RawTexture>;
  26637. /**
  26638. * Gets or sets a skeleton to apply skining transformations
  26639. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26640. */
  26641. skeleton: Nullable<Skeleton>;
  26642. /**
  26643. * An event triggered when the mesh is rebuilt.
  26644. */
  26645. onRebuildObservable: Observable<AbstractMesh>;
  26646. /**
  26647. * Creates a new AbstractMesh
  26648. * @param name defines the name of the mesh
  26649. * @param scene defines the hosting scene
  26650. */
  26651. constructor(name: string, scene?: Nullable<Scene>);
  26652. /**
  26653. * Returns the string "AbstractMesh"
  26654. * @returns "AbstractMesh"
  26655. */
  26656. getClassName(): string;
  26657. /**
  26658. * Gets a string representation of the current mesh
  26659. * @param fullDetails defines a boolean indicating if full details must be included
  26660. * @returns a string representation of the current mesh
  26661. */
  26662. toString(fullDetails?: boolean): string;
  26663. /**
  26664. * @hidden
  26665. */
  26666. protected _getEffectiveParent(): Nullable<Node>;
  26667. /** @hidden */
  26668. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26669. /** @hidden */
  26670. _rebuild(): void;
  26671. /** @hidden */
  26672. _resyncLightSources(): void;
  26673. /** @hidden */
  26674. _resyncLighSource(light: Light): void;
  26675. /** @hidden */
  26676. _unBindEffect(): void;
  26677. /** @hidden */
  26678. _removeLightSource(light: Light, dispose: boolean): void;
  26679. private _markSubMeshesAsDirty;
  26680. /** @hidden */
  26681. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26682. /** @hidden */
  26683. _markSubMeshesAsAttributesDirty(): void;
  26684. /** @hidden */
  26685. _markSubMeshesAsMiscDirty(): void;
  26686. /**
  26687. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26688. */
  26689. scaling: Vector3;
  26690. /**
  26691. * Returns true if the mesh is blocked. Implemented by child classes
  26692. */
  26693. readonly isBlocked: boolean;
  26694. /**
  26695. * Returns the mesh itself by default. Implemented by child classes
  26696. * @param camera defines the camera to use to pick the right LOD level
  26697. * @returns the currentAbstractMesh
  26698. */
  26699. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26700. /**
  26701. * Returns 0 by default. Implemented by child classes
  26702. * @returns an integer
  26703. */
  26704. getTotalVertices(): number;
  26705. /**
  26706. * Returns a positive integer : the total number of indices in this mesh geometry.
  26707. * @returns the numner of indices or zero if the mesh has no geometry.
  26708. */
  26709. getTotalIndices(): number;
  26710. /**
  26711. * Returns null by default. Implemented by child classes
  26712. * @returns null
  26713. */
  26714. getIndices(): Nullable<IndicesArray>;
  26715. /**
  26716. * Returns the array of the requested vertex data kind. Implemented by child classes
  26717. * @param kind defines the vertex data kind to use
  26718. * @returns null
  26719. */
  26720. getVerticesData(kind: string): Nullable<FloatArray>;
  26721. /**
  26722. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26723. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26724. * Note that a new underlying VertexBuffer object is created each call.
  26725. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26726. * @param kind defines vertex data kind:
  26727. * * VertexBuffer.PositionKind
  26728. * * VertexBuffer.UVKind
  26729. * * VertexBuffer.UV2Kind
  26730. * * VertexBuffer.UV3Kind
  26731. * * VertexBuffer.UV4Kind
  26732. * * VertexBuffer.UV5Kind
  26733. * * VertexBuffer.UV6Kind
  26734. * * VertexBuffer.ColorKind
  26735. * * VertexBuffer.MatricesIndicesKind
  26736. * * VertexBuffer.MatricesIndicesExtraKind
  26737. * * VertexBuffer.MatricesWeightsKind
  26738. * * VertexBuffer.MatricesWeightsExtraKind
  26739. * @param data defines the data source
  26740. * @param updatable defines if the data must be flagged as updatable (or static)
  26741. * @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
  26742. * @returns the current mesh
  26743. */
  26744. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26745. /**
  26746. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26747. * If the mesh has no geometry, it is simply returned as it is.
  26748. * @param kind defines vertex data kind:
  26749. * * VertexBuffer.PositionKind
  26750. * * VertexBuffer.UVKind
  26751. * * VertexBuffer.UV2Kind
  26752. * * VertexBuffer.UV3Kind
  26753. * * VertexBuffer.UV4Kind
  26754. * * VertexBuffer.UV5Kind
  26755. * * VertexBuffer.UV6Kind
  26756. * * VertexBuffer.ColorKind
  26757. * * VertexBuffer.MatricesIndicesKind
  26758. * * VertexBuffer.MatricesIndicesExtraKind
  26759. * * VertexBuffer.MatricesWeightsKind
  26760. * * VertexBuffer.MatricesWeightsExtraKind
  26761. * @param data defines the data source
  26762. * @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
  26763. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26764. * @returns the current mesh
  26765. */
  26766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26767. /**
  26768. * Sets the mesh indices,
  26769. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26770. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26771. * @param totalVertices Defines the total number of vertices
  26772. * @returns the current mesh
  26773. */
  26774. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26775. /**
  26776. * Gets a boolean indicating if specific vertex data is present
  26777. * @param kind defines the vertex data kind to use
  26778. * @returns true is data kind is present
  26779. */
  26780. isVerticesDataPresent(kind: string): boolean;
  26781. /**
  26782. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26783. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26784. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26785. * @returns a BoundingInfo
  26786. */
  26787. getBoundingInfo(): BoundingInfo;
  26788. /**
  26789. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26790. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26791. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26792. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26793. * @returns the current mesh
  26794. */
  26795. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26796. /**
  26797. * Overwrite the current bounding info
  26798. * @param boundingInfo defines the new bounding info
  26799. * @returns the current mesh
  26800. */
  26801. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26802. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26803. readonly useBones: boolean;
  26804. /** @hidden */
  26805. _preActivate(): void;
  26806. /** @hidden */
  26807. _preActivateForIntermediateRendering(renderId: number): void;
  26808. /** @hidden */
  26809. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26810. /** @hidden */
  26811. _postActivate(): void;
  26812. /** @hidden */
  26813. _freeze(): void;
  26814. /** @hidden */
  26815. _unFreeze(): void;
  26816. /**
  26817. * Gets the current world matrix
  26818. * @returns a Matrix
  26819. */
  26820. getWorldMatrix(): Matrix;
  26821. /** @hidden */
  26822. _getWorldMatrixDeterminant(): number;
  26823. /**
  26824. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26825. */
  26826. readonly isAnInstance: boolean;
  26827. /**
  26828. * Gets a boolean indicating if this mesh has instances
  26829. */
  26830. readonly hasInstances: boolean;
  26831. /**
  26832. * Perform relative position change from the point of view of behind the front of the mesh.
  26833. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26834. * Supports definition of mesh facing forward or backward
  26835. * @param amountRight defines the distance on the right axis
  26836. * @param amountUp defines the distance on the up axis
  26837. * @param amountForward defines the distance on the forward axis
  26838. * @returns the current mesh
  26839. */
  26840. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26841. /**
  26842. * Calculate relative position change from the point of view of behind the front of the mesh.
  26843. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26844. * Supports definition of mesh facing forward or backward
  26845. * @param amountRight defines the distance on the right axis
  26846. * @param amountUp defines the distance on the up axis
  26847. * @param amountForward defines the distance on the forward axis
  26848. * @returns the new displacement vector
  26849. */
  26850. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26851. /**
  26852. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26853. * Supports definition of mesh facing forward or backward
  26854. * @param flipBack defines the flip
  26855. * @param twirlClockwise defines the twirl
  26856. * @param tiltRight defines the tilt
  26857. * @returns the current mesh
  26858. */
  26859. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26860. /**
  26861. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26862. * Supports definition of mesh facing forward or backward.
  26863. * @param flipBack defines the flip
  26864. * @param twirlClockwise defines the twirl
  26865. * @param tiltRight defines the tilt
  26866. * @returns the new rotation vector
  26867. */
  26868. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26869. /**
  26870. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26871. * This means the mesh underlying bounding box and sphere are recomputed.
  26872. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26873. * @returns the current mesh
  26874. */
  26875. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26876. /** @hidden */
  26877. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26878. /** @hidden */
  26879. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26880. /** @hidden */
  26881. _updateBoundingInfo(): AbstractMesh;
  26882. /** @hidden */
  26883. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26884. /** @hidden */
  26885. protected _afterComputeWorldMatrix(): void;
  26886. /** @hidden */
  26887. readonly _effectiveMesh: AbstractMesh;
  26888. /**
  26889. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26890. * A mesh is in the frustum if its bounding box intersects the frustum
  26891. * @param frustumPlanes defines the frustum to test
  26892. * @returns true if the mesh is in the frustum planes
  26893. */
  26894. isInFrustum(frustumPlanes: Plane[]): boolean;
  26895. /**
  26896. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26897. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26898. * @param frustumPlanes defines the frustum to test
  26899. * @returns true if the mesh is completely in the frustum planes
  26900. */
  26901. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26902. /**
  26903. * True if the mesh intersects another mesh or a SolidParticle object
  26904. * @param mesh defines a target mesh or SolidParticle to test
  26905. * @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)
  26906. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26907. * @returns true if there is an intersection
  26908. */
  26909. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26910. /**
  26911. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26912. * @param point defines the point to test
  26913. * @returns true if there is an intersection
  26914. */
  26915. intersectsPoint(point: Vector3): boolean;
  26916. /**
  26917. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26919. */
  26920. checkCollisions: boolean;
  26921. /**
  26922. * Gets Collider object used to compute collisions (not physics)
  26923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26924. */
  26925. readonly collider: Nullable<Collider>;
  26926. /**
  26927. * Move the mesh using collision engine
  26928. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26929. * @param displacement defines the requested displacement vector
  26930. * @returns the current mesh
  26931. */
  26932. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26933. private _onCollisionPositionChange;
  26934. /** @hidden */
  26935. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26936. /** @hidden */
  26937. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26938. /** @hidden */
  26939. _checkCollision(collider: Collider): AbstractMesh;
  26940. /** @hidden */
  26941. _generatePointsArray(): boolean;
  26942. /**
  26943. * Checks if the passed Ray intersects with the mesh
  26944. * @param ray defines the ray to use
  26945. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26946. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26947. * @returns the picking info
  26948. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26949. */
  26950. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26951. /**
  26952. * Clones the current mesh
  26953. * @param name defines the mesh name
  26954. * @param newParent defines the new mesh parent
  26955. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26956. * @returns the new mesh
  26957. */
  26958. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26959. /**
  26960. * Disposes all the submeshes of the current meshnp
  26961. * @returns the current mesh
  26962. */
  26963. releaseSubMeshes(): AbstractMesh;
  26964. /**
  26965. * Releases resources associated with this abstract mesh.
  26966. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26967. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26968. */
  26969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26970. /**
  26971. * Adds the passed mesh as a child to the current mesh
  26972. * @param mesh defines the child mesh
  26973. * @returns the current mesh
  26974. */
  26975. addChild(mesh: AbstractMesh): AbstractMesh;
  26976. /**
  26977. * Removes the passed mesh from the current mesh children list
  26978. * @param mesh defines the child mesh
  26979. * @returns the current mesh
  26980. */
  26981. removeChild(mesh: AbstractMesh): AbstractMesh;
  26982. /** @hidden */
  26983. private _initFacetData;
  26984. /**
  26985. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26986. * This method can be called within the render loop.
  26987. * 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
  26988. * @returns the current mesh
  26989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26990. */
  26991. updateFacetData(): AbstractMesh;
  26992. /**
  26993. * Returns the facetLocalNormals array.
  26994. * The normals are expressed in the mesh local spac
  26995. * @returns an array of Vector3
  26996. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26997. */
  26998. getFacetLocalNormals(): Vector3[];
  26999. /**
  27000. * Returns the facetLocalPositions array.
  27001. * The facet positions are expressed in the mesh local space
  27002. * @returns an array of Vector3
  27003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27004. */
  27005. getFacetLocalPositions(): Vector3[];
  27006. /**
  27007. * Returns the facetLocalPartioning array
  27008. * @returns an array of array of numbers
  27009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27010. */
  27011. getFacetLocalPartitioning(): number[][];
  27012. /**
  27013. * Returns the i-th facet position in the world system.
  27014. * This method allocates a new Vector3 per call
  27015. * @param i defines the facet index
  27016. * @returns a new Vector3
  27017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27018. */
  27019. getFacetPosition(i: number): Vector3;
  27020. /**
  27021. * Sets the reference Vector3 with the i-th facet position in the world system
  27022. * @param i defines the facet index
  27023. * @param ref defines the target vector
  27024. * @returns the current mesh
  27025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27026. */
  27027. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27028. /**
  27029. * Returns the i-th facet normal in the world system.
  27030. * This method allocates a new Vector3 per call
  27031. * @param i defines the facet index
  27032. * @returns a new Vector3
  27033. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27034. */
  27035. getFacetNormal(i: number): Vector3;
  27036. /**
  27037. * Sets the reference Vector3 with the i-th facet normal in the world system
  27038. * @param i defines the facet index
  27039. * @param ref defines the target vector
  27040. * @returns the current mesh
  27041. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27042. */
  27043. getFacetNormalToRef(i: number, ref: Vector3): this;
  27044. /**
  27045. * 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)
  27046. * @param x defines x coordinate
  27047. * @param y defines y coordinate
  27048. * @param z defines z coordinate
  27049. * @returns the array of facet indexes
  27050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27051. */
  27052. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27053. /**
  27054. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27055. * @param projected sets as the (x,y,z) world projection on the facet
  27056. * @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
  27057. * @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
  27058. * @param x defines x coordinate
  27059. * @param y defines y coordinate
  27060. * @param z defines z coordinate
  27061. * @returns the face index if found (or null instead)
  27062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27063. */
  27064. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27065. /**
  27066. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27067. * @param projected sets as the (x,y,z) local projection on the facet
  27068. * @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
  27069. * @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
  27070. * @param x defines x coordinate
  27071. * @param y defines y coordinate
  27072. * @param z defines z coordinate
  27073. * @returns the face index if found (or null instead)
  27074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27075. */
  27076. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27077. /**
  27078. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27079. * @returns the parameters
  27080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27081. */
  27082. getFacetDataParameters(): any;
  27083. /**
  27084. * Disables the feature FacetData and frees the related memory
  27085. * @returns the current mesh
  27086. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27087. */
  27088. disableFacetData(): AbstractMesh;
  27089. /**
  27090. * Updates the AbstractMesh indices array
  27091. * @param indices defines the data source
  27092. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27093. * @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)
  27094. * @returns the current mesh
  27095. */
  27096. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27097. /**
  27098. * Creates new normals data for the mesh
  27099. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27100. * @returns the current mesh
  27101. */
  27102. createNormals(updatable: boolean): AbstractMesh;
  27103. /**
  27104. * Align the mesh with a normal
  27105. * @param normal defines the normal to use
  27106. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27107. * @returns the current mesh
  27108. */
  27109. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27110. /** @hidden */
  27111. _checkOcclusionQuery(): boolean;
  27112. /**
  27113. * Disables the mesh edge rendering mode
  27114. * @returns the currentAbstractMesh
  27115. */
  27116. disableEdgesRendering(): AbstractMesh;
  27117. /**
  27118. * Enables the edge rendering mode on the mesh.
  27119. * This mode makes the mesh edges visible
  27120. * @param epsilon defines the maximal distance between two angles to detect a face
  27121. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27122. * @returns the currentAbstractMesh
  27123. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27124. */
  27125. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27126. }
  27127. }
  27128. declare module "babylonjs/Actions/actionEvent" {
  27129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27130. import { Nullable } from "babylonjs/types";
  27131. import { Sprite } from "babylonjs/Sprites/sprite";
  27132. import { Scene } from "babylonjs/scene";
  27133. import { Vector2 } from "babylonjs/Maths/math.vector";
  27134. /**
  27135. * Interface used to define ActionEvent
  27136. */
  27137. export interface IActionEvent {
  27138. /** The mesh or sprite that triggered the action */
  27139. source: any;
  27140. /** The X mouse cursor position at the time of the event */
  27141. pointerX: number;
  27142. /** The Y mouse cursor position at the time of the event */
  27143. pointerY: number;
  27144. /** The mesh that is currently pointed at (can be null) */
  27145. meshUnderPointer: Nullable<AbstractMesh>;
  27146. /** the original (browser) event that triggered the ActionEvent */
  27147. sourceEvent?: any;
  27148. /** additional data for the event */
  27149. additionalData?: any;
  27150. }
  27151. /**
  27152. * ActionEvent is the event being sent when an action is triggered.
  27153. */
  27154. export class ActionEvent implements IActionEvent {
  27155. /** The mesh or sprite that triggered the action */
  27156. source: any;
  27157. /** The X mouse cursor position at the time of the event */
  27158. pointerX: number;
  27159. /** The Y mouse cursor position at the time of the event */
  27160. pointerY: number;
  27161. /** The mesh that is currently pointed at (can be null) */
  27162. meshUnderPointer: Nullable<AbstractMesh>;
  27163. /** the original (browser) event that triggered the ActionEvent */
  27164. sourceEvent?: any;
  27165. /** additional data for the event */
  27166. additionalData?: any;
  27167. /**
  27168. * Creates a new ActionEvent
  27169. * @param source The mesh or sprite that triggered the action
  27170. * @param pointerX The X mouse cursor position at the time of the event
  27171. * @param pointerY The Y mouse cursor position at the time of the event
  27172. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27173. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27174. * @param additionalData additional data for the event
  27175. */
  27176. constructor(
  27177. /** The mesh or sprite that triggered the action */
  27178. source: any,
  27179. /** The X mouse cursor position at the time of the event */
  27180. pointerX: number,
  27181. /** The Y mouse cursor position at the time of the event */
  27182. pointerY: number,
  27183. /** The mesh that is currently pointed at (can be null) */
  27184. meshUnderPointer: Nullable<AbstractMesh>,
  27185. /** the original (browser) event that triggered the ActionEvent */
  27186. sourceEvent?: any,
  27187. /** additional data for the event */
  27188. additionalData?: any);
  27189. /**
  27190. * Helper function to auto-create an ActionEvent from a source mesh.
  27191. * @param source The source mesh that triggered the event
  27192. * @param evt The original (browser) event
  27193. * @param additionalData additional data for the event
  27194. * @returns the new ActionEvent
  27195. */
  27196. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27197. /**
  27198. * Helper function to auto-create an ActionEvent from a source sprite
  27199. * @param source The source sprite that triggered the event
  27200. * @param scene Scene associated with the sprite
  27201. * @param evt The original (browser) event
  27202. * @param additionalData additional data for the event
  27203. * @returns the new ActionEvent
  27204. */
  27205. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27206. /**
  27207. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27208. * @param scene the scene where the event occurred
  27209. * @param evt The original (browser) event
  27210. * @returns the new ActionEvent
  27211. */
  27212. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27213. /**
  27214. * Helper function to auto-create an ActionEvent from a primitive
  27215. * @param prim defines the target primitive
  27216. * @param pointerPos defines the pointer position
  27217. * @param evt The original (browser) event
  27218. * @param additionalData additional data for the event
  27219. * @returns the new ActionEvent
  27220. */
  27221. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27222. }
  27223. }
  27224. declare module "babylonjs/Actions/abstractActionManager" {
  27225. import { IDisposable } from "babylonjs/scene";
  27226. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27227. import { IAction } from "babylonjs/Actions/action";
  27228. import { Nullable } from "babylonjs/types";
  27229. /**
  27230. * Abstract class used to decouple action Manager from scene and meshes.
  27231. * Do not instantiate.
  27232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27233. */
  27234. export abstract class AbstractActionManager implements IDisposable {
  27235. /** Gets the list of active triggers */
  27236. static Triggers: {
  27237. [key: string]: number;
  27238. };
  27239. /** Gets the cursor to use when hovering items */
  27240. hoverCursor: string;
  27241. /** Gets the list of actions */
  27242. actions: IAction[];
  27243. /**
  27244. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27245. */
  27246. isRecursive: boolean;
  27247. /**
  27248. * Releases all associated resources
  27249. */
  27250. abstract dispose(): void;
  27251. /**
  27252. * Does this action manager has pointer triggers
  27253. */
  27254. abstract readonly hasPointerTriggers: boolean;
  27255. /**
  27256. * Does this action manager has pick triggers
  27257. */
  27258. abstract readonly hasPickTriggers: boolean;
  27259. /**
  27260. * Process a specific trigger
  27261. * @param trigger defines the trigger to process
  27262. * @param evt defines the event details to be processed
  27263. */
  27264. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27265. /**
  27266. * Does this action manager handles actions of any of the given triggers
  27267. * @param triggers defines the triggers to be tested
  27268. * @return a boolean indicating whether one (or more) of the triggers is handled
  27269. */
  27270. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27271. /**
  27272. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27273. * speed.
  27274. * @param triggerA defines the trigger to be tested
  27275. * @param triggerB defines the trigger to be tested
  27276. * @return a boolean indicating whether one (or more) of the triggers is handled
  27277. */
  27278. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27279. /**
  27280. * Does this action manager handles actions of a given trigger
  27281. * @param trigger defines the trigger to be tested
  27282. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27283. * @return whether the trigger is handled
  27284. */
  27285. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27286. /**
  27287. * Serialize this manager to a JSON object
  27288. * @param name defines the property name to store this manager
  27289. * @returns a JSON representation of this manager
  27290. */
  27291. abstract serialize(name: string): any;
  27292. /**
  27293. * Registers an action to this action manager
  27294. * @param action defines the action to be registered
  27295. * @return the action amended (prepared) after registration
  27296. */
  27297. abstract registerAction(action: IAction): Nullable<IAction>;
  27298. /**
  27299. * Unregisters an action to this action manager
  27300. * @param action defines the action to be unregistered
  27301. * @return a boolean indicating whether the action has been unregistered
  27302. */
  27303. abstract unregisterAction(action: IAction): Boolean;
  27304. /**
  27305. * Does exist one action manager with at least one trigger
  27306. **/
  27307. static readonly HasTriggers: boolean;
  27308. /**
  27309. * Does exist one action manager with at least one pick trigger
  27310. **/
  27311. static readonly HasPickTriggers: boolean;
  27312. /**
  27313. * Does exist one action manager that handles actions of a given trigger
  27314. * @param trigger defines the trigger to be tested
  27315. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27316. **/
  27317. static HasSpecificTrigger(trigger: number): boolean;
  27318. }
  27319. }
  27320. declare module "babylonjs/node" {
  27321. import { Scene } from "babylonjs/scene";
  27322. import { Nullable } from "babylonjs/types";
  27323. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27324. import { Engine } from "babylonjs/Engines/engine";
  27325. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27326. import { Observable } from "babylonjs/Misc/observable";
  27327. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27328. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27329. import { Animatable } from "babylonjs/Animations/animatable";
  27330. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27331. import { Animation } from "babylonjs/Animations/animation";
  27332. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27333. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27334. /**
  27335. * Defines how a node can be built from a string name.
  27336. */
  27337. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27338. /**
  27339. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27340. */
  27341. export class Node implements IBehaviorAware<Node> {
  27342. /** @hidden */
  27343. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27344. private static _NodeConstructors;
  27345. /**
  27346. * Add a new node constructor
  27347. * @param type defines the type name of the node to construct
  27348. * @param constructorFunc defines the constructor function
  27349. */
  27350. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27351. /**
  27352. * Returns a node constructor based on type name
  27353. * @param type defines the type name
  27354. * @param name defines the new node name
  27355. * @param scene defines the hosting scene
  27356. * @param options defines optional options to transmit to constructors
  27357. * @returns the new constructor or null
  27358. */
  27359. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27360. /**
  27361. * Gets or sets the name of the node
  27362. */
  27363. name: string;
  27364. /**
  27365. * Gets or sets the id of the node
  27366. */
  27367. id: string;
  27368. /**
  27369. * Gets or sets the unique id of the node
  27370. */
  27371. uniqueId: number;
  27372. /**
  27373. * Gets or sets a string used to store user defined state for the node
  27374. */
  27375. state: string;
  27376. /**
  27377. * Gets or sets an object used to store user defined information for the node
  27378. */
  27379. metadata: any;
  27380. /**
  27381. * For internal use only. Please do not use.
  27382. */
  27383. reservedDataStore: any;
  27384. /**
  27385. * List of inspectable custom properties (used by the Inspector)
  27386. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27387. */
  27388. inspectableCustomProperties: IInspectable[];
  27389. /**
  27390. * Gets or sets a boolean used to define if the node must be serialized
  27391. */
  27392. doNotSerialize: boolean;
  27393. /** @hidden */
  27394. _isDisposed: boolean;
  27395. /**
  27396. * Gets a list of Animations associated with the node
  27397. */
  27398. animations: import("babylonjs/Animations/animation").Animation[];
  27399. protected _ranges: {
  27400. [name: string]: Nullable<AnimationRange>;
  27401. };
  27402. /**
  27403. * Callback raised when the node is ready to be used
  27404. */
  27405. onReady: Nullable<(node: Node) => void>;
  27406. private _isEnabled;
  27407. private _isParentEnabled;
  27408. private _isReady;
  27409. /** @hidden */
  27410. _currentRenderId: number;
  27411. private _parentUpdateId;
  27412. /** @hidden */
  27413. _childUpdateId: number;
  27414. /** @hidden */
  27415. _waitingParentId: Nullable<string>;
  27416. /** @hidden */
  27417. _scene: Scene;
  27418. /** @hidden */
  27419. _cache: any;
  27420. private _parentNode;
  27421. private _children;
  27422. /** @hidden */
  27423. _worldMatrix: Matrix;
  27424. /** @hidden */
  27425. _worldMatrixDeterminant: number;
  27426. /** @hidden */
  27427. _worldMatrixDeterminantIsDirty: boolean;
  27428. /** @hidden */
  27429. private _sceneRootNodesIndex;
  27430. /**
  27431. * Gets a boolean indicating if the node has been disposed
  27432. * @returns true if the node was disposed
  27433. */
  27434. isDisposed(): boolean;
  27435. /**
  27436. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27437. * @see https://doc.babylonjs.com/how_to/parenting
  27438. */
  27439. parent: Nullable<Node>;
  27440. private addToSceneRootNodes;
  27441. private removeFromSceneRootNodes;
  27442. private _animationPropertiesOverride;
  27443. /**
  27444. * Gets or sets the animation properties override
  27445. */
  27446. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27447. /**
  27448. * Gets a string idenfifying the name of the class
  27449. * @returns "Node" string
  27450. */
  27451. getClassName(): string;
  27452. /** @hidden */
  27453. readonly _isNode: boolean;
  27454. /**
  27455. * An event triggered when the mesh is disposed
  27456. */
  27457. onDisposeObservable: Observable<Node>;
  27458. private _onDisposeObserver;
  27459. /**
  27460. * Sets a callback that will be raised when the node will be disposed
  27461. */
  27462. onDispose: () => void;
  27463. /**
  27464. * Creates a new Node
  27465. * @param name the name and id to be given to this node
  27466. * @param scene the scene this node will be added to
  27467. * @param addToRootNodes the node will be added to scene.rootNodes
  27468. */
  27469. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27470. /**
  27471. * Gets the scene of the node
  27472. * @returns a scene
  27473. */
  27474. getScene(): Scene;
  27475. /**
  27476. * Gets the engine of the node
  27477. * @returns a Engine
  27478. */
  27479. getEngine(): Engine;
  27480. private _behaviors;
  27481. /**
  27482. * Attach a behavior to the node
  27483. * @see http://doc.babylonjs.com/features/behaviour
  27484. * @param behavior defines the behavior to attach
  27485. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27486. * @returns the current Node
  27487. */
  27488. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27489. /**
  27490. * Remove an attached behavior
  27491. * @see http://doc.babylonjs.com/features/behaviour
  27492. * @param behavior defines the behavior to attach
  27493. * @returns the current Node
  27494. */
  27495. removeBehavior(behavior: Behavior<Node>): Node;
  27496. /**
  27497. * Gets the list of attached behaviors
  27498. * @see http://doc.babylonjs.com/features/behaviour
  27499. */
  27500. readonly behaviors: Behavior<Node>[];
  27501. /**
  27502. * Gets an attached behavior by name
  27503. * @param name defines the name of the behavior to look for
  27504. * @see http://doc.babylonjs.com/features/behaviour
  27505. * @returns null if behavior was not found else the requested behavior
  27506. */
  27507. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27508. /**
  27509. * Returns the latest update of the World matrix
  27510. * @returns a Matrix
  27511. */
  27512. getWorldMatrix(): Matrix;
  27513. /** @hidden */
  27514. _getWorldMatrixDeterminant(): number;
  27515. /**
  27516. * Returns directly the latest state of the mesh World matrix.
  27517. * A Matrix is returned.
  27518. */
  27519. readonly worldMatrixFromCache: Matrix;
  27520. /** @hidden */
  27521. _initCache(): void;
  27522. /** @hidden */
  27523. updateCache(force?: boolean): void;
  27524. /** @hidden */
  27525. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27526. /** @hidden */
  27527. _updateCache(ignoreParentClass?: boolean): void;
  27528. /** @hidden */
  27529. _isSynchronized(): boolean;
  27530. /** @hidden */
  27531. _markSyncedWithParent(): void;
  27532. /** @hidden */
  27533. isSynchronizedWithParent(): boolean;
  27534. /** @hidden */
  27535. isSynchronized(): boolean;
  27536. /**
  27537. * Is this node ready to be used/rendered
  27538. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27539. * @return true if the node is ready
  27540. */
  27541. isReady(completeCheck?: boolean): boolean;
  27542. /**
  27543. * Is this node enabled?
  27544. * 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
  27545. * @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
  27546. * @return whether this node (and its parent) is enabled
  27547. */
  27548. isEnabled(checkAncestors?: boolean): boolean;
  27549. /** @hidden */
  27550. protected _syncParentEnabledState(): void;
  27551. /**
  27552. * Set the enabled state of this node
  27553. * @param value defines the new enabled state
  27554. */
  27555. setEnabled(value: boolean): void;
  27556. /**
  27557. * Is this node a descendant of the given node?
  27558. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27559. * @param ancestor defines the parent node to inspect
  27560. * @returns a boolean indicating if this node is a descendant of the given node
  27561. */
  27562. isDescendantOf(ancestor: Node): boolean;
  27563. /** @hidden */
  27564. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27565. /**
  27566. * Will return all nodes that have this node as ascendant
  27567. * @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
  27568. * @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
  27569. * @return all children nodes of all types
  27570. */
  27571. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27572. /**
  27573. * Get all child-meshes of this node
  27574. * @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)
  27575. * @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
  27576. * @returns an array of AbstractMesh
  27577. */
  27578. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27579. /**
  27580. * Get all direct children of this node
  27581. * @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
  27582. * @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)
  27583. * @returns an array of Node
  27584. */
  27585. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27586. /** @hidden */
  27587. _setReady(state: boolean): void;
  27588. /**
  27589. * Get an animation by name
  27590. * @param name defines the name of the animation to look for
  27591. * @returns null if not found else the requested animation
  27592. */
  27593. getAnimationByName(name: string): Nullable<Animation>;
  27594. /**
  27595. * Creates an animation range for this node
  27596. * @param name defines the name of the range
  27597. * @param from defines the starting key
  27598. * @param to defines the end key
  27599. */
  27600. createAnimationRange(name: string, from: number, to: number): void;
  27601. /**
  27602. * Delete a specific animation range
  27603. * @param name defines the name of the range to delete
  27604. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27605. */
  27606. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27607. /**
  27608. * Get an animation range by name
  27609. * @param name defines the name of the animation range to look for
  27610. * @returns null if not found else the requested animation range
  27611. */
  27612. getAnimationRange(name: string): Nullable<AnimationRange>;
  27613. /**
  27614. * Gets the list of all animation ranges defined on this node
  27615. * @returns an array
  27616. */
  27617. getAnimationRanges(): Nullable<AnimationRange>[];
  27618. /**
  27619. * Will start the animation sequence
  27620. * @param name defines the range frames for animation sequence
  27621. * @param loop defines if the animation should loop (false by default)
  27622. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27623. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27624. * @returns the object created for this animation. If range does not exist, it will return null
  27625. */
  27626. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27627. /**
  27628. * Serialize animation ranges into a JSON compatible object
  27629. * @returns serialization object
  27630. */
  27631. serializeAnimationRanges(): any;
  27632. /**
  27633. * Computes the world matrix of the node
  27634. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27635. * @returns the world matrix
  27636. */
  27637. computeWorldMatrix(force?: boolean): Matrix;
  27638. /**
  27639. * Releases resources associated with this node.
  27640. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27641. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27642. */
  27643. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27644. /**
  27645. * Parse animation range data from a serialization object and store them into a given node
  27646. * @param node defines where to store the animation ranges
  27647. * @param parsedNode defines the serialization object to read data from
  27648. * @param scene defines the hosting scene
  27649. */
  27650. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27651. /**
  27652. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27653. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27654. * @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
  27655. * @returns the new bounding vectors
  27656. */
  27657. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27658. min: Vector3;
  27659. max: Vector3;
  27660. };
  27661. }
  27662. }
  27663. declare module "babylonjs/Animations/animation" {
  27664. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27665. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27666. import { Color3 } from "babylonjs/Maths/math.color";
  27667. import { Nullable } from "babylonjs/types";
  27668. import { Scene } from "babylonjs/scene";
  27669. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27670. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27671. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27672. import { Node } from "babylonjs/node";
  27673. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27674. import { Size } from "babylonjs/Maths/math.size";
  27675. import { Animatable } from "babylonjs/Animations/animatable";
  27676. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27677. /**
  27678. * @hidden
  27679. */
  27680. export class _IAnimationState {
  27681. key: number;
  27682. repeatCount: number;
  27683. workValue?: any;
  27684. loopMode?: number;
  27685. offsetValue?: any;
  27686. highLimitValue?: any;
  27687. }
  27688. /**
  27689. * Class used to store any kind of animation
  27690. */
  27691. export class Animation {
  27692. /**Name of the animation */
  27693. name: string;
  27694. /**Property to animate */
  27695. targetProperty: string;
  27696. /**The frames per second of the animation */
  27697. framePerSecond: number;
  27698. /**The data type of the animation */
  27699. dataType: number;
  27700. /**The loop mode of the animation */
  27701. loopMode?: number | undefined;
  27702. /**Specifies if blending should be enabled */
  27703. enableBlending?: boolean | undefined;
  27704. /**
  27705. * Use matrix interpolation instead of using direct key value when animating matrices
  27706. */
  27707. static AllowMatricesInterpolation: boolean;
  27708. /**
  27709. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27710. */
  27711. static AllowMatrixDecomposeForInterpolation: boolean;
  27712. /**
  27713. * Stores the key frames of the animation
  27714. */
  27715. private _keys;
  27716. /**
  27717. * Stores the easing function of the animation
  27718. */
  27719. private _easingFunction;
  27720. /**
  27721. * @hidden Internal use only
  27722. */
  27723. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27724. /**
  27725. * The set of event that will be linked to this animation
  27726. */
  27727. private _events;
  27728. /**
  27729. * Stores an array of target property paths
  27730. */
  27731. targetPropertyPath: string[];
  27732. /**
  27733. * Stores the blending speed of the animation
  27734. */
  27735. blendingSpeed: number;
  27736. /**
  27737. * Stores the animation ranges for the animation
  27738. */
  27739. private _ranges;
  27740. /**
  27741. * @hidden Internal use
  27742. */
  27743. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27744. /**
  27745. * Sets up an animation
  27746. * @param property The property to animate
  27747. * @param animationType The animation type to apply
  27748. * @param framePerSecond The frames per second of the animation
  27749. * @param easingFunction The easing function used in the animation
  27750. * @returns The created animation
  27751. */
  27752. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27753. /**
  27754. * Create and start an animation on a node
  27755. * @param name defines the name of the global animation that will be run on all nodes
  27756. * @param node defines the root node where the animation will take place
  27757. * @param targetProperty defines property to animate
  27758. * @param framePerSecond defines the number of frame per second yo use
  27759. * @param totalFrame defines the number of frames in total
  27760. * @param from defines the initial value
  27761. * @param to defines the final value
  27762. * @param loopMode defines which loop mode you want to use (off by default)
  27763. * @param easingFunction defines the easing function to use (linear by default)
  27764. * @param onAnimationEnd defines the callback to call when animation end
  27765. * @returns the animatable created for this animation
  27766. */
  27767. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27768. /**
  27769. * Create and start an animation on a node and its descendants
  27770. * @param name defines the name of the global animation that will be run on all nodes
  27771. * @param node defines the root node where the animation will take place
  27772. * @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
  27773. * @param targetProperty defines property to animate
  27774. * @param framePerSecond defines the number of frame per second to use
  27775. * @param totalFrame defines the number of frames in total
  27776. * @param from defines the initial value
  27777. * @param to defines the final value
  27778. * @param loopMode defines which loop mode you want to use (off by default)
  27779. * @param easingFunction defines the easing function to use (linear by default)
  27780. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27781. * @returns the list of animatables created for all nodes
  27782. * @example https://www.babylonjs-playground.com/#MH0VLI
  27783. */
  27784. 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[]>;
  27785. /**
  27786. * Creates a new animation, merges it with the existing animations and starts it
  27787. * @param name Name of the animation
  27788. * @param node Node which contains the scene that begins the animations
  27789. * @param targetProperty Specifies which property to animate
  27790. * @param framePerSecond The frames per second of the animation
  27791. * @param totalFrame The total number of frames
  27792. * @param from The frame at the beginning of the animation
  27793. * @param to The frame at the end of the animation
  27794. * @param loopMode Specifies the loop mode of the animation
  27795. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27796. * @param onAnimationEnd Callback to run once the animation is complete
  27797. * @returns Nullable animation
  27798. */
  27799. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27800. /**
  27801. * Transition property of an host to the target Value
  27802. * @param property The property to transition
  27803. * @param targetValue The target Value of the property
  27804. * @param host The object where the property to animate belongs
  27805. * @param scene Scene used to run the animation
  27806. * @param frameRate Framerate (in frame/s) to use
  27807. * @param transition The transition type we want to use
  27808. * @param duration The duration of the animation, in milliseconds
  27809. * @param onAnimationEnd Callback trigger at the end of the animation
  27810. * @returns Nullable animation
  27811. */
  27812. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27813. /**
  27814. * Return the array of runtime animations currently using this animation
  27815. */
  27816. readonly runtimeAnimations: RuntimeAnimation[];
  27817. /**
  27818. * Specifies if any of the runtime animations are currently running
  27819. */
  27820. readonly hasRunningRuntimeAnimations: boolean;
  27821. /**
  27822. * Initializes the animation
  27823. * @param name Name of the animation
  27824. * @param targetProperty Property to animate
  27825. * @param framePerSecond The frames per second of the animation
  27826. * @param dataType The data type of the animation
  27827. * @param loopMode The loop mode of the animation
  27828. * @param enableBlending Specifies if blending should be enabled
  27829. */
  27830. constructor(
  27831. /**Name of the animation */
  27832. name: string,
  27833. /**Property to animate */
  27834. targetProperty: string,
  27835. /**The frames per second of the animation */
  27836. framePerSecond: number,
  27837. /**The data type of the animation */
  27838. dataType: number,
  27839. /**The loop mode of the animation */
  27840. loopMode?: number | undefined,
  27841. /**Specifies if blending should be enabled */
  27842. enableBlending?: boolean | undefined);
  27843. /**
  27844. * Converts the animation to a string
  27845. * @param fullDetails support for multiple levels of logging within scene loading
  27846. * @returns String form of the animation
  27847. */
  27848. toString(fullDetails?: boolean): string;
  27849. /**
  27850. * Add an event to this animation
  27851. * @param event Event to add
  27852. */
  27853. addEvent(event: AnimationEvent): void;
  27854. /**
  27855. * Remove all events found at the given frame
  27856. * @param frame The frame to remove events from
  27857. */
  27858. removeEvents(frame: number): void;
  27859. /**
  27860. * Retrieves all the events from the animation
  27861. * @returns Events from the animation
  27862. */
  27863. getEvents(): AnimationEvent[];
  27864. /**
  27865. * Creates an animation range
  27866. * @param name Name of the animation range
  27867. * @param from Starting frame of the animation range
  27868. * @param to Ending frame of the animation
  27869. */
  27870. createRange(name: string, from: number, to: number): void;
  27871. /**
  27872. * Deletes an animation range by name
  27873. * @param name Name of the animation range to delete
  27874. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27875. */
  27876. deleteRange(name: string, deleteFrames?: boolean): void;
  27877. /**
  27878. * Gets the animation range by name, or null if not defined
  27879. * @param name Name of the animation range
  27880. * @returns Nullable animation range
  27881. */
  27882. getRange(name: string): Nullable<AnimationRange>;
  27883. /**
  27884. * Gets the key frames from the animation
  27885. * @returns The key frames of the animation
  27886. */
  27887. getKeys(): Array<IAnimationKey>;
  27888. /**
  27889. * Gets the highest frame rate of the animation
  27890. * @returns Highest frame rate of the animation
  27891. */
  27892. getHighestFrame(): number;
  27893. /**
  27894. * Gets the easing function of the animation
  27895. * @returns Easing function of the animation
  27896. */
  27897. getEasingFunction(): IEasingFunction;
  27898. /**
  27899. * Sets the easing function of the animation
  27900. * @param easingFunction A custom mathematical formula for animation
  27901. */
  27902. setEasingFunction(easingFunction: EasingFunction): void;
  27903. /**
  27904. * Interpolates a scalar linearly
  27905. * @param startValue Start value of the animation curve
  27906. * @param endValue End value of the animation curve
  27907. * @param gradient Scalar amount to interpolate
  27908. * @returns Interpolated scalar value
  27909. */
  27910. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27911. /**
  27912. * Interpolates a scalar cubically
  27913. * @param startValue Start value of the animation curve
  27914. * @param outTangent End tangent of the animation
  27915. * @param endValue End value of the animation curve
  27916. * @param inTangent Start tangent of the animation curve
  27917. * @param gradient Scalar amount to interpolate
  27918. * @returns Interpolated scalar value
  27919. */
  27920. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27921. /**
  27922. * Interpolates a quaternion using a spherical linear interpolation
  27923. * @param startValue Start value of the animation curve
  27924. * @param endValue End value of the animation curve
  27925. * @param gradient Scalar amount to interpolate
  27926. * @returns Interpolated quaternion value
  27927. */
  27928. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27929. /**
  27930. * Interpolates a quaternion cubically
  27931. * @param startValue Start value of the animation curve
  27932. * @param outTangent End tangent of the animation curve
  27933. * @param endValue End value of the animation curve
  27934. * @param inTangent Start tangent of the animation curve
  27935. * @param gradient Scalar amount to interpolate
  27936. * @returns Interpolated quaternion value
  27937. */
  27938. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27939. /**
  27940. * Interpolates a Vector3 linearl
  27941. * @param startValue Start value of the animation curve
  27942. * @param endValue End value of the animation curve
  27943. * @param gradient Scalar amount to interpolate
  27944. * @returns Interpolated scalar value
  27945. */
  27946. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27947. /**
  27948. * Interpolates a Vector3 cubically
  27949. * @param startValue Start value of the animation curve
  27950. * @param outTangent End tangent of the animation
  27951. * @param endValue End value of the animation curve
  27952. * @param inTangent Start tangent of the animation curve
  27953. * @param gradient Scalar amount to interpolate
  27954. * @returns InterpolatedVector3 value
  27955. */
  27956. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27957. /**
  27958. * Interpolates a Vector2 linearly
  27959. * @param startValue Start value of the animation curve
  27960. * @param endValue End value of the animation curve
  27961. * @param gradient Scalar amount to interpolate
  27962. * @returns Interpolated Vector2 value
  27963. */
  27964. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27965. /**
  27966. * Interpolates a Vector2 cubically
  27967. * @param startValue Start value of the animation curve
  27968. * @param outTangent End tangent of the animation
  27969. * @param endValue End value of the animation curve
  27970. * @param inTangent Start tangent of the animation curve
  27971. * @param gradient Scalar amount to interpolate
  27972. * @returns Interpolated Vector2 value
  27973. */
  27974. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27975. /**
  27976. * Interpolates a size linearly
  27977. * @param startValue Start value of the animation curve
  27978. * @param endValue End value of the animation curve
  27979. * @param gradient Scalar amount to interpolate
  27980. * @returns Interpolated Size value
  27981. */
  27982. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27983. /**
  27984. * Interpolates a Color3 linearly
  27985. * @param startValue Start value of the animation curve
  27986. * @param endValue End value of the animation curve
  27987. * @param gradient Scalar amount to interpolate
  27988. * @returns Interpolated Color3 value
  27989. */
  27990. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27991. /**
  27992. * @hidden Internal use only
  27993. */
  27994. _getKeyValue(value: any): any;
  27995. /**
  27996. * @hidden Internal use only
  27997. */
  27998. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27999. /**
  28000. * Defines the function to use to interpolate matrices
  28001. * @param startValue defines the start matrix
  28002. * @param endValue defines the end matrix
  28003. * @param gradient defines the gradient between both matrices
  28004. * @param result defines an optional target matrix where to store the interpolation
  28005. * @returns the interpolated matrix
  28006. */
  28007. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28008. /**
  28009. * Makes a copy of the animation
  28010. * @returns Cloned animation
  28011. */
  28012. clone(): Animation;
  28013. /**
  28014. * Sets the key frames of the animation
  28015. * @param values The animation key frames to set
  28016. */
  28017. setKeys(values: Array<IAnimationKey>): void;
  28018. /**
  28019. * Serializes the animation to an object
  28020. * @returns Serialized object
  28021. */
  28022. serialize(): any;
  28023. /**
  28024. * Float animation type
  28025. */
  28026. private static _ANIMATIONTYPE_FLOAT;
  28027. /**
  28028. * Vector3 animation type
  28029. */
  28030. private static _ANIMATIONTYPE_VECTOR3;
  28031. /**
  28032. * Quaternion animation type
  28033. */
  28034. private static _ANIMATIONTYPE_QUATERNION;
  28035. /**
  28036. * Matrix animation type
  28037. */
  28038. private static _ANIMATIONTYPE_MATRIX;
  28039. /**
  28040. * Color3 animation type
  28041. */
  28042. private static _ANIMATIONTYPE_COLOR3;
  28043. /**
  28044. * Vector2 animation type
  28045. */
  28046. private static _ANIMATIONTYPE_VECTOR2;
  28047. /**
  28048. * Size animation type
  28049. */
  28050. private static _ANIMATIONTYPE_SIZE;
  28051. /**
  28052. * Relative Loop Mode
  28053. */
  28054. private static _ANIMATIONLOOPMODE_RELATIVE;
  28055. /**
  28056. * Cycle Loop Mode
  28057. */
  28058. private static _ANIMATIONLOOPMODE_CYCLE;
  28059. /**
  28060. * Constant Loop Mode
  28061. */
  28062. private static _ANIMATIONLOOPMODE_CONSTANT;
  28063. /**
  28064. * Get the float animation type
  28065. */
  28066. static readonly ANIMATIONTYPE_FLOAT: number;
  28067. /**
  28068. * Get the Vector3 animation type
  28069. */
  28070. static readonly ANIMATIONTYPE_VECTOR3: number;
  28071. /**
  28072. * Get the Vector2 animation type
  28073. */
  28074. static readonly ANIMATIONTYPE_VECTOR2: number;
  28075. /**
  28076. * Get the Size animation type
  28077. */
  28078. static readonly ANIMATIONTYPE_SIZE: number;
  28079. /**
  28080. * Get the Quaternion animation type
  28081. */
  28082. static readonly ANIMATIONTYPE_QUATERNION: number;
  28083. /**
  28084. * Get the Matrix animation type
  28085. */
  28086. static readonly ANIMATIONTYPE_MATRIX: number;
  28087. /**
  28088. * Get the Color3 animation type
  28089. */
  28090. static readonly ANIMATIONTYPE_COLOR3: number;
  28091. /**
  28092. * Get the Relative Loop Mode
  28093. */
  28094. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28095. /**
  28096. * Get the Cycle Loop Mode
  28097. */
  28098. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28099. /**
  28100. * Get the Constant Loop Mode
  28101. */
  28102. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28103. /** @hidden */
  28104. static _UniversalLerp(left: any, right: any, amount: number): any;
  28105. /**
  28106. * Parses an animation object and creates an animation
  28107. * @param parsedAnimation Parsed animation object
  28108. * @returns Animation object
  28109. */
  28110. static Parse(parsedAnimation: any): Animation;
  28111. /**
  28112. * Appends the serialized animations from the source animations
  28113. * @param source Source containing the animations
  28114. * @param destination Target to store the animations
  28115. */
  28116. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28117. }
  28118. }
  28119. declare module "babylonjs/Animations/animatable.interface" {
  28120. import { Nullable } from "babylonjs/types";
  28121. import { Animation } from "babylonjs/Animations/animation";
  28122. /**
  28123. * Interface containing an array of animations
  28124. */
  28125. export interface IAnimatable {
  28126. /**
  28127. * Array of animations
  28128. */
  28129. animations: Nullable<Array<Animation>>;
  28130. }
  28131. }
  28132. declare module "babylonjs/Materials/fresnelParameters" {
  28133. import { Color3 } from "babylonjs/Maths/math.color";
  28134. /**
  28135. * This represents all the required information to add a fresnel effect on a material:
  28136. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28137. */
  28138. export class FresnelParameters {
  28139. private _isEnabled;
  28140. /**
  28141. * Define if the fresnel effect is enable or not.
  28142. */
  28143. isEnabled: boolean;
  28144. /**
  28145. * Define the color used on edges (grazing angle)
  28146. */
  28147. leftColor: Color3;
  28148. /**
  28149. * Define the color used on center
  28150. */
  28151. rightColor: Color3;
  28152. /**
  28153. * Define bias applied to computed fresnel term
  28154. */
  28155. bias: number;
  28156. /**
  28157. * Defined the power exponent applied to fresnel term
  28158. */
  28159. power: number;
  28160. /**
  28161. * Clones the current fresnel and its valuues
  28162. * @returns a clone fresnel configuration
  28163. */
  28164. clone(): FresnelParameters;
  28165. /**
  28166. * Serializes the current fresnel parameters to a JSON representation.
  28167. * @return the JSON serialization
  28168. */
  28169. serialize(): any;
  28170. /**
  28171. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28172. * @param parsedFresnelParameters Define the JSON representation
  28173. * @returns the parsed parameters
  28174. */
  28175. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28176. }
  28177. }
  28178. declare module "babylonjs/Misc/decorators" {
  28179. import { Nullable } from "babylonjs/types";
  28180. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28181. import { Scene } from "babylonjs/scene";
  28182. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28183. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28184. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28185. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28186. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28187. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28188. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28189. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28190. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28191. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28192. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28193. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28194. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28195. /**
  28196. * Decorator used to define property that can be serialized as reference to a camera
  28197. * @param sourceName defines the name of the property to decorate
  28198. */
  28199. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28200. /**
  28201. * Class used to help serialization objects
  28202. */
  28203. export class SerializationHelper {
  28204. /** @hidden */
  28205. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28206. /** @hidden */
  28207. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28208. /** @hidden */
  28209. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28210. /** @hidden */
  28211. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28212. /**
  28213. * Appends the serialized animations from the source animations
  28214. * @param source Source containing the animations
  28215. * @param destination Target to store the animations
  28216. */
  28217. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28218. /**
  28219. * Static function used to serialized a specific entity
  28220. * @param entity defines the entity to serialize
  28221. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28222. * @returns a JSON compatible object representing the serialization of the entity
  28223. */
  28224. static Serialize<T>(entity: T, serializationObject?: any): any;
  28225. /**
  28226. * Creates a new entity from a serialization data object
  28227. * @param creationFunction defines a function used to instanciated the new entity
  28228. * @param source defines the source serialization data
  28229. * @param scene defines the hosting scene
  28230. * @param rootUrl defines the root url for resources
  28231. * @returns a new entity
  28232. */
  28233. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28234. /**
  28235. * Clones an object
  28236. * @param creationFunction defines the function used to instanciate the new object
  28237. * @param source defines the source object
  28238. * @returns the cloned object
  28239. */
  28240. static Clone<T>(creationFunction: () => T, source: T): T;
  28241. /**
  28242. * Instanciates a new object based on a source one (some data will be shared between both object)
  28243. * @param creationFunction defines the function used to instanciate the new object
  28244. * @param source defines the source object
  28245. * @returns the new object
  28246. */
  28247. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28248. }
  28249. }
  28250. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28251. import { Nullable } from "babylonjs/types";
  28252. /**
  28253. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28254. */
  28255. export interface CubeMapInfo {
  28256. /**
  28257. * The pixel array for the front face.
  28258. * This is stored in format, left to right, up to down format.
  28259. */
  28260. front: Nullable<ArrayBufferView>;
  28261. /**
  28262. * The pixel array for the back face.
  28263. * This is stored in format, left to right, up to down format.
  28264. */
  28265. back: Nullable<ArrayBufferView>;
  28266. /**
  28267. * The pixel array for the left face.
  28268. * This is stored in format, left to right, up to down format.
  28269. */
  28270. left: Nullable<ArrayBufferView>;
  28271. /**
  28272. * The pixel array for the right face.
  28273. * This is stored in format, left to right, up to down format.
  28274. */
  28275. right: Nullable<ArrayBufferView>;
  28276. /**
  28277. * The pixel array for the up face.
  28278. * This is stored in format, left to right, up to down format.
  28279. */
  28280. up: Nullable<ArrayBufferView>;
  28281. /**
  28282. * The pixel array for the down face.
  28283. * This is stored in format, left to right, up to down format.
  28284. */
  28285. down: Nullable<ArrayBufferView>;
  28286. /**
  28287. * The size of the cubemap stored.
  28288. *
  28289. * Each faces will be size * size pixels.
  28290. */
  28291. size: number;
  28292. /**
  28293. * The format of the texture.
  28294. *
  28295. * RGBA, RGB.
  28296. */
  28297. format: number;
  28298. /**
  28299. * The type of the texture data.
  28300. *
  28301. * UNSIGNED_INT, FLOAT.
  28302. */
  28303. type: number;
  28304. /**
  28305. * Specifies whether the texture is in gamma space.
  28306. */
  28307. gammaSpace: boolean;
  28308. }
  28309. /**
  28310. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28311. */
  28312. export class PanoramaToCubeMapTools {
  28313. private static FACE_FRONT;
  28314. private static FACE_BACK;
  28315. private static FACE_RIGHT;
  28316. private static FACE_LEFT;
  28317. private static FACE_DOWN;
  28318. private static FACE_UP;
  28319. /**
  28320. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28321. *
  28322. * @param float32Array The source data.
  28323. * @param inputWidth The width of the input panorama.
  28324. * @param inputHeight The height of the input panorama.
  28325. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28326. * @return The cubemap data
  28327. */
  28328. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28329. private static CreateCubemapTexture;
  28330. private static CalcProjectionSpherical;
  28331. }
  28332. }
  28333. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28334. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28336. import { Nullable } from "babylonjs/types";
  28337. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28338. /**
  28339. * Helper class dealing with the extraction of spherical polynomial dataArray
  28340. * from a cube map.
  28341. */
  28342. export class CubeMapToSphericalPolynomialTools {
  28343. private static FileFaces;
  28344. /**
  28345. * Converts a texture to the according Spherical Polynomial data.
  28346. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28347. *
  28348. * @param texture The texture to extract the information from.
  28349. * @return The Spherical Polynomial data.
  28350. */
  28351. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28352. /**
  28353. * Converts a cubemap to the according Spherical Polynomial data.
  28354. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28355. *
  28356. * @param cubeInfo The Cube map to extract the information from.
  28357. * @return The Spherical Polynomial data.
  28358. */
  28359. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28360. }
  28361. }
  28362. declare module "babylonjs/Misc/guid" {
  28363. /**
  28364. * Class used to manipulate GUIDs
  28365. */
  28366. export class GUID {
  28367. /**
  28368. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28369. * Be aware Math.random() could cause collisions, but:
  28370. * "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"
  28371. * @returns a pseudo random id
  28372. */
  28373. static RandomId(): string;
  28374. }
  28375. }
  28376. declare module "babylonjs/Materials/Textures/baseTexture" {
  28377. import { Observable } from "babylonjs/Misc/observable";
  28378. import { Nullable } from "babylonjs/types";
  28379. import { Scene } from "babylonjs/scene";
  28380. import { Matrix } from "babylonjs/Maths/math.vector";
  28381. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28383. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28384. import { ISize } from "babylonjs/Maths/math.size";
  28385. /**
  28386. * Base class of all the textures in babylon.
  28387. * It groups all the common properties the materials, post process, lights... might need
  28388. * in order to make a correct use of the texture.
  28389. */
  28390. export class BaseTexture implements IAnimatable {
  28391. /**
  28392. * Default anisotropic filtering level for the application.
  28393. * It is set to 4 as a good tradeoff between perf and quality.
  28394. */
  28395. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28396. /**
  28397. * Gets or sets the unique id of the texture
  28398. */
  28399. uniqueId: number;
  28400. /**
  28401. * Define the name of the texture.
  28402. */
  28403. name: string;
  28404. /**
  28405. * Gets or sets an object used to store user defined information.
  28406. */
  28407. metadata: any;
  28408. /**
  28409. * For internal use only. Please do not use.
  28410. */
  28411. reservedDataStore: any;
  28412. private _hasAlpha;
  28413. /**
  28414. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28415. */
  28416. hasAlpha: boolean;
  28417. /**
  28418. * Defines if the alpha value should be determined via the rgb values.
  28419. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28420. */
  28421. getAlphaFromRGB: boolean;
  28422. /**
  28423. * Intensity or strength of the texture.
  28424. * It is commonly used by materials to fine tune the intensity of the texture
  28425. */
  28426. level: number;
  28427. /**
  28428. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28429. * This is part of the texture as textures usually maps to one uv set.
  28430. */
  28431. coordinatesIndex: number;
  28432. private _coordinatesMode;
  28433. /**
  28434. * How a texture is mapped.
  28435. *
  28436. * | Value | Type | Description |
  28437. * | ----- | ----------------------------------- | ----------- |
  28438. * | 0 | EXPLICIT_MODE | |
  28439. * | 1 | SPHERICAL_MODE | |
  28440. * | 2 | PLANAR_MODE | |
  28441. * | 3 | CUBIC_MODE | |
  28442. * | 4 | PROJECTION_MODE | |
  28443. * | 5 | SKYBOX_MODE | |
  28444. * | 6 | INVCUBIC_MODE | |
  28445. * | 7 | EQUIRECTANGULAR_MODE | |
  28446. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28447. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28448. */
  28449. coordinatesMode: number;
  28450. /**
  28451. * | Value | Type | Description |
  28452. * | ----- | ------------------ | ----------- |
  28453. * | 0 | CLAMP_ADDRESSMODE | |
  28454. * | 1 | WRAP_ADDRESSMODE | |
  28455. * | 2 | MIRROR_ADDRESSMODE | |
  28456. */
  28457. wrapU: number;
  28458. /**
  28459. * | Value | Type | Description |
  28460. * | ----- | ------------------ | ----------- |
  28461. * | 0 | CLAMP_ADDRESSMODE | |
  28462. * | 1 | WRAP_ADDRESSMODE | |
  28463. * | 2 | MIRROR_ADDRESSMODE | |
  28464. */
  28465. wrapV: number;
  28466. /**
  28467. * | Value | Type | Description |
  28468. * | ----- | ------------------ | ----------- |
  28469. * | 0 | CLAMP_ADDRESSMODE | |
  28470. * | 1 | WRAP_ADDRESSMODE | |
  28471. * | 2 | MIRROR_ADDRESSMODE | |
  28472. */
  28473. wrapR: number;
  28474. /**
  28475. * With compliant hardware and browser (supporting anisotropic filtering)
  28476. * this defines the level of anisotropic filtering in the texture.
  28477. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28478. */
  28479. anisotropicFilteringLevel: number;
  28480. /**
  28481. * Define if the texture is a cube texture or if false a 2d texture.
  28482. */
  28483. isCube: boolean;
  28484. /**
  28485. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28486. */
  28487. is3D: boolean;
  28488. /**
  28489. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28490. * HDR texture are usually stored in linear space.
  28491. * This only impacts the PBR and Background materials
  28492. */
  28493. gammaSpace: boolean;
  28494. /**
  28495. * Gets or sets whether or not the texture contains RGBD data.
  28496. */
  28497. isRGBD: boolean;
  28498. /**
  28499. * Is Z inverted in the texture (useful in a cube texture).
  28500. */
  28501. invertZ: boolean;
  28502. /**
  28503. * Are mip maps generated for this texture or not.
  28504. */
  28505. readonly noMipmap: boolean;
  28506. /**
  28507. * @hidden
  28508. */
  28509. lodLevelInAlpha: boolean;
  28510. /**
  28511. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28512. */
  28513. lodGenerationOffset: number;
  28514. /**
  28515. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28516. */
  28517. lodGenerationScale: number;
  28518. /**
  28519. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28520. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28521. * average roughness values.
  28522. */
  28523. linearSpecularLOD: boolean;
  28524. /**
  28525. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28526. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28527. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28528. */
  28529. irradianceTexture: Nullable<BaseTexture>;
  28530. /**
  28531. * Define if the texture is a render target.
  28532. */
  28533. isRenderTarget: boolean;
  28534. /**
  28535. * Define the unique id of the texture in the scene.
  28536. */
  28537. readonly uid: string;
  28538. /**
  28539. * Return a string representation of the texture.
  28540. * @returns the texture as a string
  28541. */
  28542. toString(): string;
  28543. /**
  28544. * Get the class name of the texture.
  28545. * @returns "BaseTexture"
  28546. */
  28547. getClassName(): string;
  28548. /**
  28549. * Define the list of animation attached to the texture.
  28550. */
  28551. animations: import("babylonjs/Animations/animation").Animation[];
  28552. /**
  28553. * An event triggered when the texture is disposed.
  28554. */
  28555. onDisposeObservable: Observable<BaseTexture>;
  28556. private _onDisposeObserver;
  28557. /**
  28558. * Callback triggered when the texture has been disposed.
  28559. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28560. */
  28561. onDispose: () => void;
  28562. /**
  28563. * Define the current state of the loading sequence when in delayed load mode.
  28564. */
  28565. delayLoadState: number;
  28566. private _scene;
  28567. /** @hidden */
  28568. _texture: Nullable<InternalTexture>;
  28569. private _uid;
  28570. /**
  28571. * Define if the texture is preventinga material to render or not.
  28572. * If not and the texture is not ready, the engine will use a default black texture instead.
  28573. */
  28574. readonly isBlocking: boolean;
  28575. /**
  28576. * Instantiates a new BaseTexture.
  28577. * Base class of all the textures in babylon.
  28578. * It groups all the common properties the materials, post process, lights... might need
  28579. * in order to make a correct use of the texture.
  28580. * @param scene Define the scene the texture blongs to
  28581. */
  28582. constructor(scene: Nullable<Scene>);
  28583. /**
  28584. * Get the scene the texture belongs to.
  28585. * @returns the scene or null if undefined
  28586. */
  28587. getScene(): Nullable<Scene>;
  28588. /**
  28589. * Get the texture transform matrix used to offset tile the texture for istance.
  28590. * @returns the transformation matrix
  28591. */
  28592. getTextureMatrix(): Matrix;
  28593. /**
  28594. * Get the texture reflection matrix used to rotate/transform the reflection.
  28595. * @returns the reflection matrix
  28596. */
  28597. getReflectionTextureMatrix(): Matrix;
  28598. /**
  28599. * Get the underlying lower level texture from Babylon.
  28600. * @returns the insternal texture
  28601. */
  28602. getInternalTexture(): Nullable<InternalTexture>;
  28603. /**
  28604. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28605. * @returns true if ready or not blocking
  28606. */
  28607. isReadyOrNotBlocking(): boolean;
  28608. /**
  28609. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28610. * @returns true if fully ready
  28611. */
  28612. isReady(): boolean;
  28613. private _cachedSize;
  28614. /**
  28615. * Get the size of the texture.
  28616. * @returns the texture size.
  28617. */
  28618. getSize(): ISize;
  28619. /**
  28620. * Get the base size of the texture.
  28621. * It can be different from the size if the texture has been resized for POT for instance
  28622. * @returns the base size
  28623. */
  28624. getBaseSize(): ISize;
  28625. /**
  28626. * Update the sampling mode of the texture.
  28627. * Default is Trilinear mode.
  28628. *
  28629. * | Value | Type | Description |
  28630. * | ----- | ------------------ | ----------- |
  28631. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28632. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28633. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28634. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28635. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28636. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28637. * | 7 | NEAREST_LINEAR | |
  28638. * | 8 | NEAREST_NEAREST | |
  28639. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28640. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28641. * | 11 | LINEAR_LINEAR | |
  28642. * | 12 | LINEAR_NEAREST | |
  28643. *
  28644. * > _mag_: magnification filter (close to the viewer)
  28645. * > _min_: minification filter (far from the viewer)
  28646. * > _mip_: filter used between mip map levels
  28647. *@param samplingMode Define the new sampling mode of the texture
  28648. */
  28649. updateSamplingMode(samplingMode: number): void;
  28650. /**
  28651. * Scales the texture if is `canRescale()`
  28652. * @param ratio the resize factor we want to use to rescale
  28653. */
  28654. scale(ratio: number): void;
  28655. /**
  28656. * Get if the texture can rescale.
  28657. */
  28658. readonly canRescale: boolean;
  28659. /** @hidden */
  28660. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28661. /** @hidden */
  28662. _rebuild(): void;
  28663. /**
  28664. * Triggers the load sequence in delayed load mode.
  28665. */
  28666. delayLoad(): void;
  28667. /**
  28668. * Clones the texture.
  28669. * @returns the cloned texture
  28670. */
  28671. clone(): Nullable<BaseTexture>;
  28672. /**
  28673. * Get the texture underlying type (INT, FLOAT...)
  28674. */
  28675. readonly textureType: number;
  28676. /**
  28677. * Get the texture underlying format (RGB, RGBA...)
  28678. */
  28679. readonly textureFormat: number;
  28680. /**
  28681. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28682. * This will returns an RGBA array buffer containing either in values (0-255) or
  28683. * float values (0-1) depending of the underlying buffer type.
  28684. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28685. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28686. * @param buffer defines a user defined buffer to fill with data (can be null)
  28687. * @returns The Array buffer containing the pixels data.
  28688. */
  28689. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28690. /**
  28691. * Release and destroy the underlying lower level texture aka internalTexture.
  28692. */
  28693. releaseInternalTexture(): void;
  28694. /**
  28695. * Get the polynomial representation of the texture data.
  28696. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28697. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28698. */
  28699. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28700. /** @hidden */
  28701. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28702. /** @hidden */
  28703. readonly _lodTextureMid: Nullable<BaseTexture>;
  28704. /** @hidden */
  28705. readonly _lodTextureLow: Nullable<BaseTexture>;
  28706. /**
  28707. * Dispose the texture and release its associated resources.
  28708. */
  28709. dispose(): void;
  28710. /**
  28711. * Serialize the texture into a JSON representation that can be parsed later on.
  28712. * @returns the JSON representation of the texture
  28713. */
  28714. serialize(): any;
  28715. /**
  28716. * Helper function to be called back once a list of texture contains only ready textures.
  28717. * @param textures Define the list of textures to wait for
  28718. * @param callback Define the callback triggered once the entire list will be ready
  28719. */
  28720. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28721. }
  28722. }
  28723. declare module "babylonjs/Materials/Textures/internalTexture" {
  28724. import { Observable } from "babylonjs/Misc/observable";
  28725. import { Nullable, int } from "babylonjs/types";
  28726. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28727. import { Engine } from "babylonjs/Engines/engine";
  28728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28729. /**
  28730. * Class used to store data associated with WebGL texture data for the engine
  28731. * This class should not be used directly
  28732. */
  28733. export class InternalTexture {
  28734. /** @hidden */
  28735. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28736. /**
  28737. * The source of the texture data is unknown
  28738. */
  28739. static DATASOURCE_UNKNOWN: number;
  28740. /**
  28741. * Texture data comes from an URL
  28742. */
  28743. static DATASOURCE_URL: number;
  28744. /**
  28745. * Texture data is only used for temporary storage
  28746. */
  28747. static DATASOURCE_TEMP: number;
  28748. /**
  28749. * Texture data comes from raw data (ArrayBuffer)
  28750. */
  28751. static DATASOURCE_RAW: number;
  28752. /**
  28753. * Texture content is dynamic (video or dynamic texture)
  28754. */
  28755. static DATASOURCE_DYNAMIC: number;
  28756. /**
  28757. * Texture content is generated by rendering to it
  28758. */
  28759. static DATASOURCE_RENDERTARGET: number;
  28760. /**
  28761. * Texture content is part of a multi render target process
  28762. */
  28763. static DATASOURCE_MULTIRENDERTARGET: number;
  28764. /**
  28765. * Texture data comes from a cube data file
  28766. */
  28767. static DATASOURCE_CUBE: number;
  28768. /**
  28769. * Texture data comes from a raw cube data
  28770. */
  28771. static DATASOURCE_CUBERAW: number;
  28772. /**
  28773. * Texture data come from a prefiltered cube data file
  28774. */
  28775. static DATASOURCE_CUBEPREFILTERED: number;
  28776. /**
  28777. * Texture content is raw 3D data
  28778. */
  28779. static DATASOURCE_RAW3D: number;
  28780. /**
  28781. * Texture content is a depth texture
  28782. */
  28783. static DATASOURCE_DEPTHTEXTURE: number;
  28784. /**
  28785. * Texture data comes from a raw cube data encoded with RGBD
  28786. */
  28787. static DATASOURCE_CUBERAW_RGBD: number;
  28788. /**
  28789. * Defines if the texture is ready
  28790. */
  28791. isReady: boolean;
  28792. /**
  28793. * Defines if the texture is a cube texture
  28794. */
  28795. isCube: boolean;
  28796. /**
  28797. * Defines if the texture contains 3D data
  28798. */
  28799. is3D: boolean;
  28800. /**
  28801. * Defines if the texture contains multiview data
  28802. */
  28803. isMultiview: boolean;
  28804. /**
  28805. * Gets the URL used to load this texture
  28806. */
  28807. url: string;
  28808. /**
  28809. * Gets the sampling mode of the texture
  28810. */
  28811. samplingMode: number;
  28812. /**
  28813. * Gets a boolean indicating if the texture needs mipmaps generation
  28814. */
  28815. generateMipMaps: boolean;
  28816. /**
  28817. * Gets the number of samples used by the texture (WebGL2+ only)
  28818. */
  28819. samples: number;
  28820. /**
  28821. * Gets the type of the texture (int, float...)
  28822. */
  28823. type: number;
  28824. /**
  28825. * Gets the format of the texture (RGB, RGBA...)
  28826. */
  28827. format: number;
  28828. /**
  28829. * Observable called when the texture is loaded
  28830. */
  28831. onLoadedObservable: Observable<InternalTexture>;
  28832. /**
  28833. * Gets the width of the texture
  28834. */
  28835. width: number;
  28836. /**
  28837. * Gets the height of the texture
  28838. */
  28839. height: number;
  28840. /**
  28841. * Gets the depth of the texture
  28842. */
  28843. depth: number;
  28844. /**
  28845. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28846. */
  28847. baseWidth: number;
  28848. /**
  28849. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28850. */
  28851. baseHeight: number;
  28852. /**
  28853. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28854. */
  28855. baseDepth: number;
  28856. /**
  28857. * Gets a boolean indicating if the texture is inverted on Y axis
  28858. */
  28859. invertY: boolean;
  28860. /** @hidden */
  28861. _invertVScale: boolean;
  28862. /** @hidden */
  28863. _associatedChannel: number;
  28864. /** @hidden */
  28865. _dataSource: number;
  28866. /** @hidden */
  28867. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28868. /** @hidden */
  28869. _bufferView: Nullable<ArrayBufferView>;
  28870. /** @hidden */
  28871. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28872. /** @hidden */
  28873. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28874. /** @hidden */
  28875. _size: number;
  28876. /** @hidden */
  28877. _extension: string;
  28878. /** @hidden */
  28879. _files: Nullable<string[]>;
  28880. /** @hidden */
  28881. _workingCanvas: Nullable<HTMLCanvasElement>;
  28882. /** @hidden */
  28883. _workingContext: Nullable<CanvasRenderingContext2D>;
  28884. /** @hidden */
  28885. _framebuffer: Nullable<WebGLFramebuffer>;
  28886. /** @hidden */
  28887. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28888. /** @hidden */
  28889. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28890. /** @hidden */
  28891. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28892. /** @hidden */
  28893. _attachments: Nullable<number[]>;
  28894. /** @hidden */
  28895. _cachedCoordinatesMode: Nullable<number>;
  28896. /** @hidden */
  28897. _cachedWrapU: Nullable<number>;
  28898. /** @hidden */
  28899. _cachedWrapV: Nullable<number>;
  28900. /** @hidden */
  28901. _cachedWrapR: Nullable<number>;
  28902. /** @hidden */
  28903. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28904. /** @hidden */
  28905. _isDisabled: boolean;
  28906. /** @hidden */
  28907. _compression: Nullable<string>;
  28908. /** @hidden */
  28909. _generateStencilBuffer: boolean;
  28910. /** @hidden */
  28911. _generateDepthBuffer: boolean;
  28912. /** @hidden */
  28913. _comparisonFunction: number;
  28914. /** @hidden */
  28915. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28916. /** @hidden */
  28917. _lodGenerationScale: number;
  28918. /** @hidden */
  28919. _lodGenerationOffset: number;
  28920. /** @hidden */
  28921. _colorTextureArray: Nullable<WebGLTexture>;
  28922. /** @hidden */
  28923. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28924. /** @hidden */
  28925. _lodTextureHigh: Nullable<BaseTexture>;
  28926. /** @hidden */
  28927. _lodTextureMid: Nullable<BaseTexture>;
  28928. /** @hidden */
  28929. _lodTextureLow: Nullable<BaseTexture>;
  28930. /** @hidden */
  28931. _isRGBD: boolean;
  28932. /** @hidden */
  28933. _linearSpecularLOD: boolean;
  28934. /** @hidden */
  28935. _irradianceTexture: Nullable<BaseTexture>;
  28936. /** @hidden */
  28937. _webGLTexture: Nullable<WebGLTexture>;
  28938. /** @hidden */
  28939. _references: number;
  28940. private _engine;
  28941. /**
  28942. * Gets the Engine the texture belongs to.
  28943. * @returns The babylon engine
  28944. */
  28945. getEngine(): Engine;
  28946. /**
  28947. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28948. */
  28949. readonly dataSource: number;
  28950. /**
  28951. * Creates a new InternalTexture
  28952. * @param engine defines the engine to use
  28953. * @param dataSource defines the type of data that will be used
  28954. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28955. */
  28956. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28957. /**
  28958. * Increments the number of references (ie. the number of Texture that point to it)
  28959. */
  28960. incrementReferences(): void;
  28961. /**
  28962. * Change the size of the texture (not the size of the content)
  28963. * @param width defines the new width
  28964. * @param height defines the new height
  28965. * @param depth defines the new depth (1 by default)
  28966. */
  28967. updateSize(width: int, height: int, depth?: int): void;
  28968. /** @hidden */
  28969. _rebuild(): void;
  28970. /** @hidden */
  28971. _swapAndDie(target: InternalTexture): void;
  28972. /**
  28973. * Dispose the current allocated resources
  28974. */
  28975. dispose(): void;
  28976. }
  28977. }
  28978. declare module "babylonjs/Materials/effect" {
  28979. import { Observable } from "babylonjs/Misc/observable";
  28980. import { Nullable } from "babylonjs/types";
  28981. import { IDisposable } from "babylonjs/scene";
  28982. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28983. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28984. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28985. import { Engine } from "babylonjs/Engines/engine";
  28986. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28988. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28989. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28991. /**
  28992. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28993. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28994. */
  28995. export class EffectFallbacks {
  28996. private _defines;
  28997. private _currentRank;
  28998. private _maxRank;
  28999. private _mesh;
  29000. /**
  29001. * Removes the fallback from the bound mesh.
  29002. */
  29003. unBindMesh(): void;
  29004. /**
  29005. * Adds a fallback on the specified property.
  29006. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29007. * @param define The name of the define in the shader
  29008. */
  29009. addFallback(rank: number, define: string): void;
  29010. /**
  29011. * Sets the mesh to use CPU skinning when needing to fallback.
  29012. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29013. * @param mesh The mesh to use the fallbacks.
  29014. */
  29015. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29016. /**
  29017. * Checks to see if more fallbacks are still availible.
  29018. */
  29019. readonly hasMoreFallbacks: boolean;
  29020. /**
  29021. * Removes the defines that should be removed when falling back.
  29022. * @param currentDefines defines the current define statements for the shader.
  29023. * @param effect defines the current effect we try to compile
  29024. * @returns The resulting defines with defines of the current rank removed.
  29025. */
  29026. reduce(currentDefines: string, effect: Effect): string;
  29027. }
  29028. /**
  29029. * Options to be used when creating an effect.
  29030. */
  29031. export class EffectCreationOptions {
  29032. /**
  29033. * Atrributes that will be used in the shader.
  29034. */
  29035. attributes: string[];
  29036. /**
  29037. * Uniform varible names that will be set in the shader.
  29038. */
  29039. uniformsNames: string[];
  29040. /**
  29041. * Uniform buffer varible names that will be set in the shader.
  29042. */
  29043. uniformBuffersNames: string[];
  29044. /**
  29045. * Sampler texture variable names that will be set in the shader.
  29046. */
  29047. samplers: string[];
  29048. /**
  29049. * Define statements that will be set in the shader.
  29050. */
  29051. defines: any;
  29052. /**
  29053. * Possible fallbacks for this effect to improve performance when needed.
  29054. */
  29055. fallbacks: Nullable<EffectFallbacks>;
  29056. /**
  29057. * Callback that will be called when the shader is compiled.
  29058. */
  29059. onCompiled: Nullable<(effect: Effect) => void>;
  29060. /**
  29061. * Callback that will be called if an error occurs during shader compilation.
  29062. */
  29063. onError: Nullable<(effect: Effect, errors: string) => void>;
  29064. /**
  29065. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29066. */
  29067. indexParameters: any;
  29068. /**
  29069. * Max number of lights that can be used in the shader.
  29070. */
  29071. maxSimultaneousLights: number;
  29072. /**
  29073. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29074. */
  29075. transformFeedbackVaryings: Nullable<string[]>;
  29076. }
  29077. /**
  29078. * Effect containing vertex and fragment shader that can be executed on an object.
  29079. */
  29080. export class Effect implements IDisposable {
  29081. /**
  29082. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29083. */
  29084. static ShadersRepository: string;
  29085. /**
  29086. * Name of the effect.
  29087. */
  29088. name: any;
  29089. /**
  29090. * String container all the define statements that should be set on the shader.
  29091. */
  29092. defines: string;
  29093. /**
  29094. * Callback that will be called when the shader is compiled.
  29095. */
  29096. onCompiled: Nullable<(effect: Effect) => void>;
  29097. /**
  29098. * Callback that will be called if an error occurs during shader compilation.
  29099. */
  29100. onError: Nullable<(effect: Effect, errors: string) => void>;
  29101. /**
  29102. * Callback that will be called when effect is bound.
  29103. */
  29104. onBind: Nullable<(effect: Effect) => void>;
  29105. /**
  29106. * Unique ID of the effect.
  29107. */
  29108. uniqueId: number;
  29109. /**
  29110. * Observable that will be called when the shader is compiled.
  29111. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29112. */
  29113. onCompileObservable: Observable<Effect>;
  29114. /**
  29115. * Observable that will be called if an error occurs during shader compilation.
  29116. */
  29117. onErrorObservable: Observable<Effect>;
  29118. /** @hidden */
  29119. _onBindObservable: Nullable<Observable<Effect>>;
  29120. /**
  29121. * Observable that will be called when effect is bound.
  29122. */
  29123. readonly onBindObservable: Observable<Effect>;
  29124. /** @hidden */
  29125. _bonesComputationForcedToCPU: boolean;
  29126. private static _uniqueIdSeed;
  29127. private _engine;
  29128. private _uniformBuffersNames;
  29129. private _uniformsNames;
  29130. private _samplerList;
  29131. private _samplers;
  29132. private _isReady;
  29133. private _compilationError;
  29134. private _attributesNames;
  29135. private _attributes;
  29136. private _uniforms;
  29137. /**
  29138. * Key for the effect.
  29139. * @hidden
  29140. */
  29141. _key: string;
  29142. private _indexParameters;
  29143. private _fallbacks;
  29144. private _vertexSourceCode;
  29145. private _fragmentSourceCode;
  29146. private _vertexSourceCodeOverride;
  29147. private _fragmentSourceCodeOverride;
  29148. private _transformFeedbackVaryings;
  29149. /**
  29150. * Compiled shader to webGL program.
  29151. * @hidden
  29152. */
  29153. _pipelineContext: Nullable<IPipelineContext>;
  29154. private _valueCache;
  29155. private static _baseCache;
  29156. /**
  29157. * Instantiates an effect.
  29158. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29159. * @param baseName Name of the effect.
  29160. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29161. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29162. * @param samplers List of sampler variables that will be passed to the shader.
  29163. * @param engine Engine to be used to render the effect
  29164. * @param defines Define statements to be added to the shader.
  29165. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29166. * @param onCompiled Callback that will be called when the shader is compiled.
  29167. * @param onError Callback that will be called if an error occurs during shader compilation.
  29168. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29169. */
  29170. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29171. private _useFinalCode;
  29172. /**
  29173. * Unique key for this effect
  29174. */
  29175. readonly key: string;
  29176. /**
  29177. * If the effect has been compiled and prepared.
  29178. * @returns if the effect is compiled and prepared.
  29179. */
  29180. isReady(): boolean;
  29181. private _isReadyInternal;
  29182. /**
  29183. * The engine the effect was initialized with.
  29184. * @returns the engine.
  29185. */
  29186. getEngine(): Engine;
  29187. /**
  29188. * The pipeline context for this effect
  29189. * @returns the associated pipeline context
  29190. */
  29191. getPipelineContext(): Nullable<IPipelineContext>;
  29192. /**
  29193. * The set of names of attribute variables for the shader.
  29194. * @returns An array of attribute names.
  29195. */
  29196. getAttributesNames(): string[];
  29197. /**
  29198. * Returns the attribute at the given index.
  29199. * @param index The index of the attribute.
  29200. * @returns The location of the attribute.
  29201. */
  29202. getAttributeLocation(index: number): number;
  29203. /**
  29204. * Returns the attribute based on the name of the variable.
  29205. * @param name of the attribute to look up.
  29206. * @returns the attribute location.
  29207. */
  29208. getAttributeLocationByName(name: string): number;
  29209. /**
  29210. * The number of attributes.
  29211. * @returns the numnber of attributes.
  29212. */
  29213. getAttributesCount(): number;
  29214. /**
  29215. * Gets the index of a uniform variable.
  29216. * @param uniformName of the uniform to look up.
  29217. * @returns the index.
  29218. */
  29219. getUniformIndex(uniformName: string): number;
  29220. /**
  29221. * Returns the attribute based on the name of the variable.
  29222. * @param uniformName of the uniform to look up.
  29223. * @returns the location of the uniform.
  29224. */
  29225. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29226. /**
  29227. * Returns an array of sampler variable names
  29228. * @returns The array of sampler variable neames.
  29229. */
  29230. getSamplers(): string[];
  29231. /**
  29232. * The error from the last compilation.
  29233. * @returns the error string.
  29234. */
  29235. getCompilationError(): string;
  29236. /**
  29237. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29238. * @param func The callback to be used.
  29239. */
  29240. executeWhenCompiled(func: (effect: Effect) => void): void;
  29241. private _checkIsReady;
  29242. /** @hidden */
  29243. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29244. /** @hidden */
  29245. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29246. /** @hidden */
  29247. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29248. /**
  29249. * Recompiles the webGL program
  29250. * @param vertexSourceCode The source code for the vertex shader.
  29251. * @param fragmentSourceCode The source code for the fragment shader.
  29252. * @param onCompiled Callback called when completed.
  29253. * @param onError Callback called on error.
  29254. * @hidden
  29255. */
  29256. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29257. /**
  29258. * Prepares the effect
  29259. * @hidden
  29260. */
  29261. _prepareEffect(): void;
  29262. private _processCompilationErrors;
  29263. /**
  29264. * Checks if the effect is supported. (Must be called after compilation)
  29265. */
  29266. readonly isSupported: boolean;
  29267. /**
  29268. * Binds a texture to the engine to be used as output of the shader.
  29269. * @param channel Name of the output variable.
  29270. * @param texture Texture to bind.
  29271. * @hidden
  29272. */
  29273. _bindTexture(channel: string, texture: InternalTexture): void;
  29274. /**
  29275. * Sets a texture on the engine to be used in the shader.
  29276. * @param channel Name of the sampler variable.
  29277. * @param texture Texture to set.
  29278. */
  29279. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29280. /**
  29281. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29282. * @param channel Name of the sampler variable.
  29283. * @param texture Texture to set.
  29284. */
  29285. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29286. /**
  29287. * Sets an array of textures on the engine to be used in the shader.
  29288. * @param channel Name of the variable.
  29289. * @param textures Textures to set.
  29290. */
  29291. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29292. /**
  29293. * 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)
  29294. * @param channel Name of the sampler variable.
  29295. * @param postProcess Post process to get the input texture from.
  29296. */
  29297. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29298. /**
  29299. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29300. * 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)
  29301. * @param channel Name of the sampler variable.
  29302. * @param postProcess Post process to get the output texture from.
  29303. */
  29304. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29305. /** @hidden */
  29306. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29307. /** @hidden */
  29308. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29309. /** @hidden */
  29310. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29311. /** @hidden */
  29312. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29313. /**
  29314. * Binds a buffer to a uniform.
  29315. * @param buffer Buffer to bind.
  29316. * @param name Name of the uniform variable to bind to.
  29317. */
  29318. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29319. /**
  29320. * Binds block to a uniform.
  29321. * @param blockName Name of the block to bind.
  29322. * @param index Index to bind.
  29323. */
  29324. bindUniformBlock(blockName: string, index: number): void;
  29325. /**
  29326. * Sets an interger value on a uniform variable.
  29327. * @param uniformName Name of the variable.
  29328. * @param value Value to be set.
  29329. * @returns this effect.
  29330. */
  29331. setInt(uniformName: string, value: number): Effect;
  29332. /**
  29333. * Sets an int array on a uniform variable.
  29334. * @param uniformName Name of the variable.
  29335. * @param array array to be set.
  29336. * @returns this effect.
  29337. */
  29338. setIntArray(uniformName: string, array: Int32Array): Effect;
  29339. /**
  29340. * 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)
  29341. * @param uniformName Name of the variable.
  29342. * @param array array to be set.
  29343. * @returns this effect.
  29344. */
  29345. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29346. /**
  29347. * 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)
  29348. * @param uniformName Name of the variable.
  29349. * @param array array to be set.
  29350. * @returns this effect.
  29351. */
  29352. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29353. /**
  29354. * 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)
  29355. * @param uniformName Name of the variable.
  29356. * @param array array to be set.
  29357. * @returns this effect.
  29358. */
  29359. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29360. /**
  29361. * Sets an float array on a uniform variable.
  29362. * @param uniformName Name of the variable.
  29363. * @param array array to be set.
  29364. * @returns this effect.
  29365. */
  29366. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29367. /**
  29368. * 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)
  29369. * @param uniformName Name of the variable.
  29370. * @param array array to be set.
  29371. * @returns this effect.
  29372. */
  29373. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29374. /**
  29375. * 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)
  29376. * @param uniformName Name of the variable.
  29377. * @param array array to be set.
  29378. * @returns this effect.
  29379. */
  29380. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29381. /**
  29382. * 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)
  29383. * @param uniformName Name of the variable.
  29384. * @param array array to be set.
  29385. * @returns this effect.
  29386. */
  29387. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29388. /**
  29389. * Sets an array on a uniform variable.
  29390. * @param uniformName Name of the variable.
  29391. * @param array array to be set.
  29392. * @returns this effect.
  29393. */
  29394. setArray(uniformName: string, array: number[]): Effect;
  29395. /**
  29396. * 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)
  29397. * @param uniformName Name of the variable.
  29398. * @param array array to be set.
  29399. * @returns this effect.
  29400. */
  29401. setArray2(uniformName: string, array: number[]): Effect;
  29402. /**
  29403. * 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)
  29404. * @param uniformName Name of the variable.
  29405. * @param array array to be set.
  29406. * @returns this effect.
  29407. */
  29408. setArray3(uniformName: string, array: number[]): Effect;
  29409. /**
  29410. * 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)
  29411. * @param uniformName Name of the variable.
  29412. * @param array array to be set.
  29413. * @returns this effect.
  29414. */
  29415. setArray4(uniformName: string, array: number[]): Effect;
  29416. /**
  29417. * Sets matrices on a uniform variable.
  29418. * @param uniformName Name of the variable.
  29419. * @param matrices matrices to be set.
  29420. * @returns this effect.
  29421. */
  29422. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29423. /**
  29424. * Sets matrix on a uniform variable.
  29425. * @param uniformName Name of the variable.
  29426. * @param matrix matrix to be set.
  29427. * @returns this effect.
  29428. */
  29429. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29430. /**
  29431. * 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)
  29432. * @param uniformName Name of the variable.
  29433. * @param matrix matrix to be set.
  29434. * @returns this effect.
  29435. */
  29436. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29437. /**
  29438. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29439. * @param uniformName Name of the variable.
  29440. * @param matrix matrix to be set.
  29441. * @returns this effect.
  29442. */
  29443. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29444. /**
  29445. * Sets a float on a uniform variable.
  29446. * @param uniformName Name of the variable.
  29447. * @param value value to be set.
  29448. * @returns this effect.
  29449. */
  29450. setFloat(uniformName: string, value: number): Effect;
  29451. /**
  29452. * Sets a boolean on a uniform variable.
  29453. * @param uniformName Name of the variable.
  29454. * @param bool value to be set.
  29455. * @returns this effect.
  29456. */
  29457. setBool(uniformName: string, bool: boolean): Effect;
  29458. /**
  29459. * Sets a Vector2 on a uniform variable.
  29460. * @param uniformName Name of the variable.
  29461. * @param vector2 vector2 to be set.
  29462. * @returns this effect.
  29463. */
  29464. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29465. /**
  29466. * Sets a float2 on a uniform variable.
  29467. * @param uniformName Name of the variable.
  29468. * @param x First float in float2.
  29469. * @param y Second float in float2.
  29470. * @returns this effect.
  29471. */
  29472. setFloat2(uniformName: string, x: number, y: number): Effect;
  29473. /**
  29474. * Sets a Vector3 on a uniform variable.
  29475. * @param uniformName Name of the variable.
  29476. * @param vector3 Value to be set.
  29477. * @returns this effect.
  29478. */
  29479. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29480. /**
  29481. * Sets a float3 on a uniform variable.
  29482. * @param uniformName Name of the variable.
  29483. * @param x First float in float3.
  29484. * @param y Second float in float3.
  29485. * @param z Third float in float3.
  29486. * @returns this effect.
  29487. */
  29488. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29489. /**
  29490. * Sets a Vector4 on a uniform variable.
  29491. * @param uniformName Name of the variable.
  29492. * @param vector4 Value to be set.
  29493. * @returns this effect.
  29494. */
  29495. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29496. /**
  29497. * Sets a float4 on a uniform variable.
  29498. * @param uniformName Name of the variable.
  29499. * @param x First float in float4.
  29500. * @param y Second float in float4.
  29501. * @param z Third float in float4.
  29502. * @param w Fourth float in float4.
  29503. * @returns this effect.
  29504. */
  29505. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29506. /**
  29507. * Sets a Color3 on a uniform variable.
  29508. * @param uniformName Name of the variable.
  29509. * @param color3 Value to be set.
  29510. * @returns this effect.
  29511. */
  29512. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29513. /**
  29514. * Sets a Color4 on a uniform variable.
  29515. * @param uniformName Name of the variable.
  29516. * @param color3 Value to be set.
  29517. * @param alpha Alpha value to be set.
  29518. * @returns this effect.
  29519. */
  29520. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29521. /**
  29522. * Sets a Color4 on a uniform variable
  29523. * @param uniformName defines the name of the variable
  29524. * @param color4 defines the value to be set
  29525. * @returns this effect.
  29526. */
  29527. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29528. /** Release all associated resources */
  29529. dispose(): void;
  29530. /**
  29531. * This function will add a new shader to the shader store
  29532. * @param name the name of the shader
  29533. * @param pixelShader optional pixel shader content
  29534. * @param vertexShader optional vertex shader content
  29535. */
  29536. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29537. /**
  29538. * Store of each shader (The can be looked up using effect.key)
  29539. */
  29540. static ShadersStore: {
  29541. [key: string]: string;
  29542. };
  29543. /**
  29544. * Store of each included file for a shader (The can be looked up using effect.key)
  29545. */
  29546. static IncludesShadersStore: {
  29547. [key: string]: string;
  29548. };
  29549. /**
  29550. * Resets the cache of effects.
  29551. */
  29552. static ResetCache(): void;
  29553. }
  29554. }
  29555. declare module "babylonjs/Materials/uniformBuffer" {
  29556. import { Nullable, FloatArray } from "babylonjs/types";
  29557. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29558. import { Engine } from "babylonjs/Engines/engine";
  29559. import { Effect } from "babylonjs/Materials/effect";
  29560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29561. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29562. import { Color3 } from "babylonjs/Maths/math.color";
  29563. /**
  29564. * Uniform buffer objects.
  29565. *
  29566. * Handles blocks of uniform on the GPU.
  29567. *
  29568. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29569. *
  29570. * For more information, please refer to :
  29571. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29572. */
  29573. export class UniformBuffer {
  29574. private _engine;
  29575. private _buffer;
  29576. private _data;
  29577. private _bufferData;
  29578. private _dynamic?;
  29579. private _uniformLocations;
  29580. private _uniformSizes;
  29581. private _uniformLocationPointer;
  29582. private _needSync;
  29583. private _noUBO;
  29584. private _currentEffect;
  29585. private static _MAX_UNIFORM_SIZE;
  29586. private static _tempBuffer;
  29587. /**
  29588. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29589. * This is dynamic to allow compat with webgl 1 and 2.
  29590. * You will need to pass the name of the uniform as well as the value.
  29591. */
  29592. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29593. /**
  29594. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29595. * This is dynamic to allow compat with webgl 1 and 2.
  29596. * You will need to pass the name of the uniform as well as the value.
  29597. */
  29598. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29599. /**
  29600. * Lambda to Update a single float in a uniform buffer.
  29601. * This is dynamic to allow compat with webgl 1 and 2.
  29602. * You will need to pass the name of the uniform as well as the value.
  29603. */
  29604. updateFloat: (name: string, x: number) => void;
  29605. /**
  29606. * Lambda to Update a vec2 of float in a uniform buffer.
  29607. * This is dynamic to allow compat with webgl 1 and 2.
  29608. * You will need to pass the name of the uniform as well as the value.
  29609. */
  29610. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29611. /**
  29612. * Lambda to Update a vec3 of float in a uniform buffer.
  29613. * This is dynamic to allow compat with webgl 1 and 2.
  29614. * You will need to pass the name of the uniform as well as the value.
  29615. */
  29616. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29617. /**
  29618. * Lambda to Update a vec4 of float in a uniform buffer.
  29619. * This is dynamic to allow compat with webgl 1 and 2.
  29620. * You will need to pass the name of the uniform as well as the value.
  29621. */
  29622. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29623. /**
  29624. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29625. * This is dynamic to allow compat with webgl 1 and 2.
  29626. * You will need to pass the name of the uniform as well as the value.
  29627. */
  29628. updateMatrix: (name: string, mat: Matrix) => void;
  29629. /**
  29630. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29631. * This is dynamic to allow compat with webgl 1 and 2.
  29632. * You will need to pass the name of the uniform as well as the value.
  29633. */
  29634. updateVector3: (name: string, vector: Vector3) => void;
  29635. /**
  29636. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29637. * This is dynamic to allow compat with webgl 1 and 2.
  29638. * You will need to pass the name of the uniform as well as the value.
  29639. */
  29640. updateVector4: (name: string, vector: Vector4) => void;
  29641. /**
  29642. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29643. * This is dynamic to allow compat with webgl 1 and 2.
  29644. * You will need to pass the name of the uniform as well as the value.
  29645. */
  29646. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29647. /**
  29648. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29649. * This is dynamic to allow compat with webgl 1 and 2.
  29650. * You will need to pass the name of the uniform as well as the value.
  29651. */
  29652. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29653. /**
  29654. * Instantiates a new Uniform buffer objects.
  29655. *
  29656. * Handles blocks of uniform on the GPU.
  29657. *
  29658. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29659. *
  29660. * For more information, please refer to :
  29661. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29662. * @param engine Define the engine the buffer is associated with
  29663. * @param data Define the data contained in the buffer
  29664. * @param dynamic Define if the buffer is updatable
  29665. */
  29666. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29667. /**
  29668. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29669. * or just falling back on setUniformXXX calls.
  29670. */
  29671. readonly useUbo: boolean;
  29672. /**
  29673. * Indicates if the WebGL underlying uniform buffer is in sync
  29674. * with the javascript cache data.
  29675. */
  29676. readonly isSync: boolean;
  29677. /**
  29678. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29679. * Also, a dynamic UniformBuffer will disable cache verification and always
  29680. * update the underlying WebGL uniform buffer to the GPU.
  29681. * @returns if Dynamic, otherwise false
  29682. */
  29683. isDynamic(): boolean;
  29684. /**
  29685. * The data cache on JS side.
  29686. * @returns the underlying data as a float array
  29687. */
  29688. getData(): Float32Array;
  29689. /**
  29690. * The underlying WebGL Uniform buffer.
  29691. * @returns the webgl buffer
  29692. */
  29693. getBuffer(): Nullable<DataBuffer>;
  29694. /**
  29695. * std140 layout specifies how to align data within an UBO structure.
  29696. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29697. * for specs.
  29698. */
  29699. private _fillAlignment;
  29700. /**
  29701. * Adds an uniform in the buffer.
  29702. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29703. * for the layout to be correct !
  29704. * @param name Name of the uniform, as used in the uniform block in the shader.
  29705. * @param size Data size, or data directly.
  29706. */
  29707. addUniform(name: string, size: number | number[]): void;
  29708. /**
  29709. * Adds a Matrix 4x4 to the uniform buffer.
  29710. * @param name Name of the uniform, as used in the uniform block in the shader.
  29711. * @param mat A 4x4 matrix.
  29712. */
  29713. addMatrix(name: string, mat: Matrix): void;
  29714. /**
  29715. * Adds a vec2 to the uniform buffer.
  29716. * @param name Name of the uniform, as used in the uniform block in the shader.
  29717. * @param x Define the x component value of the vec2
  29718. * @param y Define the y component value of the vec2
  29719. */
  29720. addFloat2(name: string, x: number, y: number): void;
  29721. /**
  29722. * Adds a vec3 to the uniform buffer.
  29723. * @param name Name of the uniform, as used in the uniform block in the shader.
  29724. * @param x Define the x component value of the vec3
  29725. * @param y Define the y component value of the vec3
  29726. * @param z Define the z component value of the vec3
  29727. */
  29728. addFloat3(name: string, x: number, y: number, z: number): void;
  29729. /**
  29730. * Adds a vec3 to the uniform buffer.
  29731. * @param name Name of the uniform, as used in the uniform block in the shader.
  29732. * @param color Define the vec3 from a Color
  29733. */
  29734. addColor3(name: string, color: Color3): void;
  29735. /**
  29736. * Adds a vec4 to the uniform buffer.
  29737. * @param name Name of the uniform, as used in the uniform block in the shader.
  29738. * @param color Define the rgb components from a Color
  29739. * @param alpha Define the a component of the vec4
  29740. */
  29741. addColor4(name: string, color: Color3, alpha: number): void;
  29742. /**
  29743. * Adds a vec3 to the uniform buffer.
  29744. * @param name Name of the uniform, as used in the uniform block in the shader.
  29745. * @param vector Define the vec3 components from a Vector
  29746. */
  29747. addVector3(name: string, vector: Vector3): void;
  29748. /**
  29749. * Adds a Matrix 3x3 to the uniform buffer.
  29750. * @param name Name of the uniform, as used in the uniform block in the shader.
  29751. */
  29752. addMatrix3x3(name: string): void;
  29753. /**
  29754. * Adds a Matrix 2x2 to the uniform buffer.
  29755. * @param name Name of the uniform, as used in the uniform block in the shader.
  29756. */
  29757. addMatrix2x2(name: string): void;
  29758. /**
  29759. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29760. */
  29761. create(): void;
  29762. /** @hidden */
  29763. _rebuild(): void;
  29764. /**
  29765. * Updates the WebGL Uniform Buffer on the GPU.
  29766. * If the `dynamic` flag is set to true, no cache comparison is done.
  29767. * Otherwise, the buffer will be updated only if the cache differs.
  29768. */
  29769. update(): void;
  29770. /**
  29771. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29772. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29773. * @param data Define the flattened data
  29774. * @param size Define the size of the data.
  29775. */
  29776. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29777. private _valueCache;
  29778. private _cacheMatrix;
  29779. private _updateMatrix3x3ForUniform;
  29780. private _updateMatrix3x3ForEffect;
  29781. private _updateMatrix2x2ForEffect;
  29782. private _updateMatrix2x2ForUniform;
  29783. private _updateFloatForEffect;
  29784. private _updateFloatForUniform;
  29785. private _updateFloat2ForEffect;
  29786. private _updateFloat2ForUniform;
  29787. private _updateFloat3ForEffect;
  29788. private _updateFloat3ForUniform;
  29789. private _updateFloat4ForEffect;
  29790. private _updateFloat4ForUniform;
  29791. private _updateMatrixForEffect;
  29792. private _updateMatrixForUniform;
  29793. private _updateVector3ForEffect;
  29794. private _updateVector3ForUniform;
  29795. private _updateVector4ForEffect;
  29796. private _updateVector4ForUniform;
  29797. private _updateColor3ForEffect;
  29798. private _updateColor3ForUniform;
  29799. private _updateColor4ForEffect;
  29800. private _updateColor4ForUniform;
  29801. /**
  29802. * Sets a sampler uniform on the effect.
  29803. * @param name Define the name of the sampler.
  29804. * @param texture Define the texture to set in the sampler
  29805. */
  29806. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29807. /**
  29808. * Directly updates the value of the uniform in the cache AND on the GPU.
  29809. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29810. * @param data Define the flattened data
  29811. */
  29812. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29813. /**
  29814. * Binds this uniform buffer to an effect.
  29815. * @param effect Define the effect to bind the buffer to
  29816. * @param name Name of the uniform block in the shader.
  29817. */
  29818. bindToEffect(effect: Effect, name: string): void;
  29819. /**
  29820. * Disposes the uniform buffer.
  29821. */
  29822. dispose(): void;
  29823. }
  29824. }
  29825. declare module "babylonjs/Audio/analyser" {
  29826. import { Scene } from "babylonjs/scene";
  29827. /**
  29828. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29830. */
  29831. export class Analyser {
  29832. /**
  29833. * Gets or sets the smoothing
  29834. * @ignorenaming
  29835. */
  29836. SMOOTHING: number;
  29837. /**
  29838. * Gets or sets the FFT table size
  29839. * @ignorenaming
  29840. */
  29841. FFT_SIZE: number;
  29842. /**
  29843. * Gets or sets the bar graph amplitude
  29844. * @ignorenaming
  29845. */
  29846. BARGRAPHAMPLITUDE: number;
  29847. /**
  29848. * Gets or sets the position of the debug canvas
  29849. * @ignorenaming
  29850. */
  29851. DEBUGCANVASPOS: {
  29852. x: number;
  29853. y: number;
  29854. };
  29855. /**
  29856. * Gets or sets the debug canvas size
  29857. * @ignorenaming
  29858. */
  29859. DEBUGCANVASSIZE: {
  29860. width: number;
  29861. height: number;
  29862. };
  29863. private _byteFreqs;
  29864. private _byteTime;
  29865. private _floatFreqs;
  29866. private _webAudioAnalyser;
  29867. private _debugCanvas;
  29868. private _debugCanvasContext;
  29869. private _scene;
  29870. private _registerFunc;
  29871. private _audioEngine;
  29872. /**
  29873. * Creates a new analyser
  29874. * @param scene defines hosting scene
  29875. */
  29876. constructor(scene: Scene);
  29877. /**
  29878. * Get the number of data values you will have to play with for the visualization
  29879. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29880. * @returns a number
  29881. */
  29882. getFrequencyBinCount(): number;
  29883. /**
  29884. * Gets the current frequency data as a byte array
  29885. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29886. * @returns a Uint8Array
  29887. */
  29888. getByteFrequencyData(): Uint8Array;
  29889. /**
  29890. * Gets the current waveform as a byte array
  29891. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29892. * @returns a Uint8Array
  29893. */
  29894. getByteTimeDomainData(): Uint8Array;
  29895. /**
  29896. * Gets the current frequency data as a float array
  29897. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29898. * @returns a Float32Array
  29899. */
  29900. getFloatFrequencyData(): Float32Array;
  29901. /**
  29902. * Renders the debug canvas
  29903. */
  29904. drawDebugCanvas(): void;
  29905. /**
  29906. * Stops rendering the debug canvas and removes it
  29907. */
  29908. stopDebugCanvas(): void;
  29909. /**
  29910. * Connects two audio nodes
  29911. * @param inputAudioNode defines first node to connect
  29912. * @param outputAudioNode defines second node to connect
  29913. */
  29914. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29915. /**
  29916. * Releases all associated resources
  29917. */
  29918. dispose(): void;
  29919. }
  29920. }
  29921. declare module "babylonjs/Audio/audioEngine" {
  29922. import { IDisposable } from "babylonjs/scene";
  29923. import { Analyser } from "babylonjs/Audio/analyser";
  29924. import { Nullable } from "babylonjs/types";
  29925. import { Observable } from "babylonjs/Misc/observable";
  29926. /**
  29927. * This represents an audio engine and it is responsible
  29928. * to play, synchronize and analyse sounds throughout the application.
  29929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29930. */
  29931. export interface IAudioEngine extends IDisposable {
  29932. /**
  29933. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29934. */
  29935. readonly canUseWebAudio: boolean;
  29936. /**
  29937. * Gets the current AudioContext if available.
  29938. */
  29939. readonly audioContext: Nullable<AudioContext>;
  29940. /**
  29941. * The master gain node defines the global audio volume of your audio engine.
  29942. */
  29943. readonly masterGain: GainNode;
  29944. /**
  29945. * Gets whether or not mp3 are supported by your browser.
  29946. */
  29947. readonly isMP3supported: boolean;
  29948. /**
  29949. * Gets whether or not ogg are supported by your browser.
  29950. */
  29951. readonly isOGGsupported: boolean;
  29952. /**
  29953. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29954. * @ignoreNaming
  29955. */
  29956. WarnedWebAudioUnsupported: boolean;
  29957. /**
  29958. * Defines if the audio engine relies on a custom unlocked button.
  29959. * In this case, the embedded button will not be displayed.
  29960. */
  29961. useCustomUnlockedButton: boolean;
  29962. /**
  29963. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29964. */
  29965. readonly unlocked: boolean;
  29966. /**
  29967. * Event raised when audio has been unlocked on the browser.
  29968. */
  29969. onAudioUnlockedObservable: Observable<AudioEngine>;
  29970. /**
  29971. * Event raised when audio has been locked on the browser.
  29972. */
  29973. onAudioLockedObservable: Observable<AudioEngine>;
  29974. /**
  29975. * Flags the audio engine in Locked state.
  29976. * This happens due to new browser policies preventing audio to autoplay.
  29977. */
  29978. lock(): void;
  29979. /**
  29980. * Unlocks the audio engine once a user action has been done on the dom.
  29981. * This is helpful to resume play once browser policies have been satisfied.
  29982. */
  29983. unlock(): void;
  29984. }
  29985. /**
  29986. * This represents the default audio engine used in babylon.
  29987. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29989. */
  29990. export class AudioEngine implements IAudioEngine {
  29991. private _audioContext;
  29992. private _audioContextInitialized;
  29993. private _muteButton;
  29994. private _hostElement;
  29995. /**
  29996. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29997. */
  29998. canUseWebAudio: boolean;
  29999. /**
  30000. * The master gain node defines the global audio volume of your audio engine.
  30001. */
  30002. masterGain: GainNode;
  30003. /**
  30004. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30005. * @ignoreNaming
  30006. */
  30007. WarnedWebAudioUnsupported: boolean;
  30008. /**
  30009. * Gets whether or not mp3 are supported by your browser.
  30010. */
  30011. isMP3supported: boolean;
  30012. /**
  30013. * Gets whether or not ogg are supported by your browser.
  30014. */
  30015. isOGGsupported: boolean;
  30016. /**
  30017. * Gets whether audio has been unlocked on the device.
  30018. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30019. * a user interaction has happened.
  30020. */
  30021. unlocked: boolean;
  30022. /**
  30023. * Defines if the audio engine relies on a custom unlocked button.
  30024. * In this case, the embedded button will not be displayed.
  30025. */
  30026. useCustomUnlockedButton: boolean;
  30027. /**
  30028. * Event raised when audio has been unlocked on the browser.
  30029. */
  30030. onAudioUnlockedObservable: Observable<AudioEngine>;
  30031. /**
  30032. * Event raised when audio has been locked on the browser.
  30033. */
  30034. onAudioLockedObservable: Observable<AudioEngine>;
  30035. /**
  30036. * Gets the current AudioContext if available.
  30037. */
  30038. readonly audioContext: Nullable<AudioContext>;
  30039. private _connectedAnalyser;
  30040. /**
  30041. * Instantiates a new audio engine.
  30042. *
  30043. * There should be only one per page as some browsers restrict the number
  30044. * of audio contexts you can create.
  30045. * @param hostElement defines the host element where to display the mute icon if necessary
  30046. */
  30047. constructor(hostElement?: Nullable<HTMLElement>);
  30048. /**
  30049. * Flags the audio engine in Locked state.
  30050. * This happens due to new browser policies preventing audio to autoplay.
  30051. */
  30052. lock(): void;
  30053. /**
  30054. * Unlocks the audio engine once a user action has been done on the dom.
  30055. * This is helpful to resume play once browser policies have been satisfied.
  30056. */
  30057. unlock(): void;
  30058. private _resumeAudioContext;
  30059. private _initializeAudioContext;
  30060. private _tryToRun;
  30061. private _triggerRunningState;
  30062. private _triggerSuspendedState;
  30063. private _displayMuteButton;
  30064. private _moveButtonToTopLeft;
  30065. private _onResize;
  30066. private _hideMuteButton;
  30067. /**
  30068. * Destroy and release the resources associated with the audio ccontext.
  30069. */
  30070. dispose(): void;
  30071. /**
  30072. * Gets the global volume sets on the master gain.
  30073. * @returns the global volume if set or -1 otherwise
  30074. */
  30075. getGlobalVolume(): number;
  30076. /**
  30077. * Sets the global volume of your experience (sets on the master gain).
  30078. * @param newVolume Defines the new global volume of the application
  30079. */
  30080. setGlobalVolume(newVolume: number): void;
  30081. /**
  30082. * Connect the audio engine to an audio analyser allowing some amazing
  30083. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30085. * @param analyser The analyser to connect to the engine
  30086. */
  30087. connectToAnalyser(analyser: Analyser): void;
  30088. }
  30089. }
  30090. declare module "babylonjs/Loading/loadingScreen" {
  30091. /**
  30092. * Interface used to present a loading screen while loading a scene
  30093. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30094. */
  30095. export interface ILoadingScreen {
  30096. /**
  30097. * Function called to display the loading screen
  30098. */
  30099. displayLoadingUI: () => void;
  30100. /**
  30101. * Function called to hide the loading screen
  30102. */
  30103. hideLoadingUI: () => void;
  30104. /**
  30105. * Gets or sets the color to use for the background
  30106. */
  30107. loadingUIBackgroundColor: string;
  30108. /**
  30109. * Gets or sets the text to display while loading
  30110. */
  30111. loadingUIText: string;
  30112. }
  30113. /**
  30114. * Class used for the default loading screen
  30115. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30116. */
  30117. export class DefaultLoadingScreen implements ILoadingScreen {
  30118. private _renderingCanvas;
  30119. private _loadingText;
  30120. private _loadingDivBackgroundColor;
  30121. private _loadingDiv;
  30122. private _loadingTextDiv;
  30123. /** Gets or sets the logo url to use for the default loading screen */
  30124. static DefaultLogoUrl: string;
  30125. /** Gets or sets the spinner url to use for the default loading screen */
  30126. static DefaultSpinnerUrl: string;
  30127. /**
  30128. * Creates a new default loading screen
  30129. * @param _renderingCanvas defines the canvas used to render the scene
  30130. * @param _loadingText defines the default text to display
  30131. * @param _loadingDivBackgroundColor defines the default background color
  30132. */
  30133. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30134. /**
  30135. * Function called to display the loading screen
  30136. */
  30137. displayLoadingUI(): void;
  30138. /**
  30139. * Function called to hide the loading screen
  30140. */
  30141. hideLoadingUI(): void;
  30142. /**
  30143. * Gets or sets the text to display while loading
  30144. */
  30145. loadingUIText: string;
  30146. /**
  30147. * Gets or sets the color to use for the background
  30148. */
  30149. loadingUIBackgroundColor: string;
  30150. private _resizeLoadingUI;
  30151. }
  30152. }
  30153. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30154. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30155. import { Engine } from "babylonjs/Engines/engine";
  30156. import { Nullable } from "babylonjs/types";
  30157. /** @hidden */
  30158. export class WebGLPipelineContext implements IPipelineContext {
  30159. engine: Engine;
  30160. program: Nullable<WebGLProgram>;
  30161. context?: WebGLRenderingContext;
  30162. vertexShader?: WebGLShader;
  30163. fragmentShader?: WebGLShader;
  30164. isParallelCompiled: boolean;
  30165. onCompiled?: () => void;
  30166. transformFeedback?: WebGLTransformFeedback | null;
  30167. readonly isAsync: boolean;
  30168. readonly isReady: boolean;
  30169. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30170. }
  30171. }
  30172. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30173. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30174. /** @hidden */
  30175. export class WebGLDataBuffer extends DataBuffer {
  30176. private _buffer;
  30177. constructor(resource: WebGLBuffer);
  30178. readonly underlyingResource: any;
  30179. }
  30180. }
  30181. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30182. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30183. /** @hidden */
  30184. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30185. attributeProcessor(attribute: string): string;
  30186. varyingProcessor(varying: string, isFragment: boolean): string;
  30187. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30188. }
  30189. }
  30190. declare module "babylonjs/Misc/perfCounter" {
  30191. /**
  30192. * This class is used to track a performance counter which is number based.
  30193. * The user has access to many properties which give statistics of different nature.
  30194. *
  30195. * The implementer can track two kinds of Performance Counter: time and count.
  30196. * 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.
  30197. * 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.
  30198. */
  30199. export class PerfCounter {
  30200. /**
  30201. * Gets or sets a global boolean to turn on and off all the counters
  30202. */
  30203. static Enabled: boolean;
  30204. /**
  30205. * Returns the smallest value ever
  30206. */
  30207. readonly min: number;
  30208. /**
  30209. * Returns the biggest value ever
  30210. */
  30211. readonly max: number;
  30212. /**
  30213. * Returns the average value since the performance counter is running
  30214. */
  30215. readonly average: number;
  30216. /**
  30217. * Returns the average value of the last second the counter was monitored
  30218. */
  30219. readonly lastSecAverage: number;
  30220. /**
  30221. * Returns the current value
  30222. */
  30223. readonly current: number;
  30224. /**
  30225. * Gets the accumulated total
  30226. */
  30227. readonly total: number;
  30228. /**
  30229. * Gets the total value count
  30230. */
  30231. readonly count: number;
  30232. /**
  30233. * Creates a new counter
  30234. */
  30235. constructor();
  30236. /**
  30237. * Call this method to start monitoring a new frame.
  30238. * 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.
  30239. */
  30240. fetchNewFrame(): void;
  30241. /**
  30242. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30243. * @param newCount the count value to add to the monitored count
  30244. * @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.
  30245. */
  30246. addCount(newCount: number, fetchResult: boolean): void;
  30247. /**
  30248. * Start monitoring this performance counter
  30249. */
  30250. beginMonitoring(): void;
  30251. /**
  30252. * Compute the time lapsed since the previous beginMonitoring() call.
  30253. * @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
  30254. */
  30255. endMonitoring(newFrame?: boolean): void;
  30256. private _fetchResult;
  30257. private _startMonitoringTime;
  30258. private _min;
  30259. private _max;
  30260. private _average;
  30261. private _current;
  30262. private _totalValueCount;
  30263. private _totalAccumulated;
  30264. private _lastSecAverage;
  30265. private _lastSecAccumulated;
  30266. private _lastSecTime;
  30267. private _lastSecValueCount;
  30268. }
  30269. }
  30270. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30271. /**
  30272. * Interface for any object that can request an animation frame
  30273. */
  30274. export interface ICustomAnimationFrameRequester {
  30275. /**
  30276. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30277. */
  30278. renderFunction?: Function;
  30279. /**
  30280. * Called to request the next frame to render to
  30281. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30282. */
  30283. requestAnimationFrame: Function;
  30284. /**
  30285. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30286. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30287. */
  30288. requestID?: number;
  30289. }
  30290. }
  30291. declare module "babylonjs/Materials/Textures/videoTexture" {
  30292. import { Observable } from "babylonjs/Misc/observable";
  30293. import { Nullable } from "babylonjs/types";
  30294. import { Scene } from "babylonjs/scene";
  30295. import { Texture } from "babylonjs/Materials/Textures/texture";
  30296. /**
  30297. * Settings for finer control over video usage
  30298. */
  30299. export interface VideoTextureSettings {
  30300. /**
  30301. * Applies `autoplay` to video, if specified
  30302. */
  30303. autoPlay?: boolean;
  30304. /**
  30305. * Applies `loop` to video, if specified
  30306. */
  30307. loop?: boolean;
  30308. /**
  30309. * Automatically updates internal texture from video at every frame in the render loop
  30310. */
  30311. autoUpdateTexture: boolean;
  30312. /**
  30313. * Image src displayed during the video loading or until the user interacts with the video.
  30314. */
  30315. poster?: string;
  30316. }
  30317. /**
  30318. * If you want to display a video in your scene, this is the special texture for that.
  30319. * This special texture works similar to other textures, with the exception of a few parameters.
  30320. * @see https://doc.babylonjs.com/how_to/video_texture
  30321. */
  30322. export class VideoTexture extends Texture {
  30323. /**
  30324. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30325. */
  30326. readonly autoUpdateTexture: boolean;
  30327. /**
  30328. * The video instance used by the texture internally
  30329. */
  30330. readonly video: HTMLVideoElement;
  30331. private _onUserActionRequestedObservable;
  30332. /**
  30333. * Event triggerd when a dom action is required by the user to play the video.
  30334. * This happens due to recent changes in browser policies preventing video to auto start.
  30335. */
  30336. readonly onUserActionRequestedObservable: Observable<Texture>;
  30337. private _generateMipMaps;
  30338. private _engine;
  30339. private _stillImageCaptured;
  30340. private _displayingPosterTexture;
  30341. private _settings;
  30342. private _createInternalTextureOnEvent;
  30343. private _frameId;
  30344. /**
  30345. * Creates a video texture.
  30346. * If you want to display a video in your scene, this is the special texture for that.
  30347. * This special texture works similar to other textures, with the exception of a few parameters.
  30348. * @see https://doc.babylonjs.com/how_to/video_texture
  30349. * @param name optional name, will detect from video source, if not defined
  30350. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30351. * @param scene is obviously the current scene.
  30352. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30353. * @param invertY is false by default but can be used to invert video on Y axis
  30354. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30355. * @param settings allows finer control over video usage
  30356. */
  30357. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30358. private _getName;
  30359. private _getVideo;
  30360. private _createInternalTexture;
  30361. private reset;
  30362. /**
  30363. * @hidden Internal method to initiate `update`.
  30364. */
  30365. _rebuild(): void;
  30366. /**
  30367. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30368. */
  30369. update(): void;
  30370. /**
  30371. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30372. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30373. */
  30374. updateTexture(isVisible: boolean): void;
  30375. protected _updateInternalTexture: () => void;
  30376. /**
  30377. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30378. * @param url New url.
  30379. */
  30380. updateURL(url: string): void;
  30381. /**
  30382. * Dispose the texture and release its associated resources.
  30383. */
  30384. dispose(): void;
  30385. /**
  30386. * Creates a video texture straight from a stream.
  30387. * @param scene Define the scene the texture should be created in
  30388. * @param stream Define the stream the texture should be created from
  30389. * @returns The created video texture as a promise
  30390. */
  30391. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30392. /**
  30393. * Creates a video texture straight from your WebCam video feed.
  30394. * @param scene Define the scene the texture should be created in
  30395. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30396. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30397. * @returns The created video texture as a promise
  30398. */
  30399. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30400. minWidth: number;
  30401. maxWidth: number;
  30402. minHeight: number;
  30403. maxHeight: number;
  30404. deviceId: string;
  30405. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30406. /**
  30407. * Creates a video texture straight from your WebCam video feed.
  30408. * @param scene Define the scene the texture should be created in
  30409. * @param onReady Define a callback to triggered once the texture will be ready
  30410. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30411. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30412. */
  30413. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30414. minWidth: number;
  30415. maxWidth: number;
  30416. minHeight: number;
  30417. maxHeight: number;
  30418. deviceId: string;
  30419. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30420. }
  30421. }
  30422. declare module "babylonjs/Engines/engine" {
  30423. import { Observable } from "babylonjs/Misc/observable";
  30424. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30425. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30426. import { Scene } from "babylonjs/scene";
  30427. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30428. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30429. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30430. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30433. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30434. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30435. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30436. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30437. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30438. import { WebRequest } from "babylonjs/Misc/webRequest";
  30439. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30440. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30441. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30442. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30443. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30444. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30445. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30446. import { Material } from "babylonjs/Materials/material";
  30447. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30448. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30449. /**
  30450. * Defines the interface used by objects containing a viewport (like a camera)
  30451. */
  30452. interface IViewportOwnerLike {
  30453. /**
  30454. * Gets or sets the viewport
  30455. */
  30456. viewport: IViewportLike;
  30457. }
  30458. /**
  30459. * Interface for attribute information associated with buffer instanciation
  30460. */
  30461. export class InstancingAttributeInfo {
  30462. /**
  30463. * Index/offset of the attribute in the vertex shader
  30464. */
  30465. index: number;
  30466. /**
  30467. * size of the attribute, 1, 2, 3 or 4
  30468. */
  30469. attributeSize: number;
  30470. /**
  30471. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30472. * default is FLOAT
  30473. */
  30474. attribyteType: number;
  30475. /**
  30476. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30477. */
  30478. normalized: boolean;
  30479. /**
  30480. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30481. */
  30482. offset: number;
  30483. /**
  30484. * Name of the GLSL attribute, for debugging purpose only
  30485. */
  30486. attributeName: string;
  30487. }
  30488. /**
  30489. * Define options used to create a depth texture
  30490. */
  30491. export class DepthTextureCreationOptions {
  30492. /** Specifies whether or not a stencil should be allocated in the texture */
  30493. generateStencil?: boolean;
  30494. /** Specifies whether or not bilinear filtering is enable on the texture */
  30495. bilinearFiltering?: boolean;
  30496. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30497. comparisonFunction?: number;
  30498. /** Specifies if the created texture is a cube texture */
  30499. isCube?: boolean;
  30500. }
  30501. /**
  30502. * Class used to describe the capabilities of the engine relatively to the current browser
  30503. */
  30504. export class EngineCapabilities {
  30505. /** Maximum textures units per fragment shader */
  30506. maxTexturesImageUnits: number;
  30507. /** Maximum texture units per vertex shader */
  30508. maxVertexTextureImageUnits: number;
  30509. /** Maximum textures units in the entire pipeline */
  30510. maxCombinedTexturesImageUnits: number;
  30511. /** Maximum texture size */
  30512. maxTextureSize: number;
  30513. /** Maximum cube texture size */
  30514. maxCubemapTextureSize: number;
  30515. /** Maximum render texture size */
  30516. maxRenderTextureSize: number;
  30517. /** Maximum number of vertex attributes */
  30518. maxVertexAttribs: number;
  30519. /** Maximum number of varyings */
  30520. maxVaryingVectors: number;
  30521. /** Maximum number of uniforms per vertex shader */
  30522. maxVertexUniformVectors: number;
  30523. /** Maximum number of uniforms per fragment shader */
  30524. maxFragmentUniformVectors: number;
  30525. /** Defines if standard derivates (dx/dy) are supported */
  30526. standardDerivatives: boolean;
  30527. /** Defines if s3tc texture compression is supported */
  30528. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30529. /** Defines if pvrtc texture compression is supported */
  30530. pvrtc: any;
  30531. /** Defines if etc1 texture compression is supported */
  30532. etc1: any;
  30533. /** Defines if etc2 texture compression is supported */
  30534. etc2: any;
  30535. /** Defines if astc texture compression is supported */
  30536. astc: any;
  30537. /** Defines if float textures are supported */
  30538. textureFloat: boolean;
  30539. /** Defines if vertex array objects are supported */
  30540. vertexArrayObject: boolean;
  30541. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30542. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30543. /** Gets the maximum level of anisotropy supported */
  30544. maxAnisotropy: number;
  30545. /** Defines if instancing is supported */
  30546. instancedArrays: boolean;
  30547. /** Defines if 32 bits indices are supported */
  30548. uintIndices: boolean;
  30549. /** Defines if high precision shaders are supported */
  30550. highPrecisionShaderSupported: boolean;
  30551. /** Defines if depth reading in the fragment shader is supported */
  30552. fragmentDepthSupported: boolean;
  30553. /** Defines if float texture linear filtering is supported*/
  30554. textureFloatLinearFiltering: boolean;
  30555. /** Defines if rendering to float textures is supported */
  30556. textureFloatRender: boolean;
  30557. /** Defines if half float textures are supported*/
  30558. textureHalfFloat: boolean;
  30559. /** Defines if half float texture linear filtering is supported*/
  30560. textureHalfFloatLinearFiltering: boolean;
  30561. /** Defines if rendering to half float textures is supported */
  30562. textureHalfFloatRender: boolean;
  30563. /** Defines if textureLOD shader command is supported */
  30564. textureLOD: boolean;
  30565. /** Defines if draw buffers extension is supported */
  30566. drawBuffersExtension: boolean;
  30567. /** Defines if depth textures are supported */
  30568. depthTextureExtension: boolean;
  30569. /** Defines if float color buffer are supported */
  30570. colorBufferFloat: boolean;
  30571. /** Gets disjoint timer query extension (null if not supported) */
  30572. timerQuery: EXT_disjoint_timer_query;
  30573. /** Defines if timestamp can be used with timer query */
  30574. canUseTimestampForTimerQuery: boolean;
  30575. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30576. multiview: any;
  30577. /** Function used to let the system compiles shaders in background */
  30578. parallelShaderCompile: {
  30579. COMPLETION_STATUS_KHR: number;
  30580. };
  30581. /** Max number of texture samples for MSAA */
  30582. maxMSAASamples: number;
  30583. }
  30584. /** Interface defining initialization parameters for Engine class */
  30585. export interface EngineOptions extends WebGLContextAttributes {
  30586. /**
  30587. * Defines if the engine should no exceed a specified device ratio
  30588. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30589. */
  30590. limitDeviceRatio?: number;
  30591. /**
  30592. * Defines if webvr should be enabled automatically
  30593. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30594. */
  30595. autoEnableWebVR?: boolean;
  30596. /**
  30597. * Defines if webgl2 should be turned off even if supported
  30598. * @see http://doc.babylonjs.com/features/webgl2
  30599. */
  30600. disableWebGL2Support?: boolean;
  30601. /**
  30602. * Defines if webaudio should be initialized as well
  30603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30604. */
  30605. audioEngine?: boolean;
  30606. /**
  30607. * Defines if animations should run using a deterministic lock step
  30608. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30609. */
  30610. deterministicLockstep?: boolean;
  30611. /** Defines the maximum steps to use with deterministic lock step mode */
  30612. lockstepMaxSteps?: number;
  30613. /**
  30614. * Defines that engine should ignore context lost events
  30615. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30616. */
  30617. doNotHandleContextLost?: boolean;
  30618. /**
  30619. * Defines that engine should ignore modifying touch action attribute and style
  30620. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30621. */
  30622. doNotHandleTouchAction?: boolean;
  30623. /**
  30624. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30625. */
  30626. useHighPrecisionFloats?: boolean;
  30627. }
  30628. /**
  30629. * Defines the interface used by display changed events
  30630. */
  30631. export interface IDisplayChangedEventArgs {
  30632. /** Gets the vrDisplay object (if any) */
  30633. vrDisplay: Nullable<any>;
  30634. /** Gets a boolean indicating if webVR is supported */
  30635. vrSupported: boolean;
  30636. }
  30637. /**
  30638. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30639. */
  30640. export class Engine {
  30641. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30642. static ExceptionList: ({
  30643. key: string;
  30644. capture: string;
  30645. captureConstraint: number;
  30646. targets: string[];
  30647. } | {
  30648. key: string;
  30649. capture: null;
  30650. captureConstraint: null;
  30651. targets: string[];
  30652. })[];
  30653. /** Gets the list of created engines */
  30654. static readonly Instances: Engine[];
  30655. /**
  30656. * Gets the latest created engine
  30657. */
  30658. static readonly LastCreatedEngine: Nullable<Engine>;
  30659. /**
  30660. * Gets the latest created scene
  30661. */
  30662. static readonly LastCreatedScene: Nullable<Scene>;
  30663. /**
  30664. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30665. * @param flag defines which part of the materials must be marked as dirty
  30666. * @param predicate defines a predicate used to filter which materials should be affected
  30667. */
  30668. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30669. /** @hidden */
  30670. static _TextureLoaders: IInternalTextureLoader[];
  30671. /** Defines that alpha blending is disabled */
  30672. static readonly ALPHA_DISABLE: number;
  30673. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30674. static readonly ALPHA_ADD: number;
  30675. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30676. static readonly ALPHA_COMBINE: number;
  30677. /** Defines that alpha blending to DEST - SRC * DEST */
  30678. static readonly ALPHA_SUBTRACT: number;
  30679. /** Defines that alpha blending to SRC * DEST */
  30680. static readonly ALPHA_MULTIPLY: number;
  30681. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30682. static readonly ALPHA_MAXIMIZED: number;
  30683. /** Defines that alpha blending to SRC + DEST */
  30684. static readonly ALPHA_ONEONE: number;
  30685. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30686. static readonly ALPHA_PREMULTIPLIED: number;
  30687. /**
  30688. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30689. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30690. */
  30691. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30692. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30693. static readonly ALPHA_INTERPOLATE: number;
  30694. /**
  30695. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30696. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30697. */
  30698. static readonly ALPHA_SCREENMODE: number;
  30699. /** Defines that the ressource is not delayed*/
  30700. static readonly DELAYLOADSTATE_NONE: number;
  30701. /** Defines that the ressource was successfully delay loaded */
  30702. static readonly DELAYLOADSTATE_LOADED: number;
  30703. /** Defines that the ressource is currently delay loading */
  30704. static readonly DELAYLOADSTATE_LOADING: number;
  30705. /** Defines that the ressource is delayed and has not started loading */
  30706. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30708. static readonly NEVER: number;
  30709. /** 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 */
  30710. static readonly ALWAYS: number;
  30711. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30712. static readonly LESS: number;
  30713. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30714. static readonly EQUAL: number;
  30715. /** 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 */
  30716. static readonly LEQUAL: number;
  30717. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30718. static readonly GREATER: number;
  30719. /** 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 */
  30720. static readonly GEQUAL: number;
  30721. /** 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 */
  30722. static readonly NOTEQUAL: number;
  30723. /** Passed to stencilOperation to specify that stencil value must be kept */
  30724. static readonly KEEP: number;
  30725. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30726. static readonly REPLACE: number;
  30727. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30728. static readonly INCR: number;
  30729. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30730. static readonly DECR: number;
  30731. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30732. static readonly INVERT: number;
  30733. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30734. static readonly INCR_WRAP: number;
  30735. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30736. static readonly DECR_WRAP: number;
  30737. /** Texture is not repeating outside of 0..1 UVs */
  30738. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30739. /** Texture is repeating outside of 0..1 UVs */
  30740. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30741. /** Texture is repeating and mirrored */
  30742. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30743. /** ALPHA */
  30744. static readonly TEXTUREFORMAT_ALPHA: number;
  30745. /** LUMINANCE */
  30746. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30747. /** LUMINANCE_ALPHA */
  30748. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30749. /** RGB */
  30750. static readonly TEXTUREFORMAT_RGB: number;
  30751. /** RGBA */
  30752. static readonly TEXTUREFORMAT_RGBA: number;
  30753. /** RED */
  30754. static readonly TEXTUREFORMAT_RED: number;
  30755. /** RED (2nd reference) */
  30756. static readonly TEXTUREFORMAT_R: number;
  30757. /** RG */
  30758. static readonly TEXTUREFORMAT_RG: number;
  30759. /** RED_INTEGER */
  30760. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30761. /** RED_INTEGER (2nd reference) */
  30762. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30763. /** RG_INTEGER */
  30764. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30765. /** RGB_INTEGER */
  30766. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30767. /** RGBA_INTEGER */
  30768. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30769. /** UNSIGNED_BYTE */
  30770. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30771. /** UNSIGNED_BYTE (2nd reference) */
  30772. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30773. /** FLOAT */
  30774. static readonly TEXTURETYPE_FLOAT: number;
  30775. /** HALF_FLOAT */
  30776. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30777. /** BYTE */
  30778. static readonly TEXTURETYPE_BYTE: number;
  30779. /** SHORT */
  30780. static readonly TEXTURETYPE_SHORT: number;
  30781. /** UNSIGNED_SHORT */
  30782. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30783. /** INT */
  30784. static readonly TEXTURETYPE_INT: number;
  30785. /** UNSIGNED_INT */
  30786. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30787. /** UNSIGNED_SHORT_4_4_4_4 */
  30788. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30789. /** UNSIGNED_SHORT_5_5_5_1 */
  30790. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30791. /** UNSIGNED_SHORT_5_6_5 */
  30792. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30793. /** UNSIGNED_INT_2_10_10_10_REV */
  30794. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30795. /** UNSIGNED_INT_24_8 */
  30796. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30797. /** UNSIGNED_INT_10F_11F_11F_REV */
  30798. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30799. /** UNSIGNED_INT_5_9_9_9_REV */
  30800. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30801. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30802. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30803. /** nearest is mag = nearest and min = nearest and mip = linear */
  30804. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30805. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30806. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30807. /** Trilinear is mag = linear and min = linear and mip = linear */
  30808. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30809. /** nearest is mag = nearest and min = nearest and mip = linear */
  30810. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30811. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30812. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30813. /** Trilinear is mag = linear and min = linear and mip = linear */
  30814. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30815. /** mag = nearest and min = nearest and mip = nearest */
  30816. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30817. /** mag = nearest and min = linear and mip = nearest */
  30818. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30819. /** mag = nearest and min = linear and mip = linear */
  30820. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30821. /** mag = nearest and min = linear and mip = none */
  30822. static readonly TEXTURE_NEAREST_LINEAR: number;
  30823. /** mag = nearest and min = nearest and mip = none */
  30824. static readonly TEXTURE_NEAREST_NEAREST: number;
  30825. /** mag = linear and min = nearest and mip = nearest */
  30826. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30827. /** mag = linear and min = nearest and mip = linear */
  30828. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30829. /** mag = linear and min = linear and mip = none */
  30830. static readonly TEXTURE_LINEAR_LINEAR: number;
  30831. /** mag = linear and min = nearest and mip = none */
  30832. static readonly TEXTURE_LINEAR_NEAREST: number;
  30833. /** Explicit coordinates mode */
  30834. static readonly TEXTURE_EXPLICIT_MODE: number;
  30835. /** Spherical coordinates mode */
  30836. static readonly TEXTURE_SPHERICAL_MODE: number;
  30837. /** Planar coordinates mode */
  30838. static readonly TEXTURE_PLANAR_MODE: number;
  30839. /** Cubic coordinates mode */
  30840. static readonly TEXTURE_CUBIC_MODE: number;
  30841. /** Projection coordinates mode */
  30842. static readonly TEXTURE_PROJECTION_MODE: number;
  30843. /** Skybox coordinates mode */
  30844. static readonly TEXTURE_SKYBOX_MODE: number;
  30845. /** Inverse Cubic coordinates mode */
  30846. static readonly TEXTURE_INVCUBIC_MODE: number;
  30847. /** Equirectangular coordinates mode */
  30848. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30849. /** Equirectangular Fixed coordinates mode */
  30850. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30851. /** Equirectangular Fixed Mirrored coordinates mode */
  30852. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30853. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30854. static readonly SCALEMODE_FLOOR: number;
  30855. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30856. static readonly SCALEMODE_NEAREST: number;
  30857. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30858. static readonly SCALEMODE_CEILING: number;
  30859. /**
  30860. * Returns the current npm package of the sdk
  30861. */
  30862. static readonly NpmPackage: string;
  30863. /**
  30864. * Returns the current version of the framework
  30865. */
  30866. static readonly Version: string;
  30867. /**
  30868. * Returns a string describing the current engine
  30869. */
  30870. readonly description: string;
  30871. /**
  30872. * Gets or sets the epsilon value used by collision engine
  30873. */
  30874. static CollisionsEpsilon: number;
  30875. /**
  30876. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30877. */
  30878. static ShadersRepository: string;
  30879. /**
  30880. * Method called to create the default loading screen.
  30881. * This can be overriden in your own app.
  30882. * @param canvas The rendering canvas element
  30883. * @returns The loading screen
  30884. */
  30885. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30886. /**
  30887. * Method called to create the default rescale post process on each engine.
  30888. */
  30889. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30890. /** @hidden */
  30891. _shaderProcessor: IShaderProcessor;
  30892. /**
  30893. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30894. */
  30895. forcePOTTextures: boolean;
  30896. /**
  30897. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30898. */
  30899. isFullscreen: boolean;
  30900. /**
  30901. * Gets a boolean indicating if the pointer is currently locked
  30902. */
  30903. isPointerLock: boolean;
  30904. /**
  30905. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30906. */
  30907. cullBackFaces: boolean;
  30908. /**
  30909. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30910. */
  30911. renderEvenInBackground: boolean;
  30912. /**
  30913. * Gets or sets a boolean indicating that cache can be kept between frames
  30914. */
  30915. preventCacheWipeBetweenFrames: boolean;
  30916. /**
  30917. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30918. **/
  30919. enableOfflineSupport: boolean;
  30920. /**
  30921. * 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)
  30922. **/
  30923. disableManifestCheck: boolean;
  30924. /**
  30925. * Gets the list of created scenes
  30926. */
  30927. scenes: Scene[];
  30928. /**
  30929. * Event raised when a new scene is created
  30930. */
  30931. onNewSceneAddedObservable: Observable<Scene>;
  30932. /**
  30933. * Gets the list of created postprocesses
  30934. */
  30935. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30936. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30937. validateShaderPrograms: boolean;
  30938. /**
  30939. * Observable event triggered each time the rendering canvas is resized
  30940. */
  30941. onResizeObservable: Observable<Engine>;
  30942. /**
  30943. * Observable event triggered each time the canvas loses focus
  30944. */
  30945. onCanvasBlurObservable: Observable<Engine>;
  30946. /**
  30947. * Observable event triggered each time the canvas gains focus
  30948. */
  30949. onCanvasFocusObservable: Observable<Engine>;
  30950. /**
  30951. * Observable event triggered each time the canvas receives pointerout event
  30952. */
  30953. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30954. /**
  30955. * Observable event triggered before each texture is initialized
  30956. */
  30957. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30958. /**
  30959. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30960. */
  30961. disableUniformBuffers: boolean;
  30962. /** @hidden */
  30963. _uniformBuffers: UniformBuffer[];
  30964. /**
  30965. * Gets a boolean indicating that the engine supports uniform buffers
  30966. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30967. */
  30968. readonly supportsUniformBuffers: boolean;
  30969. /**
  30970. * Observable raised when the engine begins a new frame
  30971. */
  30972. onBeginFrameObservable: Observable<Engine>;
  30973. /**
  30974. * If set, will be used to request the next animation frame for the render loop
  30975. */
  30976. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30977. /**
  30978. * Observable raised when the engine ends the current frame
  30979. */
  30980. onEndFrameObservable: Observable<Engine>;
  30981. /**
  30982. * Observable raised when the engine is about to compile a shader
  30983. */
  30984. onBeforeShaderCompilationObservable: Observable<Engine>;
  30985. /**
  30986. * Observable raised when the engine has jsut compiled a shader
  30987. */
  30988. onAfterShaderCompilationObservable: Observable<Engine>;
  30989. /** @hidden */
  30990. _gl: WebGLRenderingContext;
  30991. private _renderingCanvas;
  30992. private _windowIsBackground;
  30993. protected _webGLVersion: number;
  30994. protected _highPrecisionShadersAllowed: boolean;
  30995. /** @hidden */
  30996. readonly _shouldUseHighPrecisionShader: boolean;
  30997. /**
  30998. * Gets a boolean indicating that only power of 2 textures are supported
  30999. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31000. */
  31001. readonly needPOTTextures: boolean;
  31002. /** @hidden */
  31003. _badOS: boolean;
  31004. /** @hidden */
  31005. _badDesktopOS: boolean;
  31006. /**
  31007. * Gets the audio engine
  31008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31009. * @ignorenaming
  31010. */
  31011. static audioEngine: IAudioEngine;
  31012. /**
  31013. * Default AudioEngine factory responsible of creating the Audio Engine.
  31014. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31015. */
  31016. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31017. /**
  31018. * Default offline support factory responsible of creating a tool used to store data locally.
  31019. * By default, this will create a Database object if the workload has been embedded.
  31020. */
  31021. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31022. private _onFocus;
  31023. private _onBlur;
  31024. private _onCanvasPointerOut;
  31025. private _onCanvasBlur;
  31026. private _onCanvasFocus;
  31027. private _onFullscreenChange;
  31028. private _onPointerLockChange;
  31029. private _hardwareScalingLevel;
  31030. /** @hidden */
  31031. _caps: EngineCapabilities;
  31032. private _pointerLockRequested;
  31033. private _isStencilEnable;
  31034. protected _colorWrite: boolean;
  31035. private _loadingScreen;
  31036. /** @hidden */
  31037. _drawCalls: PerfCounter;
  31038. private _glVersion;
  31039. private _glRenderer;
  31040. private _glVendor;
  31041. private _videoTextureSupported;
  31042. private _renderingQueueLaunched;
  31043. private _activeRenderLoops;
  31044. private _deterministicLockstep;
  31045. private _lockstepMaxSteps;
  31046. /**
  31047. * Observable signaled when a context lost event is raised
  31048. */
  31049. onContextLostObservable: Observable<Engine>;
  31050. /**
  31051. * Observable signaled when a context restored event is raised
  31052. */
  31053. onContextRestoredObservable: Observable<Engine>;
  31054. private _onContextLost;
  31055. private _onContextRestored;
  31056. private _contextWasLost;
  31057. /** @hidden */
  31058. _doNotHandleContextLost: boolean;
  31059. /**
  31060. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31062. */
  31063. doNotHandleContextLost: boolean;
  31064. private _performanceMonitor;
  31065. private _fps;
  31066. private _deltaTime;
  31067. /**
  31068. * Turn this value on if you want to pause FPS computation when in background
  31069. */
  31070. disablePerformanceMonitorInBackground: boolean;
  31071. /**
  31072. * Gets the performance monitor attached to this engine
  31073. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31074. */
  31075. readonly performanceMonitor: PerformanceMonitor;
  31076. /**
  31077. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31078. */
  31079. disableVertexArrayObjects: boolean;
  31080. /** @hidden */
  31081. protected _depthCullingState: _DepthCullingState;
  31082. /** @hidden */
  31083. protected _stencilState: _StencilState;
  31084. /** @hidden */
  31085. protected _alphaState: _AlphaState;
  31086. /** @hidden */
  31087. protected _alphaMode: number;
  31088. /** @hidden */
  31089. _internalTexturesCache: InternalTexture[];
  31090. /** @hidden */
  31091. protected _activeChannel: number;
  31092. private _currentTextureChannel;
  31093. /** @hidden */
  31094. protected _boundTexturesCache: {
  31095. [key: string]: Nullable<InternalTexture>;
  31096. };
  31097. /** @hidden */
  31098. protected _currentEffect: Nullable<Effect>;
  31099. /** @hidden */
  31100. protected _currentProgram: Nullable<WebGLProgram>;
  31101. private _compiledEffects;
  31102. private _vertexAttribArraysEnabled;
  31103. /** @hidden */
  31104. protected _cachedViewport: Nullable<IViewportLike>;
  31105. private _cachedVertexArrayObject;
  31106. /** @hidden */
  31107. protected _cachedVertexBuffers: any;
  31108. /** @hidden */
  31109. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31110. /** @hidden */
  31111. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31112. /** @hidden */
  31113. _currentRenderTarget: Nullable<InternalTexture>;
  31114. private _uintIndicesCurrentlySet;
  31115. private _currentBoundBuffer;
  31116. /** @hidden */
  31117. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31118. private _currentBufferPointers;
  31119. private _currentInstanceLocations;
  31120. private _currentInstanceBuffers;
  31121. private _textureUnits;
  31122. /** @hidden */
  31123. _workingCanvas: Nullable<HTMLCanvasElement>;
  31124. /** @hidden */
  31125. _workingContext: Nullable<CanvasRenderingContext2D>;
  31126. private _rescalePostProcess;
  31127. private _dummyFramebuffer;
  31128. private _externalData;
  31129. /** @hidden */
  31130. _bindedRenderFunction: any;
  31131. private _vaoRecordInProgress;
  31132. private _mustWipeVertexAttributes;
  31133. private _emptyTexture;
  31134. private _emptyCubeTexture;
  31135. private _emptyTexture3D;
  31136. /** @hidden */
  31137. _frameHandler: number;
  31138. private _nextFreeTextureSlots;
  31139. private _maxSimultaneousTextures;
  31140. private _activeRequests;
  31141. private _texturesSupported;
  31142. /** @hidden */
  31143. _textureFormatInUse: Nullable<string>;
  31144. /**
  31145. * Gets the list of texture formats supported
  31146. */
  31147. readonly texturesSupported: Array<string>;
  31148. /**
  31149. * Gets the list of texture formats in use
  31150. */
  31151. readonly textureFormatInUse: Nullable<string>;
  31152. /**
  31153. * Gets the current viewport
  31154. */
  31155. readonly currentViewport: Nullable<IViewportLike>;
  31156. /**
  31157. * Gets the default empty texture
  31158. */
  31159. readonly emptyTexture: InternalTexture;
  31160. /**
  31161. * Gets the default empty 3D texture
  31162. */
  31163. readonly emptyTexture3D: InternalTexture;
  31164. /**
  31165. * Gets the default empty cube texture
  31166. */
  31167. readonly emptyCubeTexture: InternalTexture;
  31168. /**
  31169. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31170. */
  31171. readonly premultipliedAlpha: boolean;
  31172. /**
  31173. * Creates a new engine
  31174. * @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
  31175. * @param antialias defines enable antialiasing (default: false)
  31176. * @param options defines further options to be sent to the getContext() function
  31177. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31178. */
  31179. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31180. /**
  31181. * Initializes a webVR display and starts listening to display change events
  31182. * The onVRDisplayChangedObservable will be notified upon these changes
  31183. * @returns The onVRDisplayChangedObservable
  31184. */
  31185. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31186. /** @hidden */
  31187. _prepareVRComponent(): void;
  31188. /** @hidden */
  31189. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31190. /** @hidden */
  31191. _submitVRFrame(): void;
  31192. /**
  31193. * Call this function to leave webVR mode
  31194. * Will do nothing if webVR is not supported or if there is no webVR device
  31195. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31196. */
  31197. disableVR(): void;
  31198. /**
  31199. * Gets a boolean indicating that the system is in VR mode and is presenting
  31200. * @returns true if VR mode is engaged
  31201. */
  31202. isVRPresenting(): boolean;
  31203. /** @hidden */
  31204. _requestVRFrame(): void;
  31205. private _disableTouchAction;
  31206. private _rebuildInternalTextures;
  31207. private _rebuildEffects;
  31208. /**
  31209. * Gets a boolean indicating if all created effects are ready
  31210. * @returns true if all effects are ready
  31211. */
  31212. areAllEffectsReady(): boolean;
  31213. private _rebuildBuffers;
  31214. private _initGLContext;
  31215. /**
  31216. * Gets version of the current webGL context
  31217. */
  31218. readonly webGLVersion: number;
  31219. /**
  31220. * Gets a string idenfifying the name of the class
  31221. * @returns "Engine" string
  31222. */
  31223. getClassName(): string;
  31224. /**
  31225. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31226. */
  31227. readonly isStencilEnable: boolean;
  31228. /** @hidden */
  31229. _prepareWorkingCanvas(): void;
  31230. /**
  31231. * Reset the texture cache to empty state
  31232. */
  31233. resetTextureCache(): void;
  31234. /**
  31235. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31237. * @returns true if engine is in deterministic lock step mode
  31238. */
  31239. isDeterministicLockStep(): boolean;
  31240. /**
  31241. * Gets the max steps when engine is running in deterministic lock step
  31242. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31243. * @returns the max steps
  31244. */
  31245. getLockstepMaxSteps(): number;
  31246. /**
  31247. * Gets an object containing information about the current webGL context
  31248. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31249. */
  31250. getGlInfo(): {
  31251. vendor: string;
  31252. renderer: string;
  31253. version: string;
  31254. };
  31255. /**
  31256. * Gets current aspect ratio
  31257. * @param viewportOwner defines the camera to use to get the aspect ratio
  31258. * @param useScreen defines if screen size must be used (or the current render target if any)
  31259. * @returns a number defining the aspect ratio
  31260. */
  31261. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31262. /**
  31263. * Gets current screen aspect ratio
  31264. * @returns a number defining the aspect ratio
  31265. */
  31266. getScreenAspectRatio(): number;
  31267. /**
  31268. * Gets the current render width
  31269. * @param useScreen defines if screen size must be used (or the current render target if any)
  31270. * @returns a number defining the current render width
  31271. */
  31272. getRenderWidth(useScreen?: boolean): number;
  31273. /**
  31274. * Gets the current render height
  31275. * @param useScreen defines if screen size must be used (or the current render target if any)
  31276. * @returns a number defining the current render height
  31277. */
  31278. getRenderHeight(useScreen?: boolean): number;
  31279. /**
  31280. * Gets the HTML canvas attached with the current webGL context
  31281. * @returns a HTML canvas
  31282. */
  31283. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31284. /**
  31285. * Gets host window
  31286. * @returns the host window object
  31287. */
  31288. getHostWindow(): Window;
  31289. /**
  31290. * Gets host document
  31291. * @returns the host document object
  31292. */
  31293. getHostDocument(): Document;
  31294. /**
  31295. * Gets the client rect of the HTML canvas attached with the current webGL context
  31296. * @returns a client rectanglee
  31297. */
  31298. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31299. /**
  31300. * Defines the hardware scaling level.
  31301. * By default the hardware scaling level is computed from the window device ratio.
  31302. * 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.
  31303. * @param level defines the level to use
  31304. */
  31305. setHardwareScalingLevel(level: number): void;
  31306. /**
  31307. * Gets the current hardware scaling level.
  31308. * By default the hardware scaling level is computed from the window device ratio.
  31309. * 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.
  31310. * @returns a number indicating the current hardware scaling level
  31311. */
  31312. getHardwareScalingLevel(): number;
  31313. /**
  31314. * Gets the list of loaded textures
  31315. * @returns an array containing all loaded textures
  31316. */
  31317. getLoadedTexturesCache(): InternalTexture[];
  31318. /**
  31319. * Gets the object containing all engine capabilities
  31320. * @returns the EngineCapabilities object
  31321. */
  31322. getCaps(): EngineCapabilities;
  31323. /**
  31324. * Gets the current depth function
  31325. * @returns a number defining the depth function
  31326. */
  31327. getDepthFunction(): Nullable<number>;
  31328. /**
  31329. * Sets the current depth function
  31330. * @param depthFunc defines the function to use
  31331. */
  31332. setDepthFunction(depthFunc: number): void;
  31333. /**
  31334. * Sets the current depth function to GREATER
  31335. */
  31336. setDepthFunctionToGreater(): void;
  31337. /**
  31338. * Sets the current depth function to GEQUAL
  31339. */
  31340. setDepthFunctionToGreaterOrEqual(): void;
  31341. /**
  31342. * Sets the current depth function to LESS
  31343. */
  31344. setDepthFunctionToLess(): void;
  31345. private _cachedStencilBuffer;
  31346. private _cachedStencilFunction;
  31347. private _cachedStencilMask;
  31348. private _cachedStencilOperationPass;
  31349. private _cachedStencilOperationFail;
  31350. private _cachedStencilOperationDepthFail;
  31351. private _cachedStencilReference;
  31352. /**
  31353. * Caches the the state of the stencil buffer
  31354. */
  31355. cacheStencilState(): void;
  31356. /**
  31357. * Restores the state of the stencil buffer
  31358. */
  31359. restoreStencilState(): void;
  31360. /**
  31361. * Sets the current depth function to LEQUAL
  31362. */
  31363. setDepthFunctionToLessOrEqual(): void;
  31364. /**
  31365. * Gets a boolean indicating if stencil buffer is enabled
  31366. * @returns the current stencil buffer state
  31367. */
  31368. getStencilBuffer(): boolean;
  31369. /**
  31370. * Enable or disable the stencil buffer
  31371. * @param enable defines if the stencil buffer must be enabled or disabled
  31372. */
  31373. setStencilBuffer(enable: boolean): void;
  31374. /**
  31375. * Gets the current stencil mask
  31376. * @returns a number defining the new stencil mask to use
  31377. */
  31378. getStencilMask(): number;
  31379. /**
  31380. * Sets the current stencil mask
  31381. * @param mask defines the new stencil mask to use
  31382. */
  31383. setStencilMask(mask: number): void;
  31384. /**
  31385. * Gets the current stencil function
  31386. * @returns a number defining the stencil function to use
  31387. */
  31388. getStencilFunction(): number;
  31389. /**
  31390. * Gets the current stencil reference value
  31391. * @returns a number defining the stencil reference value to use
  31392. */
  31393. getStencilFunctionReference(): number;
  31394. /**
  31395. * Gets the current stencil mask
  31396. * @returns a number defining the stencil mask to use
  31397. */
  31398. getStencilFunctionMask(): number;
  31399. /**
  31400. * Sets the current stencil function
  31401. * @param stencilFunc defines the new stencil function to use
  31402. */
  31403. setStencilFunction(stencilFunc: number): void;
  31404. /**
  31405. * Sets the current stencil reference
  31406. * @param reference defines the new stencil reference to use
  31407. */
  31408. setStencilFunctionReference(reference: number): void;
  31409. /**
  31410. * Sets the current stencil mask
  31411. * @param mask defines the new stencil mask to use
  31412. */
  31413. setStencilFunctionMask(mask: number): void;
  31414. /**
  31415. * Gets the current stencil operation when stencil fails
  31416. * @returns a number defining stencil operation to use when stencil fails
  31417. */
  31418. getStencilOperationFail(): number;
  31419. /**
  31420. * Gets the current stencil operation when depth fails
  31421. * @returns a number defining stencil operation to use when depth fails
  31422. */
  31423. getStencilOperationDepthFail(): number;
  31424. /**
  31425. * Gets the current stencil operation when stencil passes
  31426. * @returns a number defining stencil operation to use when stencil passes
  31427. */
  31428. getStencilOperationPass(): number;
  31429. /**
  31430. * Sets the stencil operation to use when stencil fails
  31431. * @param operation defines the stencil operation to use when stencil fails
  31432. */
  31433. setStencilOperationFail(operation: number): void;
  31434. /**
  31435. * Sets the stencil operation to use when depth fails
  31436. * @param operation defines the stencil operation to use when depth fails
  31437. */
  31438. setStencilOperationDepthFail(operation: number): void;
  31439. /**
  31440. * Sets the stencil operation to use when stencil passes
  31441. * @param operation defines the stencil operation to use when stencil passes
  31442. */
  31443. setStencilOperationPass(operation: number): void;
  31444. /**
  31445. * Sets a boolean indicating if the dithering state is enabled or disabled
  31446. * @param value defines the dithering state
  31447. */
  31448. setDitheringState(value: boolean): void;
  31449. /**
  31450. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31451. * @param value defines the rasterizer state
  31452. */
  31453. setRasterizerState(value: boolean): void;
  31454. /**
  31455. * stop executing a render loop function and remove it from the execution array
  31456. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31457. */
  31458. stopRenderLoop(renderFunction?: () => void): void;
  31459. /** @hidden */
  31460. _renderLoop(): void;
  31461. /**
  31462. * Can be used to override the current requestAnimationFrame requester.
  31463. * @hidden
  31464. */
  31465. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31466. /**
  31467. * Register and execute a render loop. The engine can have more than one render function
  31468. * @param renderFunction defines the function to continuously execute
  31469. */
  31470. runRenderLoop(renderFunction: () => void): void;
  31471. /**
  31472. * Toggle full screen mode
  31473. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31474. */
  31475. switchFullscreen(requestPointerLock: boolean): void;
  31476. /**
  31477. * Enters full screen mode
  31478. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31479. */
  31480. enterFullscreen(requestPointerLock: boolean): void;
  31481. /**
  31482. * Exits full screen mode
  31483. */
  31484. exitFullscreen(): void;
  31485. /**
  31486. * Enters Pointerlock mode
  31487. */
  31488. enterPointerlock(): void;
  31489. /**
  31490. * Exits Pointerlock mode
  31491. */
  31492. exitPointerlock(): void;
  31493. /**
  31494. * Clear the current render buffer or the current render target (if any is set up)
  31495. * @param color defines the color to use
  31496. * @param backBuffer defines if the back buffer must be cleared
  31497. * @param depth defines if the depth buffer must be cleared
  31498. * @param stencil defines if the stencil buffer must be cleared
  31499. */
  31500. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31501. /**
  31502. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31503. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31504. * @param y defines the y-coordinate of the corner of the clear rectangle
  31505. * @param width defines the width of the clear rectangle
  31506. * @param height defines the height of the clear rectangle
  31507. * @param clearColor defines the clear color
  31508. */
  31509. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31510. /**
  31511. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31512. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31513. * @param y defines the y-coordinate of the corner of the clear rectangle
  31514. * @param width defines the width of the clear rectangle
  31515. * @param height defines the height of the clear rectangle
  31516. */
  31517. enableScissor(x: number, y: number, width: number, height: number): void;
  31518. /**
  31519. * Disable previously set scissor test rectangle
  31520. */
  31521. disableScissor(): void;
  31522. private _viewportCached;
  31523. /** @hidden */
  31524. _viewport(x: number, y: number, width: number, height: number): void;
  31525. /**
  31526. * Set the WebGL's viewport
  31527. * @param viewport defines the viewport element to be used
  31528. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31529. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31530. */
  31531. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31532. /**
  31533. * Directly set the WebGL Viewport
  31534. * @param x defines the x coordinate of the viewport (in screen space)
  31535. * @param y defines the y coordinate of the viewport (in screen space)
  31536. * @param width defines the width of the viewport (in screen space)
  31537. * @param height defines the height of the viewport (in screen space)
  31538. * @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
  31539. */
  31540. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31541. /**
  31542. * Begin a new frame
  31543. */
  31544. beginFrame(): void;
  31545. /**
  31546. * Enf the current frame
  31547. */
  31548. endFrame(): void;
  31549. /**
  31550. * Resize the view according to the canvas' size
  31551. */
  31552. resize(): void;
  31553. /**
  31554. * Force a specific size of the canvas
  31555. * @param width defines the new canvas' width
  31556. * @param height defines the new canvas' height
  31557. */
  31558. setSize(width: number, height: number): void;
  31559. /**
  31560. * Binds the frame buffer to the specified texture.
  31561. * @param texture The texture to render to or null for the default canvas
  31562. * @param faceIndex The face of the texture to render to in case of cube texture
  31563. * @param requiredWidth The width of the target to render to
  31564. * @param requiredHeight The height of the target to render to
  31565. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31566. * @param depthStencilTexture The depth stencil texture to use to render
  31567. * @param lodLevel defines le lod level to bind to the frame buffer
  31568. */
  31569. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31570. /** @hidden */
  31571. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31572. /**
  31573. * Unbind the current render target texture from the webGL context
  31574. * @param texture defines the render target texture to unbind
  31575. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31576. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31577. */
  31578. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31579. /**
  31580. * Force the mipmap generation for the given render target texture
  31581. * @param texture defines the render target texture to use
  31582. */
  31583. generateMipMapsForCubemap(texture: InternalTexture): void;
  31584. /**
  31585. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31586. */
  31587. flushFramebuffer(): void;
  31588. /**
  31589. * Unbind the current render target and bind the default framebuffer
  31590. */
  31591. restoreDefaultFramebuffer(): void;
  31592. /**
  31593. * Create an uniform buffer
  31594. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31595. * @param elements defines the content of the uniform buffer
  31596. * @returns the webGL uniform buffer
  31597. */
  31598. createUniformBuffer(elements: FloatArray): DataBuffer;
  31599. /**
  31600. * Create a dynamic uniform buffer
  31601. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31602. * @param elements defines the content of the uniform buffer
  31603. * @returns the webGL uniform buffer
  31604. */
  31605. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31606. /**
  31607. * Update an existing uniform buffer
  31608. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31609. * @param uniformBuffer defines the target uniform buffer
  31610. * @param elements defines the content to update
  31611. * @param offset defines the offset in the uniform buffer where update should start
  31612. * @param count defines the size of the data to update
  31613. */
  31614. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31615. private _resetVertexBufferBinding;
  31616. /**
  31617. * Creates a vertex buffer
  31618. * @param data the data for the vertex buffer
  31619. * @returns the new WebGL static buffer
  31620. */
  31621. createVertexBuffer(data: DataArray): DataBuffer;
  31622. /**
  31623. * Creates a dynamic vertex buffer
  31624. * @param data the data for the dynamic vertex buffer
  31625. * @returns the new WebGL dynamic buffer
  31626. */
  31627. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31628. /**
  31629. * Update a dynamic index buffer
  31630. * @param indexBuffer defines the target index buffer
  31631. * @param indices defines the data to update
  31632. * @param offset defines the offset in the target index buffer where update should start
  31633. */
  31634. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31635. /**
  31636. * Updates a dynamic vertex buffer.
  31637. * @param vertexBuffer the vertex buffer to update
  31638. * @param data the data used to update the vertex buffer
  31639. * @param byteOffset the byte offset of the data
  31640. * @param byteLength the byte length of the data
  31641. */
  31642. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31643. private _resetIndexBufferBinding;
  31644. /**
  31645. * Creates a new index buffer
  31646. * @param indices defines the content of the index buffer
  31647. * @param updatable defines if the index buffer must be updatable
  31648. * @returns a new webGL buffer
  31649. */
  31650. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31651. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31652. /**
  31653. * Bind a webGL buffer to the webGL context
  31654. * @param buffer defines the buffer to bind
  31655. */
  31656. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31657. /**
  31658. * Bind an uniform buffer to the current webGL context
  31659. * @param buffer defines the buffer to bind
  31660. */
  31661. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31662. /**
  31663. * Bind a buffer to the current webGL context at a given location
  31664. * @param buffer defines the buffer to bind
  31665. * @param location defines the index where to bind the buffer
  31666. */
  31667. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31668. /**
  31669. * Bind a specific block at a given index in a specific shader program
  31670. * @param pipelineContext defines the pipeline context to use
  31671. * @param blockName defines the block name
  31672. * @param index defines the index where to bind the block
  31673. */
  31674. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31675. private bindIndexBuffer;
  31676. private bindBuffer;
  31677. /**
  31678. * update the bound buffer with the given data
  31679. * @param data defines the data to update
  31680. */
  31681. updateArrayBuffer(data: Float32Array): void;
  31682. private _vertexAttribPointer;
  31683. private _bindIndexBufferWithCache;
  31684. private _bindVertexBuffersAttributes;
  31685. /**
  31686. * Records a vertex array object
  31687. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31688. * @param vertexBuffers defines the list of vertex buffers to store
  31689. * @param indexBuffer defines the index buffer to store
  31690. * @param effect defines the effect to store
  31691. * @returns the new vertex array object
  31692. */
  31693. recordVertexArrayObject(vertexBuffers: {
  31694. [key: string]: VertexBuffer;
  31695. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31696. /**
  31697. * Bind a specific vertex array object
  31698. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31699. * @param vertexArrayObject defines the vertex array object to bind
  31700. * @param indexBuffer defines the index buffer to bind
  31701. */
  31702. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31703. /**
  31704. * Bind webGl buffers directly to the webGL context
  31705. * @param vertexBuffer defines the vertex buffer to bind
  31706. * @param indexBuffer defines the index buffer to bind
  31707. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31708. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31709. * @param effect defines the effect associated with the vertex buffer
  31710. */
  31711. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31712. private _unbindVertexArrayObject;
  31713. /**
  31714. * Bind a list of vertex buffers to the webGL context
  31715. * @param vertexBuffers defines the list of vertex buffers to bind
  31716. * @param indexBuffer defines the index buffer to bind
  31717. * @param effect defines the effect associated with the vertex buffers
  31718. */
  31719. bindBuffers(vertexBuffers: {
  31720. [key: string]: Nullable<VertexBuffer>;
  31721. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31722. /**
  31723. * Unbind all instance attributes
  31724. */
  31725. unbindInstanceAttributes(): void;
  31726. /**
  31727. * Release and free the memory of a vertex array object
  31728. * @param vao defines the vertex array object to delete
  31729. */
  31730. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31731. /** @hidden */
  31732. _releaseBuffer(buffer: DataBuffer): boolean;
  31733. protected _deleteBuffer(buffer: DataBuffer): void;
  31734. /**
  31735. * Creates a webGL buffer to use with instanciation
  31736. * @param capacity defines the size of the buffer
  31737. * @returns the webGL buffer
  31738. */
  31739. createInstancesBuffer(capacity: number): DataBuffer;
  31740. /**
  31741. * Delete a webGL buffer used with instanciation
  31742. * @param buffer defines the webGL buffer to delete
  31743. */
  31744. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31745. /**
  31746. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31747. * @param instancesBuffer defines the webGL buffer to update and bind
  31748. * @param data defines the data to store in the buffer
  31749. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31750. */
  31751. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31752. /**
  31753. * Apply all cached states (depth, culling, stencil and alpha)
  31754. */
  31755. applyStates(): void;
  31756. /**
  31757. * Send a draw order
  31758. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31759. * @param indexStart defines the starting index
  31760. * @param indexCount defines the number of index to draw
  31761. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31762. */
  31763. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31764. /**
  31765. * Draw a list of points
  31766. * @param verticesStart defines the index of first vertex to draw
  31767. * @param verticesCount defines the count of vertices to draw
  31768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31769. */
  31770. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31771. /**
  31772. * Draw a list of unindexed primitives
  31773. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31774. * @param verticesStart defines the index of first vertex to draw
  31775. * @param verticesCount defines the count of vertices to draw
  31776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31777. */
  31778. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31779. /**
  31780. * Draw a list of indexed primitives
  31781. * @param fillMode defines the primitive to use
  31782. * @param indexStart defines the starting index
  31783. * @param indexCount defines the number of index to draw
  31784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31785. */
  31786. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31787. /**
  31788. * Draw a list of unindexed primitives
  31789. * @param fillMode defines the primitive to use
  31790. * @param verticesStart defines the index of first vertex to draw
  31791. * @param verticesCount defines the count of vertices to draw
  31792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31793. */
  31794. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31795. private _drawMode;
  31796. /** @hidden */
  31797. _releaseEffect(effect: Effect): void;
  31798. /** @hidden */
  31799. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31800. /**
  31801. * Create a new effect (used to store vertex/fragment shaders)
  31802. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31803. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31804. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31805. * @param samplers defines an array of string used to represent textures
  31806. * @param defines defines the string containing the defines to use to compile the shaders
  31807. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31808. * @param onCompiled defines a function to call when the effect creation is successful
  31809. * @param onError defines a function to call when the effect creation has failed
  31810. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31811. * @returns the new Effect
  31812. */
  31813. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31814. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31815. private _compileShader;
  31816. private _compileRawShader;
  31817. /**
  31818. * Directly creates a webGL program
  31819. * @param pipelineContext defines the pipeline context to attach to
  31820. * @param vertexCode defines the vertex shader code to use
  31821. * @param fragmentCode defines the fragment shader code to use
  31822. * @param context defines the webGL context to use (if not set, the current one will be used)
  31823. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31824. * @returns the new webGL program
  31825. */
  31826. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31827. /**
  31828. * Creates a webGL program
  31829. * @param pipelineContext defines the pipeline context to attach to
  31830. * @param vertexCode defines the vertex shader code to use
  31831. * @param fragmentCode defines the fragment shader code to use
  31832. * @param defines defines the string containing the defines to use to compile the shaders
  31833. * @param context defines the webGL context to use (if not set, the current one will be used)
  31834. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31835. * @returns the new webGL program
  31836. */
  31837. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31838. /**
  31839. * Creates a new pipeline context
  31840. * @returns the new pipeline
  31841. */
  31842. createPipelineContext(): IPipelineContext;
  31843. private _createShaderProgram;
  31844. private _finalizePipelineContext;
  31845. /** @hidden */
  31846. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31847. /** @hidden */
  31848. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31849. /** @hidden */
  31850. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31851. /**
  31852. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31853. * @param pipelineContext defines the pipeline context to use
  31854. * @param uniformsNames defines the list of uniform names
  31855. * @returns an array of webGL uniform locations
  31856. */
  31857. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31858. /**
  31859. * Gets the lsit of active attributes for a given webGL program
  31860. * @param pipelineContext defines the pipeline context to use
  31861. * @param attributesNames defines the list of attribute names to get
  31862. * @returns an array of indices indicating the offset of each attribute
  31863. */
  31864. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31865. /**
  31866. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31867. * @param effect defines the effect to activate
  31868. */
  31869. enableEffect(effect: Nullable<Effect>): void;
  31870. /**
  31871. * Set the value of an uniform to an array of int32
  31872. * @param uniform defines the webGL uniform location where to store the value
  31873. * @param array defines the array of int32 to store
  31874. */
  31875. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31876. /**
  31877. * Set the value of an uniform to an array of int32 (stored as vec2)
  31878. * @param uniform defines the webGL uniform location where to store the value
  31879. * @param array defines the array of int32 to store
  31880. */
  31881. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31882. /**
  31883. * Set the value of an uniform to an array of int32 (stored as vec3)
  31884. * @param uniform defines the webGL uniform location where to store the value
  31885. * @param array defines the array of int32 to store
  31886. */
  31887. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31888. /**
  31889. * Set the value of an uniform to an array of int32 (stored as vec4)
  31890. * @param uniform defines the webGL uniform location where to store the value
  31891. * @param array defines the array of int32 to store
  31892. */
  31893. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31894. /**
  31895. * Set the value of an uniform to an array of float32
  31896. * @param uniform defines the webGL uniform location where to store the value
  31897. * @param array defines the array of float32 to store
  31898. */
  31899. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31900. /**
  31901. * Set the value of an uniform to an array of float32 (stored as vec2)
  31902. * @param uniform defines the webGL uniform location where to store the value
  31903. * @param array defines the array of float32 to store
  31904. */
  31905. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31906. /**
  31907. * Set the value of an uniform to an array of float32 (stored as vec3)
  31908. * @param uniform defines the webGL uniform location where to store the value
  31909. * @param array defines the array of float32 to store
  31910. */
  31911. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31912. /**
  31913. * Set the value of an uniform to an array of float32 (stored as vec4)
  31914. * @param uniform defines the webGL uniform location where to store the value
  31915. * @param array defines the array of float32 to store
  31916. */
  31917. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31918. /**
  31919. * Set the value of an uniform to an array of number
  31920. * @param uniform defines the webGL uniform location where to store the value
  31921. * @param array defines the array of number to store
  31922. */
  31923. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31924. /**
  31925. * Set the value of an uniform to an array of number (stored as vec2)
  31926. * @param uniform defines the webGL uniform location where to store the value
  31927. * @param array defines the array of number to store
  31928. */
  31929. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31930. /**
  31931. * Set the value of an uniform to an array of number (stored as vec3)
  31932. * @param uniform defines the webGL uniform location where to store the value
  31933. * @param array defines the array of number to store
  31934. */
  31935. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31936. /**
  31937. * Set the value of an uniform to an array of number (stored as vec4)
  31938. * @param uniform defines the webGL uniform location where to store the value
  31939. * @param array defines the array of number to store
  31940. */
  31941. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31942. /**
  31943. * Set the value of an uniform to an array of float32 (stored as matrices)
  31944. * @param uniform defines the webGL uniform location where to store the value
  31945. * @param matrices defines the array of float32 to store
  31946. */
  31947. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31948. /**
  31949. * Set the value of an uniform to a matrix (3x3)
  31950. * @param uniform defines the webGL uniform location where to store the value
  31951. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31952. */
  31953. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31954. /**
  31955. * Set the value of an uniform to a matrix (2x2)
  31956. * @param uniform defines the webGL uniform location where to store the value
  31957. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31958. */
  31959. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31960. /**
  31961. * Set the value of an uniform to a number (int)
  31962. * @param uniform defines the webGL uniform location where to store the value
  31963. * @param value defines the int number to store
  31964. */
  31965. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31966. /**
  31967. * Set the value of an uniform to a number (float)
  31968. * @param uniform defines the webGL uniform location where to store the value
  31969. * @param value defines the float number to store
  31970. */
  31971. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31972. /**
  31973. * Set the value of an uniform to a vec2
  31974. * @param uniform defines the webGL uniform location where to store the value
  31975. * @param x defines the 1st component of the value
  31976. * @param y defines the 2nd component of the value
  31977. */
  31978. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31979. /**
  31980. * Set the value of an uniform to a vec3
  31981. * @param uniform defines the webGL uniform location where to store the value
  31982. * @param x defines the 1st component of the value
  31983. * @param y defines the 2nd component of the value
  31984. * @param z defines the 3rd component of the value
  31985. */
  31986. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31987. /**
  31988. * Set the value of an uniform to a boolean
  31989. * @param uniform defines the webGL uniform location where to store the value
  31990. * @param bool defines the boolean to store
  31991. */
  31992. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31993. /**
  31994. * Set the value of an uniform to a vec4
  31995. * @param uniform defines the webGL uniform location where to store the value
  31996. * @param x defines the 1st component of the value
  31997. * @param y defines the 2nd component of the value
  31998. * @param z defines the 3rd component of the value
  31999. * @param w defines the 4th component of the value
  32000. */
  32001. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32002. /**
  32003. * Sets a Color4 on a uniform variable
  32004. * @param uniform defines the uniform location
  32005. * @param color4 defines the value to be set
  32006. */
  32007. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32008. /**
  32009. * Set various states to the webGL context
  32010. * @param culling defines backface culling state
  32011. * @param zOffset defines the value to apply to zOffset (0 by default)
  32012. * @param force defines if states must be applied even if cache is up to date
  32013. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32014. */
  32015. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32016. /**
  32017. * Set the z offset to apply to current rendering
  32018. * @param value defines the offset to apply
  32019. */
  32020. setZOffset(value: number): void;
  32021. /**
  32022. * Gets the current value of the zOffset
  32023. * @returns the current zOffset state
  32024. */
  32025. getZOffset(): number;
  32026. /**
  32027. * Enable or disable depth buffering
  32028. * @param enable defines the state to set
  32029. */
  32030. setDepthBuffer(enable: boolean): void;
  32031. /**
  32032. * Gets a boolean indicating if depth writing is enabled
  32033. * @returns the current depth writing state
  32034. */
  32035. getDepthWrite(): boolean;
  32036. /**
  32037. * Enable or disable depth writing
  32038. * @param enable defines the state to set
  32039. */
  32040. setDepthWrite(enable: boolean): void;
  32041. /**
  32042. * Enable or disable color writing
  32043. * @param enable defines the state to set
  32044. */
  32045. setColorWrite(enable: boolean): void;
  32046. /**
  32047. * Gets a boolean indicating if color writing is enabled
  32048. * @returns the current color writing state
  32049. */
  32050. getColorWrite(): boolean;
  32051. /**
  32052. * Sets alpha constants used by some alpha blending modes
  32053. * @param r defines the red component
  32054. * @param g defines the green component
  32055. * @param b defines the blue component
  32056. * @param a defines the alpha component
  32057. */
  32058. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32059. /**
  32060. * Sets the current alpha mode
  32061. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32062. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32063. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32064. */
  32065. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32066. /**
  32067. * Gets the current alpha mode
  32068. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32069. * @returns the current alpha mode
  32070. */
  32071. getAlphaMode(): number;
  32072. /**
  32073. * Clears the list of texture accessible through engine.
  32074. * This can help preventing texture load conflict due to name collision.
  32075. */
  32076. clearInternalTexturesCache(): void;
  32077. /**
  32078. * Force the entire cache to be cleared
  32079. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32080. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32081. */
  32082. wipeCaches(bruteForce?: boolean): void;
  32083. /**
  32084. * Set the compressed texture format to use, based on the formats you have, and the formats
  32085. * supported by the hardware / browser.
  32086. *
  32087. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32088. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32089. * to API arguments needed to compressed textures. This puts the burden on the container
  32090. * generator to house the arcane code for determining these for current & future formats.
  32091. *
  32092. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32093. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32094. *
  32095. * Note: The result of this call is not taken into account when a texture is base64.
  32096. *
  32097. * @param formatsAvailable defines the list of those format families you have created
  32098. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32099. *
  32100. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32101. * @returns The extension selected.
  32102. */
  32103. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32104. /** @hidden */
  32105. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32106. min: number;
  32107. mag: number;
  32108. };
  32109. /** @hidden */
  32110. _createTexture(): WebGLTexture;
  32111. /**
  32112. * Usually called from Texture.ts.
  32113. * Passed information to create a WebGLTexture
  32114. * @param urlArg defines a value which contains one of the following:
  32115. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32116. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32117. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32118. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32119. * @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)
  32120. * @param scene needed for loading to the correct scene
  32121. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32122. * @param onLoad optional callback to be called upon successful completion
  32123. * @param onError optional callback to be called upon failure
  32124. * @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
  32125. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32126. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32127. * @param forcedExtension defines the extension to use to pick the right loader
  32128. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32129. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32130. */
  32131. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32132. /**
  32133. * @hidden
  32134. * Rescales a texture
  32135. * @param source input texutre
  32136. * @param destination destination texture
  32137. * @param scene scene to use to render the resize
  32138. * @param internalFormat format to use when resizing
  32139. * @param onComplete callback to be called when resize has completed
  32140. */
  32141. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32142. private _unpackFlipYCached;
  32143. /**
  32144. * In case you are sharing the context with other applications, it might
  32145. * be interested to not cache the unpack flip y state to ensure a consistent
  32146. * value would be set.
  32147. */
  32148. enableUnpackFlipYCached: boolean;
  32149. /** @hidden */
  32150. _unpackFlipY(value: boolean): void;
  32151. /** @hidden */
  32152. _getUnpackAlignement(): number;
  32153. /**
  32154. * Creates a dynamic texture
  32155. * @param width defines the width of the texture
  32156. * @param height defines the height of the texture
  32157. * @param generateMipMaps defines if the engine should generate the mip levels
  32158. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32159. * @returns the dynamic texture inside an InternalTexture
  32160. */
  32161. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32162. /**
  32163. * Update the sampling mode of a given texture
  32164. * @param samplingMode defines the required sampling mode
  32165. * @param texture defines the texture to update
  32166. */
  32167. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32168. /**
  32169. * Update the content of a dynamic texture
  32170. * @param texture defines the texture to update
  32171. * @param canvas defines the canvas containing the source
  32172. * @param invertY defines if data must be stored with Y axis inverted
  32173. * @param premulAlpha defines if alpha is stored as premultiplied
  32174. * @param format defines the format of the data
  32175. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32176. */
  32177. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32178. /**
  32179. * Update a video texture
  32180. * @param texture defines the texture to update
  32181. * @param video defines the video element to use
  32182. * @param invertY defines if data must be stored with Y axis inverted
  32183. */
  32184. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32185. /**
  32186. * Updates a depth texture Comparison Mode and Function.
  32187. * If the comparison Function is equal to 0, the mode will be set to none.
  32188. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32189. * @param texture The texture to set the comparison function for
  32190. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32191. */
  32192. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32193. /** @hidden */
  32194. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32195. width: number;
  32196. height: number;
  32197. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32198. /**
  32199. * Creates a depth stencil texture.
  32200. * This is only available in WebGL 2 or with the depth texture extension available.
  32201. * @param size The size of face edge in the texture.
  32202. * @param options The options defining the texture.
  32203. * @returns The texture
  32204. */
  32205. createDepthStencilTexture(size: number | {
  32206. width: number;
  32207. height: number;
  32208. }, options: DepthTextureCreationOptions): InternalTexture;
  32209. /**
  32210. * Creates a depth stencil texture.
  32211. * This is only available in WebGL 2 or with the depth texture extension available.
  32212. * @param size The size of face edge in the texture.
  32213. * @param options The options defining the texture.
  32214. * @returns The texture
  32215. */
  32216. private _createDepthStencilTexture;
  32217. /**
  32218. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32219. * @param renderTarget The render target to set the frame buffer for
  32220. */
  32221. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32222. /**
  32223. * Creates a new render target texture
  32224. * @param size defines the size of the texture
  32225. * @param options defines the options used to create the texture
  32226. * @returns a new render target texture stored in an InternalTexture
  32227. */
  32228. createRenderTargetTexture(size: number | {
  32229. width: number;
  32230. height: number;
  32231. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32232. /** @hidden */
  32233. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32234. /**
  32235. * Updates the sample count of a render target texture
  32236. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32237. * @param texture defines the texture to update
  32238. * @param samples defines the sample count to set
  32239. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32240. */
  32241. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32242. /** @hidden */
  32243. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32244. /** @hidden */
  32245. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32246. /** @hidden */
  32247. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32248. /** @hidden */
  32249. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32250. /**
  32251. * @hidden
  32252. */
  32253. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32254. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32255. private _prepareWebGLTexture;
  32256. /** @hidden */
  32257. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32258. /** @hidden */
  32259. _releaseFramebufferObjects(texture: InternalTexture): void;
  32260. /** @hidden */
  32261. _releaseTexture(texture: InternalTexture): void;
  32262. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32263. protected _setProgram(program: WebGLProgram): void;
  32264. protected _boundUniforms: {
  32265. [key: number]: WebGLUniformLocation;
  32266. };
  32267. /**
  32268. * Binds an effect to the webGL context
  32269. * @param effect defines the effect to bind
  32270. */
  32271. bindSamplers(effect: Effect): void;
  32272. private _activateCurrentTexture;
  32273. /** @hidden */
  32274. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32275. /** @hidden */
  32276. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32277. /**
  32278. * Sets a texture to the webGL context from a postprocess
  32279. * @param channel defines the channel to use
  32280. * @param postProcess defines the source postprocess
  32281. */
  32282. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32283. /**
  32284. * Binds the output of the passed in post process to the texture channel specified
  32285. * @param channel The channel the texture should be bound to
  32286. * @param postProcess The post process which's output should be bound
  32287. */
  32288. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32289. /**
  32290. * Unbind all textures from the webGL context
  32291. */
  32292. unbindAllTextures(): void;
  32293. /**
  32294. * Sets a texture to the according uniform.
  32295. * @param channel The texture channel
  32296. * @param uniform The uniform to set
  32297. * @param texture The texture to apply
  32298. */
  32299. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32300. /**
  32301. * Sets a depth stencil texture from a render target to the according uniform.
  32302. * @param channel The texture channel
  32303. * @param uniform The uniform to set
  32304. * @param texture The render target texture containing the depth stencil texture to apply
  32305. */
  32306. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32307. private _bindSamplerUniformToChannel;
  32308. private _getTextureWrapMode;
  32309. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32310. /**
  32311. * Sets an array of texture to the webGL context
  32312. * @param channel defines the channel where the texture array must be set
  32313. * @param uniform defines the associated uniform location
  32314. * @param textures defines the array of textures to bind
  32315. */
  32316. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32317. /** @hidden */
  32318. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32319. private _setTextureParameterFloat;
  32320. private _setTextureParameterInteger;
  32321. /**
  32322. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32323. * @param x defines the x coordinate of the rectangle where pixels must be read
  32324. * @param y defines the y coordinate of the rectangle where pixels must be read
  32325. * @param width defines the width of the rectangle where pixels must be read
  32326. * @param height defines the height of the rectangle where pixels must be read
  32327. * @returns a Uint8Array containing RGBA colors
  32328. */
  32329. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32330. /**
  32331. * Add an externaly attached data from its key.
  32332. * This method call will fail and return false, if such key already exists.
  32333. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32334. * @param key the unique key that identifies the data
  32335. * @param data the data object to associate to the key for this Engine instance
  32336. * @return true if no such key were already present and the data was added successfully, false otherwise
  32337. */
  32338. addExternalData<T>(key: string, data: T): boolean;
  32339. /**
  32340. * Get an externaly attached data from its key
  32341. * @param key the unique key that identifies the data
  32342. * @return the associated data, if present (can be null), or undefined if not present
  32343. */
  32344. getExternalData<T>(key: string): T;
  32345. /**
  32346. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32347. * @param key the unique key that identifies the data
  32348. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32349. * @return the associated data, can be null if the factory returned null.
  32350. */
  32351. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32352. /**
  32353. * Remove an externaly attached data from the Engine instance
  32354. * @param key the unique key that identifies the data
  32355. * @return true if the data was successfully removed, false if it doesn't exist
  32356. */
  32357. removeExternalData(key: string): boolean;
  32358. /**
  32359. * Unbind all vertex attributes from the webGL context
  32360. */
  32361. unbindAllAttributes(): void;
  32362. /**
  32363. * 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
  32364. */
  32365. releaseEffects(): void;
  32366. /**
  32367. * Dispose and release all associated resources
  32368. */
  32369. dispose(): void;
  32370. /**
  32371. * Display the loading screen
  32372. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32373. */
  32374. displayLoadingUI(): void;
  32375. /**
  32376. * Hide the loading screen
  32377. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32378. */
  32379. hideLoadingUI(): void;
  32380. /**
  32381. * Gets the current loading screen object
  32382. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32383. */
  32384. /**
  32385. * Sets the current loading screen object
  32386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32387. */
  32388. loadingScreen: ILoadingScreen;
  32389. /**
  32390. * Sets the current loading screen text
  32391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32392. */
  32393. loadingUIText: string;
  32394. /**
  32395. * Sets the current loading screen background color
  32396. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32397. */
  32398. loadingUIBackgroundColor: string;
  32399. /**
  32400. * Attach a new callback raised when context lost event is fired
  32401. * @param callback defines the callback to call
  32402. */
  32403. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32404. /**
  32405. * Attach a new callback raised when context restored event is fired
  32406. * @param callback defines the callback to call
  32407. */
  32408. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32409. /**
  32410. * Gets the source code of the vertex shader associated with a specific webGL program
  32411. * @param program defines the program to use
  32412. * @returns a string containing the source code of the vertex shader associated with the program
  32413. */
  32414. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32415. /**
  32416. * Gets the source code of the fragment shader associated with a specific webGL program
  32417. * @param program defines the program to use
  32418. * @returns a string containing the source code of the fragment shader associated with the program
  32419. */
  32420. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32421. /**
  32422. * Get the current error code of the webGL context
  32423. * @returns the error code
  32424. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32425. */
  32426. getError(): number;
  32427. /**
  32428. * Gets the current framerate
  32429. * @returns a number representing the framerate
  32430. */
  32431. getFps(): number;
  32432. /**
  32433. * Gets the time spent between current and previous frame
  32434. * @returns a number representing the delta time in ms
  32435. */
  32436. getDeltaTime(): number;
  32437. private _measureFps;
  32438. /** @hidden */
  32439. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32440. private _canRenderToFloatFramebuffer;
  32441. private _canRenderToHalfFloatFramebuffer;
  32442. private _canRenderToFramebuffer;
  32443. /** @hidden */
  32444. _getWebGLTextureType(type: number): number;
  32445. /** @hidden */
  32446. _getInternalFormat(format: number): number;
  32447. /** @hidden */
  32448. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32449. /** @hidden */
  32450. _getRGBAMultiSampleBufferFormat(type: number): number;
  32451. /** @hidden */
  32452. _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;
  32453. /** @hidden */
  32454. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32455. /**
  32456. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32457. * @returns true if the engine can be created
  32458. * @ignorenaming
  32459. */
  32460. static isSupported(): boolean;
  32461. /**
  32462. * Find the next highest power of two.
  32463. * @param x Number to start search from.
  32464. * @return Next highest power of two.
  32465. */
  32466. static CeilingPOT(x: number): number;
  32467. /**
  32468. * Find the next lowest power of two.
  32469. * @param x Number to start search from.
  32470. * @return Next lowest power of two.
  32471. */
  32472. static FloorPOT(x: number): number;
  32473. /**
  32474. * Find the nearest power of two.
  32475. * @param x Number to start search from.
  32476. * @return Next nearest power of two.
  32477. */
  32478. static NearestPOT(x: number): number;
  32479. /**
  32480. * Get the closest exponent of two
  32481. * @param value defines the value to approximate
  32482. * @param max defines the maximum value to return
  32483. * @param mode defines how to define the closest value
  32484. * @returns closest exponent of two of the given value
  32485. */
  32486. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32487. /**
  32488. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32489. * @param func - the function to be called
  32490. * @param requester - the object that will request the next frame. Falls back to window.
  32491. * @returns frame number
  32492. */
  32493. static QueueNewFrame(func: () => void, requester?: any): number;
  32494. /**
  32495. * Ask the browser to promote the current element to pointerlock mode
  32496. * @param element defines the DOM element to promote
  32497. */
  32498. static _RequestPointerlock(element: HTMLElement): void;
  32499. /**
  32500. * Asks the browser to exit pointerlock mode
  32501. */
  32502. static _ExitPointerlock(): void;
  32503. /**
  32504. * Ask the browser to promote the current element to fullscreen rendering mode
  32505. * @param element defines the DOM element to promote
  32506. */
  32507. static _RequestFullscreen(element: HTMLElement): void;
  32508. /**
  32509. * Asks the browser to exit fullscreen mode
  32510. */
  32511. static _ExitFullscreen(): void;
  32512. }
  32513. }
  32514. declare module "babylonjs/Engines/engineStore" {
  32515. import { Nullable } from "babylonjs/types";
  32516. import { Engine } from "babylonjs/Engines/engine";
  32517. import { Scene } from "babylonjs/scene";
  32518. /**
  32519. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32520. * during the life time of the application.
  32521. */
  32522. export class EngineStore {
  32523. /** Gets the list of created engines */
  32524. static Instances: import("babylonjs/Engines/engine").Engine[];
  32525. /** @hidden */
  32526. static _LastCreatedScene: Nullable<Scene>;
  32527. /**
  32528. * Gets the latest created engine
  32529. */
  32530. static readonly LastCreatedEngine: Nullable<Engine>;
  32531. /**
  32532. * Gets the latest created scene
  32533. */
  32534. static readonly LastCreatedScene: Nullable<Scene>;
  32535. /**
  32536. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32537. * @ignorenaming
  32538. */
  32539. static UseFallbackTexture: boolean;
  32540. /**
  32541. * Texture content used if a texture cannot loaded
  32542. * @ignorenaming
  32543. */
  32544. static FallbackTexture: string;
  32545. }
  32546. }
  32547. declare module "babylonjs/Misc/promise" {
  32548. /**
  32549. * Helper class that provides a small promise polyfill
  32550. */
  32551. export class PromisePolyfill {
  32552. /**
  32553. * Static function used to check if the polyfill is required
  32554. * If this is the case then the function will inject the polyfill to window.Promise
  32555. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32556. */
  32557. static Apply(force?: boolean): void;
  32558. }
  32559. }
  32560. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32561. /**
  32562. * Interface for screenshot methods with describe argument called `size` as object with options
  32563. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32564. */
  32565. export interface IScreenshotSize {
  32566. /**
  32567. * number in pixels for canvas height
  32568. */
  32569. height?: number;
  32570. /**
  32571. * multiplier allowing render at a higher or lower resolution
  32572. * If value is defined then height and width will be ignored and taken from camera
  32573. */
  32574. precision?: number;
  32575. /**
  32576. * number in pixels for canvas width
  32577. */
  32578. width?: number;
  32579. }
  32580. }
  32581. declare module "babylonjs/Misc/tools" {
  32582. import { Nullable, float } from "babylonjs/types";
  32583. import { DomManagement } from "babylonjs/Misc/domManagement";
  32584. import { WebRequest } from "babylonjs/Misc/webRequest";
  32585. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32586. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32587. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32588. import { Camera } from "babylonjs/Cameras/camera";
  32589. import { Engine } from "babylonjs/Engines/engine";
  32590. interface IColor4Like {
  32591. r: float;
  32592. g: float;
  32593. b: float;
  32594. a: float;
  32595. }
  32596. /**
  32597. * Class containing a set of static utilities functions
  32598. */
  32599. export class Tools {
  32600. /**
  32601. * Gets or sets the base URL to use to load assets
  32602. */
  32603. static BaseUrl: string;
  32604. /**
  32605. * Enable/Disable Custom HTTP Request Headers globally.
  32606. * default = false
  32607. * @see CustomRequestHeaders
  32608. */
  32609. static UseCustomRequestHeaders: boolean;
  32610. /**
  32611. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32612. * i.e. when loading files, where the server/service expects an Authorization header
  32613. */
  32614. static CustomRequestHeaders: {
  32615. [key: string]: string;
  32616. };
  32617. /**
  32618. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32619. */
  32620. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32621. /**
  32622. * Default behaviour for cors in the application.
  32623. * It can be a string if the expected behavior is identical in the entire app.
  32624. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32625. */
  32626. static CorsBehavior: string | ((url: string | string[]) => string);
  32627. /**
  32628. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32629. * @ignorenaming
  32630. */
  32631. static UseFallbackTexture: boolean;
  32632. /**
  32633. * Use this object to register external classes like custom textures or material
  32634. * to allow the laoders to instantiate them
  32635. */
  32636. static RegisteredExternalClasses: {
  32637. [key: string]: Object;
  32638. };
  32639. /**
  32640. * Texture content used if a texture cannot loaded
  32641. * @ignorenaming
  32642. */
  32643. static fallbackTexture: string;
  32644. /**
  32645. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32646. * @param u defines the coordinate on X axis
  32647. * @param v defines the coordinate on Y axis
  32648. * @param width defines the width of the source data
  32649. * @param height defines the height of the source data
  32650. * @param pixels defines the source byte array
  32651. * @param color defines the output color
  32652. */
  32653. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32654. /**
  32655. * Interpolates between a and b via alpha
  32656. * @param a The lower value (returned when alpha = 0)
  32657. * @param b The upper value (returned when alpha = 1)
  32658. * @param alpha The interpolation-factor
  32659. * @return The mixed value
  32660. */
  32661. static Mix(a: number, b: number, alpha: number): number;
  32662. /**
  32663. * Tries to instantiate a new object from a given class name
  32664. * @param className defines the class name to instantiate
  32665. * @returns the new object or null if the system was not able to do the instantiation
  32666. */
  32667. static Instantiate(className: string): any;
  32668. /**
  32669. * Provides a slice function that will work even on IE
  32670. * @param data defines the array to slice
  32671. * @param start defines the start of the data (optional)
  32672. * @param end defines the end of the data (optional)
  32673. * @returns the new sliced array
  32674. */
  32675. static Slice<T>(data: T, start?: number, end?: number): T;
  32676. /**
  32677. * Polyfill for setImmediate
  32678. * @param action defines the action to execute after the current execution block
  32679. */
  32680. static SetImmediate(action: () => void): void;
  32681. /**
  32682. * Function indicating if a number is an exponent of 2
  32683. * @param value defines the value to test
  32684. * @returns true if the value is an exponent of 2
  32685. */
  32686. static IsExponentOfTwo(value: number): boolean;
  32687. private static _tmpFloatArray;
  32688. /**
  32689. * Returns the nearest 32-bit single precision float representation of a Number
  32690. * @param value A Number. If the parameter is of a different type, it will get converted
  32691. * to a number or to NaN if it cannot be converted
  32692. * @returns number
  32693. */
  32694. static FloatRound(value: number): number;
  32695. /**
  32696. * Extracts the filename from a path
  32697. * @param path defines the path to use
  32698. * @returns the filename
  32699. */
  32700. static GetFilename(path: string): string;
  32701. /**
  32702. * Extracts the "folder" part of a path (everything before the filename).
  32703. * @param uri The URI to extract the info from
  32704. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32705. * @returns The "folder" part of the path
  32706. */
  32707. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32708. /**
  32709. * Extracts text content from a DOM element hierarchy
  32710. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32711. */
  32712. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32713. /**
  32714. * Convert an angle in radians to degrees
  32715. * @param angle defines the angle to convert
  32716. * @returns the angle in degrees
  32717. */
  32718. static ToDegrees(angle: number): number;
  32719. /**
  32720. * Convert an angle in degrees to radians
  32721. * @param angle defines the angle to convert
  32722. * @returns the angle in radians
  32723. */
  32724. static ToRadians(angle: number): number;
  32725. /**
  32726. * Encode a buffer to a base64 string
  32727. * @param buffer defines the buffer to encode
  32728. * @returns the encoded string
  32729. */
  32730. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32731. /**
  32732. * Returns an array if obj is not an array
  32733. * @param obj defines the object to evaluate as an array
  32734. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32735. * @returns either obj directly if obj is an array or a new array containing obj
  32736. */
  32737. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32738. /**
  32739. * Gets the pointer prefix to use
  32740. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32741. */
  32742. static GetPointerPrefix(): string;
  32743. /**
  32744. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32745. * @param url define the url we are trying
  32746. * @param element define the dom element where to configure the cors policy
  32747. */
  32748. static SetCorsBehavior(url: string | string[], element: {
  32749. crossOrigin: string | null;
  32750. }): void;
  32751. /**
  32752. * Removes unwanted characters from an url
  32753. * @param url defines the url to clean
  32754. * @returns the cleaned url
  32755. */
  32756. static CleanUrl(url: string): string;
  32757. /**
  32758. * Gets or sets a function used to pre-process url before using them to load assets
  32759. */
  32760. static PreprocessUrl: (url: string) => string;
  32761. /**
  32762. * Loads an image as an HTMLImageElement.
  32763. * @param input url string, ArrayBuffer, or Blob to load
  32764. * @param onLoad callback called when the image successfully loads
  32765. * @param onError callback called when the image fails to load
  32766. * @param offlineProvider offline provider for caching
  32767. * @returns the HTMLImageElement of the loaded image
  32768. */
  32769. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32770. /**
  32771. * Loads a file
  32772. * @param url url string, ArrayBuffer, or Blob to load
  32773. * @param onSuccess callback called when the file successfully loads
  32774. * @param onProgress callback called while file is loading (if the server supports this mode)
  32775. * @param offlineProvider defines the offline provider for caching
  32776. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32777. * @param onError callback called when the file fails to load
  32778. * @returns a file request object
  32779. */
  32780. 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;
  32781. /**
  32782. * Loads a file from a url
  32783. * @param url the file url to load
  32784. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32785. */
  32786. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32787. /**
  32788. * Load a script (identified by an url). When the url returns, the
  32789. * content of this file is added into a new script element, attached to the DOM (body element)
  32790. * @param scriptUrl defines the url of the script to laod
  32791. * @param onSuccess defines the callback called when the script is loaded
  32792. * @param onError defines the callback to call if an error occurs
  32793. * @param scriptId defines the id of the script element
  32794. */
  32795. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32796. /**
  32797. * Load an asynchronous script (identified by an url). When the url returns, the
  32798. * content of this file is added into a new script element, attached to the DOM (body element)
  32799. * @param scriptUrl defines the url of the script to laod
  32800. * @param scriptId defines the id of the script element
  32801. * @returns a promise request object
  32802. */
  32803. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32804. /**
  32805. * Loads a file from a blob
  32806. * @param fileToLoad defines the blob to use
  32807. * @param callback defines the callback to call when data is loaded
  32808. * @param progressCallback defines the callback to call during loading process
  32809. * @returns a file request object
  32810. */
  32811. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32812. /**
  32813. * Loads a file
  32814. * @param fileToLoad defines the file to load
  32815. * @param callback defines the callback to call when data is loaded
  32816. * @param progressCallBack defines the callback to call during loading process
  32817. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32818. * @returns a file request object
  32819. */
  32820. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32821. /**
  32822. * Creates a data url from a given string content
  32823. * @param content defines the content to convert
  32824. * @returns the new data url link
  32825. */
  32826. static FileAsURL(content: string): string;
  32827. /**
  32828. * Format the given number to a specific decimal format
  32829. * @param value defines the number to format
  32830. * @param decimals defines the number of decimals to use
  32831. * @returns the formatted string
  32832. */
  32833. static Format(value: number, decimals?: number): string;
  32834. /**
  32835. * Tries to copy an object by duplicating every property
  32836. * @param source defines the source object
  32837. * @param destination defines the target object
  32838. * @param doNotCopyList defines a list of properties to avoid
  32839. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32840. */
  32841. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32842. /**
  32843. * Gets a boolean indicating if the given object has no own property
  32844. * @param obj defines the object to test
  32845. * @returns true if object has no own property
  32846. */
  32847. static IsEmpty(obj: any): boolean;
  32848. /**
  32849. * Function used to register events at window level
  32850. * @param windowElement defines the Window object to use
  32851. * @param events defines the events to register
  32852. */
  32853. static RegisterTopRootEvents(windowElement: Window, events: {
  32854. name: string;
  32855. handler: Nullable<(e: FocusEvent) => any>;
  32856. }[]): void;
  32857. /**
  32858. * Function used to unregister events from window level
  32859. * @param windowElement defines the Window object to use
  32860. * @param events defines the events to unregister
  32861. */
  32862. static UnregisterTopRootEvents(windowElement: Window, events: {
  32863. name: string;
  32864. handler: Nullable<(e: FocusEvent) => any>;
  32865. }[]): void;
  32866. /**
  32867. * @ignore
  32868. */
  32869. static _ScreenshotCanvas: HTMLCanvasElement;
  32870. /**
  32871. * Dumps the current bound framebuffer
  32872. * @param width defines the rendering width
  32873. * @param height defines the rendering height
  32874. * @param engine defines the hosting engine
  32875. * @param successCallback defines the callback triggered once the data are available
  32876. * @param mimeType defines the mime type of the result
  32877. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32878. */
  32879. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32880. /**
  32881. * Converts the canvas data to blob.
  32882. * This acts as a polyfill for browsers not supporting the to blob function.
  32883. * @param canvas Defines the canvas to extract the data from
  32884. * @param successCallback Defines the callback triggered once the data are available
  32885. * @param mimeType Defines the mime type of the result
  32886. */
  32887. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32888. /**
  32889. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32890. * @param successCallback defines the callback triggered once the data are available
  32891. * @param mimeType defines the mime type of the result
  32892. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32893. */
  32894. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32895. /**
  32896. * Downloads a blob in the browser
  32897. * @param blob defines the blob to download
  32898. * @param fileName defines the name of the downloaded file
  32899. */
  32900. static Download(blob: Blob, fileName: string): void;
  32901. /**
  32902. * Captures a screenshot of the current rendering
  32903. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32904. * @param engine defines the rendering engine
  32905. * @param camera defines the source camera
  32906. * @param size This parameter can be set to a single number or to an object with the
  32907. * following (optional) properties: precision, width, height. If a single number is passed,
  32908. * it will be used for both width and height. If an object is passed, the screenshot size
  32909. * will be derived from the parameters. The precision property is a multiplier allowing
  32910. * rendering at a higher or lower resolution
  32911. * @param successCallback defines the callback receives a single parameter which contains the
  32912. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32913. * src parameter of an <img> to display it
  32914. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32915. * Check your browser for supported MIME types
  32916. */
  32917. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32918. /**
  32919. * Captures a screenshot of the current rendering
  32920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32921. * @param engine defines the rendering engine
  32922. * @param camera defines the source camera
  32923. * @param size This parameter can be set to a single number or to an object with the
  32924. * following (optional) properties: precision, width, height. If a single number is passed,
  32925. * it will be used for both width and height. If an object is passed, the screenshot size
  32926. * will be derived from the parameters. The precision property is a multiplier allowing
  32927. * rendering at a higher or lower resolution
  32928. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32929. * Check your browser for supported MIME types
  32930. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32931. * to the src parameter of an <img> to display it
  32932. */
  32933. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32934. /**
  32935. * Generates an image screenshot from the specified camera.
  32936. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32937. * @param engine The engine to use for rendering
  32938. * @param camera The camera to use for rendering
  32939. * @param size This parameter can be set to a single number or to an object with the
  32940. * following (optional) properties: precision, width, height. If a single number is passed,
  32941. * it will be used for both width and height. If an object is passed, the screenshot size
  32942. * will be derived from the parameters. The precision property is a multiplier allowing
  32943. * rendering at a higher or lower resolution
  32944. * @param successCallback The callback receives a single parameter which contains the
  32945. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32946. * src parameter of an <img> to display it
  32947. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32948. * Check your browser for supported MIME types
  32949. * @param samples Texture samples (default: 1)
  32950. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32951. * @param fileName A name for for the downloaded file.
  32952. */
  32953. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32954. /**
  32955. * Generates an image screenshot from the specified camera.
  32956. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32957. * @param engine The engine to use for rendering
  32958. * @param camera The camera to use for rendering
  32959. * @param size This parameter can be set to a single number or to an object with the
  32960. * following (optional) properties: precision, width, height. If a single number is passed,
  32961. * it will be used for both width and height. If an object is passed, the screenshot size
  32962. * will be derived from the parameters. The precision property is a multiplier allowing
  32963. * rendering at a higher or lower resolution
  32964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32965. * Check your browser for supported MIME types
  32966. * @param samples Texture samples (default: 1)
  32967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32968. * @param fileName A name for for the downloaded file.
  32969. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32970. * to the src parameter of an <img> to display it
  32971. */
  32972. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32973. /**
  32974. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32975. * Be aware Math.random() could cause collisions, but:
  32976. * "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"
  32977. * @returns a pseudo random id
  32978. */
  32979. static RandomId(): string;
  32980. /**
  32981. * Test if the given uri is a base64 string
  32982. * @param uri The uri to test
  32983. * @return True if the uri is a base64 string or false otherwise
  32984. */
  32985. static IsBase64(uri: string): boolean;
  32986. /**
  32987. * Decode the given base64 uri.
  32988. * @param uri The uri to decode
  32989. * @return The decoded base64 data.
  32990. */
  32991. static DecodeBase64(uri: string): ArrayBuffer;
  32992. /**
  32993. * Gets the absolute url.
  32994. * @param url the input url
  32995. * @return the absolute url
  32996. */
  32997. static GetAbsoluteUrl(url: string): string;
  32998. /**
  32999. * No log
  33000. */
  33001. static readonly NoneLogLevel: number;
  33002. /**
  33003. * Only message logs
  33004. */
  33005. static readonly MessageLogLevel: number;
  33006. /**
  33007. * Only warning logs
  33008. */
  33009. static readonly WarningLogLevel: number;
  33010. /**
  33011. * Only error logs
  33012. */
  33013. static readonly ErrorLogLevel: number;
  33014. /**
  33015. * All logs
  33016. */
  33017. static readonly AllLogLevel: number;
  33018. /**
  33019. * Gets a value indicating the number of loading errors
  33020. * @ignorenaming
  33021. */
  33022. static readonly errorsCount: number;
  33023. /**
  33024. * Callback called when a new log is added
  33025. */
  33026. static OnNewCacheEntry: (entry: string) => void;
  33027. /**
  33028. * Log a message to the console
  33029. * @param message defines the message to log
  33030. */
  33031. static Log(message: string): void;
  33032. /**
  33033. * Write a warning message to the console
  33034. * @param message defines the message to log
  33035. */
  33036. static Warn(message: string): void;
  33037. /**
  33038. * Write an error message to the console
  33039. * @param message defines the message to log
  33040. */
  33041. static Error(message: string): void;
  33042. /**
  33043. * Gets current log cache (list of logs)
  33044. */
  33045. static readonly LogCache: string;
  33046. /**
  33047. * Clears the log cache
  33048. */
  33049. static ClearLogCache(): void;
  33050. /**
  33051. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33052. */
  33053. static LogLevels: number;
  33054. /**
  33055. * Checks if the window object exists
  33056. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33057. */
  33058. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33059. /**
  33060. * No performance log
  33061. */
  33062. static readonly PerformanceNoneLogLevel: number;
  33063. /**
  33064. * Use user marks to log performance
  33065. */
  33066. static readonly PerformanceUserMarkLogLevel: number;
  33067. /**
  33068. * Log performance to the console
  33069. */
  33070. static readonly PerformanceConsoleLogLevel: number;
  33071. private static _performance;
  33072. /**
  33073. * Sets the current performance log level
  33074. */
  33075. static PerformanceLogLevel: number;
  33076. private static _StartPerformanceCounterDisabled;
  33077. private static _EndPerformanceCounterDisabled;
  33078. private static _StartUserMark;
  33079. private static _EndUserMark;
  33080. private static _StartPerformanceConsole;
  33081. private static _EndPerformanceConsole;
  33082. /**
  33083. * Starts a performance counter
  33084. */
  33085. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33086. /**
  33087. * Ends a specific performance coutner
  33088. */
  33089. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33090. /**
  33091. * Gets either window.performance.now() if supported or Date.now() else
  33092. */
  33093. static readonly Now: number;
  33094. /**
  33095. * This method will return the name of the class used to create the instance of the given object.
  33096. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33097. * @param object the object to get the class name from
  33098. * @param isType defines if the object is actually a type
  33099. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33100. */
  33101. static GetClassName(object: any, isType?: boolean): string;
  33102. /**
  33103. * Gets the first element of an array satisfying a given predicate
  33104. * @param array defines the array to browse
  33105. * @param predicate defines the predicate to use
  33106. * @returns null if not found or the element
  33107. */
  33108. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33109. /**
  33110. * This method will return the name of the full name of the class, including its owning module (if any).
  33111. * 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).
  33112. * @param object the object to get the class name from
  33113. * @param isType defines if the object is actually a type
  33114. * @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.
  33115. * @ignorenaming
  33116. */
  33117. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33118. /**
  33119. * Returns a promise that resolves after the given amount of time.
  33120. * @param delay Number of milliseconds to delay
  33121. * @returns Promise that resolves after the given amount of time
  33122. */
  33123. static DelayAsync(delay: number): Promise<void>;
  33124. }
  33125. /**
  33126. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33127. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33128. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33129. * @param name The name of the class, case should be preserved
  33130. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33131. */
  33132. export function className(name: string, module?: string): (target: Object) => void;
  33133. /**
  33134. * An implementation of a loop for asynchronous functions.
  33135. */
  33136. export class AsyncLoop {
  33137. /**
  33138. * Defines the number of iterations for the loop
  33139. */
  33140. iterations: number;
  33141. /**
  33142. * Defines the current index of the loop.
  33143. */
  33144. index: number;
  33145. private _done;
  33146. private _fn;
  33147. private _successCallback;
  33148. /**
  33149. * Constructor.
  33150. * @param iterations the number of iterations.
  33151. * @param func the function to run each iteration
  33152. * @param successCallback the callback that will be called upon succesful execution
  33153. * @param offset starting offset.
  33154. */
  33155. constructor(
  33156. /**
  33157. * Defines the number of iterations for the loop
  33158. */
  33159. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33160. /**
  33161. * Execute the next iteration. Must be called after the last iteration was finished.
  33162. */
  33163. executeNext(): void;
  33164. /**
  33165. * Break the loop and run the success callback.
  33166. */
  33167. breakLoop(): void;
  33168. /**
  33169. * Create and run an async loop.
  33170. * @param iterations the number of iterations.
  33171. * @param fn the function to run each iteration
  33172. * @param successCallback the callback that will be called upon succesful execution
  33173. * @param offset starting offset.
  33174. * @returns the created async loop object
  33175. */
  33176. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33177. /**
  33178. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33179. * @param iterations total number of iterations
  33180. * @param syncedIterations number of synchronous iterations in each async iteration.
  33181. * @param fn the function to call each iteration.
  33182. * @param callback a success call back that will be called when iterating stops.
  33183. * @param breakFunction a break condition (optional)
  33184. * @param timeout timeout settings for the setTimeout function. default - 0.
  33185. * @returns the created async loop object
  33186. */
  33187. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33188. }
  33189. }
  33190. declare module "babylonjs/Collisions/collisionCoordinator" {
  33191. import { Nullable } from "babylonjs/types";
  33192. import { Scene } from "babylonjs/scene";
  33193. import { Vector3 } from "babylonjs/Maths/math.vector";
  33194. import { Collider } from "babylonjs/Collisions/collider";
  33195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33196. /** @hidden */
  33197. export interface ICollisionCoordinator {
  33198. createCollider(): Collider;
  33199. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33200. init(scene: Scene): void;
  33201. }
  33202. /** @hidden */
  33203. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33204. private _scene;
  33205. private _scaledPosition;
  33206. private _scaledVelocity;
  33207. private _finalPosition;
  33208. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33209. createCollider(): Collider;
  33210. init(scene: Scene): void;
  33211. private _collideWithWorld;
  33212. }
  33213. }
  33214. declare module "babylonjs/Inputs/scene.inputManager" {
  33215. import { Nullable } from "babylonjs/types";
  33216. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33217. import { Vector2 } from "babylonjs/Maths/math.vector";
  33218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33219. import { Scene } from "babylonjs/scene";
  33220. /**
  33221. * Class used to manage all inputs for the scene.
  33222. */
  33223. export class InputManager {
  33224. /** The distance in pixel that you have to move to prevent some events */
  33225. static DragMovementThreshold: number;
  33226. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33227. static LongPressDelay: number;
  33228. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33229. static DoubleClickDelay: number;
  33230. /** If you need to check double click without raising a single click at first click, enable this flag */
  33231. static ExclusiveDoubleClickMode: boolean;
  33232. private _wheelEventName;
  33233. private _onPointerMove;
  33234. private _onPointerDown;
  33235. private _onPointerUp;
  33236. private _initClickEvent;
  33237. private _initActionManager;
  33238. private _delayedSimpleClick;
  33239. private _delayedSimpleClickTimeout;
  33240. private _previousDelayedSimpleClickTimeout;
  33241. private _meshPickProceed;
  33242. private _previousButtonPressed;
  33243. private _currentPickResult;
  33244. private _previousPickResult;
  33245. private _totalPointersPressed;
  33246. private _doubleClickOccured;
  33247. private _pointerOverMesh;
  33248. private _pickedDownMesh;
  33249. private _pickedUpMesh;
  33250. private _pointerX;
  33251. private _pointerY;
  33252. private _unTranslatedPointerX;
  33253. private _unTranslatedPointerY;
  33254. private _startingPointerPosition;
  33255. private _previousStartingPointerPosition;
  33256. private _startingPointerTime;
  33257. private _previousStartingPointerTime;
  33258. private _pointerCaptures;
  33259. private _onKeyDown;
  33260. private _onKeyUp;
  33261. private _onCanvasFocusObserver;
  33262. private _onCanvasBlurObserver;
  33263. private _scene;
  33264. /**
  33265. * Creates a new InputManager
  33266. * @param scene defines the hosting scene
  33267. */
  33268. constructor(scene: Scene);
  33269. /**
  33270. * Gets the mesh that is currently under the pointer
  33271. */
  33272. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33273. /**
  33274. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33275. */
  33276. readonly unTranslatedPointer: Vector2;
  33277. /**
  33278. * Gets or sets the current on-screen X position of the pointer
  33279. */
  33280. pointerX: number;
  33281. /**
  33282. * Gets or sets the current on-screen Y position of the pointer
  33283. */
  33284. pointerY: number;
  33285. private _updatePointerPosition;
  33286. private _processPointerMove;
  33287. private _setRayOnPointerInfo;
  33288. private _checkPrePointerObservable;
  33289. /**
  33290. * Use this method to simulate a pointer move on a mesh
  33291. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33292. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33293. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33294. */
  33295. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33296. /**
  33297. * Use this method to simulate a pointer down on a mesh
  33298. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33299. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33300. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33301. */
  33302. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33303. private _processPointerDown;
  33304. /** @hidden */
  33305. _isPointerSwiping(): boolean;
  33306. /**
  33307. * Use this method to simulate a pointer up on a mesh
  33308. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33309. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33310. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33311. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33312. */
  33313. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33314. private _processPointerUp;
  33315. /**
  33316. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33317. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33318. * @returns true if the pointer was captured
  33319. */
  33320. isPointerCaptured(pointerId?: number): boolean;
  33321. /**
  33322. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33323. * @param attachUp defines if you want to attach events to pointerup
  33324. * @param attachDown defines if you want to attach events to pointerdown
  33325. * @param attachMove defines if you want to attach events to pointermove
  33326. */
  33327. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33328. /**
  33329. * Detaches all event handlers
  33330. */
  33331. detachControl(): void;
  33332. /**
  33333. * Force the value of meshUnderPointer
  33334. * @param mesh defines the mesh to use
  33335. */
  33336. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33337. /**
  33338. * Gets the mesh under the pointer
  33339. * @returns a Mesh or null if no mesh is under the pointer
  33340. */
  33341. getPointerOverMesh(): Nullable<AbstractMesh>;
  33342. }
  33343. }
  33344. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33345. /**
  33346. * Helper class used to generate session unique ID
  33347. */
  33348. export class UniqueIdGenerator {
  33349. private static _UniqueIdCounter;
  33350. /**
  33351. * Gets an unique (relatively to the current scene) Id
  33352. */
  33353. static readonly UniqueId: number;
  33354. }
  33355. }
  33356. declare module "babylonjs/Animations/animationGroup" {
  33357. import { Animatable } from "babylonjs/Animations/animatable";
  33358. import { Animation } from "babylonjs/Animations/animation";
  33359. import { Scene, IDisposable } from "babylonjs/scene";
  33360. import { Observable } from "babylonjs/Misc/observable";
  33361. import { Nullable } from "babylonjs/types";
  33362. import "babylonjs/Animations/animatable";
  33363. /**
  33364. * This class defines the direct association between an animation and a target
  33365. */
  33366. export class TargetedAnimation {
  33367. /**
  33368. * Animation to perform
  33369. */
  33370. animation: Animation;
  33371. /**
  33372. * Target to animate
  33373. */
  33374. target: any;
  33375. /**
  33376. * Serialize the object
  33377. * @returns the JSON object representing the current entity
  33378. */
  33379. serialize(): any;
  33380. }
  33381. /**
  33382. * Use this class to create coordinated animations on multiple targets
  33383. */
  33384. export class AnimationGroup implements IDisposable {
  33385. /** The name of the animation group */
  33386. name: string;
  33387. private _scene;
  33388. private _targetedAnimations;
  33389. private _animatables;
  33390. private _from;
  33391. private _to;
  33392. private _isStarted;
  33393. private _isPaused;
  33394. private _speedRatio;
  33395. private _loopAnimation;
  33396. /**
  33397. * Gets or sets the unique id of the node
  33398. */
  33399. uniqueId: number;
  33400. /**
  33401. * This observable will notify when one animation have ended
  33402. */
  33403. onAnimationEndObservable: Observable<TargetedAnimation>;
  33404. /**
  33405. * Observer raised when one animation loops
  33406. */
  33407. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33408. /**
  33409. * This observable will notify when all animations have ended.
  33410. */
  33411. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33412. /**
  33413. * This observable will notify when all animations have paused.
  33414. */
  33415. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33416. /**
  33417. * This observable will notify when all animations are playing.
  33418. */
  33419. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33420. /**
  33421. * Gets the first frame
  33422. */
  33423. readonly from: number;
  33424. /**
  33425. * Gets the last frame
  33426. */
  33427. readonly to: number;
  33428. /**
  33429. * Define if the animations are started
  33430. */
  33431. readonly isStarted: boolean;
  33432. /**
  33433. * Gets a value indicating that the current group is playing
  33434. */
  33435. readonly isPlaying: boolean;
  33436. /**
  33437. * Gets or sets the speed ratio to use for all animations
  33438. */
  33439. /**
  33440. * Gets or sets the speed ratio to use for all animations
  33441. */
  33442. speedRatio: number;
  33443. /**
  33444. * Gets or sets if all animations should loop or not
  33445. */
  33446. loopAnimation: boolean;
  33447. /**
  33448. * Gets the targeted animations for this animation group
  33449. */
  33450. readonly targetedAnimations: Array<TargetedAnimation>;
  33451. /**
  33452. * returning the list of animatables controlled by this animation group.
  33453. */
  33454. readonly animatables: Array<Animatable>;
  33455. /**
  33456. * Instantiates a new Animation Group.
  33457. * This helps managing several animations at once.
  33458. * @see http://doc.babylonjs.com/how_to/group
  33459. * @param name Defines the name of the group
  33460. * @param scene Defines the scene the group belongs to
  33461. */
  33462. constructor(
  33463. /** The name of the animation group */
  33464. name: string, scene?: Nullable<Scene>);
  33465. /**
  33466. * Add an animation (with its target) in the group
  33467. * @param animation defines the animation we want to add
  33468. * @param target defines the target of the animation
  33469. * @returns the TargetedAnimation object
  33470. */
  33471. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33472. /**
  33473. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33474. * It can add constant keys at begin or end
  33475. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33476. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33477. * @returns the animation group
  33478. */
  33479. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33480. /**
  33481. * Start all animations on given targets
  33482. * @param loop defines if animations must loop
  33483. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33484. * @param from defines the from key (optional)
  33485. * @param to defines the to key (optional)
  33486. * @returns the current animation group
  33487. */
  33488. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33489. /**
  33490. * Pause all animations
  33491. * @returns the animation group
  33492. */
  33493. pause(): AnimationGroup;
  33494. /**
  33495. * Play all animations to initial state
  33496. * This function will start() the animations if they were not started or will restart() them if they were paused
  33497. * @param loop defines if animations must loop
  33498. * @returns the animation group
  33499. */
  33500. play(loop?: boolean): AnimationGroup;
  33501. /**
  33502. * Reset all animations to initial state
  33503. * @returns the animation group
  33504. */
  33505. reset(): AnimationGroup;
  33506. /**
  33507. * Restart animations from key 0
  33508. * @returns the animation group
  33509. */
  33510. restart(): AnimationGroup;
  33511. /**
  33512. * Stop all animations
  33513. * @returns the animation group
  33514. */
  33515. stop(): AnimationGroup;
  33516. /**
  33517. * Set animation weight for all animatables
  33518. * @param weight defines the weight to use
  33519. * @return the animationGroup
  33520. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33521. */
  33522. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33523. /**
  33524. * Synchronize and normalize all animatables with a source animatable
  33525. * @param root defines the root animatable to synchronize with
  33526. * @return the animationGroup
  33527. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33528. */
  33529. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33530. /**
  33531. * Goes to a specific frame in this animation group
  33532. * @param frame the frame number to go to
  33533. * @return the animationGroup
  33534. */
  33535. goToFrame(frame: number): AnimationGroup;
  33536. /**
  33537. * Dispose all associated resources
  33538. */
  33539. dispose(): void;
  33540. private _checkAnimationGroupEnded;
  33541. /**
  33542. * Clone the current animation group and returns a copy
  33543. * @param newName defines the name of the new group
  33544. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33545. * @returns the new aniamtion group
  33546. */
  33547. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33548. /**
  33549. * Serializes the animationGroup to an object
  33550. * @returns Serialized object
  33551. */
  33552. serialize(): any;
  33553. /**
  33554. * Returns a new AnimationGroup object parsed from the source provided.
  33555. * @param parsedAnimationGroup defines the source
  33556. * @param scene defines the scene that will receive the animationGroup
  33557. * @returns a new AnimationGroup
  33558. */
  33559. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33560. /**
  33561. * Returns the string "AnimationGroup"
  33562. * @returns "AnimationGroup"
  33563. */
  33564. getClassName(): string;
  33565. /**
  33566. * Creates a detailled string about the object
  33567. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33568. * @returns a string representing the object
  33569. */
  33570. toString(fullDetails?: boolean): string;
  33571. }
  33572. }
  33573. declare module "babylonjs/scene" {
  33574. import { Nullable } from "babylonjs/types";
  33575. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33576. import { Observable } from "babylonjs/Misc/observable";
  33577. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33578. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33579. import { Geometry } from "babylonjs/Meshes/geometry";
  33580. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33581. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33583. import { Mesh } from "babylonjs/Meshes/mesh";
  33584. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33585. import { Bone } from "babylonjs/Bones/bone";
  33586. import { Skeleton } from "babylonjs/Bones/skeleton";
  33587. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33588. import { Camera } from "babylonjs/Cameras/camera";
  33589. import { AbstractScene } from "babylonjs/abstractScene";
  33590. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33591. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33592. import { Material } from "babylonjs/Materials/material";
  33593. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33594. import { Effect } from "babylonjs/Materials/effect";
  33595. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33596. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33597. import { Light } from "babylonjs/Lights/light";
  33598. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33599. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33600. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33601. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33602. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33603. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33604. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33605. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33606. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33607. import { Engine } from "babylonjs/Engines/engine";
  33608. import { Node } from "babylonjs/node";
  33609. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33610. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33611. import { WebRequest } from "babylonjs/Misc/webRequest";
  33612. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33613. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33614. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33615. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33616. import { Plane } from "babylonjs/Maths/math.plane";
  33617. import { Ray } from "babylonjs/Culling/ray";
  33618. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33619. import { Animation } from "babylonjs/Animations/animation";
  33620. import { Animatable } from "babylonjs/Animations/animatable";
  33621. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33622. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33623. import { Collider } from "babylonjs/Collisions/collider";
  33624. /**
  33625. * Define an interface for all classes that will hold resources
  33626. */
  33627. export interface IDisposable {
  33628. /**
  33629. * Releases all held resources
  33630. */
  33631. dispose(): void;
  33632. }
  33633. /** Interface defining initialization parameters for Scene class */
  33634. export interface SceneOptions {
  33635. /**
  33636. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33637. * It will improve performance when the number of geometries becomes important.
  33638. */
  33639. useGeometryUniqueIdsMap?: boolean;
  33640. /**
  33641. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33642. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33643. */
  33644. useMaterialMeshMap?: boolean;
  33645. /**
  33646. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33647. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33648. */
  33649. useClonedMeshhMap?: boolean;
  33650. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33651. virtual?: boolean;
  33652. }
  33653. /**
  33654. * Represents a scene to be rendered by the engine.
  33655. * @see http://doc.babylonjs.com/features/scene
  33656. */
  33657. export class Scene extends AbstractScene implements IAnimatable {
  33658. /** The fog is deactivated */
  33659. static readonly FOGMODE_NONE: number;
  33660. /** The fog density is following an exponential function */
  33661. static readonly FOGMODE_EXP: number;
  33662. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33663. static readonly FOGMODE_EXP2: number;
  33664. /** The fog density is following a linear function. */
  33665. static readonly FOGMODE_LINEAR: number;
  33666. /**
  33667. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33668. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33669. */
  33670. static MinDeltaTime: number;
  33671. /**
  33672. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33673. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33674. */
  33675. static MaxDeltaTime: number;
  33676. /**
  33677. * Factory used to create the default material.
  33678. * @param name The name of the material to create
  33679. * @param scene The scene to create the material for
  33680. * @returns The default material
  33681. */
  33682. static DefaultMaterialFactory(scene: Scene): Material;
  33683. /**
  33684. * Factory used to create the a collision coordinator.
  33685. * @returns The collision coordinator
  33686. */
  33687. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33688. /** @hidden */
  33689. _inputManager: InputManager;
  33690. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33691. cameraToUseForPointers: Nullable<Camera>;
  33692. /** @hidden */
  33693. readonly _isScene: boolean;
  33694. /**
  33695. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33696. */
  33697. autoClear: boolean;
  33698. /**
  33699. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33700. */
  33701. autoClearDepthAndStencil: boolean;
  33702. /**
  33703. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33704. */
  33705. clearColor: Color4;
  33706. /**
  33707. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33708. */
  33709. ambientColor: Color3;
  33710. /**
  33711. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33712. * It should only be one of the following (if not the default embedded one):
  33713. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33714. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33715. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33716. * The material properties need to be setup according to the type of texture in use.
  33717. */
  33718. environmentBRDFTexture: BaseTexture;
  33719. /** @hidden */
  33720. protected _environmentTexture: Nullable<BaseTexture>;
  33721. /**
  33722. * Texture used in all pbr material as the reflection texture.
  33723. * As in the majority of the scene they are the same (exception for multi room and so on),
  33724. * this is easier to reference from here than from all the materials.
  33725. */
  33726. /**
  33727. * Texture used in all pbr material as the reflection texture.
  33728. * As in the majority of the scene they are the same (exception for multi room and so on),
  33729. * this is easier to set here than in all the materials.
  33730. */
  33731. environmentTexture: Nullable<BaseTexture>;
  33732. /** @hidden */
  33733. protected _environmentIntensity: number;
  33734. /**
  33735. * Intensity of the environment in all pbr material.
  33736. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33737. * As in the majority of the scene they are the same (exception for multi room and so on),
  33738. * this is easier to reference from here than from all the materials.
  33739. */
  33740. /**
  33741. * Intensity of the environment in all pbr material.
  33742. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33743. * As in the majority of the scene they are the same (exception for multi room and so on),
  33744. * this is easier to set here than in all the materials.
  33745. */
  33746. environmentIntensity: number;
  33747. /** @hidden */
  33748. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33749. /**
  33750. * Default image processing configuration used either in the rendering
  33751. * Forward main pass or through the imageProcessingPostProcess if present.
  33752. * As in the majority of the scene they are the same (exception for multi camera),
  33753. * this is easier to reference from here than from all the materials and post process.
  33754. *
  33755. * No setter as we it is a shared configuration, you can set the values instead.
  33756. */
  33757. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33758. private _forceWireframe;
  33759. /**
  33760. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33761. */
  33762. forceWireframe: boolean;
  33763. private _forcePointsCloud;
  33764. /**
  33765. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33766. */
  33767. forcePointsCloud: boolean;
  33768. /**
  33769. * Gets or sets the active clipplane 1
  33770. */
  33771. clipPlane: Nullable<Plane>;
  33772. /**
  33773. * Gets or sets the active clipplane 2
  33774. */
  33775. clipPlane2: Nullable<Plane>;
  33776. /**
  33777. * Gets or sets the active clipplane 3
  33778. */
  33779. clipPlane3: Nullable<Plane>;
  33780. /**
  33781. * Gets or sets the active clipplane 4
  33782. */
  33783. clipPlane4: Nullable<Plane>;
  33784. /**
  33785. * Gets or sets a boolean indicating if animations are enabled
  33786. */
  33787. animationsEnabled: boolean;
  33788. private _animationPropertiesOverride;
  33789. /**
  33790. * Gets or sets the animation properties override
  33791. */
  33792. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33793. /**
  33794. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33795. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33796. */
  33797. useConstantAnimationDeltaTime: boolean;
  33798. /**
  33799. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33800. * Please note that it requires to run a ray cast through the scene on every frame
  33801. */
  33802. constantlyUpdateMeshUnderPointer: boolean;
  33803. /**
  33804. * Defines the HTML cursor to use when hovering over interactive elements
  33805. */
  33806. hoverCursor: string;
  33807. /**
  33808. * Defines the HTML default cursor to use (empty by default)
  33809. */
  33810. defaultCursor: string;
  33811. /**
  33812. * This is used to call preventDefault() on pointer down
  33813. * in order to block unwanted artifacts like system double clicks
  33814. */
  33815. preventDefaultOnPointerDown: boolean;
  33816. /**
  33817. * This is used to call preventDefault() on pointer up
  33818. * in order to block unwanted artifacts like system double clicks
  33819. */
  33820. preventDefaultOnPointerUp: boolean;
  33821. /**
  33822. * Gets or sets user defined metadata
  33823. */
  33824. metadata: any;
  33825. /**
  33826. * For internal use only. Please do not use.
  33827. */
  33828. reservedDataStore: any;
  33829. /**
  33830. * Gets the name of the plugin used to load this scene (null by default)
  33831. */
  33832. loadingPluginName: string;
  33833. /**
  33834. * Use this array to add regular expressions used to disable offline support for specific urls
  33835. */
  33836. disableOfflineSupportExceptionRules: RegExp[];
  33837. /**
  33838. * An event triggered when the scene is disposed.
  33839. */
  33840. onDisposeObservable: Observable<Scene>;
  33841. private _onDisposeObserver;
  33842. /** Sets a function to be executed when this scene is disposed. */
  33843. onDispose: () => void;
  33844. /**
  33845. * An event triggered before rendering the scene (right after animations and physics)
  33846. */
  33847. onBeforeRenderObservable: Observable<Scene>;
  33848. private _onBeforeRenderObserver;
  33849. /** Sets a function to be executed before rendering this scene */
  33850. beforeRender: Nullable<() => void>;
  33851. /**
  33852. * An event triggered after rendering the scene
  33853. */
  33854. onAfterRenderObservable: Observable<Scene>;
  33855. /**
  33856. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33857. */
  33858. onAfterRenderCameraObservable: Observable<Camera>;
  33859. private _onAfterRenderObserver;
  33860. /** Sets a function to be executed after rendering this scene */
  33861. afterRender: Nullable<() => void>;
  33862. /**
  33863. * An event triggered before animating the scene
  33864. */
  33865. onBeforeAnimationsObservable: Observable<Scene>;
  33866. /**
  33867. * An event triggered after animations processing
  33868. */
  33869. onAfterAnimationsObservable: Observable<Scene>;
  33870. /**
  33871. * An event triggered before draw calls are ready to be sent
  33872. */
  33873. onBeforeDrawPhaseObservable: Observable<Scene>;
  33874. /**
  33875. * An event triggered after draw calls have been sent
  33876. */
  33877. onAfterDrawPhaseObservable: Observable<Scene>;
  33878. /**
  33879. * An event triggered when the scene is ready
  33880. */
  33881. onReadyObservable: Observable<Scene>;
  33882. /**
  33883. * An event triggered before rendering a camera
  33884. */
  33885. onBeforeCameraRenderObservable: Observable<Camera>;
  33886. private _onBeforeCameraRenderObserver;
  33887. /** Sets a function to be executed before rendering a camera*/
  33888. beforeCameraRender: () => void;
  33889. /**
  33890. * An event triggered after rendering a camera
  33891. */
  33892. onAfterCameraRenderObservable: Observable<Camera>;
  33893. private _onAfterCameraRenderObserver;
  33894. /** Sets a function to be executed after rendering a camera*/
  33895. afterCameraRender: () => void;
  33896. /**
  33897. * An event triggered when active meshes evaluation is about to start
  33898. */
  33899. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33900. /**
  33901. * An event triggered when active meshes evaluation is done
  33902. */
  33903. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33904. /**
  33905. * An event triggered when particles rendering is about to start
  33906. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33907. */
  33908. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33909. /**
  33910. * An event triggered when particles rendering is done
  33911. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33912. */
  33913. onAfterParticlesRenderingObservable: Observable<Scene>;
  33914. /**
  33915. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33916. */
  33917. onDataLoadedObservable: Observable<Scene>;
  33918. /**
  33919. * An event triggered when a camera is created
  33920. */
  33921. onNewCameraAddedObservable: Observable<Camera>;
  33922. /**
  33923. * An event triggered when a camera is removed
  33924. */
  33925. onCameraRemovedObservable: Observable<Camera>;
  33926. /**
  33927. * An event triggered when a light is created
  33928. */
  33929. onNewLightAddedObservable: Observable<Light>;
  33930. /**
  33931. * An event triggered when a light is removed
  33932. */
  33933. onLightRemovedObservable: Observable<Light>;
  33934. /**
  33935. * An event triggered when a geometry is created
  33936. */
  33937. onNewGeometryAddedObservable: Observable<Geometry>;
  33938. /**
  33939. * An event triggered when a geometry is removed
  33940. */
  33941. onGeometryRemovedObservable: Observable<Geometry>;
  33942. /**
  33943. * An event triggered when a transform node is created
  33944. */
  33945. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33946. /**
  33947. * An event triggered when a transform node is removed
  33948. */
  33949. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33950. /**
  33951. * An event triggered when a mesh is created
  33952. */
  33953. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33954. /**
  33955. * An event triggered when a mesh is removed
  33956. */
  33957. onMeshRemovedObservable: Observable<AbstractMesh>;
  33958. /**
  33959. * An event triggered when a skeleton is created
  33960. */
  33961. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33962. /**
  33963. * An event triggered when a skeleton is removed
  33964. */
  33965. onSkeletonRemovedObservable: Observable<Skeleton>;
  33966. /**
  33967. * An event triggered when a material is created
  33968. */
  33969. onNewMaterialAddedObservable: Observable<Material>;
  33970. /**
  33971. * An event triggered when a material is removed
  33972. */
  33973. onMaterialRemovedObservable: Observable<Material>;
  33974. /**
  33975. * An event triggered when a texture is created
  33976. */
  33977. onNewTextureAddedObservable: Observable<BaseTexture>;
  33978. /**
  33979. * An event triggered when a texture is removed
  33980. */
  33981. onTextureRemovedObservable: Observable<BaseTexture>;
  33982. /**
  33983. * An event triggered when render targets are about to be rendered
  33984. * Can happen multiple times per frame.
  33985. */
  33986. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33987. /**
  33988. * An event triggered when render targets were rendered.
  33989. * Can happen multiple times per frame.
  33990. */
  33991. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33992. /**
  33993. * An event triggered before calculating deterministic simulation step
  33994. */
  33995. onBeforeStepObservable: Observable<Scene>;
  33996. /**
  33997. * An event triggered after calculating deterministic simulation step
  33998. */
  33999. onAfterStepObservable: Observable<Scene>;
  34000. /**
  34001. * An event triggered when the activeCamera property is updated
  34002. */
  34003. onActiveCameraChanged: Observable<Scene>;
  34004. /**
  34005. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34006. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34007. * 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)
  34008. */
  34009. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34010. /**
  34011. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34012. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34013. * 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)
  34014. */
  34015. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34016. /**
  34017. * This Observable will when a mesh has been imported into the scene.
  34018. */
  34019. onMeshImportedObservable: Observable<AbstractMesh>;
  34020. /**
  34021. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34022. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34023. */
  34024. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34025. /** @hidden */
  34026. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34027. /**
  34028. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34029. */
  34030. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34031. /**
  34032. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34033. */
  34034. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34035. /**
  34036. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34037. */
  34038. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34039. /** Callback called when a pointer move is detected */
  34040. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34041. /** Callback called when a pointer down is detected */
  34042. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34043. /** Callback called when a pointer up is detected */
  34044. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34045. /** Callback called when a pointer pick is detected */
  34046. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34047. /**
  34048. * 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).
  34049. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34050. */
  34051. onPrePointerObservable: Observable<PointerInfoPre>;
  34052. /**
  34053. * Observable event triggered each time an input event is received from the rendering canvas
  34054. */
  34055. onPointerObservable: Observable<PointerInfo>;
  34056. /**
  34057. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34058. */
  34059. readonly unTranslatedPointer: Vector2;
  34060. /**
  34061. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34062. */
  34063. static DragMovementThreshold: number;
  34064. /**
  34065. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34066. */
  34067. static LongPressDelay: number;
  34068. /**
  34069. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34070. */
  34071. static DoubleClickDelay: number;
  34072. /** If you need to check double click without raising a single click at first click, enable this flag */
  34073. static ExclusiveDoubleClickMode: boolean;
  34074. /** @hidden */
  34075. _mirroredCameraPosition: Nullable<Vector3>;
  34076. /**
  34077. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34078. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34079. */
  34080. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34081. /**
  34082. * Observable event triggered each time an keyboard event is received from the hosting window
  34083. */
  34084. onKeyboardObservable: Observable<KeyboardInfo>;
  34085. private _useRightHandedSystem;
  34086. /**
  34087. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34088. */
  34089. useRightHandedSystem: boolean;
  34090. private _timeAccumulator;
  34091. private _currentStepId;
  34092. private _currentInternalStep;
  34093. /**
  34094. * Sets the step Id used by deterministic lock step
  34095. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34096. * @param newStepId defines the step Id
  34097. */
  34098. setStepId(newStepId: number): void;
  34099. /**
  34100. * Gets the step Id used by deterministic lock step
  34101. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34102. * @returns the step Id
  34103. */
  34104. getStepId(): number;
  34105. /**
  34106. * Gets the internal step used by deterministic lock step
  34107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34108. * @returns the internal step
  34109. */
  34110. getInternalStep(): number;
  34111. private _fogEnabled;
  34112. /**
  34113. * Gets or sets a boolean indicating if fog is enabled on this scene
  34114. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34115. * (Default is true)
  34116. */
  34117. fogEnabled: boolean;
  34118. private _fogMode;
  34119. /**
  34120. * Gets or sets the fog mode to use
  34121. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34122. * | mode | value |
  34123. * | --- | --- |
  34124. * | FOGMODE_NONE | 0 |
  34125. * | FOGMODE_EXP | 1 |
  34126. * | FOGMODE_EXP2 | 2 |
  34127. * | FOGMODE_LINEAR | 3 |
  34128. */
  34129. fogMode: number;
  34130. /**
  34131. * Gets or sets the fog color to use
  34132. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34133. * (Default is Color3(0.2, 0.2, 0.3))
  34134. */
  34135. fogColor: Color3;
  34136. /**
  34137. * Gets or sets the fog density to use
  34138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34139. * (Default is 0.1)
  34140. */
  34141. fogDensity: number;
  34142. /**
  34143. * Gets or sets the fog start distance to use
  34144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34145. * (Default is 0)
  34146. */
  34147. fogStart: number;
  34148. /**
  34149. * Gets or sets the fog end distance to use
  34150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34151. * (Default is 1000)
  34152. */
  34153. fogEnd: number;
  34154. private _shadowsEnabled;
  34155. /**
  34156. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34157. */
  34158. shadowsEnabled: boolean;
  34159. private _lightsEnabled;
  34160. /**
  34161. * Gets or sets a boolean indicating if lights are enabled on this scene
  34162. */
  34163. lightsEnabled: boolean;
  34164. /** All of the active cameras added to this scene. */
  34165. activeCameras: Camera[];
  34166. /** @hidden */
  34167. _activeCamera: Nullable<Camera>;
  34168. /** Gets or sets the current active camera */
  34169. activeCamera: Nullable<Camera>;
  34170. private _defaultMaterial;
  34171. /** The default material used on meshes when no material is affected */
  34172. /** The default material used on meshes when no material is affected */
  34173. defaultMaterial: Material;
  34174. private _texturesEnabled;
  34175. /**
  34176. * Gets or sets a boolean indicating if textures are enabled on this scene
  34177. */
  34178. texturesEnabled: boolean;
  34179. /**
  34180. * Gets or sets a boolean indicating if particles are enabled on this scene
  34181. */
  34182. particlesEnabled: boolean;
  34183. /**
  34184. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34185. */
  34186. spritesEnabled: boolean;
  34187. private _skeletonsEnabled;
  34188. /**
  34189. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34190. */
  34191. skeletonsEnabled: boolean;
  34192. /**
  34193. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34194. */
  34195. lensFlaresEnabled: boolean;
  34196. /**
  34197. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34198. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34199. */
  34200. collisionsEnabled: boolean;
  34201. private _collisionCoordinator;
  34202. /** @hidden */
  34203. readonly collisionCoordinator: ICollisionCoordinator;
  34204. /**
  34205. * Defines the gravity applied to this scene (used only for collisions)
  34206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34207. */
  34208. gravity: Vector3;
  34209. /**
  34210. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34211. */
  34212. postProcessesEnabled: boolean;
  34213. /**
  34214. * The list of postprocesses added to the scene
  34215. */
  34216. postProcesses: PostProcess[];
  34217. /**
  34218. * Gets the current postprocess manager
  34219. */
  34220. postProcessManager: PostProcessManager;
  34221. /**
  34222. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34223. */
  34224. renderTargetsEnabled: boolean;
  34225. /**
  34226. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34227. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34228. */
  34229. dumpNextRenderTargets: boolean;
  34230. /**
  34231. * The list of user defined render targets added to the scene
  34232. */
  34233. customRenderTargets: RenderTargetTexture[];
  34234. /**
  34235. * Defines if texture loading must be delayed
  34236. * If true, textures will only be loaded when they need to be rendered
  34237. */
  34238. useDelayedTextureLoading: boolean;
  34239. /**
  34240. * Gets the list of meshes imported to the scene through SceneLoader
  34241. */
  34242. importedMeshesFiles: String[];
  34243. /**
  34244. * Gets or sets a boolean indicating if probes are enabled on this scene
  34245. */
  34246. probesEnabled: boolean;
  34247. /**
  34248. * Gets or sets the current offline provider to use to store scene data
  34249. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34250. */
  34251. offlineProvider: IOfflineProvider;
  34252. /**
  34253. * Gets or sets the action manager associated with the scene
  34254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34255. */
  34256. actionManager: AbstractActionManager;
  34257. private _meshesForIntersections;
  34258. /**
  34259. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34260. */
  34261. proceduralTexturesEnabled: boolean;
  34262. private _engine;
  34263. private _totalVertices;
  34264. /** @hidden */
  34265. _activeIndices: PerfCounter;
  34266. /** @hidden */
  34267. _activeParticles: PerfCounter;
  34268. /** @hidden */
  34269. _activeBones: PerfCounter;
  34270. private _animationRatio;
  34271. /** @hidden */
  34272. _animationTimeLast: number;
  34273. /** @hidden */
  34274. _animationTime: number;
  34275. /**
  34276. * Gets or sets a general scale for animation speed
  34277. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34278. */
  34279. animationTimeScale: number;
  34280. /** @hidden */
  34281. _cachedMaterial: Nullable<Material>;
  34282. /** @hidden */
  34283. _cachedEffect: Nullable<Effect>;
  34284. /** @hidden */
  34285. _cachedVisibility: Nullable<number>;
  34286. private _renderId;
  34287. private _frameId;
  34288. private _executeWhenReadyTimeoutId;
  34289. private _intermediateRendering;
  34290. private _viewUpdateFlag;
  34291. private _projectionUpdateFlag;
  34292. /** @hidden */
  34293. _toBeDisposed: Nullable<IDisposable>[];
  34294. private _activeRequests;
  34295. /** @hidden */
  34296. _pendingData: any[];
  34297. private _isDisposed;
  34298. /**
  34299. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34300. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34301. */
  34302. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34303. private _activeMeshes;
  34304. private _processedMaterials;
  34305. private _renderTargets;
  34306. /** @hidden */
  34307. _activeParticleSystems: SmartArray<IParticleSystem>;
  34308. private _activeSkeletons;
  34309. private _softwareSkinnedMeshes;
  34310. private _renderingManager;
  34311. /** @hidden */
  34312. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34313. private _transformMatrix;
  34314. private _sceneUbo;
  34315. /** @hidden */
  34316. _viewMatrix: Matrix;
  34317. private _projectionMatrix;
  34318. /** @hidden */
  34319. _forcedViewPosition: Nullable<Vector3>;
  34320. /** @hidden */
  34321. _frustumPlanes: Plane[];
  34322. /**
  34323. * Gets the list of frustum planes (built from the active camera)
  34324. */
  34325. readonly frustumPlanes: Plane[];
  34326. /**
  34327. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34328. * This is useful if there are more lights that the maximum simulteanous authorized
  34329. */
  34330. requireLightSorting: boolean;
  34331. /** @hidden */
  34332. readonly useMaterialMeshMap: boolean;
  34333. /** @hidden */
  34334. readonly useClonedMeshhMap: boolean;
  34335. private _externalData;
  34336. private _uid;
  34337. /**
  34338. * @hidden
  34339. * Backing store of defined scene components.
  34340. */
  34341. _components: ISceneComponent[];
  34342. /**
  34343. * @hidden
  34344. * Backing store of defined scene components.
  34345. */
  34346. _serializableComponents: ISceneSerializableComponent[];
  34347. /**
  34348. * List of components to register on the next registration step.
  34349. */
  34350. private _transientComponents;
  34351. /**
  34352. * Registers the transient components if needed.
  34353. */
  34354. private _registerTransientComponents;
  34355. /**
  34356. * @hidden
  34357. * Add a component to the scene.
  34358. * Note that the ccomponent could be registered on th next frame if this is called after
  34359. * the register component stage.
  34360. * @param component Defines the component to add to the scene
  34361. */
  34362. _addComponent(component: ISceneComponent): void;
  34363. /**
  34364. * @hidden
  34365. * Gets a component from the scene.
  34366. * @param name defines the name of the component to retrieve
  34367. * @returns the component or null if not present
  34368. */
  34369. _getComponent(name: string): Nullable<ISceneComponent>;
  34370. /**
  34371. * @hidden
  34372. * Defines the actions happening before camera updates.
  34373. */
  34374. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34375. /**
  34376. * @hidden
  34377. * Defines the actions happening before clear the canvas.
  34378. */
  34379. _beforeClearStage: Stage<SimpleStageAction>;
  34380. /**
  34381. * @hidden
  34382. * Defines the actions when collecting render targets for the frame.
  34383. */
  34384. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34385. /**
  34386. * @hidden
  34387. * Defines the actions happening for one camera in the frame.
  34388. */
  34389. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34390. /**
  34391. * @hidden
  34392. * Defines the actions happening during the per mesh ready checks.
  34393. */
  34394. _isReadyForMeshStage: Stage<MeshStageAction>;
  34395. /**
  34396. * @hidden
  34397. * Defines the actions happening before evaluate active mesh checks.
  34398. */
  34399. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34400. /**
  34401. * @hidden
  34402. * Defines the actions happening during the evaluate sub mesh checks.
  34403. */
  34404. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34405. /**
  34406. * @hidden
  34407. * Defines the actions happening during the active mesh stage.
  34408. */
  34409. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34410. /**
  34411. * @hidden
  34412. * Defines the actions happening during the per camera render target step.
  34413. */
  34414. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34415. /**
  34416. * @hidden
  34417. * Defines the actions happening just before the active camera is drawing.
  34418. */
  34419. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34420. /**
  34421. * @hidden
  34422. * Defines the actions happening just before a render target is drawing.
  34423. */
  34424. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34425. /**
  34426. * @hidden
  34427. * Defines the actions happening just before a rendering group is drawing.
  34428. */
  34429. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34430. /**
  34431. * @hidden
  34432. * Defines the actions happening just before a mesh is drawing.
  34433. */
  34434. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34435. /**
  34436. * @hidden
  34437. * Defines the actions happening just after a mesh has been drawn.
  34438. */
  34439. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34440. /**
  34441. * @hidden
  34442. * Defines the actions happening just after a rendering group has been drawn.
  34443. */
  34444. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34445. /**
  34446. * @hidden
  34447. * Defines the actions happening just after the active camera has been drawn.
  34448. */
  34449. _afterCameraDrawStage: Stage<CameraStageAction>;
  34450. /**
  34451. * @hidden
  34452. * Defines the actions happening just after a render target has been drawn.
  34453. */
  34454. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34455. /**
  34456. * @hidden
  34457. * Defines the actions happening just after rendering all cameras and computing intersections.
  34458. */
  34459. _afterRenderStage: Stage<SimpleStageAction>;
  34460. /**
  34461. * @hidden
  34462. * Defines the actions happening when a pointer move event happens.
  34463. */
  34464. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34465. /**
  34466. * @hidden
  34467. * Defines the actions happening when a pointer down event happens.
  34468. */
  34469. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34470. /**
  34471. * @hidden
  34472. * Defines the actions happening when a pointer up event happens.
  34473. */
  34474. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34475. /**
  34476. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34477. */
  34478. private geometriesByUniqueId;
  34479. /**
  34480. * Creates a new Scene
  34481. * @param engine defines the engine to use to render this scene
  34482. * @param options defines the scene options
  34483. */
  34484. constructor(engine: Engine, options?: SceneOptions);
  34485. /**
  34486. * Gets a string idenfifying the name of the class
  34487. * @returns "Scene" string
  34488. */
  34489. getClassName(): string;
  34490. private _defaultMeshCandidates;
  34491. /**
  34492. * @hidden
  34493. */
  34494. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34495. private _defaultSubMeshCandidates;
  34496. /**
  34497. * @hidden
  34498. */
  34499. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34500. /**
  34501. * Sets the default candidate providers for the scene.
  34502. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34503. * and getCollidingSubMeshCandidates to their default function
  34504. */
  34505. setDefaultCandidateProviders(): void;
  34506. /**
  34507. * Gets the mesh that is currently under the pointer
  34508. */
  34509. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34510. /**
  34511. * Gets or sets the current on-screen X position of the pointer
  34512. */
  34513. pointerX: number;
  34514. /**
  34515. * Gets or sets the current on-screen Y position of the pointer
  34516. */
  34517. pointerY: number;
  34518. /**
  34519. * Gets the cached material (ie. the latest rendered one)
  34520. * @returns the cached material
  34521. */
  34522. getCachedMaterial(): Nullable<Material>;
  34523. /**
  34524. * Gets the cached effect (ie. the latest rendered one)
  34525. * @returns the cached effect
  34526. */
  34527. getCachedEffect(): Nullable<Effect>;
  34528. /**
  34529. * Gets the cached visibility state (ie. the latest rendered one)
  34530. * @returns the cached visibility state
  34531. */
  34532. getCachedVisibility(): Nullable<number>;
  34533. /**
  34534. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34535. * @param material defines the current material
  34536. * @param effect defines the current effect
  34537. * @param visibility defines the current visibility state
  34538. * @returns true if one parameter is not cached
  34539. */
  34540. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34541. /**
  34542. * Gets the engine associated with the scene
  34543. * @returns an Engine
  34544. */
  34545. getEngine(): Engine;
  34546. /**
  34547. * Gets the total number of vertices rendered per frame
  34548. * @returns the total number of vertices rendered per frame
  34549. */
  34550. getTotalVertices(): number;
  34551. /**
  34552. * Gets the performance counter for total vertices
  34553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34554. */
  34555. readonly totalVerticesPerfCounter: PerfCounter;
  34556. /**
  34557. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34558. * @returns the total number of active indices rendered per frame
  34559. */
  34560. getActiveIndices(): number;
  34561. /**
  34562. * Gets the performance counter for active indices
  34563. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34564. */
  34565. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34566. /**
  34567. * Gets the total number of active particles rendered per frame
  34568. * @returns the total number of active particles rendered per frame
  34569. */
  34570. getActiveParticles(): number;
  34571. /**
  34572. * Gets the performance counter for active particles
  34573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34574. */
  34575. readonly activeParticlesPerfCounter: PerfCounter;
  34576. /**
  34577. * Gets the total number of active bones rendered per frame
  34578. * @returns the total number of active bones rendered per frame
  34579. */
  34580. getActiveBones(): number;
  34581. /**
  34582. * Gets the performance counter for active bones
  34583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34584. */
  34585. readonly activeBonesPerfCounter: PerfCounter;
  34586. /**
  34587. * Gets the array of active meshes
  34588. * @returns an array of AbstractMesh
  34589. */
  34590. getActiveMeshes(): SmartArray<AbstractMesh>;
  34591. /**
  34592. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34593. * @returns a number
  34594. */
  34595. getAnimationRatio(): number;
  34596. /**
  34597. * Gets an unique Id for the current render phase
  34598. * @returns a number
  34599. */
  34600. getRenderId(): number;
  34601. /**
  34602. * Gets an unique Id for the current frame
  34603. * @returns a number
  34604. */
  34605. getFrameId(): number;
  34606. /** Call this function if you want to manually increment the render Id*/
  34607. incrementRenderId(): void;
  34608. private _createUbo;
  34609. /**
  34610. * Use this method to simulate a pointer move on a mesh
  34611. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34612. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34613. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34614. * @returns the current scene
  34615. */
  34616. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34617. /**
  34618. * Use this method to simulate a pointer down on a mesh
  34619. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34620. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34621. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34622. * @returns the current scene
  34623. */
  34624. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34625. /**
  34626. * Use this method to simulate a pointer up on a mesh
  34627. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34628. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34629. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34630. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34631. * @returns the current scene
  34632. */
  34633. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34634. /**
  34635. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34636. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34637. * @returns true if the pointer was captured
  34638. */
  34639. isPointerCaptured(pointerId?: number): boolean;
  34640. /**
  34641. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34642. * @param attachUp defines if you want to attach events to pointerup
  34643. * @param attachDown defines if you want to attach events to pointerdown
  34644. * @param attachMove defines if you want to attach events to pointermove
  34645. */
  34646. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34647. /** Detaches all event handlers*/
  34648. detachControl(): void;
  34649. /**
  34650. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34651. * Delay loaded resources are not taking in account
  34652. * @return true if all required resources are ready
  34653. */
  34654. isReady(): boolean;
  34655. /** Resets all cached information relative to material (including effect and visibility) */
  34656. resetCachedMaterial(): void;
  34657. /**
  34658. * Registers a function to be called before every frame render
  34659. * @param func defines the function to register
  34660. */
  34661. registerBeforeRender(func: () => void): void;
  34662. /**
  34663. * Unregisters a function called before every frame render
  34664. * @param func defines the function to unregister
  34665. */
  34666. unregisterBeforeRender(func: () => void): void;
  34667. /**
  34668. * Registers a function to be called after every frame render
  34669. * @param func defines the function to register
  34670. */
  34671. registerAfterRender(func: () => void): void;
  34672. /**
  34673. * Unregisters a function called after every frame render
  34674. * @param func defines the function to unregister
  34675. */
  34676. unregisterAfterRender(func: () => void): void;
  34677. private _executeOnceBeforeRender;
  34678. /**
  34679. * The provided function will run before render once and will be disposed afterwards.
  34680. * A timeout delay can be provided so that the function will be executed in N ms.
  34681. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34682. * @param func The function to be executed.
  34683. * @param timeout optional delay in ms
  34684. */
  34685. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34686. /** @hidden */
  34687. _addPendingData(data: any): void;
  34688. /** @hidden */
  34689. _removePendingData(data: any): void;
  34690. /**
  34691. * Returns the number of items waiting to be loaded
  34692. * @returns the number of items waiting to be loaded
  34693. */
  34694. getWaitingItemsCount(): number;
  34695. /**
  34696. * Returns a boolean indicating if the scene is still loading data
  34697. */
  34698. readonly isLoading: boolean;
  34699. /**
  34700. * Registers a function to be executed when the scene is ready
  34701. * @param {Function} func - the function to be executed
  34702. */
  34703. executeWhenReady(func: () => void): void;
  34704. /**
  34705. * Returns a promise that resolves when the scene is ready
  34706. * @returns A promise that resolves when the scene is ready
  34707. */
  34708. whenReadyAsync(): Promise<void>;
  34709. /** @hidden */
  34710. _checkIsReady(): void;
  34711. /**
  34712. * Gets all animatable attached to the scene
  34713. */
  34714. readonly animatables: Animatable[];
  34715. /**
  34716. * Resets the last animation time frame.
  34717. * Useful to override when animations start running when loading a scene for the first time.
  34718. */
  34719. resetLastAnimationTimeFrame(): void;
  34720. /**
  34721. * Gets the current view matrix
  34722. * @returns a Matrix
  34723. */
  34724. getViewMatrix(): Matrix;
  34725. /**
  34726. * Gets the current projection matrix
  34727. * @returns a Matrix
  34728. */
  34729. getProjectionMatrix(): Matrix;
  34730. /**
  34731. * Gets the current transform matrix
  34732. * @returns a Matrix made of View * Projection
  34733. */
  34734. getTransformMatrix(): Matrix;
  34735. /**
  34736. * Sets the current transform matrix
  34737. * @param viewL defines the View matrix to use
  34738. * @param projectionL defines the Projection matrix to use
  34739. * @param viewR defines the right View matrix to use (if provided)
  34740. * @param projectionR defines the right Projection matrix to use (if provided)
  34741. */
  34742. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34743. /**
  34744. * Gets the uniform buffer used to store scene data
  34745. * @returns a UniformBuffer
  34746. */
  34747. getSceneUniformBuffer(): UniformBuffer;
  34748. /**
  34749. * Gets an unique (relatively to the current scene) Id
  34750. * @returns an unique number for the scene
  34751. */
  34752. getUniqueId(): number;
  34753. /**
  34754. * Add a mesh to the list of scene's meshes
  34755. * @param newMesh defines the mesh to add
  34756. * @param recursive if all child meshes should also be added to the scene
  34757. */
  34758. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34759. /**
  34760. * Remove a mesh for the list of scene's meshes
  34761. * @param toRemove defines the mesh to remove
  34762. * @param recursive if all child meshes should also be removed from the scene
  34763. * @returns the index where the mesh was in the mesh list
  34764. */
  34765. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34766. /**
  34767. * Add a transform node to the list of scene's transform nodes
  34768. * @param newTransformNode defines the transform node to add
  34769. */
  34770. addTransformNode(newTransformNode: TransformNode): void;
  34771. /**
  34772. * Remove a transform node for the list of scene's transform nodes
  34773. * @param toRemove defines the transform node to remove
  34774. * @returns the index where the transform node was in the transform node list
  34775. */
  34776. removeTransformNode(toRemove: TransformNode): number;
  34777. /**
  34778. * Remove a skeleton for the list of scene's skeletons
  34779. * @param toRemove defines the skeleton to remove
  34780. * @returns the index where the skeleton was in the skeleton list
  34781. */
  34782. removeSkeleton(toRemove: Skeleton): number;
  34783. /**
  34784. * Remove a morph target for the list of scene's morph targets
  34785. * @param toRemove defines the morph target to remove
  34786. * @returns the index where the morph target was in the morph target list
  34787. */
  34788. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34789. /**
  34790. * Remove a light for the list of scene's lights
  34791. * @param toRemove defines the light to remove
  34792. * @returns the index where the light was in the light list
  34793. */
  34794. removeLight(toRemove: Light): number;
  34795. /**
  34796. * Remove a camera for the list of scene's cameras
  34797. * @param toRemove defines the camera to remove
  34798. * @returns the index where the camera was in the camera list
  34799. */
  34800. removeCamera(toRemove: Camera): number;
  34801. /**
  34802. * Remove a particle system for the list of scene's particle systems
  34803. * @param toRemove defines the particle system to remove
  34804. * @returns the index where the particle system was in the particle system list
  34805. */
  34806. removeParticleSystem(toRemove: IParticleSystem): number;
  34807. /**
  34808. * Remove a animation for the list of scene's animations
  34809. * @param toRemove defines the animation to remove
  34810. * @returns the index where the animation was in the animation list
  34811. */
  34812. removeAnimation(toRemove: Animation): number;
  34813. /**
  34814. * Will stop the animation of the given target
  34815. * @param target - the target
  34816. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34817. * @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)
  34818. */
  34819. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34820. /**
  34821. * Removes the given animation group from this scene.
  34822. * @param toRemove The animation group to remove
  34823. * @returns The index of the removed animation group
  34824. */
  34825. removeAnimationGroup(toRemove: AnimationGroup): number;
  34826. /**
  34827. * Removes the given multi-material from this scene.
  34828. * @param toRemove The multi-material to remove
  34829. * @returns The index of the removed multi-material
  34830. */
  34831. removeMultiMaterial(toRemove: MultiMaterial): number;
  34832. /**
  34833. * Removes the given material from this scene.
  34834. * @param toRemove The material to remove
  34835. * @returns The index of the removed material
  34836. */
  34837. removeMaterial(toRemove: Material): number;
  34838. /**
  34839. * Removes the given action manager from this scene.
  34840. * @param toRemove The action manager to remove
  34841. * @returns The index of the removed action manager
  34842. */
  34843. removeActionManager(toRemove: AbstractActionManager): number;
  34844. /**
  34845. * Removes the given texture from this scene.
  34846. * @param toRemove The texture to remove
  34847. * @returns The index of the removed texture
  34848. */
  34849. removeTexture(toRemove: BaseTexture): number;
  34850. /**
  34851. * Adds the given light to this scene
  34852. * @param newLight The light to add
  34853. */
  34854. addLight(newLight: Light): void;
  34855. /**
  34856. * Sorts the list list based on light priorities
  34857. */
  34858. sortLightsByPriority(): void;
  34859. /**
  34860. * Adds the given camera to this scene
  34861. * @param newCamera The camera to add
  34862. */
  34863. addCamera(newCamera: Camera): void;
  34864. /**
  34865. * Adds the given skeleton to this scene
  34866. * @param newSkeleton The skeleton to add
  34867. */
  34868. addSkeleton(newSkeleton: Skeleton): void;
  34869. /**
  34870. * Adds the given particle system to this scene
  34871. * @param newParticleSystem The particle system to add
  34872. */
  34873. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34874. /**
  34875. * Adds the given animation to this scene
  34876. * @param newAnimation The animation to add
  34877. */
  34878. addAnimation(newAnimation: Animation): void;
  34879. /**
  34880. * Adds the given animation group to this scene.
  34881. * @param newAnimationGroup The animation group to add
  34882. */
  34883. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34884. /**
  34885. * Adds the given multi-material to this scene
  34886. * @param newMultiMaterial The multi-material to add
  34887. */
  34888. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34889. /**
  34890. * Adds the given material to this scene
  34891. * @param newMaterial The material to add
  34892. */
  34893. addMaterial(newMaterial: Material): void;
  34894. /**
  34895. * Adds the given morph target to this scene
  34896. * @param newMorphTargetManager The morph target to add
  34897. */
  34898. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34899. /**
  34900. * Adds the given geometry to this scene
  34901. * @param newGeometry The geometry to add
  34902. */
  34903. addGeometry(newGeometry: Geometry): void;
  34904. /**
  34905. * Adds the given action manager to this scene
  34906. * @param newActionManager The action manager to add
  34907. */
  34908. addActionManager(newActionManager: AbstractActionManager): void;
  34909. /**
  34910. * Adds the given texture to this scene.
  34911. * @param newTexture The texture to add
  34912. */
  34913. addTexture(newTexture: BaseTexture): void;
  34914. /**
  34915. * Switch active camera
  34916. * @param newCamera defines the new active camera
  34917. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34918. */
  34919. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34920. /**
  34921. * sets the active camera of the scene using its ID
  34922. * @param id defines the camera's ID
  34923. * @return the new active camera or null if none found.
  34924. */
  34925. setActiveCameraByID(id: string): Nullable<Camera>;
  34926. /**
  34927. * sets the active camera of the scene using its name
  34928. * @param name defines the camera's name
  34929. * @returns the new active camera or null if none found.
  34930. */
  34931. setActiveCameraByName(name: string): Nullable<Camera>;
  34932. /**
  34933. * get an animation group using its name
  34934. * @param name defines the material's name
  34935. * @return the animation group or null if none found.
  34936. */
  34937. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34938. /**
  34939. * Get a material using its unique id
  34940. * @param uniqueId defines the material's unique id
  34941. * @return the material or null if none found.
  34942. */
  34943. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34944. /**
  34945. * get a material using its id
  34946. * @param id defines the material's ID
  34947. * @return the material or null if none found.
  34948. */
  34949. getMaterialByID(id: string): Nullable<Material>;
  34950. /**
  34951. * Gets a the last added material using a given id
  34952. * @param id defines the material's ID
  34953. * @return the last material with the given id or null if none found.
  34954. */
  34955. getLastMaterialByID(id: string): Nullable<Material>;
  34956. /**
  34957. * Gets a material using its name
  34958. * @param name defines the material's name
  34959. * @return the material or null if none found.
  34960. */
  34961. getMaterialByName(name: string): Nullable<Material>;
  34962. /**
  34963. * Get a texture using its unique id
  34964. * @param uniqueId defines the texture's unique id
  34965. * @return the texture or null if none found.
  34966. */
  34967. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34968. /**
  34969. * Gets a camera using its id
  34970. * @param id defines the id to look for
  34971. * @returns the camera or null if not found
  34972. */
  34973. getCameraByID(id: string): Nullable<Camera>;
  34974. /**
  34975. * Gets a camera using its unique id
  34976. * @param uniqueId defines the unique id to look for
  34977. * @returns the camera or null if not found
  34978. */
  34979. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34980. /**
  34981. * Gets a camera using its name
  34982. * @param name defines the camera's name
  34983. * @return the camera or null if none found.
  34984. */
  34985. getCameraByName(name: string): Nullable<Camera>;
  34986. /**
  34987. * Gets a bone using its id
  34988. * @param id defines the bone's id
  34989. * @return the bone or null if not found
  34990. */
  34991. getBoneByID(id: string): Nullable<Bone>;
  34992. /**
  34993. * Gets a bone using its id
  34994. * @param name defines the bone's name
  34995. * @return the bone or null if not found
  34996. */
  34997. getBoneByName(name: string): Nullable<Bone>;
  34998. /**
  34999. * Gets a light node using its name
  35000. * @param name defines the the light's name
  35001. * @return the light or null if none found.
  35002. */
  35003. getLightByName(name: string): Nullable<Light>;
  35004. /**
  35005. * Gets a light node using its id
  35006. * @param id defines the light's id
  35007. * @return the light or null if none found.
  35008. */
  35009. getLightByID(id: string): Nullable<Light>;
  35010. /**
  35011. * Gets a light node using its scene-generated unique ID
  35012. * @param uniqueId defines the light's unique id
  35013. * @return the light or null if none found.
  35014. */
  35015. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35016. /**
  35017. * Gets a particle system by id
  35018. * @param id defines the particle system id
  35019. * @return the corresponding system or null if none found
  35020. */
  35021. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35022. /**
  35023. * Gets a geometry using its ID
  35024. * @param id defines the geometry's id
  35025. * @return the geometry or null if none found.
  35026. */
  35027. getGeometryByID(id: string): Nullable<Geometry>;
  35028. private _getGeometryByUniqueID;
  35029. /**
  35030. * Add a new geometry to this scene
  35031. * @param geometry defines the geometry to be added to the scene.
  35032. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35033. * @return a boolean defining if the geometry was added or not
  35034. */
  35035. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35036. /**
  35037. * Removes an existing geometry
  35038. * @param geometry defines the geometry to be removed from the scene
  35039. * @return a boolean defining if the geometry was removed or not
  35040. */
  35041. removeGeometry(geometry: Geometry): boolean;
  35042. /**
  35043. * Gets the list of geometries attached to the scene
  35044. * @returns an array of Geometry
  35045. */
  35046. getGeometries(): Geometry[];
  35047. /**
  35048. * Gets the first added mesh found of a given ID
  35049. * @param id defines the id to search for
  35050. * @return the mesh found or null if not found at all
  35051. */
  35052. getMeshByID(id: string): Nullable<AbstractMesh>;
  35053. /**
  35054. * Gets a list of meshes using their id
  35055. * @param id defines the id to search for
  35056. * @returns a list of meshes
  35057. */
  35058. getMeshesByID(id: string): Array<AbstractMesh>;
  35059. /**
  35060. * Gets the first added transform node found of a given ID
  35061. * @param id defines the id to search for
  35062. * @return the found transform node or null if not found at all.
  35063. */
  35064. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35065. /**
  35066. * Gets a transform node with its auto-generated unique id
  35067. * @param uniqueId efines the unique id to search for
  35068. * @return the found transform node or null if not found at all.
  35069. */
  35070. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35071. /**
  35072. * Gets a list of transform nodes using their id
  35073. * @param id defines the id to search for
  35074. * @returns a list of transform nodes
  35075. */
  35076. getTransformNodesByID(id: string): Array<TransformNode>;
  35077. /**
  35078. * Gets a mesh with its auto-generated unique id
  35079. * @param uniqueId defines the unique id to search for
  35080. * @return the found mesh or null if not found at all.
  35081. */
  35082. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35083. /**
  35084. * Gets a the last added mesh using a given id
  35085. * @param id defines the id to search for
  35086. * @return the found mesh or null if not found at all.
  35087. */
  35088. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35089. /**
  35090. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35091. * @param id defines the id to search for
  35092. * @return the found node or null if not found at all
  35093. */
  35094. getLastEntryByID(id: string): Nullable<Node>;
  35095. /**
  35096. * Gets a node (Mesh, Camera, Light) using a given id
  35097. * @param id defines the id to search for
  35098. * @return the found node or null if not found at all
  35099. */
  35100. getNodeByID(id: string): Nullable<Node>;
  35101. /**
  35102. * Gets a node (Mesh, Camera, Light) using a given name
  35103. * @param name defines the name to search for
  35104. * @return the found node or null if not found at all.
  35105. */
  35106. getNodeByName(name: string): Nullable<Node>;
  35107. /**
  35108. * Gets a mesh using a given name
  35109. * @param name defines the name to search for
  35110. * @return the found mesh or null if not found at all.
  35111. */
  35112. getMeshByName(name: string): Nullable<AbstractMesh>;
  35113. /**
  35114. * Gets a transform node using a given name
  35115. * @param name defines the name to search for
  35116. * @return the found transform node or null if not found at all.
  35117. */
  35118. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35119. /**
  35120. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35121. * @param id defines the id to search for
  35122. * @return the found skeleton or null if not found at all.
  35123. */
  35124. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35125. /**
  35126. * Gets a skeleton using a given auto generated unique id
  35127. * @param uniqueId defines the unique id to search for
  35128. * @return the found skeleton or null if not found at all.
  35129. */
  35130. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35131. /**
  35132. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35133. * @param id defines the id to search for
  35134. * @return the found skeleton or null if not found at all.
  35135. */
  35136. getSkeletonById(id: string): Nullable<Skeleton>;
  35137. /**
  35138. * Gets a skeleton using a given name
  35139. * @param name defines the name to search for
  35140. * @return the found skeleton or null if not found at all.
  35141. */
  35142. getSkeletonByName(name: string): Nullable<Skeleton>;
  35143. /**
  35144. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35145. * @param id defines the id to search for
  35146. * @return the found morph target manager or null if not found at all.
  35147. */
  35148. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35149. /**
  35150. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35151. * @param id defines the id to search for
  35152. * @return the found morph target or null if not found at all.
  35153. */
  35154. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35155. /**
  35156. * Gets a boolean indicating if the given mesh is active
  35157. * @param mesh defines the mesh to look for
  35158. * @returns true if the mesh is in the active list
  35159. */
  35160. isActiveMesh(mesh: AbstractMesh): boolean;
  35161. /**
  35162. * Return a unique id as a string which can serve as an identifier for the scene
  35163. */
  35164. readonly uid: string;
  35165. /**
  35166. * Add an externaly attached data from its key.
  35167. * This method call will fail and return false, if such key already exists.
  35168. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35169. * @param key the unique key that identifies the data
  35170. * @param data the data object to associate to the key for this Engine instance
  35171. * @return true if no such key were already present and the data was added successfully, false otherwise
  35172. */
  35173. addExternalData<T>(key: string, data: T): boolean;
  35174. /**
  35175. * Get an externaly attached data from its key
  35176. * @param key the unique key that identifies the data
  35177. * @return the associated data, if present (can be null), or undefined if not present
  35178. */
  35179. getExternalData<T>(key: string): Nullable<T>;
  35180. /**
  35181. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35182. * @param key the unique key that identifies the data
  35183. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35184. * @return the associated data, can be null if the factory returned null.
  35185. */
  35186. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35187. /**
  35188. * Remove an externaly attached data from the Engine instance
  35189. * @param key the unique key that identifies the data
  35190. * @return true if the data was successfully removed, false if it doesn't exist
  35191. */
  35192. removeExternalData(key: string): boolean;
  35193. private _evaluateSubMesh;
  35194. /**
  35195. * Clear the processed materials smart array preventing retention point in material dispose.
  35196. */
  35197. freeProcessedMaterials(): void;
  35198. private _preventFreeActiveMeshesAndRenderingGroups;
  35199. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35200. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35201. * when disposing several meshes in a row or a hierarchy of meshes.
  35202. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35203. */
  35204. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35205. /**
  35206. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35207. */
  35208. freeActiveMeshes(): void;
  35209. /**
  35210. * Clear the info related to rendering groups preventing retention points during dispose.
  35211. */
  35212. freeRenderingGroups(): void;
  35213. /** @hidden */
  35214. _isInIntermediateRendering(): boolean;
  35215. /**
  35216. * Lambda returning the list of potentially active meshes.
  35217. */
  35218. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35219. /**
  35220. * Lambda returning the list of potentially active sub meshes.
  35221. */
  35222. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35223. /**
  35224. * Lambda returning the list of potentially intersecting sub meshes.
  35225. */
  35226. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35227. /**
  35228. * Lambda returning the list of potentially colliding sub meshes.
  35229. */
  35230. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35231. private _activeMeshesFrozen;
  35232. /**
  35233. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35234. * @returns the current scene
  35235. */
  35236. freezeActiveMeshes(): Scene;
  35237. /**
  35238. * Use this function to restart evaluating active meshes on every frame
  35239. * @returns the current scene
  35240. */
  35241. unfreezeActiveMeshes(): Scene;
  35242. private _evaluateActiveMeshes;
  35243. private _activeMesh;
  35244. /**
  35245. * Update the transform matrix to update from the current active camera
  35246. * @param force defines a boolean used to force the update even if cache is up to date
  35247. */
  35248. updateTransformMatrix(force?: boolean): void;
  35249. private _bindFrameBuffer;
  35250. /** @hidden */
  35251. _allowPostProcessClearColor: boolean;
  35252. /** @hidden */
  35253. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35254. private _processSubCameras;
  35255. private _checkIntersections;
  35256. /** @hidden */
  35257. _advancePhysicsEngineStep(step: number): void;
  35258. /**
  35259. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35260. */
  35261. getDeterministicFrameTime: () => number;
  35262. /** @hidden */
  35263. _animate(): void;
  35264. /** Execute all animations (for a frame) */
  35265. animate(): void;
  35266. /**
  35267. * Render the scene
  35268. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35269. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35270. */
  35271. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35272. /**
  35273. * Freeze all materials
  35274. * A frozen material will not be updatable but should be faster to render
  35275. */
  35276. freezeMaterials(): void;
  35277. /**
  35278. * Unfreeze all materials
  35279. * A frozen material will not be updatable but should be faster to render
  35280. */
  35281. unfreezeMaterials(): void;
  35282. /**
  35283. * Releases all held ressources
  35284. */
  35285. dispose(): void;
  35286. /**
  35287. * Gets if the scene is already disposed
  35288. */
  35289. readonly isDisposed: boolean;
  35290. /**
  35291. * Call this function to reduce memory footprint of the scene.
  35292. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35293. */
  35294. clearCachedVertexData(): void;
  35295. /**
  35296. * This function will remove the local cached buffer data from texture.
  35297. * It will save memory but will prevent the texture from being rebuilt
  35298. */
  35299. cleanCachedTextureBuffer(): void;
  35300. /**
  35301. * Get the world extend vectors with an optional filter
  35302. *
  35303. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35304. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35305. */
  35306. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35307. min: Vector3;
  35308. max: Vector3;
  35309. };
  35310. /**
  35311. * Creates a ray that can be used to pick in the scene
  35312. * @param x defines the x coordinate of the origin (on-screen)
  35313. * @param y defines the y coordinate of the origin (on-screen)
  35314. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35315. * @param camera defines the camera to use for the picking
  35316. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35317. * @returns a Ray
  35318. */
  35319. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35320. /**
  35321. * Creates a ray that can be used to pick in the scene
  35322. * @param x defines the x coordinate of the origin (on-screen)
  35323. * @param y defines the y coordinate of the origin (on-screen)
  35324. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35325. * @param result defines the ray where to store the picking ray
  35326. * @param camera defines the camera to use for the picking
  35327. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35328. * @returns the current scene
  35329. */
  35330. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35331. /**
  35332. * Creates a ray that can be used to pick in the scene
  35333. * @param x defines the x coordinate of the origin (on-screen)
  35334. * @param y defines the y coordinate of the origin (on-screen)
  35335. * @param camera defines the camera to use for the picking
  35336. * @returns a Ray
  35337. */
  35338. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35339. /**
  35340. * Creates a ray that can be used to pick in the scene
  35341. * @param x defines the x coordinate of the origin (on-screen)
  35342. * @param y defines the y coordinate of the origin (on-screen)
  35343. * @param result defines the ray where to store the picking ray
  35344. * @param camera defines the camera to use for the picking
  35345. * @returns the current scene
  35346. */
  35347. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35348. /** Launch a ray to try to pick a mesh in the scene
  35349. * @param x position on screen
  35350. * @param y position on screen
  35351. * @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
  35352. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35353. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35354. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35355. * @returns a PickingInfo
  35356. */
  35357. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35358. /** Use the given ray to pick a mesh in the scene
  35359. * @param ray The ray to use to pick meshes
  35360. * @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
  35361. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35362. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35363. * @returns a PickingInfo
  35364. */
  35365. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35366. /**
  35367. * Launch a ray to try to pick a mesh in the scene
  35368. * @param x X position on screen
  35369. * @param y Y position on screen
  35370. * @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
  35371. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35372. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35373. * @returns an array of PickingInfo
  35374. */
  35375. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35376. /**
  35377. * Launch a ray to try to pick a mesh in the scene
  35378. * @param ray Ray to use
  35379. * @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
  35380. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35381. * @returns an array of PickingInfo
  35382. */
  35383. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35384. /**
  35385. * Force the value of meshUnderPointer
  35386. * @param mesh defines the mesh to use
  35387. */
  35388. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35389. /**
  35390. * Gets the mesh under the pointer
  35391. * @returns a Mesh or null if no mesh is under the pointer
  35392. */
  35393. getPointerOverMesh(): Nullable<AbstractMesh>;
  35394. /** @hidden */
  35395. _rebuildGeometries(): void;
  35396. /** @hidden */
  35397. _rebuildTextures(): void;
  35398. private _getByTags;
  35399. /**
  35400. * Get a list of meshes by tags
  35401. * @param tagsQuery defines the tags query to use
  35402. * @param forEach defines a predicate used to filter results
  35403. * @returns an array of Mesh
  35404. */
  35405. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35406. /**
  35407. * Get a list of cameras by tags
  35408. * @param tagsQuery defines the tags query to use
  35409. * @param forEach defines a predicate used to filter results
  35410. * @returns an array of Camera
  35411. */
  35412. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35413. /**
  35414. * Get a list of lights by tags
  35415. * @param tagsQuery defines the tags query to use
  35416. * @param forEach defines a predicate used to filter results
  35417. * @returns an array of Light
  35418. */
  35419. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35420. /**
  35421. * Get a list of materials by tags
  35422. * @param tagsQuery defines the tags query to use
  35423. * @param forEach defines a predicate used to filter results
  35424. * @returns an array of Material
  35425. */
  35426. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35427. /**
  35428. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35429. * This allowed control for front to back rendering or reversly depending of the special needs.
  35430. *
  35431. * @param renderingGroupId The rendering group id corresponding to its index
  35432. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35433. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35434. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35435. */
  35436. 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;
  35437. /**
  35438. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35439. *
  35440. * @param renderingGroupId The rendering group id corresponding to its index
  35441. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35442. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35443. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35444. */
  35445. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35446. /**
  35447. * Gets the current auto clear configuration for one rendering group of the rendering
  35448. * manager.
  35449. * @param index the rendering group index to get the information for
  35450. * @returns The auto clear setup for the requested rendering group
  35451. */
  35452. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35453. private _blockMaterialDirtyMechanism;
  35454. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35455. blockMaterialDirtyMechanism: boolean;
  35456. /**
  35457. * Will flag all materials as dirty to trigger new shader compilation
  35458. * @param flag defines the flag used to specify which material part must be marked as dirty
  35459. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35460. */
  35461. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35462. /** @hidden */
  35463. _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;
  35464. /** @hidden */
  35465. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35466. }
  35467. }
  35468. declare module "babylonjs/assetContainer" {
  35469. import { AbstractScene } from "babylonjs/abstractScene";
  35470. import { Scene } from "babylonjs/scene";
  35471. import { Mesh } from "babylonjs/Meshes/mesh";
  35472. /**
  35473. * Set of assets to keep when moving a scene into an asset container.
  35474. */
  35475. export class KeepAssets extends AbstractScene {
  35476. }
  35477. /**
  35478. * Container with a set of assets that can be added or removed from a scene.
  35479. */
  35480. export class AssetContainer extends AbstractScene {
  35481. /**
  35482. * The scene the AssetContainer belongs to.
  35483. */
  35484. scene: Scene;
  35485. /**
  35486. * Instantiates an AssetContainer.
  35487. * @param scene The scene the AssetContainer belongs to.
  35488. */
  35489. constructor(scene: Scene);
  35490. /**
  35491. * Adds all the assets from the container to the scene.
  35492. */
  35493. addAllToScene(): void;
  35494. /**
  35495. * Removes all the assets in the container from the scene
  35496. */
  35497. removeAllFromScene(): void;
  35498. /**
  35499. * Disposes all the assets in the container
  35500. */
  35501. dispose(): void;
  35502. private _moveAssets;
  35503. /**
  35504. * Removes all the assets contained in the scene and adds them to the container.
  35505. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35506. */
  35507. moveAllFromScene(keepAssets?: KeepAssets): void;
  35508. /**
  35509. * 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.
  35510. * @returns the root mesh
  35511. */
  35512. createRootMesh(): Mesh;
  35513. }
  35514. }
  35515. declare module "babylonjs/abstractScene" {
  35516. import { Scene } from "babylonjs/scene";
  35517. import { Nullable } from "babylonjs/types";
  35518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35519. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35520. import { Geometry } from "babylonjs/Meshes/geometry";
  35521. import { Skeleton } from "babylonjs/Bones/skeleton";
  35522. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35523. import { AssetContainer } from "babylonjs/assetContainer";
  35524. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35525. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35527. import { Material } from "babylonjs/Materials/material";
  35528. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35529. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35530. import { Camera } from "babylonjs/Cameras/camera";
  35531. import { Light } from "babylonjs/Lights/light";
  35532. import { Node } from "babylonjs/node";
  35533. import { Animation } from "babylonjs/Animations/animation";
  35534. /**
  35535. * Defines how the parser contract is defined.
  35536. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35537. */
  35538. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35539. /**
  35540. * Defines how the individual parser contract is defined.
  35541. * These parser can parse an individual asset
  35542. */
  35543. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35544. /**
  35545. * Base class of the scene acting as a container for the different elements composing a scene.
  35546. * This class is dynamically extended by the different components of the scene increasing
  35547. * flexibility and reducing coupling
  35548. */
  35549. export abstract class AbstractScene {
  35550. /**
  35551. * Stores the list of available parsers in the application.
  35552. */
  35553. private static _BabylonFileParsers;
  35554. /**
  35555. * Stores the list of available individual parsers in the application.
  35556. */
  35557. private static _IndividualBabylonFileParsers;
  35558. /**
  35559. * Adds a parser in the list of available ones
  35560. * @param name Defines the name of the parser
  35561. * @param parser Defines the parser to add
  35562. */
  35563. static AddParser(name: string, parser: BabylonFileParser): void;
  35564. /**
  35565. * Gets a general parser from the list of avaialble ones
  35566. * @param name Defines the name of the parser
  35567. * @returns the requested parser or null
  35568. */
  35569. static GetParser(name: string): Nullable<BabylonFileParser>;
  35570. /**
  35571. * Adds n individual parser in the list of available ones
  35572. * @param name Defines the name of the parser
  35573. * @param parser Defines the parser to add
  35574. */
  35575. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35576. /**
  35577. * Gets an individual parser from the list of avaialble ones
  35578. * @param name Defines the name of the parser
  35579. * @returns the requested parser or null
  35580. */
  35581. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35582. /**
  35583. * Parser json data and populate both a scene and its associated container object
  35584. * @param jsonData Defines the data to parse
  35585. * @param scene Defines the scene to parse the data for
  35586. * @param container Defines the container attached to the parsing sequence
  35587. * @param rootUrl Defines the root url of the data
  35588. */
  35589. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35590. /**
  35591. * Gets the list of root nodes (ie. nodes with no parent)
  35592. */
  35593. rootNodes: Node[];
  35594. /** All of the cameras added to this scene
  35595. * @see http://doc.babylonjs.com/babylon101/cameras
  35596. */
  35597. cameras: Camera[];
  35598. /**
  35599. * All of the lights added to this scene
  35600. * @see http://doc.babylonjs.com/babylon101/lights
  35601. */
  35602. lights: Light[];
  35603. /**
  35604. * All of the (abstract) meshes added to this scene
  35605. */
  35606. meshes: AbstractMesh[];
  35607. /**
  35608. * The list of skeletons added to the scene
  35609. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35610. */
  35611. skeletons: Skeleton[];
  35612. /**
  35613. * All of the particle systems added to this scene
  35614. * @see http://doc.babylonjs.com/babylon101/particles
  35615. */
  35616. particleSystems: IParticleSystem[];
  35617. /**
  35618. * Gets a list of Animations associated with the scene
  35619. */
  35620. animations: Animation[];
  35621. /**
  35622. * All of the animation groups added to this scene
  35623. * @see http://doc.babylonjs.com/how_to/group
  35624. */
  35625. animationGroups: AnimationGroup[];
  35626. /**
  35627. * All of the multi-materials added to this scene
  35628. * @see http://doc.babylonjs.com/how_to/multi_materials
  35629. */
  35630. multiMaterials: MultiMaterial[];
  35631. /**
  35632. * All of the materials added to this scene
  35633. * In the context of a Scene, it is not supposed to be modified manually.
  35634. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35635. * Note also that the order of the Material wihin the array is not significant and might change.
  35636. * @see http://doc.babylonjs.com/babylon101/materials
  35637. */
  35638. materials: Material[];
  35639. /**
  35640. * The list of morph target managers added to the scene
  35641. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35642. */
  35643. morphTargetManagers: MorphTargetManager[];
  35644. /**
  35645. * The list of geometries used in the scene.
  35646. */
  35647. geometries: Geometry[];
  35648. /**
  35649. * All of the tranform nodes added to this scene
  35650. * In the context of a Scene, it is not supposed to be modified manually.
  35651. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35652. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35653. * @see http://doc.babylonjs.com/how_to/transformnode
  35654. */
  35655. transformNodes: TransformNode[];
  35656. /**
  35657. * ActionManagers available on the scene.
  35658. */
  35659. actionManagers: AbstractActionManager[];
  35660. /**
  35661. * Textures to keep.
  35662. */
  35663. textures: BaseTexture[];
  35664. /**
  35665. * Environment texture for the scene
  35666. */
  35667. environmentTexture: Nullable<BaseTexture>;
  35668. }
  35669. }
  35670. declare module "babylonjs/Audio/sound" {
  35671. import { Observable } from "babylonjs/Misc/observable";
  35672. import { Vector3 } from "babylonjs/Maths/math.vector";
  35673. import { Nullable } from "babylonjs/types";
  35674. import { Scene } from "babylonjs/scene";
  35675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35676. /**
  35677. * Interface used to define options for Sound class
  35678. */
  35679. export interface ISoundOptions {
  35680. /**
  35681. * Does the sound autoplay once loaded.
  35682. */
  35683. autoplay?: boolean;
  35684. /**
  35685. * Does the sound loop after it finishes playing once.
  35686. */
  35687. loop?: boolean;
  35688. /**
  35689. * Sound's volume
  35690. */
  35691. volume?: number;
  35692. /**
  35693. * Is it a spatial sound?
  35694. */
  35695. spatialSound?: boolean;
  35696. /**
  35697. * Maximum distance to hear that sound
  35698. */
  35699. maxDistance?: number;
  35700. /**
  35701. * Uses user defined attenuation function
  35702. */
  35703. useCustomAttenuation?: boolean;
  35704. /**
  35705. * Define the roll off factor of spatial sounds.
  35706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35707. */
  35708. rolloffFactor?: number;
  35709. /**
  35710. * Define the reference distance the sound should be heard perfectly.
  35711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35712. */
  35713. refDistance?: number;
  35714. /**
  35715. * Define the distance attenuation model the sound will follow.
  35716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35717. */
  35718. distanceModel?: string;
  35719. /**
  35720. * Defines the playback speed (1 by default)
  35721. */
  35722. playbackRate?: number;
  35723. /**
  35724. * Defines if the sound is from a streaming source
  35725. */
  35726. streaming?: boolean;
  35727. /**
  35728. * Defines an optional length (in seconds) inside the sound file
  35729. */
  35730. length?: number;
  35731. /**
  35732. * Defines an optional offset (in seconds) inside the sound file
  35733. */
  35734. offset?: number;
  35735. /**
  35736. * If true, URLs will not be required to state the audio file codec to use.
  35737. */
  35738. skipCodecCheck?: boolean;
  35739. }
  35740. /**
  35741. * Defines a sound that can be played in the application.
  35742. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35744. */
  35745. export class Sound {
  35746. /**
  35747. * The name of the sound in the scene.
  35748. */
  35749. name: string;
  35750. /**
  35751. * Does the sound autoplay once loaded.
  35752. */
  35753. autoplay: boolean;
  35754. /**
  35755. * Does the sound loop after it finishes playing once.
  35756. */
  35757. loop: boolean;
  35758. /**
  35759. * Does the sound use a custom attenuation curve to simulate the falloff
  35760. * happening when the source gets further away from the camera.
  35761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35762. */
  35763. useCustomAttenuation: boolean;
  35764. /**
  35765. * The sound track id this sound belongs to.
  35766. */
  35767. soundTrackId: number;
  35768. /**
  35769. * Is this sound currently played.
  35770. */
  35771. isPlaying: boolean;
  35772. /**
  35773. * Is this sound currently paused.
  35774. */
  35775. isPaused: boolean;
  35776. /**
  35777. * Does this sound enables spatial sound.
  35778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35779. */
  35780. spatialSound: boolean;
  35781. /**
  35782. * Define the reference distance the sound should be heard perfectly.
  35783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35784. */
  35785. refDistance: number;
  35786. /**
  35787. * Define the roll off factor of spatial sounds.
  35788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35789. */
  35790. rolloffFactor: number;
  35791. /**
  35792. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35794. */
  35795. maxDistance: number;
  35796. /**
  35797. * Define the distance attenuation model the sound will follow.
  35798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35799. */
  35800. distanceModel: string;
  35801. /**
  35802. * @hidden
  35803. * Back Compat
  35804. **/
  35805. onended: () => any;
  35806. /**
  35807. * Observable event when the current playing sound finishes.
  35808. */
  35809. onEndedObservable: Observable<Sound>;
  35810. private _panningModel;
  35811. private _playbackRate;
  35812. private _streaming;
  35813. private _startTime;
  35814. private _startOffset;
  35815. private _position;
  35816. /** @hidden */
  35817. _positionInEmitterSpace: boolean;
  35818. private _localDirection;
  35819. private _volume;
  35820. private _isReadyToPlay;
  35821. private _isDirectional;
  35822. private _readyToPlayCallback;
  35823. private _audioBuffer;
  35824. private _soundSource;
  35825. private _streamingSource;
  35826. private _soundPanner;
  35827. private _soundGain;
  35828. private _inputAudioNode;
  35829. private _outputAudioNode;
  35830. private _coneInnerAngle;
  35831. private _coneOuterAngle;
  35832. private _coneOuterGain;
  35833. private _scene;
  35834. private _connectedTransformNode;
  35835. private _customAttenuationFunction;
  35836. private _registerFunc;
  35837. private _isOutputConnected;
  35838. private _htmlAudioElement;
  35839. private _urlType;
  35840. private _length?;
  35841. private _offset?;
  35842. /** @hidden */
  35843. static _SceneComponentInitialization: (scene: Scene) => void;
  35844. /**
  35845. * Create a sound and attach it to a scene
  35846. * @param name Name of your sound
  35847. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35848. * @param scene defines the scene the sound belongs to
  35849. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35850. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35851. */
  35852. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35853. /**
  35854. * Release the sound and its associated resources
  35855. */
  35856. dispose(): void;
  35857. /**
  35858. * Gets if the sounds is ready to be played or not.
  35859. * @returns true if ready, otherwise false
  35860. */
  35861. isReady(): boolean;
  35862. private _soundLoaded;
  35863. /**
  35864. * Sets the data of the sound from an audiobuffer
  35865. * @param audioBuffer The audioBuffer containing the data
  35866. */
  35867. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35868. /**
  35869. * Updates the current sounds options such as maxdistance, loop...
  35870. * @param options A JSON object containing values named as the object properties
  35871. */
  35872. updateOptions(options: ISoundOptions): void;
  35873. private _createSpatialParameters;
  35874. private _updateSpatialParameters;
  35875. /**
  35876. * Switch the panning model to HRTF:
  35877. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35879. */
  35880. switchPanningModelToHRTF(): void;
  35881. /**
  35882. * Switch the panning model to Equal Power:
  35883. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35885. */
  35886. switchPanningModelToEqualPower(): void;
  35887. private _switchPanningModel;
  35888. /**
  35889. * Connect this sound to a sound track audio node like gain...
  35890. * @param soundTrackAudioNode the sound track audio node to connect to
  35891. */
  35892. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35893. /**
  35894. * Transform this sound into a directional source
  35895. * @param coneInnerAngle Size of the inner cone in degree
  35896. * @param coneOuterAngle Size of the outer cone in degree
  35897. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35898. */
  35899. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35900. /**
  35901. * Gets or sets the inner angle for the directional cone.
  35902. */
  35903. /**
  35904. * Gets or sets the inner angle for the directional cone.
  35905. */
  35906. directionalConeInnerAngle: number;
  35907. /**
  35908. * Gets or sets the outer angle for the directional cone.
  35909. */
  35910. /**
  35911. * Gets or sets the outer angle for the directional cone.
  35912. */
  35913. directionalConeOuterAngle: number;
  35914. /**
  35915. * Sets the position of the emitter if spatial sound is enabled
  35916. * @param newPosition Defines the new posisiton
  35917. */
  35918. setPosition(newPosition: Vector3): void;
  35919. /**
  35920. * Sets the local direction of the emitter if spatial sound is enabled
  35921. * @param newLocalDirection Defines the new local direction
  35922. */
  35923. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35924. private _updateDirection;
  35925. /** @hidden */
  35926. updateDistanceFromListener(): void;
  35927. /**
  35928. * Sets a new custom attenuation function for the sound.
  35929. * @param callback Defines the function used for the attenuation
  35930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35931. */
  35932. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35933. /**
  35934. * Play the sound
  35935. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35936. * @param offset (optional) Start the sound at a specific time in seconds
  35937. * @param length (optional) Sound duration (in seconds)
  35938. */
  35939. play(time?: number, offset?: number, length?: number): void;
  35940. private _onended;
  35941. /**
  35942. * Stop the sound
  35943. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35944. */
  35945. stop(time?: number): void;
  35946. /**
  35947. * Put the sound in pause
  35948. */
  35949. pause(): void;
  35950. /**
  35951. * Sets a dedicated volume for this sounds
  35952. * @param newVolume Define the new volume of the sound
  35953. * @param time Define time for gradual change to new volume
  35954. */
  35955. setVolume(newVolume: number, time?: number): void;
  35956. /**
  35957. * Set the sound play back rate
  35958. * @param newPlaybackRate Define the playback rate the sound should be played at
  35959. */
  35960. setPlaybackRate(newPlaybackRate: number): void;
  35961. /**
  35962. * Gets the volume of the sound.
  35963. * @returns the volume of the sound
  35964. */
  35965. getVolume(): number;
  35966. /**
  35967. * Attach the sound to a dedicated mesh
  35968. * @param transformNode The transform node to connect the sound with
  35969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35970. */
  35971. attachToMesh(transformNode: TransformNode): void;
  35972. /**
  35973. * Detach the sound from the previously attached mesh
  35974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35975. */
  35976. detachFromMesh(): void;
  35977. private _onRegisterAfterWorldMatrixUpdate;
  35978. /**
  35979. * Clone the current sound in the scene.
  35980. * @returns the new sound clone
  35981. */
  35982. clone(): Nullable<Sound>;
  35983. /**
  35984. * Gets the current underlying audio buffer containing the data
  35985. * @returns the audio buffer
  35986. */
  35987. getAudioBuffer(): Nullable<AudioBuffer>;
  35988. /**
  35989. * Serializes the Sound in a JSON representation
  35990. * @returns the JSON representation of the sound
  35991. */
  35992. serialize(): any;
  35993. /**
  35994. * Parse a JSON representation of a sound to innstantiate in a given scene
  35995. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35996. * @param scene Define the scene the new parsed sound should be created in
  35997. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35998. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35999. * @returns the newly parsed sound
  36000. */
  36001. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36002. }
  36003. }
  36004. declare module "babylonjs/Actions/directAudioActions" {
  36005. import { Action } from "babylonjs/Actions/action";
  36006. import { Condition } from "babylonjs/Actions/condition";
  36007. import { Sound } from "babylonjs/Audio/sound";
  36008. /**
  36009. * This defines an action helpful to play a defined sound on a triggered action.
  36010. */
  36011. export class PlaySoundAction extends Action {
  36012. private _sound;
  36013. /**
  36014. * Instantiate the action
  36015. * @param triggerOptions defines the trigger options
  36016. * @param sound defines the sound to play
  36017. * @param condition defines the trigger related conditions
  36018. */
  36019. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36020. /** @hidden */
  36021. _prepare(): void;
  36022. /**
  36023. * Execute the action and play the sound.
  36024. */
  36025. execute(): void;
  36026. /**
  36027. * Serializes the actions and its related information.
  36028. * @param parent defines the object to serialize in
  36029. * @returns the serialized object
  36030. */
  36031. serialize(parent: any): any;
  36032. }
  36033. /**
  36034. * This defines an action helpful to stop a defined sound on a triggered action.
  36035. */
  36036. export class StopSoundAction extends Action {
  36037. private _sound;
  36038. /**
  36039. * Instantiate the action
  36040. * @param triggerOptions defines the trigger options
  36041. * @param sound defines the sound to stop
  36042. * @param condition defines the trigger related conditions
  36043. */
  36044. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36045. /** @hidden */
  36046. _prepare(): void;
  36047. /**
  36048. * Execute the action and stop the sound.
  36049. */
  36050. execute(): void;
  36051. /**
  36052. * Serializes the actions and its related information.
  36053. * @param parent defines the object to serialize in
  36054. * @returns the serialized object
  36055. */
  36056. serialize(parent: any): any;
  36057. }
  36058. }
  36059. declare module "babylonjs/Actions/interpolateValueAction" {
  36060. import { Action } from "babylonjs/Actions/action";
  36061. import { Condition } from "babylonjs/Actions/condition";
  36062. import { Observable } from "babylonjs/Misc/observable";
  36063. /**
  36064. * This defines an action responsible to change the value of a property
  36065. * by interpolating between its current value and the newly set one once triggered.
  36066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36067. */
  36068. export class InterpolateValueAction extends Action {
  36069. /**
  36070. * Defines the path of the property where the value should be interpolated
  36071. */
  36072. propertyPath: string;
  36073. /**
  36074. * Defines the target value at the end of the interpolation.
  36075. */
  36076. value: any;
  36077. /**
  36078. * Defines the time it will take for the property to interpolate to the value.
  36079. */
  36080. duration: number;
  36081. /**
  36082. * Defines if the other scene animations should be stopped when the action has been triggered
  36083. */
  36084. stopOtherAnimations?: boolean;
  36085. /**
  36086. * Defines a callback raised once the interpolation animation has been done.
  36087. */
  36088. onInterpolationDone?: () => void;
  36089. /**
  36090. * Observable triggered once the interpolation animation has been done.
  36091. */
  36092. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36093. private _target;
  36094. private _effectiveTarget;
  36095. private _property;
  36096. /**
  36097. * Instantiate the action
  36098. * @param triggerOptions defines the trigger options
  36099. * @param target defines the object containing the value to interpolate
  36100. * @param propertyPath defines the path to the property in the target object
  36101. * @param value defines the target value at the end of the interpolation
  36102. * @param duration deines the time it will take for the property to interpolate to the value.
  36103. * @param condition defines the trigger related conditions
  36104. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36105. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36106. */
  36107. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36108. /** @hidden */
  36109. _prepare(): void;
  36110. /**
  36111. * Execute the action starts the value interpolation.
  36112. */
  36113. execute(): void;
  36114. /**
  36115. * Serializes the actions and its related information.
  36116. * @param parent defines the object to serialize in
  36117. * @returns the serialized object
  36118. */
  36119. serialize(parent: any): any;
  36120. }
  36121. }
  36122. declare module "babylonjs/Actions/index" {
  36123. export * from "babylonjs/Actions/abstractActionManager";
  36124. export * from "babylonjs/Actions/action";
  36125. export * from "babylonjs/Actions/actionEvent";
  36126. export * from "babylonjs/Actions/actionManager";
  36127. export * from "babylonjs/Actions/condition";
  36128. export * from "babylonjs/Actions/directActions";
  36129. export * from "babylonjs/Actions/directAudioActions";
  36130. export * from "babylonjs/Actions/interpolateValueAction";
  36131. }
  36132. declare module "babylonjs/Animations/index" {
  36133. export * from "babylonjs/Animations/animatable";
  36134. export * from "babylonjs/Animations/animation";
  36135. export * from "babylonjs/Animations/animationGroup";
  36136. export * from "babylonjs/Animations/animationPropertiesOverride";
  36137. export * from "babylonjs/Animations/easing";
  36138. export * from "babylonjs/Animations/runtimeAnimation";
  36139. export * from "babylonjs/Animations/animationEvent";
  36140. export * from "babylonjs/Animations/animationGroup";
  36141. export * from "babylonjs/Animations/animationKey";
  36142. export * from "babylonjs/Animations/animationRange";
  36143. export * from "babylonjs/Animations/animatable.interface";
  36144. }
  36145. declare module "babylonjs/Audio/soundTrack" {
  36146. import { Sound } from "babylonjs/Audio/sound";
  36147. import { Analyser } from "babylonjs/Audio/analyser";
  36148. import { Scene } from "babylonjs/scene";
  36149. /**
  36150. * Options allowed during the creation of a sound track.
  36151. */
  36152. export interface ISoundTrackOptions {
  36153. /**
  36154. * The volume the sound track should take during creation
  36155. */
  36156. volume?: number;
  36157. /**
  36158. * Define if the sound track is the main sound track of the scene
  36159. */
  36160. mainTrack?: boolean;
  36161. }
  36162. /**
  36163. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36164. * It will be also used in a future release to apply effects on a specific track.
  36165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36166. */
  36167. export class SoundTrack {
  36168. /**
  36169. * The unique identifier of the sound track in the scene.
  36170. */
  36171. id: number;
  36172. /**
  36173. * The list of sounds included in the sound track.
  36174. */
  36175. soundCollection: Array<Sound>;
  36176. private _outputAudioNode;
  36177. private _scene;
  36178. private _isMainTrack;
  36179. private _connectedAnalyser;
  36180. private _options;
  36181. private _isInitialized;
  36182. /**
  36183. * Creates a new sound track.
  36184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36185. * @param scene Define the scene the sound track belongs to
  36186. * @param options
  36187. */
  36188. constructor(scene: Scene, options?: ISoundTrackOptions);
  36189. private _initializeSoundTrackAudioGraph;
  36190. /**
  36191. * Release the sound track and its associated resources
  36192. */
  36193. dispose(): void;
  36194. /**
  36195. * Adds a sound to this sound track
  36196. * @param sound define the cound to add
  36197. * @ignoreNaming
  36198. */
  36199. AddSound(sound: Sound): void;
  36200. /**
  36201. * Removes a sound to this sound track
  36202. * @param sound define the cound to remove
  36203. * @ignoreNaming
  36204. */
  36205. RemoveSound(sound: Sound): void;
  36206. /**
  36207. * Set a global volume for the full sound track.
  36208. * @param newVolume Define the new volume of the sound track
  36209. */
  36210. setVolume(newVolume: number): void;
  36211. /**
  36212. * Switch the panning model to HRTF:
  36213. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36215. */
  36216. switchPanningModelToHRTF(): void;
  36217. /**
  36218. * Switch the panning model to Equal Power:
  36219. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36221. */
  36222. switchPanningModelToEqualPower(): void;
  36223. /**
  36224. * Connect the sound track to an audio analyser allowing some amazing
  36225. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36227. * @param analyser The analyser to connect to the engine
  36228. */
  36229. connectToAnalyser(analyser: Analyser): void;
  36230. }
  36231. }
  36232. declare module "babylonjs/Audio/audioSceneComponent" {
  36233. import { Sound } from "babylonjs/Audio/sound";
  36234. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36235. import { Nullable } from "babylonjs/types";
  36236. import { Vector3 } from "babylonjs/Maths/math.vector";
  36237. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36238. import { Scene } from "babylonjs/scene";
  36239. import { AbstractScene } from "babylonjs/abstractScene";
  36240. import "babylonjs/Audio/audioEngine";
  36241. module "babylonjs/abstractScene" {
  36242. interface AbstractScene {
  36243. /**
  36244. * The list of sounds used in the scene.
  36245. */
  36246. sounds: Nullable<Array<Sound>>;
  36247. }
  36248. }
  36249. module "babylonjs/scene" {
  36250. interface Scene {
  36251. /**
  36252. * @hidden
  36253. * Backing field
  36254. */
  36255. _mainSoundTrack: SoundTrack;
  36256. /**
  36257. * The main sound track played by the scene.
  36258. * It cotains your primary collection of sounds.
  36259. */
  36260. mainSoundTrack: SoundTrack;
  36261. /**
  36262. * The list of sound tracks added to the scene
  36263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36264. */
  36265. soundTracks: Nullable<Array<SoundTrack>>;
  36266. /**
  36267. * Gets a sound using a given name
  36268. * @param name defines the name to search for
  36269. * @return the found sound or null if not found at all.
  36270. */
  36271. getSoundByName(name: string): Nullable<Sound>;
  36272. /**
  36273. * Gets or sets if audio support is enabled
  36274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36275. */
  36276. audioEnabled: boolean;
  36277. /**
  36278. * Gets or sets if audio will be output to headphones
  36279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36280. */
  36281. headphone: boolean;
  36282. /**
  36283. * Gets or sets custom audio listener position provider
  36284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36285. */
  36286. audioListenerPositionProvider: Nullable<() => Vector3>;
  36287. }
  36288. }
  36289. /**
  36290. * Defines the sound scene component responsible to manage any sounds
  36291. * in a given scene.
  36292. */
  36293. export class AudioSceneComponent implements ISceneSerializableComponent {
  36294. /**
  36295. * The component name helpfull to identify the component in the list of scene components.
  36296. */
  36297. readonly name: string;
  36298. /**
  36299. * The scene the component belongs to.
  36300. */
  36301. scene: Scene;
  36302. private _audioEnabled;
  36303. /**
  36304. * Gets whether audio is enabled or not.
  36305. * Please use related enable/disable method to switch state.
  36306. */
  36307. readonly audioEnabled: boolean;
  36308. private _headphone;
  36309. /**
  36310. * Gets whether audio is outputing to headphone or not.
  36311. * Please use the according Switch methods to change output.
  36312. */
  36313. readonly headphone: boolean;
  36314. private _audioListenerPositionProvider;
  36315. /**
  36316. * Gets the current audio listener position provider
  36317. */
  36318. /**
  36319. * Sets a custom listener position for all sounds in the scene
  36320. * By default, this is the position of the first active camera
  36321. */
  36322. audioListenerPositionProvider: Nullable<() => Vector3>;
  36323. /**
  36324. * Creates a new instance of the component for the given scene
  36325. * @param scene Defines the scene to register the component in
  36326. */
  36327. constructor(scene: Scene);
  36328. /**
  36329. * Registers the component in a given scene
  36330. */
  36331. register(): void;
  36332. /**
  36333. * Rebuilds the elements related to this component in case of
  36334. * context lost for instance.
  36335. */
  36336. rebuild(): void;
  36337. /**
  36338. * Serializes the component data to the specified json object
  36339. * @param serializationObject The object to serialize to
  36340. */
  36341. serialize(serializationObject: any): void;
  36342. /**
  36343. * Adds all the elements from the container to the scene
  36344. * @param container the container holding the elements
  36345. */
  36346. addFromContainer(container: AbstractScene): void;
  36347. /**
  36348. * Removes all the elements in the container from the scene
  36349. * @param container contains the elements to remove
  36350. * @param dispose if the removed element should be disposed (default: false)
  36351. */
  36352. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36353. /**
  36354. * Disposes the component and the associated ressources.
  36355. */
  36356. dispose(): void;
  36357. /**
  36358. * Disables audio in the associated scene.
  36359. */
  36360. disableAudio(): void;
  36361. /**
  36362. * Enables audio in the associated scene.
  36363. */
  36364. enableAudio(): void;
  36365. /**
  36366. * Switch audio to headphone output.
  36367. */
  36368. switchAudioModeForHeadphones(): void;
  36369. /**
  36370. * Switch audio to normal speakers.
  36371. */
  36372. switchAudioModeForNormalSpeakers(): void;
  36373. private _afterRender;
  36374. }
  36375. }
  36376. declare module "babylonjs/Audio/weightedsound" {
  36377. import { Sound } from "babylonjs/Audio/sound";
  36378. /**
  36379. * Wraps one or more Sound objects and selects one with random weight for playback.
  36380. */
  36381. export class WeightedSound {
  36382. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36383. loop: boolean;
  36384. private _coneInnerAngle;
  36385. private _coneOuterAngle;
  36386. private _volume;
  36387. /** A Sound is currently playing. */
  36388. isPlaying: boolean;
  36389. /** A Sound is currently paused. */
  36390. isPaused: boolean;
  36391. private _sounds;
  36392. private _weights;
  36393. private _currentIndex?;
  36394. /**
  36395. * Creates a new WeightedSound from the list of sounds given.
  36396. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36397. * @param sounds Array of Sounds that will be selected from.
  36398. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36399. */
  36400. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36401. /**
  36402. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36403. */
  36404. /**
  36405. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36406. */
  36407. directionalConeInnerAngle: number;
  36408. /**
  36409. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36410. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36411. */
  36412. /**
  36413. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36414. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36415. */
  36416. directionalConeOuterAngle: number;
  36417. /**
  36418. * Playback volume.
  36419. */
  36420. /**
  36421. * Playback volume.
  36422. */
  36423. volume: number;
  36424. private _onended;
  36425. /**
  36426. * Suspend playback
  36427. */
  36428. pause(): void;
  36429. /**
  36430. * Stop playback
  36431. */
  36432. stop(): void;
  36433. /**
  36434. * Start playback.
  36435. * @param startOffset Position the clip head at a specific time in seconds.
  36436. */
  36437. play(startOffset?: number): void;
  36438. }
  36439. }
  36440. declare module "babylonjs/Audio/index" {
  36441. export * from "babylonjs/Audio/analyser";
  36442. export * from "babylonjs/Audio/audioEngine";
  36443. export * from "babylonjs/Audio/audioSceneComponent";
  36444. export * from "babylonjs/Audio/sound";
  36445. export * from "babylonjs/Audio/soundTrack";
  36446. export * from "babylonjs/Audio/weightedsound";
  36447. }
  36448. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36449. import { Behavior } from "babylonjs/Behaviors/behavior";
  36450. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36451. import { BackEase } from "babylonjs/Animations/easing";
  36452. /**
  36453. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36454. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36455. */
  36456. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36457. /**
  36458. * Gets the name of the behavior.
  36459. */
  36460. readonly name: string;
  36461. /**
  36462. * The easing function used by animations
  36463. */
  36464. static EasingFunction: BackEase;
  36465. /**
  36466. * The easing mode used by animations
  36467. */
  36468. static EasingMode: number;
  36469. /**
  36470. * The duration of the animation, in milliseconds
  36471. */
  36472. transitionDuration: number;
  36473. /**
  36474. * Length of the distance animated by the transition when lower radius is reached
  36475. */
  36476. lowerRadiusTransitionRange: number;
  36477. /**
  36478. * Length of the distance animated by the transition when upper radius is reached
  36479. */
  36480. upperRadiusTransitionRange: number;
  36481. private _autoTransitionRange;
  36482. /**
  36483. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36484. */
  36485. /**
  36486. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36487. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36488. */
  36489. autoTransitionRange: boolean;
  36490. private _attachedCamera;
  36491. private _onAfterCheckInputsObserver;
  36492. private _onMeshTargetChangedObserver;
  36493. /**
  36494. * Initializes the behavior.
  36495. */
  36496. init(): void;
  36497. /**
  36498. * Attaches the behavior to its arc rotate camera.
  36499. * @param camera Defines the camera to attach the behavior to
  36500. */
  36501. attach(camera: ArcRotateCamera): void;
  36502. /**
  36503. * Detaches the behavior from its current arc rotate camera.
  36504. */
  36505. detach(): void;
  36506. private _radiusIsAnimating;
  36507. private _radiusBounceTransition;
  36508. private _animatables;
  36509. private _cachedWheelPrecision;
  36510. /**
  36511. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36512. * @param radiusLimit The limit to check against.
  36513. * @return Bool to indicate if at limit.
  36514. */
  36515. private _isRadiusAtLimit;
  36516. /**
  36517. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36518. * @param radiusDelta The delta by which to animate to. Can be negative.
  36519. */
  36520. private _applyBoundRadiusAnimation;
  36521. /**
  36522. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36523. */
  36524. protected _clearAnimationLocks(): void;
  36525. /**
  36526. * Stops and removes all animations that have been applied to the camera
  36527. */
  36528. stopAllAnimations(): void;
  36529. }
  36530. }
  36531. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36532. import { Behavior } from "babylonjs/Behaviors/behavior";
  36533. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36534. import { ExponentialEase } from "babylonjs/Animations/easing";
  36535. import { Nullable } from "babylonjs/types";
  36536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36537. import { Vector3 } from "babylonjs/Maths/math.vector";
  36538. /**
  36539. * 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.
  36540. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36541. */
  36542. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36543. /**
  36544. * Gets the name of the behavior.
  36545. */
  36546. readonly name: string;
  36547. private _mode;
  36548. private _radiusScale;
  36549. private _positionScale;
  36550. private _defaultElevation;
  36551. private _elevationReturnTime;
  36552. private _elevationReturnWaitTime;
  36553. private _zoomStopsAnimation;
  36554. private _framingTime;
  36555. /**
  36556. * The easing function used by animations
  36557. */
  36558. static EasingFunction: ExponentialEase;
  36559. /**
  36560. * The easing mode used by animations
  36561. */
  36562. static EasingMode: number;
  36563. /**
  36564. * Sets the current mode used by the behavior
  36565. */
  36566. /**
  36567. * Gets current mode used by the behavior.
  36568. */
  36569. mode: number;
  36570. /**
  36571. * Sets the scale applied to the radius (1 by default)
  36572. */
  36573. /**
  36574. * Gets the scale applied to the radius
  36575. */
  36576. radiusScale: number;
  36577. /**
  36578. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36579. */
  36580. /**
  36581. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36582. */
  36583. positionScale: number;
  36584. /**
  36585. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36586. * behaviour is triggered, in radians.
  36587. */
  36588. /**
  36589. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36590. * behaviour is triggered, in radians.
  36591. */
  36592. defaultElevation: number;
  36593. /**
  36594. * Sets the time (in milliseconds) taken to return to the default beta position.
  36595. * Negative value indicates camera should not return to default.
  36596. */
  36597. /**
  36598. * Gets the time (in milliseconds) taken to return to the default beta position.
  36599. * Negative value indicates camera should not return to default.
  36600. */
  36601. elevationReturnTime: number;
  36602. /**
  36603. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36604. */
  36605. /**
  36606. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36607. */
  36608. elevationReturnWaitTime: number;
  36609. /**
  36610. * Sets the flag that indicates if user zooming should stop animation.
  36611. */
  36612. /**
  36613. * Gets the flag that indicates if user zooming should stop animation.
  36614. */
  36615. zoomStopsAnimation: boolean;
  36616. /**
  36617. * Sets the transition time when framing the mesh, in milliseconds
  36618. */
  36619. /**
  36620. * Gets the transition time when framing the mesh, in milliseconds
  36621. */
  36622. framingTime: number;
  36623. /**
  36624. * Define if the behavior should automatically change the configured
  36625. * camera limits and sensibilities.
  36626. */
  36627. autoCorrectCameraLimitsAndSensibility: boolean;
  36628. private _onPrePointerObservableObserver;
  36629. private _onAfterCheckInputsObserver;
  36630. private _onMeshTargetChangedObserver;
  36631. private _attachedCamera;
  36632. private _isPointerDown;
  36633. private _lastInteractionTime;
  36634. /**
  36635. * Initializes the behavior.
  36636. */
  36637. init(): void;
  36638. /**
  36639. * Attaches the behavior to its arc rotate camera.
  36640. * @param camera Defines the camera to attach the behavior to
  36641. */
  36642. attach(camera: ArcRotateCamera): void;
  36643. /**
  36644. * Detaches the behavior from its current arc rotate camera.
  36645. */
  36646. detach(): void;
  36647. private _animatables;
  36648. private _betaIsAnimating;
  36649. private _betaTransition;
  36650. private _radiusTransition;
  36651. private _vectorTransition;
  36652. /**
  36653. * Targets the given mesh and updates zoom level accordingly.
  36654. * @param mesh The mesh to target.
  36655. * @param radius Optional. If a cached radius position already exists, overrides default.
  36656. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36657. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36658. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36659. */
  36660. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36661. /**
  36662. * Targets the given mesh with its children and updates zoom level accordingly.
  36663. * @param mesh The mesh to target.
  36664. * @param radius Optional. If a cached radius position already exists, overrides default.
  36665. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36666. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36667. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36668. */
  36669. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36670. /**
  36671. * Targets the given meshes with their children and updates zoom level accordingly.
  36672. * @param meshes The mesh to target.
  36673. * @param radius Optional. If a cached radius position already exists, overrides default.
  36674. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36677. */
  36678. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36679. /**
  36680. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36681. * @param minimumWorld Determines the smaller position of the bounding box extend
  36682. * @param maximumWorld Determines the bigger position of the bounding box extend
  36683. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36684. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36685. */
  36686. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36687. /**
  36688. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36689. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36690. * frustum width.
  36691. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36692. * to fully enclose the mesh in the viewing frustum.
  36693. */
  36694. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36695. /**
  36696. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36697. * is automatically returned to its default position (expected to be above ground plane).
  36698. */
  36699. private _maintainCameraAboveGround;
  36700. /**
  36701. * Returns the frustum slope based on the canvas ratio and camera FOV
  36702. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36703. */
  36704. private _getFrustumSlope;
  36705. /**
  36706. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36707. */
  36708. private _clearAnimationLocks;
  36709. /**
  36710. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36711. */
  36712. private _applyUserInteraction;
  36713. /**
  36714. * Stops and removes all animations that have been applied to the camera
  36715. */
  36716. stopAllAnimations(): void;
  36717. /**
  36718. * Gets a value indicating if the user is moving the camera
  36719. */
  36720. readonly isUserIsMoving: boolean;
  36721. /**
  36722. * The camera can move all the way towards the mesh.
  36723. */
  36724. static IgnoreBoundsSizeMode: number;
  36725. /**
  36726. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36727. */
  36728. static FitFrustumSidesMode: number;
  36729. }
  36730. }
  36731. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36732. import { Nullable } from "babylonjs/types";
  36733. import { Camera } from "babylonjs/Cameras/camera";
  36734. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36735. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36736. /**
  36737. * Base class for Camera Pointer Inputs.
  36738. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36739. * for example usage.
  36740. */
  36741. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36742. /**
  36743. * Defines the camera the input is attached to.
  36744. */
  36745. abstract camera: Camera;
  36746. /**
  36747. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36748. */
  36749. protected _altKey: boolean;
  36750. protected _ctrlKey: boolean;
  36751. protected _metaKey: boolean;
  36752. protected _shiftKey: boolean;
  36753. /**
  36754. * Which mouse buttons were pressed at time of last mouse event.
  36755. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36756. */
  36757. protected _buttonsPressed: number;
  36758. /**
  36759. * Defines the buttons associated with the input to handle camera move.
  36760. */
  36761. buttons: number[];
  36762. /**
  36763. * Attach the input controls to a specific dom element to get the input from.
  36764. * @param element Defines the element the controls should be listened from
  36765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36766. */
  36767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36768. /**
  36769. * Detach the current controls from the specified dom element.
  36770. * @param element Defines the element to stop listening the inputs from
  36771. */
  36772. detachControl(element: Nullable<HTMLElement>): void;
  36773. /**
  36774. * Gets the class name of the current input.
  36775. * @returns the class name
  36776. */
  36777. getClassName(): string;
  36778. /**
  36779. * Get the friendly name associated with the input class.
  36780. * @returns the input friendly name
  36781. */
  36782. getSimpleName(): string;
  36783. /**
  36784. * Called on pointer POINTERDOUBLETAP event.
  36785. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36786. */
  36787. protected onDoubleTap(type: string): void;
  36788. /**
  36789. * Called on pointer POINTERMOVE event if only a single touch is active.
  36790. * Override this method to provide functionality.
  36791. */
  36792. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36793. /**
  36794. * Called on pointer POINTERMOVE event if multiple touches are active.
  36795. * Override this method to provide functionality.
  36796. */
  36797. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36798. /**
  36799. * Called on JS contextmenu event.
  36800. * Override this method to provide functionality.
  36801. */
  36802. protected onContextMenu(evt: PointerEvent): void;
  36803. /**
  36804. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36805. * press.
  36806. * Override this method to provide functionality.
  36807. */
  36808. protected onButtonDown(evt: PointerEvent): void;
  36809. /**
  36810. * Called each time a new POINTERUP event occurs. Ie, for each button
  36811. * release.
  36812. * Override this method to provide functionality.
  36813. */
  36814. protected onButtonUp(evt: PointerEvent): void;
  36815. /**
  36816. * Called when window becomes inactive.
  36817. * Override this method to provide functionality.
  36818. */
  36819. protected onLostFocus(): void;
  36820. private _pointerInput;
  36821. private _observer;
  36822. private _onLostFocus;
  36823. private pointA;
  36824. private pointB;
  36825. }
  36826. }
  36827. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36828. import { Nullable } from "babylonjs/types";
  36829. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36830. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36831. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36832. /**
  36833. * Manage the pointers inputs to control an arc rotate camera.
  36834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36835. */
  36836. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36837. /**
  36838. * Defines the camera the input is attached to.
  36839. */
  36840. camera: ArcRotateCamera;
  36841. /**
  36842. * Gets the class name of the current input.
  36843. * @returns the class name
  36844. */
  36845. getClassName(): string;
  36846. /**
  36847. * Defines the buttons associated with the input to handle camera move.
  36848. */
  36849. buttons: number[];
  36850. /**
  36851. * Defines the pointer angular sensibility along the X axis or how fast is
  36852. * the camera rotating.
  36853. */
  36854. angularSensibilityX: number;
  36855. /**
  36856. * Defines the pointer angular sensibility along the Y axis or how fast is
  36857. * the camera rotating.
  36858. */
  36859. angularSensibilityY: number;
  36860. /**
  36861. * Defines the pointer pinch precision or how fast is the camera zooming.
  36862. */
  36863. pinchPrecision: number;
  36864. /**
  36865. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36866. * from 0.
  36867. * It defines the percentage of current camera.radius to use as delta when
  36868. * pinch zoom is used.
  36869. */
  36870. pinchDeltaPercentage: number;
  36871. /**
  36872. * Defines the pointer panning sensibility or how fast is the camera moving.
  36873. */
  36874. panningSensibility: number;
  36875. /**
  36876. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36877. */
  36878. multiTouchPanning: boolean;
  36879. /**
  36880. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36881. * zoom (pinch) through multitouch.
  36882. */
  36883. multiTouchPanAndZoom: boolean;
  36884. /**
  36885. * Revers pinch action direction.
  36886. */
  36887. pinchInwards: boolean;
  36888. private _isPanClick;
  36889. private _twoFingerActivityCount;
  36890. private _isPinching;
  36891. /**
  36892. * Called on pointer POINTERMOVE event if only a single touch is active.
  36893. */
  36894. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36895. /**
  36896. * Called on pointer POINTERDOUBLETAP event.
  36897. */
  36898. protected onDoubleTap(type: string): void;
  36899. /**
  36900. * Called on pointer POINTERMOVE event if multiple touches are active.
  36901. */
  36902. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36903. /**
  36904. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36905. * press.
  36906. */
  36907. protected onButtonDown(evt: PointerEvent): void;
  36908. /**
  36909. * Called each time a new POINTERUP event occurs. Ie, for each button
  36910. * release.
  36911. */
  36912. protected onButtonUp(evt: PointerEvent): void;
  36913. /**
  36914. * Called when window becomes inactive.
  36915. */
  36916. protected onLostFocus(): void;
  36917. }
  36918. }
  36919. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36920. import { Nullable } from "babylonjs/types";
  36921. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36922. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36923. /**
  36924. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36925. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36926. */
  36927. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36928. /**
  36929. * Defines the camera the input is attached to.
  36930. */
  36931. camera: ArcRotateCamera;
  36932. /**
  36933. * Defines the list of key codes associated with the up action (increase alpha)
  36934. */
  36935. keysUp: number[];
  36936. /**
  36937. * Defines the list of key codes associated with the down action (decrease alpha)
  36938. */
  36939. keysDown: number[];
  36940. /**
  36941. * Defines the list of key codes associated with the left action (increase beta)
  36942. */
  36943. keysLeft: number[];
  36944. /**
  36945. * Defines the list of key codes associated with the right action (decrease beta)
  36946. */
  36947. keysRight: number[];
  36948. /**
  36949. * Defines the list of key codes associated with the reset action.
  36950. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36951. */
  36952. keysReset: number[];
  36953. /**
  36954. * Defines the panning sensibility of the inputs.
  36955. * (How fast is the camera paning)
  36956. */
  36957. panningSensibility: number;
  36958. /**
  36959. * Defines the zooming sensibility of the inputs.
  36960. * (How fast is the camera zooming)
  36961. */
  36962. zoomingSensibility: number;
  36963. /**
  36964. * Defines wether maintaining the alt key down switch the movement mode from
  36965. * orientation to zoom.
  36966. */
  36967. useAltToZoom: boolean;
  36968. /**
  36969. * Rotation speed of the camera
  36970. */
  36971. angularSpeed: number;
  36972. private _keys;
  36973. private _ctrlPressed;
  36974. private _altPressed;
  36975. private _onCanvasBlurObserver;
  36976. private _onKeyboardObserver;
  36977. private _engine;
  36978. private _scene;
  36979. /**
  36980. * Attach the input controls to a specific dom element to get the input from.
  36981. * @param element Defines the element the controls should be listened from
  36982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36983. */
  36984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36985. /**
  36986. * Detach the current controls from the specified dom element.
  36987. * @param element Defines the element to stop listening the inputs from
  36988. */
  36989. detachControl(element: Nullable<HTMLElement>): void;
  36990. /**
  36991. * Update the current camera state depending on the inputs that have been used this frame.
  36992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36993. */
  36994. checkInputs(): void;
  36995. /**
  36996. * Gets the class name of the current intput.
  36997. * @returns the class name
  36998. */
  36999. getClassName(): string;
  37000. /**
  37001. * Get the friendly name associated with the input class.
  37002. * @returns the input friendly name
  37003. */
  37004. getSimpleName(): string;
  37005. }
  37006. }
  37007. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37008. import { Nullable } from "babylonjs/types";
  37009. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37010. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37011. /**
  37012. * Manage the mouse wheel inputs to control an arc rotate camera.
  37013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37014. */
  37015. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37016. /**
  37017. * Defines the camera the input is attached to.
  37018. */
  37019. camera: ArcRotateCamera;
  37020. /**
  37021. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37022. */
  37023. wheelPrecision: number;
  37024. /**
  37025. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37026. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37027. */
  37028. wheelDeltaPercentage: number;
  37029. private _wheel;
  37030. private _observer;
  37031. private computeDeltaFromMouseWheelLegacyEvent;
  37032. /**
  37033. * Attach the input controls to a specific dom element to get the input from.
  37034. * @param element Defines the element the controls should be listened from
  37035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37036. */
  37037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37038. /**
  37039. * Detach the current controls from the specified dom element.
  37040. * @param element Defines the element to stop listening the inputs from
  37041. */
  37042. detachControl(element: Nullable<HTMLElement>): void;
  37043. /**
  37044. * Gets the class name of the current intput.
  37045. * @returns the class name
  37046. */
  37047. getClassName(): string;
  37048. /**
  37049. * Get the friendly name associated with the input class.
  37050. * @returns the input friendly name
  37051. */
  37052. getSimpleName(): string;
  37053. }
  37054. }
  37055. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37056. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37057. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37058. /**
  37059. * Default Inputs manager for the ArcRotateCamera.
  37060. * It groups all the default supported inputs for ease of use.
  37061. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37062. */
  37063. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37064. /**
  37065. * Instantiates a new ArcRotateCameraInputsManager.
  37066. * @param camera Defines the camera the inputs belong to
  37067. */
  37068. constructor(camera: ArcRotateCamera);
  37069. /**
  37070. * Add mouse wheel input support to the input manager.
  37071. * @returns the current input manager
  37072. */
  37073. addMouseWheel(): ArcRotateCameraInputsManager;
  37074. /**
  37075. * Add pointers input support to the input manager.
  37076. * @returns the current input manager
  37077. */
  37078. addPointers(): ArcRotateCameraInputsManager;
  37079. /**
  37080. * Add keyboard input support to the input manager.
  37081. * @returns the current input manager
  37082. */
  37083. addKeyboard(): ArcRotateCameraInputsManager;
  37084. }
  37085. }
  37086. declare module "babylonjs/Cameras/arcRotateCamera" {
  37087. import { Observable } from "babylonjs/Misc/observable";
  37088. import { Nullable } from "babylonjs/types";
  37089. import { Scene } from "babylonjs/scene";
  37090. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37092. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37093. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37094. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37095. import { Camera } from "babylonjs/Cameras/camera";
  37096. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37097. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37098. import { Collider } from "babylonjs/Collisions/collider";
  37099. /**
  37100. * This represents an orbital type of camera.
  37101. *
  37102. * 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.
  37103. * 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.
  37104. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37105. */
  37106. export class ArcRotateCamera extends TargetCamera {
  37107. /**
  37108. * Defines the rotation angle of the camera along the longitudinal axis.
  37109. */
  37110. alpha: number;
  37111. /**
  37112. * Defines the rotation angle of the camera along the latitudinal axis.
  37113. */
  37114. beta: number;
  37115. /**
  37116. * Defines the radius of the camera from it s target point.
  37117. */
  37118. radius: number;
  37119. protected _target: Vector3;
  37120. protected _targetHost: Nullable<AbstractMesh>;
  37121. /**
  37122. * Defines the target point of the camera.
  37123. * The camera looks towards it form the radius distance.
  37124. */
  37125. target: Vector3;
  37126. /**
  37127. * Define the current local position of the camera in the scene
  37128. */
  37129. position: Vector3;
  37130. protected _upVector: Vector3;
  37131. protected _upToYMatrix: Matrix;
  37132. protected _YToUpMatrix: Matrix;
  37133. /**
  37134. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37135. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37136. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37137. */
  37138. upVector: Vector3;
  37139. /**
  37140. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37141. */
  37142. setMatUp(): void;
  37143. /**
  37144. * Current inertia value on the longitudinal axis.
  37145. * The bigger this number the longer it will take for the camera to stop.
  37146. */
  37147. inertialAlphaOffset: number;
  37148. /**
  37149. * Current inertia value on the latitudinal axis.
  37150. * The bigger this number the longer it will take for the camera to stop.
  37151. */
  37152. inertialBetaOffset: number;
  37153. /**
  37154. * Current inertia value on the radius axis.
  37155. * The bigger this number the longer it will take for the camera to stop.
  37156. */
  37157. inertialRadiusOffset: number;
  37158. /**
  37159. * Minimum allowed angle on the longitudinal axis.
  37160. * This can help limiting how the Camera is able to move in the scene.
  37161. */
  37162. lowerAlphaLimit: Nullable<number>;
  37163. /**
  37164. * Maximum allowed angle on the longitudinal axis.
  37165. * This can help limiting how the Camera is able to move in the scene.
  37166. */
  37167. upperAlphaLimit: Nullable<number>;
  37168. /**
  37169. * Minimum allowed angle on the latitudinal axis.
  37170. * This can help limiting how the Camera is able to move in the scene.
  37171. */
  37172. lowerBetaLimit: number;
  37173. /**
  37174. * Maximum allowed angle on the latitudinal axis.
  37175. * This can help limiting how the Camera is able to move in the scene.
  37176. */
  37177. upperBetaLimit: number;
  37178. /**
  37179. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37180. * This can help limiting how the Camera is able to move in the scene.
  37181. */
  37182. lowerRadiusLimit: Nullable<number>;
  37183. /**
  37184. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37185. * This can help limiting how the Camera is able to move in the scene.
  37186. */
  37187. upperRadiusLimit: Nullable<number>;
  37188. /**
  37189. * Defines the current inertia value used during panning of the camera along the X axis.
  37190. */
  37191. inertialPanningX: number;
  37192. /**
  37193. * Defines the current inertia value used during panning of the camera along the Y axis.
  37194. */
  37195. inertialPanningY: number;
  37196. /**
  37197. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37198. * Basically if your fingers moves away from more than this distance you will be considered
  37199. * in pinch mode.
  37200. */
  37201. pinchToPanMaxDistance: number;
  37202. /**
  37203. * Defines the maximum distance the camera can pan.
  37204. * This could help keeping the cammera always in your scene.
  37205. */
  37206. panningDistanceLimit: Nullable<number>;
  37207. /**
  37208. * Defines the target of the camera before paning.
  37209. */
  37210. panningOriginTarget: Vector3;
  37211. /**
  37212. * Defines the value of the inertia used during panning.
  37213. * 0 would mean stop inertia and one would mean no decelleration at all.
  37214. */
  37215. panningInertia: number;
  37216. /**
  37217. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37218. */
  37219. angularSensibilityX: number;
  37220. /**
  37221. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37222. */
  37223. angularSensibilityY: number;
  37224. /**
  37225. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37226. */
  37227. pinchPrecision: number;
  37228. /**
  37229. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37230. * It will be used instead of pinchDeltaPrecision if different from 0.
  37231. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37232. */
  37233. pinchDeltaPercentage: number;
  37234. /**
  37235. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37236. */
  37237. panningSensibility: number;
  37238. /**
  37239. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37240. */
  37241. keysUp: number[];
  37242. /**
  37243. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37244. */
  37245. keysDown: number[];
  37246. /**
  37247. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37248. */
  37249. keysLeft: number[];
  37250. /**
  37251. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37252. */
  37253. keysRight: number[];
  37254. /**
  37255. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37256. */
  37257. wheelPrecision: number;
  37258. /**
  37259. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37260. * It will be used instead of pinchDeltaPrecision if different from 0.
  37261. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37262. */
  37263. wheelDeltaPercentage: number;
  37264. /**
  37265. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37266. */
  37267. zoomOnFactor: number;
  37268. /**
  37269. * Defines a screen offset for the camera position.
  37270. */
  37271. targetScreenOffset: Vector2;
  37272. /**
  37273. * Allows the camera to be completely reversed.
  37274. * If false the camera can not arrive upside down.
  37275. */
  37276. allowUpsideDown: boolean;
  37277. /**
  37278. * Define if double tap/click is used to restore the previously saved state of the camera.
  37279. */
  37280. useInputToRestoreState: boolean;
  37281. /** @hidden */
  37282. _viewMatrix: Matrix;
  37283. /** @hidden */
  37284. _useCtrlForPanning: boolean;
  37285. /** @hidden */
  37286. _panningMouseButton: number;
  37287. /**
  37288. * Defines the input associated to the camera.
  37289. */
  37290. inputs: ArcRotateCameraInputsManager;
  37291. /** @hidden */
  37292. _reset: () => void;
  37293. /**
  37294. * Defines the allowed panning axis.
  37295. */
  37296. panningAxis: Vector3;
  37297. protected _localDirection: Vector3;
  37298. protected _transformedDirection: Vector3;
  37299. private _bouncingBehavior;
  37300. /**
  37301. * Gets the bouncing behavior of the camera if it has been enabled.
  37302. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37303. */
  37304. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37305. /**
  37306. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37308. */
  37309. useBouncingBehavior: boolean;
  37310. private _framingBehavior;
  37311. /**
  37312. * Gets the framing behavior of the camera if it has been enabled.
  37313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37314. */
  37315. readonly framingBehavior: Nullable<FramingBehavior>;
  37316. /**
  37317. * Defines if the framing behavior of the camera is enabled on the camera.
  37318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37319. */
  37320. useFramingBehavior: boolean;
  37321. private _autoRotationBehavior;
  37322. /**
  37323. * Gets the auto rotation behavior of the camera if it has been enabled.
  37324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37325. */
  37326. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37327. /**
  37328. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37329. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37330. */
  37331. useAutoRotationBehavior: boolean;
  37332. /**
  37333. * Observable triggered when the mesh target has been changed on the camera.
  37334. */
  37335. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37336. /**
  37337. * Event raised when the camera is colliding with a mesh.
  37338. */
  37339. onCollide: (collidedMesh: AbstractMesh) => void;
  37340. /**
  37341. * Defines whether the camera should check collision with the objects oh the scene.
  37342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37343. */
  37344. checkCollisions: boolean;
  37345. /**
  37346. * Defines the collision radius of the camera.
  37347. * This simulates a sphere around the camera.
  37348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37349. */
  37350. collisionRadius: Vector3;
  37351. protected _collider: Collider;
  37352. protected _previousPosition: Vector3;
  37353. protected _collisionVelocity: Vector3;
  37354. protected _newPosition: Vector3;
  37355. protected _previousAlpha: number;
  37356. protected _previousBeta: number;
  37357. protected _previousRadius: number;
  37358. protected _collisionTriggered: boolean;
  37359. protected _targetBoundingCenter: Nullable<Vector3>;
  37360. private _computationVector;
  37361. /**
  37362. * Instantiates a new ArcRotateCamera in a given scene
  37363. * @param name Defines the name of the camera
  37364. * @param alpha Defines the camera rotation along the logitudinal axis
  37365. * @param beta Defines the camera rotation along the latitudinal axis
  37366. * @param radius Defines the camera distance from its target
  37367. * @param target Defines the camera target
  37368. * @param scene Defines the scene the camera belongs to
  37369. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37370. */
  37371. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37372. /** @hidden */
  37373. _initCache(): void;
  37374. /** @hidden */
  37375. _updateCache(ignoreParentClass?: boolean): void;
  37376. protected _getTargetPosition(): Vector3;
  37377. private _storedAlpha;
  37378. private _storedBeta;
  37379. private _storedRadius;
  37380. private _storedTarget;
  37381. private _storedTargetScreenOffset;
  37382. /**
  37383. * Stores the current state of the camera (alpha, beta, radius and target)
  37384. * @returns the camera itself
  37385. */
  37386. storeState(): Camera;
  37387. /**
  37388. * @hidden
  37389. * Restored camera state. You must call storeState() first
  37390. */
  37391. _restoreStateValues(): boolean;
  37392. /** @hidden */
  37393. _isSynchronizedViewMatrix(): boolean;
  37394. /**
  37395. * Attached controls to the current camera.
  37396. * @param element Defines the element the controls should be listened from
  37397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37398. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37399. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37400. */
  37401. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37402. /**
  37403. * Detach the current controls from the camera.
  37404. * The camera will stop reacting to inputs.
  37405. * @param element Defines the element to stop listening the inputs from
  37406. */
  37407. detachControl(element: HTMLElement): void;
  37408. /** @hidden */
  37409. _checkInputs(): void;
  37410. protected _checkLimits(): void;
  37411. /**
  37412. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37413. */
  37414. rebuildAnglesAndRadius(): void;
  37415. /**
  37416. * Use a position to define the current camera related information like aplha, beta and radius
  37417. * @param position Defines the position to set the camera at
  37418. */
  37419. setPosition(position: Vector3): void;
  37420. /**
  37421. * Defines the target the camera should look at.
  37422. * This will automatically adapt alpha beta and radius to fit within the new target.
  37423. * @param target Defines the new target as a Vector or a mesh
  37424. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37425. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37426. */
  37427. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37428. /** @hidden */
  37429. _getViewMatrix(): Matrix;
  37430. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37431. /**
  37432. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37433. * @param meshes Defines the mesh to zoom on
  37434. * @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)
  37435. */
  37436. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37437. /**
  37438. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37439. * The target will be changed but the radius
  37440. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37441. * @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)
  37442. */
  37443. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37444. min: Vector3;
  37445. max: Vector3;
  37446. distance: number;
  37447. }, doNotUpdateMaxZ?: boolean): void;
  37448. /**
  37449. * @override
  37450. * Override Camera.createRigCamera
  37451. */
  37452. createRigCamera(name: string, cameraIndex: number): Camera;
  37453. /**
  37454. * @hidden
  37455. * @override
  37456. * Override Camera._updateRigCameras
  37457. */
  37458. _updateRigCameras(): void;
  37459. /**
  37460. * Destroy the camera and release the current resources hold by it.
  37461. */
  37462. dispose(): void;
  37463. /**
  37464. * Gets the current object class name.
  37465. * @return the class name
  37466. */
  37467. getClassName(): string;
  37468. }
  37469. }
  37470. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37471. import { Behavior } from "babylonjs/Behaviors/behavior";
  37472. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37473. /**
  37474. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37475. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37476. */
  37477. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37478. /**
  37479. * Gets the name of the behavior.
  37480. */
  37481. readonly name: string;
  37482. private _zoomStopsAnimation;
  37483. private _idleRotationSpeed;
  37484. private _idleRotationWaitTime;
  37485. private _idleRotationSpinupTime;
  37486. /**
  37487. * Sets the flag that indicates if user zooming should stop animation.
  37488. */
  37489. /**
  37490. * Gets the flag that indicates if user zooming should stop animation.
  37491. */
  37492. zoomStopsAnimation: boolean;
  37493. /**
  37494. * Sets the default speed at which the camera rotates around the model.
  37495. */
  37496. /**
  37497. * Gets the default speed at which the camera rotates around the model.
  37498. */
  37499. idleRotationSpeed: number;
  37500. /**
  37501. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37502. */
  37503. /**
  37504. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37505. */
  37506. idleRotationWaitTime: number;
  37507. /**
  37508. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37509. */
  37510. /**
  37511. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37512. */
  37513. idleRotationSpinupTime: number;
  37514. /**
  37515. * Gets a value indicating if the camera is currently rotating because of this behavior
  37516. */
  37517. readonly rotationInProgress: boolean;
  37518. private _onPrePointerObservableObserver;
  37519. private _onAfterCheckInputsObserver;
  37520. private _attachedCamera;
  37521. private _isPointerDown;
  37522. private _lastFrameTime;
  37523. private _lastInteractionTime;
  37524. private _cameraRotationSpeed;
  37525. /**
  37526. * Initializes the behavior.
  37527. */
  37528. init(): void;
  37529. /**
  37530. * Attaches the behavior to its arc rotate camera.
  37531. * @param camera Defines the camera to attach the behavior to
  37532. */
  37533. attach(camera: ArcRotateCamera): void;
  37534. /**
  37535. * Detaches the behavior from its current arc rotate camera.
  37536. */
  37537. detach(): void;
  37538. /**
  37539. * Returns true if user is scrolling.
  37540. * @return true if user is scrolling.
  37541. */
  37542. private _userIsZooming;
  37543. private _lastFrameRadius;
  37544. private _shouldAnimationStopForInteraction;
  37545. /**
  37546. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37547. */
  37548. private _applyUserInteraction;
  37549. private _userIsMoving;
  37550. }
  37551. }
  37552. declare module "babylonjs/Behaviors/Cameras/index" {
  37553. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37554. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37555. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37556. }
  37557. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37558. import { Mesh } from "babylonjs/Meshes/mesh";
  37559. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37560. import { Behavior } from "babylonjs/Behaviors/behavior";
  37561. /**
  37562. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37563. */
  37564. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37565. private ui;
  37566. /**
  37567. * The name of the behavior
  37568. */
  37569. name: string;
  37570. /**
  37571. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37572. */
  37573. distanceAwayFromFace: number;
  37574. /**
  37575. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37576. */
  37577. distanceAwayFromBottomOfFace: number;
  37578. private _faceVectors;
  37579. private _target;
  37580. private _scene;
  37581. private _onRenderObserver;
  37582. private _tmpMatrix;
  37583. private _tmpVector;
  37584. /**
  37585. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37586. * @param ui The transform node that should be attched to the mesh
  37587. */
  37588. constructor(ui: TransformNode);
  37589. /**
  37590. * Initializes the behavior
  37591. */
  37592. init(): void;
  37593. private _closestFace;
  37594. private _zeroVector;
  37595. private _lookAtTmpMatrix;
  37596. private _lookAtToRef;
  37597. /**
  37598. * Attaches the AttachToBoxBehavior to the passed in mesh
  37599. * @param target The mesh that the specified node will be attached to
  37600. */
  37601. attach(target: Mesh): void;
  37602. /**
  37603. * Detaches the behavior from the mesh
  37604. */
  37605. detach(): void;
  37606. }
  37607. }
  37608. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37609. import { Behavior } from "babylonjs/Behaviors/behavior";
  37610. import { Mesh } from "babylonjs/Meshes/mesh";
  37611. /**
  37612. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37613. */
  37614. export class FadeInOutBehavior implements Behavior<Mesh> {
  37615. /**
  37616. * Time in milliseconds to delay before fading in (Default: 0)
  37617. */
  37618. delay: number;
  37619. /**
  37620. * Time in milliseconds for the mesh to fade in (Default: 300)
  37621. */
  37622. fadeInTime: number;
  37623. private _millisecondsPerFrame;
  37624. private _hovered;
  37625. private _hoverValue;
  37626. private _ownerNode;
  37627. /**
  37628. * Instatiates the FadeInOutBehavior
  37629. */
  37630. constructor();
  37631. /**
  37632. * The name of the behavior
  37633. */
  37634. readonly name: string;
  37635. /**
  37636. * Initializes the behavior
  37637. */
  37638. init(): void;
  37639. /**
  37640. * Attaches the fade behavior on the passed in mesh
  37641. * @param ownerNode The mesh that will be faded in/out once attached
  37642. */
  37643. attach(ownerNode: Mesh): void;
  37644. /**
  37645. * Detaches the behavior from the mesh
  37646. */
  37647. detach(): void;
  37648. /**
  37649. * Triggers the mesh to begin fading in or out
  37650. * @param value if the object should fade in or out (true to fade in)
  37651. */
  37652. fadeIn(value: boolean): void;
  37653. private _update;
  37654. private _setAllVisibility;
  37655. }
  37656. }
  37657. declare module "babylonjs/Misc/pivotTools" {
  37658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37659. /**
  37660. * Class containing a set of static utilities functions for managing Pivots
  37661. * @hidden
  37662. */
  37663. export class PivotTools {
  37664. private static _PivotCached;
  37665. private static _OldPivotPoint;
  37666. private static _PivotTranslation;
  37667. private static _PivotTmpVector;
  37668. /** @hidden */
  37669. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37670. /** @hidden */
  37671. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37672. }
  37673. }
  37674. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37675. import { Scene } from "babylonjs/scene";
  37676. import { Vector4 } from "babylonjs/Maths/math.vector";
  37677. import { Mesh } from "babylonjs/Meshes/mesh";
  37678. import { Nullable } from "babylonjs/types";
  37679. import { Plane } from "babylonjs/Maths/math.plane";
  37680. /**
  37681. * Class containing static functions to help procedurally build meshes
  37682. */
  37683. export class PlaneBuilder {
  37684. /**
  37685. * Creates a plane mesh
  37686. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37687. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37688. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37690. * * 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
  37691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37692. * @param name defines the name of the mesh
  37693. * @param options defines the options used to create the mesh
  37694. * @param scene defines the hosting scene
  37695. * @returns the plane mesh
  37696. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37697. */
  37698. static CreatePlane(name: string, options: {
  37699. size?: number;
  37700. width?: number;
  37701. height?: number;
  37702. sideOrientation?: number;
  37703. frontUVs?: Vector4;
  37704. backUVs?: Vector4;
  37705. updatable?: boolean;
  37706. sourcePlane?: Plane;
  37707. }, scene?: Nullable<Scene>): Mesh;
  37708. }
  37709. }
  37710. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37711. import { Behavior } from "babylonjs/Behaviors/behavior";
  37712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37713. import { Observable } from "babylonjs/Misc/observable";
  37714. import { Vector3 } from "babylonjs/Maths/math.vector";
  37715. import { Ray } from "babylonjs/Culling/ray";
  37716. import "babylonjs/Meshes/Builders/planeBuilder";
  37717. /**
  37718. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37719. */
  37720. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37721. private static _AnyMouseID;
  37722. /**
  37723. * Abstract mesh the behavior is set on
  37724. */
  37725. attachedNode: AbstractMesh;
  37726. private _dragPlane;
  37727. private _scene;
  37728. private _pointerObserver;
  37729. private _beforeRenderObserver;
  37730. private static _planeScene;
  37731. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37732. /**
  37733. * 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)
  37734. */
  37735. maxDragAngle: number;
  37736. /**
  37737. * @hidden
  37738. */
  37739. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37740. /**
  37741. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37742. */
  37743. currentDraggingPointerID: number;
  37744. /**
  37745. * The last position where the pointer hit the drag plane in world space
  37746. */
  37747. lastDragPosition: Vector3;
  37748. /**
  37749. * If the behavior is currently in a dragging state
  37750. */
  37751. dragging: boolean;
  37752. /**
  37753. * 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)
  37754. */
  37755. dragDeltaRatio: number;
  37756. /**
  37757. * If the drag plane orientation should be updated during the dragging (Default: true)
  37758. */
  37759. updateDragPlane: boolean;
  37760. private _debugMode;
  37761. private _moving;
  37762. /**
  37763. * Fires each time the attached mesh is dragged with the pointer
  37764. * * delta between last drag position and current drag position in world space
  37765. * * dragDistance along the drag axis
  37766. * * dragPlaneNormal normal of the current drag plane used during the drag
  37767. * * dragPlanePoint in world space where the drag intersects the drag plane
  37768. */
  37769. onDragObservable: Observable<{
  37770. delta: Vector3;
  37771. dragPlanePoint: Vector3;
  37772. dragPlaneNormal: Vector3;
  37773. dragDistance: number;
  37774. pointerId: number;
  37775. }>;
  37776. /**
  37777. * Fires each time a drag begins (eg. mouse down on mesh)
  37778. */
  37779. onDragStartObservable: Observable<{
  37780. dragPlanePoint: Vector3;
  37781. pointerId: number;
  37782. }>;
  37783. /**
  37784. * Fires each time a drag ends (eg. mouse release after drag)
  37785. */
  37786. onDragEndObservable: Observable<{
  37787. dragPlanePoint: Vector3;
  37788. pointerId: number;
  37789. }>;
  37790. /**
  37791. * If the attached mesh should be moved when dragged
  37792. */
  37793. moveAttached: boolean;
  37794. /**
  37795. * If the drag behavior will react to drag events (Default: true)
  37796. */
  37797. enabled: boolean;
  37798. /**
  37799. * If pointer events should start and release the drag (Default: true)
  37800. */
  37801. startAndReleaseDragOnPointerEvents: boolean;
  37802. /**
  37803. * If camera controls should be detached during the drag
  37804. */
  37805. detachCameraControls: boolean;
  37806. /**
  37807. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37808. */
  37809. useObjectOrienationForDragging: boolean;
  37810. private _options;
  37811. /**
  37812. * Creates a pointer drag behavior that can be attached to a mesh
  37813. * @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)
  37814. */
  37815. constructor(options?: {
  37816. dragAxis?: Vector3;
  37817. dragPlaneNormal?: Vector3;
  37818. });
  37819. /**
  37820. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37821. */
  37822. validateDrag: (targetPosition: Vector3) => boolean;
  37823. /**
  37824. * The name of the behavior
  37825. */
  37826. readonly name: string;
  37827. /**
  37828. * Initializes the behavior
  37829. */
  37830. init(): void;
  37831. private _tmpVector;
  37832. private _alternatePickedPoint;
  37833. private _worldDragAxis;
  37834. private _targetPosition;
  37835. private _attachedElement;
  37836. /**
  37837. * Attaches the drag behavior the passed in mesh
  37838. * @param ownerNode The mesh that will be dragged around once attached
  37839. * @param predicate Predicate to use for pick filtering
  37840. */
  37841. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37842. /**
  37843. * Force relase the drag action by code.
  37844. */
  37845. releaseDrag(): void;
  37846. private _startDragRay;
  37847. private _lastPointerRay;
  37848. /**
  37849. * Simulates the start of a pointer drag event on the behavior
  37850. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37851. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37852. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37853. */
  37854. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37855. private _startDrag;
  37856. private _dragDelta;
  37857. private _moveDrag;
  37858. private _pickWithRayOnDragPlane;
  37859. private _pointA;
  37860. private _pointB;
  37861. private _pointC;
  37862. private _lineA;
  37863. private _lineB;
  37864. private _localAxis;
  37865. private _lookAt;
  37866. private _updateDragPlanePosition;
  37867. /**
  37868. * Detaches the behavior from the mesh
  37869. */
  37870. detach(): void;
  37871. }
  37872. }
  37873. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37874. import { Mesh } from "babylonjs/Meshes/mesh";
  37875. import { Behavior } from "babylonjs/Behaviors/behavior";
  37876. /**
  37877. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37878. */
  37879. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37880. private _dragBehaviorA;
  37881. private _dragBehaviorB;
  37882. private _startDistance;
  37883. private _initialScale;
  37884. private _targetScale;
  37885. private _ownerNode;
  37886. private _sceneRenderObserver;
  37887. /**
  37888. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37889. */
  37890. constructor();
  37891. /**
  37892. * The name of the behavior
  37893. */
  37894. readonly name: string;
  37895. /**
  37896. * Initializes the behavior
  37897. */
  37898. init(): void;
  37899. private _getCurrentDistance;
  37900. /**
  37901. * Attaches the scale behavior the passed in mesh
  37902. * @param ownerNode The mesh that will be scaled around once attached
  37903. */
  37904. attach(ownerNode: Mesh): void;
  37905. /**
  37906. * Detaches the behavior from the mesh
  37907. */
  37908. detach(): void;
  37909. }
  37910. }
  37911. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37912. import { Behavior } from "babylonjs/Behaviors/behavior";
  37913. import { Mesh } from "babylonjs/Meshes/mesh";
  37914. import { Observable } from "babylonjs/Misc/observable";
  37915. /**
  37916. * 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
  37917. */
  37918. export class SixDofDragBehavior implements Behavior<Mesh> {
  37919. private static _virtualScene;
  37920. private _ownerNode;
  37921. private _sceneRenderObserver;
  37922. private _scene;
  37923. private _targetPosition;
  37924. private _virtualOriginMesh;
  37925. private _virtualDragMesh;
  37926. private _pointerObserver;
  37927. private _moving;
  37928. private _startingOrientation;
  37929. /**
  37930. * 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)
  37931. */
  37932. private zDragFactor;
  37933. /**
  37934. * If the object should rotate to face the drag origin
  37935. */
  37936. rotateDraggedObject: boolean;
  37937. /**
  37938. * If the behavior is currently in a dragging state
  37939. */
  37940. dragging: boolean;
  37941. /**
  37942. * 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)
  37943. */
  37944. dragDeltaRatio: number;
  37945. /**
  37946. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37947. */
  37948. currentDraggingPointerID: number;
  37949. /**
  37950. * If camera controls should be detached during the drag
  37951. */
  37952. detachCameraControls: boolean;
  37953. /**
  37954. * Fires each time a drag starts
  37955. */
  37956. onDragStartObservable: Observable<{}>;
  37957. /**
  37958. * Fires each time a drag ends (eg. mouse release after drag)
  37959. */
  37960. onDragEndObservable: Observable<{}>;
  37961. /**
  37962. * 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
  37963. */
  37964. constructor();
  37965. /**
  37966. * The name of the behavior
  37967. */
  37968. readonly name: string;
  37969. /**
  37970. * Initializes the behavior
  37971. */
  37972. init(): void;
  37973. /**
  37974. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37975. */
  37976. private readonly _pointerCamera;
  37977. /**
  37978. * Attaches the scale behavior the passed in mesh
  37979. * @param ownerNode The mesh that will be scaled around once attached
  37980. */
  37981. attach(ownerNode: Mesh): void;
  37982. /**
  37983. * Detaches the behavior from the mesh
  37984. */
  37985. detach(): void;
  37986. }
  37987. }
  37988. declare module "babylonjs/Behaviors/Meshes/index" {
  37989. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37990. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37991. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37992. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37993. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37994. }
  37995. declare module "babylonjs/Behaviors/index" {
  37996. export * from "babylonjs/Behaviors/behavior";
  37997. export * from "babylonjs/Behaviors/Cameras/index";
  37998. export * from "babylonjs/Behaviors/Meshes/index";
  37999. }
  38000. declare module "babylonjs/Bones/boneIKController" {
  38001. import { Bone } from "babylonjs/Bones/bone";
  38002. import { Vector3 } from "babylonjs/Maths/math.vector";
  38003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38004. import { Nullable } from "babylonjs/types";
  38005. /**
  38006. * Class used to apply inverse kinematics to bones
  38007. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38008. */
  38009. export class BoneIKController {
  38010. private static _tmpVecs;
  38011. private static _tmpQuat;
  38012. private static _tmpMats;
  38013. /**
  38014. * Gets or sets the target mesh
  38015. */
  38016. targetMesh: AbstractMesh;
  38017. /** Gets or sets the mesh used as pole */
  38018. poleTargetMesh: AbstractMesh;
  38019. /**
  38020. * Gets or sets the bone used as pole
  38021. */
  38022. poleTargetBone: Nullable<Bone>;
  38023. /**
  38024. * Gets or sets the target position
  38025. */
  38026. targetPosition: Vector3;
  38027. /**
  38028. * Gets or sets the pole target position
  38029. */
  38030. poleTargetPosition: Vector3;
  38031. /**
  38032. * Gets or sets the pole target local offset
  38033. */
  38034. poleTargetLocalOffset: Vector3;
  38035. /**
  38036. * Gets or sets the pole angle
  38037. */
  38038. poleAngle: number;
  38039. /**
  38040. * Gets or sets the mesh associated with the controller
  38041. */
  38042. mesh: AbstractMesh;
  38043. /**
  38044. * 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)
  38045. */
  38046. slerpAmount: number;
  38047. private _bone1Quat;
  38048. private _bone1Mat;
  38049. private _bone2Ang;
  38050. private _bone1;
  38051. private _bone2;
  38052. private _bone1Length;
  38053. private _bone2Length;
  38054. private _maxAngle;
  38055. private _maxReach;
  38056. private _rightHandedSystem;
  38057. private _bendAxis;
  38058. private _slerping;
  38059. private _adjustRoll;
  38060. /**
  38061. * Gets or sets maximum allowed angle
  38062. */
  38063. maxAngle: number;
  38064. /**
  38065. * Creates a new BoneIKController
  38066. * @param mesh defines the mesh to control
  38067. * @param bone defines the bone to control
  38068. * @param options defines options to set up the controller
  38069. */
  38070. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38071. targetMesh?: AbstractMesh;
  38072. poleTargetMesh?: AbstractMesh;
  38073. poleTargetBone?: Bone;
  38074. poleTargetLocalOffset?: Vector3;
  38075. poleAngle?: number;
  38076. bendAxis?: Vector3;
  38077. maxAngle?: number;
  38078. slerpAmount?: number;
  38079. });
  38080. private _setMaxAngle;
  38081. /**
  38082. * Force the controller to update the bones
  38083. */
  38084. update(): void;
  38085. }
  38086. }
  38087. declare module "babylonjs/Bones/boneLookController" {
  38088. import { Vector3 } from "babylonjs/Maths/math.vector";
  38089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38090. import { Bone } from "babylonjs/Bones/bone";
  38091. import { Space } from "babylonjs/Maths/math.axis";
  38092. /**
  38093. * Class used to make a bone look toward a point in space
  38094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38095. */
  38096. export class BoneLookController {
  38097. private static _tmpVecs;
  38098. private static _tmpQuat;
  38099. private static _tmpMats;
  38100. /**
  38101. * The target Vector3 that the bone will look at
  38102. */
  38103. target: Vector3;
  38104. /**
  38105. * The mesh that the bone is attached to
  38106. */
  38107. mesh: AbstractMesh;
  38108. /**
  38109. * The bone that will be looking to the target
  38110. */
  38111. bone: Bone;
  38112. /**
  38113. * The up axis of the coordinate system that is used when the bone is rotated
  38114. */
  38115. upAxis: Vector3;
  38116. /**
  38117. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38118. */
  38119. upAxisSpace: Space;
  38120. /**
  38121. * Used to make an adjustment to the yaw of the bone
  38122. */
  38123. adjustYaw: number;
  38124. /**
  38125. * Used to make an adjustment to the pitch of the bone
  38126. */
  38127. adjustPitch: number;
  38128. /**
  38129. * Used to make an adjustment to the roll of the bone
  38130. */
  38131. adjustRoll: number;
  38132. /**
  38133. * 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)
  38134. */
  38135. slerpAmount: number;
  38136. private _minYaw;
  38137. private _maxYaw;
  38138. private _minPitch;
  38139. private _maxPitch;
  38140. private _minYawSin;
  38141. private _minYawCos;
  38142. private _maxYawSin;
  38143. private _maxYawCos;
  38144. private _midYawConstraint;
  38145. private _minPitchTan;
  38146. private _maxPitchTan;
  38147. private _boneQuat;
  38148. private _slerping;
  38149. private _transformYawPitch;
  38150. private _transformYawPitchInv;
  38151. private _firstFrameSkipped;
  38152. private _yawRange;
  38153. private _fowardAxis;
  38154. /**
  38155. * Gets or sets the minimum yaw angle that the bone can look to
  38156. */
  38157. minYaw: number;
  38158. /**
  38159. * Gets or sets the maximum yaw angle that the bone can look to
  38160. */
  38161. maxYaw: number;
  38162. /**
  38163. * Gets or sets the minimum pitch angle that the bone can look to
  38164. */
  38165. minPitch: number;
  38166. /**
  38167. * Gets or sets the maximum pitch angle that the bone can look to
  38168. */
  38169. maxPitch: number;
  38170. /**
  38171. * Create a BoneLookController
  38172. * @param mesh the mesh that the bone belongs to
  38173. * @param bone the bone that will be looking to the target
  38174. * @param target the target Vector3 to look at
  38175. * @param options optional settings:
  38176. * * maxYaw: the maximum angle the bone will yaw to
  38177. * * minYaw: the minimum angle the bone will yaw to
  38178. * * maxPitch: the maximum angle the bone will pitch to
  38179. * * minPitch: the minimum angle the bone will yaw to
  38180. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38181. * * upAxis: the up axis of the coordinate system
  38182. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38183. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38184. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38185. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38186. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38187. * * adjustRoll: used to make an adjustment to the roll of the bone
  38188. **/
  38189. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38190. maxYaw?: number;
  38191. minYaw?: number;
  38192. maxPitch?: number;
  38193. minPitch?: number;
  38194. slerpAmount?: number;
  38195. upAxis?: Vector3;
  38196. upAxisSpace?: Space;
  38197. yawAxis?: Vector3;
  38198. pitchAxis?: Vector3;
  38199. adjustYaw?: number;
  38200. adjustPitch?: number;
  38201. adjustRoll?: number;
  38202. });
  38203. /**
  38204. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38205. */
  38206. update(): void;
  38207. private _getAngleDiff;
  38208. private _getAngleBetween;
  38209. private _isAngleBetween;
  38210. }
  38211. }
  38212. declare module "babylonjs/Bones/index" {
  38213. export * from "babylonjs/Bones/bone";
  38214. export * from "babylonjs/Bones/boneIKController";
  38215. export * from "babylonjs/Bones/boneLookController";
  38216. export * from "babylonjs/Bones/skeleton";
  38217. }
  38218. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38219. import { Nullable } from "babylonjs/types";
  38220. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38221. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38222. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38223. /**
  38224. * Manage the gamepad inputs to control an arc rotate camera.
  38225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38226. */
  38227. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38228. /**
  38229. * Defines the camera the input is attached to.
  38230. */
  38231. camera: ArcRotateCamera;
  38232. /**
  38233. * Defines the gamepad the input is gathering event from.
  38234. */
  38235. gamepad: Nullable<Gamepad>;
  38236. /**
  38237. * Defines the gamepad rotation sensiblity.
  38238. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38239. */
  38240. gamepadRotationSensibility: number;
  38241. /**
  38242. * Defines the gamepad move sensiblity.
  38243. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38244. */
  38245. gamepadMoveSensibility: number;
  38246. private _onGamepadConnectedObserver;
  38247. private _onGamepadDisconnectedObserver;
  38248. /**
  38249. * Attach the input controls to a specific dom element to get the input from.
  38250. * @param element Defines the element the controls should be listened from
  38251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38252. */
  38253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38254. /**
  38255. * Detach the current controls from the specified dom element.
  38256. * @param element Defines the element to stop listening the inputs from
  38257. */
  38258. detachControl(element: Nullable<HTMLElement>): void;
  38259. /**
  38260. * Update the current camera state depending on the inputs that have been used this frame.
  38261. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38262. */
  38263. checkInputs(): void;
  38264. /**
  38265. * Gets the class name of the current intput.
  38266. * @returns the class name
  38267. */
  38268. getClassName(): string;
  38269. /**
  38270. * Get the friendly name associated with the input class.
  38271. * @returns the input friendly name
  38272. */
  38273. getSimpleName(): string;
  38274. }
  38275. }
  38276. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38277. import { Nullable } from "babylonjs/types";
  38278. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38279. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38280. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38281. interface ArcRotateCameraInputsManager {
  38282. /**
  38283. * Add orientation input support to the input manager.
  38284. * @returns the current input manager
  38285. */
  38286. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38287. }
  38288. }
  38289. /**
  38290. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38292. */
  38293. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38294. /**
  38295. * Defines the camera the input is attached to.
  38296. */
  38297. camera: ArcRotateCamera;
  38298. /**
  38299. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38300. */
  38301. alphaCorrection: number;
  38302. /**
  38303. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38304. */
  38305. gammaCorrection: number;
  38306. private _alpha;
  38307. private _gamma;
  38308. private _dirty;
  38309. private _deviceOrientationHandler;
  38310. /**
  38311. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38312. */
  38313. constructor();
  38314. /**
  38315. * Attach the input controls to a specific dom element to get the input from.
  38316. * @param element Defines the element the controls should be listened from
  38317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38318. */
  38319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38320. /** @hidden */
  38321. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38322. /**
  38323. * Update the current camera state depending on the inputs that have been used this frame.
  38324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38325. */
  38326. checkInputs(): void;
  38327. /**
  38328. * Detach the current controls from the specified dom element.
  38329. * @param element Defines the element to stop listening the inputs from
  38330. */
  38331. detachControl(element: Nullable<HTMLElement>): void;
  38332. /**
  38333. * Gets the class name of the current intput.
  38334. * @returns the class name
  38335. */
  38336. getClassName(): string;
  38337. /**
  38338. * Get the friendly name associated with the input class.
  38339. * @returns the input friendly name
  38340. */
  38341. getSimpleName(): string;
  38342. }
  38343. }
  38344. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38345. import { Nullable } from "babylonjs/types";
  38346. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38347. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38348. /**
  38349. * Listen to mouse events to control the camera.
  38350. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38351. */
  38352. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38353. /**
  38354. * Defines the camera the input is attached to.
  38355. */
  38356. camera: FlyCamera;
  38357. /**
  38358. * Defines if touch is enabled. (Default is true.)
  38359. */
  38360. touchEnabled: boolean;
  38361. /**
  38362. * Defines the buttons associated with the input to handle camera rotation.
  38363. */
  38364. buttons: number[];
  38365. /**
  38366. * Assign buttons for Yaw control.
  38367. */
  38368. buttonsYaw: number[];
  38369. /**
  38370. * Assign buttons for Pitch control.
  38371. */
  38372. buttonsPitch: number[];
  38373. /**
  38374. * Assign buttons for Roll control.
  38375. */
  38376. buttonsRoll: number[];
  38377. /**
  38378. * Detect if any button is being pressed while mouse is moved.
  38379. * -1 = Mouse locked.
  38380. * 0 = Left button.
  38381. * 1 = Middle Button.
  38382. * 2 = Right Button.
  38383. */
  38384. activeButton: number;
  38385. /**
  38386. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38387. * Higher values reduce its sensitivity.
  38388. */
  38389. angularSensibility: number;
  38390. private _mousemoveCallback;
  38391. private _observer;
  38392. private _rollObserver;
  38393. private previousPosition;
  38394. private noPreventDefault;
  38395. private element;
  38396. /**
  38397. * Listen to mouse events to control the camera.
  38398. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38400. */
  38401. constructor(touchEnabled?: boolean);
  38402. /**
  38403. * Attach the mouse control to the HTML DOM element.
  38404. * @param element Defines the element that listens to the input events.
  38405. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38406. */
  38407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38408. /**
  38409. * Detach the current controls from the specified dom element.
  38410. * @param element Defines the element to stop listening the inputs from
  38411. */
  38412. detachControl(element: Nullable<HTMLElement>): void;
  38413. /**
  38414. * Gets the class name of the current input.
  38415. * @returns the class name.
  38416. */
  38417. getClassName(): string;
  38418. /**
  38419. * Get the friendly name associated with the input class.
  38420. * @returns the input's friendly name.
  38421. */
  38422. getSimpleName(): string;
  38423. private _pointerInput;
  38424. private _onMouseMove;
  38425. /**
  38426. * Rotate camera by mouse offset.
  38427. */
  38428. private rotateCamera;
  38429. }
  38430. }
  38431. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38432. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38433. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38434. /**
  38435. * Default Inputs manager for the FlyCamera.
  38436. * It groups all the default supported inputs for ease of use.
  38437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38438. */
  38439. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38440. /**
  38441. * Instantiates a new FlyCameraInputsManager.
  38442. * @param camera Defines the camera the inputs belong to.
  38443. */
  38444. constructor(camera: FlyCamera);
  38445. /**
  38446. * Add keyboard input support to the input manager.
  38447. * @returns the new FlyCameraKeyboardMoveInput().
  38448. */
  38449. addKeyboard(): FlyCameraInputsManager;
  38450. /**
  38451. * Add mouse input support to the input manager.
  38452. * @param touchEnabled Enable touch screen support.
  38453. * @returns the new FlyCameraMouseInput().
  38454. */
  38455. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38456. }
  38457. }
  38458. declare module "babylonjs/Cameras/flyCamera" {
  38459. import { Scene } from "babylonjs/scene";
  38460. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38462. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38463. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38464. /**
  38465. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38466. * such as in a 3D Space Shooter or a Flight Simulator.
  38467. */
  38468. export class FlyCamera extends TargetCamera {
  38469. /**
  38470. * Define the collision ellipsoid of the camera.
  38471. * This is helpful for simulating a camera body, like a player's body.
  38472. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38473. */
  38474. ellipsoid: Vector3;
  38475. /**
  38476. * Define an offset for the position of the ellipsoid around the camera.
  38477. * This can be helpful if the camera is attached away from the player's body center,
  38478. * such as at its head.
  38479. */
  38480. ellipsoidOffset: Vector3;
  38481. /**
  38482. * Enable or disable collisions of the camera with the rest of the scene objects.
  38483. */
  38484. checkCollisions: boolean;
  38485. /**
  38486. * Enable or disable gravity on the camera.
  38487. */
  38488. applyGravity: boolean;
  38489. /**
  38490. * Define the current direction the camera is moving to.
  38491. */
  38492. cameraDirection: Vector3;
  38493. /**
  38494. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38495. * This overrides and empties cameraRotation.
  38496. */
  38497. rotationQuaternion: Quaternion;
  38498. /**
  38499. * Track Roll to maintain the wanted Rolling when looking around.
  38500. */
  38501. _trackRoll: number;
  38502. /**
  38503. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38504. */
  38505. rollCorrect: number;
  38506. /**
  38507. * Mimic a banked turn, Rolling the camera when Yawing.
  38508. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38509. */
  38510. bankedTurn: boolean;
  38511. /**
  38512. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38513. */
  38514. bankedTurnLimit: number;
  38515. /**
  38516. * Value of 0 disables the banked Roll.
  38517. * Value of 1 is equal to the Yaw angle in radians.
  38518. */
  38519. bankedTurnMultiplier: number;
  38520. /**
  38521. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38522. */
  38523. inputs: FlyCameraInputsManager;
  38524. /**
  38525. * Gets the input sensibility for mouse input.
  38526. * Higher values reduce sensitivity.
  38527. */
  38528. /**
  38529. * Sets the input sensibility for a mouse input.
  38530. * Higher values reduce sensitivity.
  38531. */
  38532. angularSensibility: number;
  38533. /**
  38534. * Get the keys for camera movement forward.
  38535. */
  38536. /**
  38537. * Set the keys for camera movement forward.
  38538. */
  38539. keysForward: number[];
  38540. /**
  38541. * Get the keys for camera movement backward.
  38542. */
  38543. keysBackward: number[];
  38544. /**
  38545. * Get the keys for camera movement up.
  38546. */
  38547. /**
  38548. * Set the keys for camera movement up.
  38549. */
  38550. keysUp: number[];
  38551. /**
  38552. * Get the keys for camera movement down.
  38553. */
  38554. /**
  38555. * Set the keys for camera movement down.
  38556. */
  38557. keysDown: number[];
  38558. /**
  38559. * Get the keys for camera movement left.
  38560. */
  38561. /**
  38562. * Set the keys for camera movement left.
  38563. */
  38564. keysLeft: number[];
  38565. /**
  38566. * Set the keys for camera movement right.
  38567. */
  38568. /**
  38569. * Set the keys for camera movement right.
  38570. */
  38571. keysRight: number[];
  38572. /**
  38573. * Event raised when the camera collides with a mesh in the scene.
  38574. */
  38575. onCollide: (collidedMesh: AbstractMesh) => void;
  38576. private _collider;
  38577. private _needMoveForGravity;
  38578. private _oldPosition;
  38579. private _diffPosition;
  38580. private _newPosition;
  38581. /** @hidden */
  38582. _localDirection: Vector3;
  38583. /** @hidden */
  38584. _transformedDirection: Vector3;
  38585. /**
  38586. * Instantiates a FlyCamera.
  38587. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38588. * such as in a 3D Space Shooter or a Flight Simulator.
  38589. * @param name Define the name of the camera in the scene.
  38590. * @param position Define the starting position of the camera in the scene.
  38591. * @param scene Define the scene the camera belongs to.
  38592. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38593. */
  38594. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38595. /**
  38596. * Attach a control to the HTML DOM element.
  38597. * @param element Defines the element that listens to the input events.
  38598. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38599. */
  38600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38601. /**
  38602. * Detach a control from the HTML DOM element.
  38603. * The camera will stop reacting to that input.
  38604. * @param element Defines the element that listens to the input events.
  38605. */
  38606. detachControl(element: HTMLElement): void;
  38607. private _collisionMask;
  38608. /**
  38609. * Get the mask that the camera ignores in collision events.
  38610. */
  38611. /**
  38612. * Set the mask that the camera ignores in collision events.
  38613. */
  38614. collisionMask: number;
  38615. /** @hidden */
  38616. _collideWithWorld(displacement: Vector3): void;
  38617. /** @hidden */
  38618. private _onCollisionPositionChange;
  38619. /** @hidden */
  38620. _checkInputs(): void;
  38621. /** @hidden */
  38622. _decideIfNeedsToMove(): boolean;
  38623. /** @hidden */
  38624. _updatePosition(): void;
  38625. /**
  38626. * Restore the Roll to its target value at the rate specified.
  38627. * @param rate - Higher means slower restoring.
  38628. * @hidden
  38629. */
  38630. restoreRoll(rate: number): void;
  38631. /**
  38632. * Destroy the camera and release the current resources held by it.
  38633. */
  38634. dispose(): void;
  38635. /**
  38636. * Get the current object class name.
  38637. * @returns the class name.
  38638. */
  38639. getClassName(): string;
  38640. }
  38641. }
  38642. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38643. import { Nullable } from "babylonjs/types";
  38644. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38645. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38646. /**
  38647. * Listen to keyboard events to control the camera.
  38648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38649. */
  38650. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38651. /**
  38652. * Defines the camera the input is attached to.
  38653. */
  38654. camera: FlyCamera;
  38655. /**
  38656. * The list of keyboard keys used to control the forward move of the camera.
  38657. */
  38658. keysForward: number[];
  38659. /**
  38660. * The list of keyboard keys used to control the backward move of the camera.
  38661. */
  38662. keysBackward: number[];
  38663. /**
  38664. * The list of keyboard keys used to control the forward move of the camera.
  38665. */
  38666. keysUp: number[];
  38667. /**
  38668. * The list of keyboard keys used to control the backward move of the camera.
  38669. */
  38670. keysDown: number[];
  38671. /**
  38672. * The list of keyboard keys used to control the right strafe move of the camera.
  38673. */
  38674. keysRight: number[];
  38675. /**
  38676. * The list of keyboard keys used to control the left strafe move of the camera.
  38677. */
  38678. keysLeft: number[];
  38679. private _keys;
  38680. private _onCanvasBlurObserver;
  38681. private _onKeyboardObserver;
  38682. private _engine;
  38683. private _scene;
  38684. /**
  38685. * Attach the input controls to a specific dom element to get the input from.
  38686. * @param element Defines the element the controls should be listened from
  38687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38688. */
  38689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38690. /**
  38691. * Detach the current controls from the specified dom element.
  38692. * @param element Defines the element to stop listening the inputs from
  38693. */
  38694. detachControl(element: Nullable<HTMLElement>): void;
  38695. /**
  38696. * Gets the class name of the current intput.
  38697. * @returns the class name
  38698. */
  38699. getClassName(): string;
  38700. /** @hidden */
  38701. _onLostFocus(e: FocusEvent): void;
  38702. /**
  38703. * Get the friendly name associated with the input class.
  38704. * @returns the input friendly name
  38705. */
  38706. getSimpleName(): string;
  38707. /**
  38708. * Update the current camera state depending on the inputs that have been used this frame.
  38709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38710. */
  38711. checkInputs(): void;
  38712. }
  38713. }
  38714. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38715. import { Nullable } from "babylonjs/types";
  38716. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38717. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38718. /**
  38719. * Manage the mouse wheel inputs to control a follow camera.
  38720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38721. */
  38722. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38723. /**
  38724. * Defines the camera the input is attached to.
  38725. */
  38726. camera: FollowCamera;
  38727. /**
  38728. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38729. */
  38730. axisControlRadius: boolean;
  38731. /**
  38732. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38733. */
  38734. axisControlHeight: boolean;
  38735. /**
  38736. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38737. */
  38738. axisControlRotation: boolean;
  38739. /**
  38740. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38741. * relation to mouseWheel events.
  38742. */
  38743. wheelPrecision: number;
  38744. /**
  38745. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38746. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38747. */
  38748. wheelDeltaPercentage: number;
  38749. private _wheel;
  38750. private _observer;
  38751. /**
  38752. * Attach the input controls to a specific dom element to get the input from.
  38753. * @param element Defines the element the controls should be listened from
  38754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38755. */
  38756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38757. /**
  38758. * Detach the current controls from the specified dom element.
  38759. * @param element Defines the element to stop listening the inputs from
  38760. */
  38761. detachControl(element: Nullable<HTMLElement>): void;
  38762. /**
  38763. * Gets the class name of the current intput.
  38764. * @returns the class name
  38765. */
  38766. getClassName(): string;
  38767. /**
  38768. * Get the friendly name associated with the input class.
  38769. * @returns the input friendly name
  38770. */
  38771. getSimpleName(): string;
  38772. }
  38773. }
  38774. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38775. import { Nullable } from "babylonjs/types";
  38776. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38777. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38778. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38779. /**
  38780. * Manage the pointers inputs to control an follow camera.
  38781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38782. */
  38783. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38784. /**
  38785. * Defines the camera the input is attached to.
  38786. */
  38787. camera: FollowCamera;
  38788. /**
  38789. * Gets the class name of the current input.
  38790. * @returns the class name
  38791. */
  38792. getClassName(): string;
  38793. /**
  38794. * Defines the pointer angular sensibility along the X axis or how fast is
  38795. * the camera rotating.
  38796. * A negative number will reverse the axis direction.
  38797. */
  38798. angularSensibilityX: number;
  38799. /**
  38800. * Defines the pointer angular sensibility along the Y axis or how fast is
  38801. * the camera rotating.
  38802. * A negative number will reverse the axis direction.
  38803. */
  38804. angularSensibilityY: number;
  38805. /**
  38806. * Defines the pointer pinch precision or how fast is the camera zooming.
  38807. * A negative number will reverse the axis direction.
  38808. */
  38809. pinchPrecision: number;
  38810. /**
  38811. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38812. * from 0.
  38813. * It defines the percentage of current camera.radius to use as delta when
  38814. * pinch zoom is used.
  38815. */
  38816. pinchDeltaPercentage: number;
  38817. /**
  38818. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38819. */
  38820. axisXControlRadius: boolean;
  38821. /**
  38822. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38823. */
  38824. axisXControlHeight: boolean;
  38825. /**
  38826. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38827. */
  38828. axisXControlRotation: boolean;
  38829. /**
  38830. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38831. */
  38832. axisYControlRadius: boolean;
  38833. /**
  38834. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38835. */
  38836. axisYControlHeight: boolean;
  38837. /**
  38838. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38839. */
  38840. axisYControlRotation: boolean;
  38841. /**
  38842. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38843. */
  38844. axisPinchControlRadius: boolean;
  38845. /**
  38846. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38847. */
  38848. axisPinchControlHeight: boolean;
  38849. /**
  38850. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38851. */
  38852. axisPinchControlRotation: boolean;
  38853. /**
  38854. * Log error messages if basic misconfiguration has occurred.
  38855. */
  38856. warningEnable: boolean;
  38857. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38858. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38859. private _warningCounter;
  38860. private _warning;
  38861. }
  38862. }
  38863. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38864. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38865. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38866. /**
  38867. * Default Inputs manager for the FollowCamera.
  38868. * It groups all the default supported inputs for ease of use.
  38869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38870. */
  38871. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38872. /**
  38873. * Instantiates a new FollowCameraInputsManager.
  38874. * @param camera Defines the camera the inputs belong to
  38875. */
  38876. constructor(camera: FollowCamera);
  38877. /**
  38878. * Add keyboard input support to the input manager.
  38879. * @returns the current input manager
  38880. */
  38881. addKeyboard(): FollowCameraInputsManager;
  38882. /**
  38883. * Add mouse wheel input support to the input manager.
  38884. * @returns the current input manager
  38885. */
  38886. addMouseWheel(): FollowCameraInputsManager;
  38887. /**
  38888. * Add pointers input support to the input manager.
  38889. * @returns the current input manager
  38890. */
  38891. addPointers(): FollowCameraInputsManager;
  38892. /**
  38893. * Add orientation input support to the input manager.
  38894. * @returns the current input manager
  38895. */
  38896. addVRDeviceOrientation(): FollowCameraInputsManager;
  38897. }
  38898. }
  38899. declare module "babylonjs/Cameras/followCamera" {
  38900. import { Nullable } from "babylonjs/types";
  38901. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38902. import { Scene } from "babylonjs/scene";
  38903. import { Vector3 } from "babylonjs/Maths/math.vector";
  38904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38905. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38906. /**
  38907. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38908. * an arc rotate version arcFollowCamera are available.
  38909. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38910. */
  38911. export class FollowCamera extends TargetCamera {
  38912. /**
  38913. * Distance the follow camera should follow an object at
  38914. */
  38915. radius: number;
  38916. /**
  38917. * Minimum allowed distance of the camera to the axis of rotation
  38918. * (The camera can not get closer).
  38919. * This can help limiting how the Camera is able to move in the scene.
  38920. */
  38921. lowerRadiusLimit: Nullable<number>;
  38922. /**
  38923. * Maximum allowed distance of the camera to the axis of rotation
  38924. * (The camera can not get further).
  38925. * This can help limiting how the Camera is able to move in the scene.
  38926. */
  38927. upperRadiusLimit: Nullable<number>;
  38928. /**
  38929. * Define a rotation offset between the camera and the object it follows
  38930. */
  38931. rotationOffset: number;
  38932. /**
  38933. * Minimum allowed angle to camera position relative to target object.
  38934. * This can help limiting how the Camera is able to move in the scene.
  38935. */
  38936. lowerRotationOffsetLimit: Nullable<number>;
  38937. /**
  38938. * Maximum allowed angle to camera position relative to target object.
  38939. * This can help limiting how the Camera is able to move in the scene.
  38940. */
  38941. upperRotationOffsetLimit: Nullable<number>;
  38942. /**
  38943. * Define a height offset between the camera and the object it follows.
  38944. * It can help following an object from the top (like a car chaing a plane)
  38945. */
  38946. heightOffset: number;
  38947. /**
  38948. * Minimum allowed height of camera position relative to target object.
  38949. * This can help limiting how the Camera is able to move in the scene.
  38950. */
  38951. lowerHeightOffsetLimit: Nullable<number>;
  38952. /**
  38953. * Maximum allowed height of camera position relative to target object.
  38954. * This can help limiting how the Camera is able to move in the scene.
  38955. */
  38956. upperHeightOffsetLimit: Nullable<number>;
  38957. /**
  38958. * Define how fast the camera can accelerate to follow it s target.
  38959. */
  38960. cameraAcceleration: number;
  38961. /**
  38962. * Define the speed limit of the camera following an object.
  38963. */
  38964. maxCameraSpeed: number;
  38965. /**
  38966. * Define the target of the camera.
  38967. */
  38968. lockedTarget: Nullable<AbstractMesh>;
  38969. /**
  38970. * Defines the input associated with the camera.
  38971. */
  38972. inputs: FollowCameraInputsManager;
  38973. /**
  38974. * Instantiates the follow camera.
  38975. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38976. * @param name Define the name of the camera in the scene
  38977. * @param position Define the position of the camera
  38978. * @param scene Define the scene the camera belong to
  38979. * @param lockedTarget Define the target of the camera
  38980. */
  38981. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38982. private _follow;
  38983. /**
  38984. * Attached controls to the current camera.
  38985. * @param element Defines the element the controls should be listened from
  38986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38987. */
  38988. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38989. /**
  38990. * Detach the current controls from the camera.
  38991. * The camera will stop reacting to inputs.
  38992. * @param element Defines the element to stop listening the inputs from
  38993. */
  38994. detachControl(element: HTMLElement): void;
  38995. /** @hidden */
  38996. _checkInputs(): void;
  38997. private _checkLimits;
  38998. /**
  38999. * Gets the camera class name.
  39000. * @returns the class name
  39001. */
  39002. getClassName(): string;
  39003. }
  39004. /**
  39005. * Arc Rotate version of the follow camera.
  39006. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39007. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39008. */
  39009. export class ArcFollowCamera extends TargetCamera {
  39010. /** The longitudinal angle of the camera */
  39011. alpha: number;
  39012. /** The latitudinal angle of the camera */
  39013. beta: number;
  39014. /** The radius of the camera from its target */
  39015. radius: number;
  39016. /** Define the camera target (the messh it should follow) */
  39017. target: Nullable<AbstractMesh>;
  39018. private _cartesianCoordinates;
  39019. /**
  39020. * Instantiates a new ArcFollowCamera
  39021. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39022. * @param name Define the name of the camera
  39023. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39024. * @param beta Define the rotation angle of the camera around the elevation axis
  39025. * @param radius Define the radius of the camera from its target point
  39026. * @param target Define the target of the camera
  39027. * @param scene Define the scene the camera belongs to
  39028. */
  39029. constructor(name: string,
  39030. /** The longitudinal angle of the camera */
  39031. alpha: number,
  39032. /** The latitudinal angle of the camera */
  39033. beta: number,
  39034. /** The radius of the camera from its target */
  39035. radius: number,
  39036. /** Define the camera target (the messh it should follow) */
  39037. target: Nullable<AbstractMesh>, scene: Scene);
  39038. private _follow;
  39039. /** @hidden */
  39040. _checkInputs(): void;
  39041. /**
  39042. * Returns the class name of the object.
  39043. * It is mostly used internally for serialization purposes.
  39044. */
  39045. getClassName(): string;
  39046. }
  39047. }
  39048. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39050. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39051. import { Nullable } from "babylonjs/types";
  39052. /**
  39053. * Manage the keyboard inputs to control the movement of a follow camera.
  39054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39055. */
  39056. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39057. /**
  39058. * Defines the camera the input is attached to.
  39059. */
  39060. camera: FollowCamera;
  39061. /**
  39062. * Defines the list of key codes associated with the up action (increase heightOffset)
  39063. */
  39064. keysHeightOffsetIncr: number[];
  39065. /**
  39066. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39067. */
  39068. keysHeightOffsetDecr: number[];
  39069. /**
  39070. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39071. */
  39072. keysHeightOffsetModifierAlt: boolean;
  39073. /**
  39074. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39075. */
  39076. keysHeightOffsetModifierCtrl: boolean;
  39077. /**
  39078. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39079. */
  39080. keysHeightOffsetModifierShift: boolean;
  39081. /**
  39082. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39083. */
  39084. keysRotationOffsetIncr: number[];
  39085. /**
  39086. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39087. */
  39088. keysRotationOffsetDecr: number[];
  39089. /**
  39090. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39091. */
  39092. keysRotationOffsetModifierAlt: boolean;
  39093. /**
  39094. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39095. */
  39096. keysRotationOffsetModifierCtrl: boolean;
  39097. /**
  39098. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39099. */
  39100. keysRotationOffsetModifierShift: boolean;
  39101. /**
  39102. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39103. */
  39104. keysRadiusIncr: number[];
  39105. /**
  39106. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39107. */
  39108. keysRadiusDecr: number[];
  39109. /**
  39110. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39111. */
  39112. keysRadiusModifierAlt: boolean;
  39113. /**
  39114. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39115. */
  39116. keysRadiusModifierCtrl: boolean;
  39117. /**
  39118. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39119. */
  39120. keysRadiusModifierShift: boolean;
  39121. /**
  39122. * Defines the rate of change of heightOffset.
  39123. */
  39124. heightSensibility: number;
  39125. /**
  39126. * Defines the rate of change of rotationOffset.
  39127. */
  39128. rotationSensibility: number;
  39129. /**
  39130. * Defines the rate of change of radius.
  39131. */
  39132. radiusSensibility: number;
  39133. private _keys;
  39134. private _ctrlPressed;
  39135. private _altPressed;
  39136. private _shiftPressed;
  39137. private _onCanvasBlurObserver;
  39138. private _onKeyboardObserver;
  39139. private _engine;
  39140. private _scene;
  39141. /**
  39142. * Attach the input controls to a specific dom element to get the input from.
  39143. * @param element Defines the element the controls should be listened from
  39144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39145. */
  39146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39147. /**
  39148. * Detach the current controls from the specified dom element.
  39149. * @param element Defines the element to stop listening the inputs from
  39150. */
  39151. detachControl(element: Nullable<HTMLElement>): void;
  39152. /**
  39153. * Update the current camera state depending on the inputs that have been used this frame.
  39154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39155. */
  39156. checkInputs(): void;
  39157. /**
  39158. * Gets the class name of the current input.
  39159. * @returns the class name
  39160. */
  39161. getClassName(): string;
  39162. /**
  39163. * Get the friendly name associated with the input class.
  39164. * @returns the input friendly name
  39165. */
  39166. getSimpleName(): string;
  39167. /**
  39168. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39169. * allow modification of the heightOffset value.
  39170. */
  39171. private _modifierHeightOffset;
  39172. /**
  39173. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39174. * allow modification of the rotationOffset value.
  39175. */
  39176. private _modifierRotationOffset;
  39177. /**
  39178. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39179. * allow modification of the radius value.
  39180. */
  39181. private _modifierRadius;
  39182. }
  39183. }
  39184. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39185. import { Nullable } from "babylonjs/types";
  39186. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39187. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39188. import { Observable } from "babylonjs/Misc/observable";
  39189. module "babylonjs/Cameras/freeCameraInputsManager" {
  39190. interface FreeCameraInputsManager {
  39191. /**
  39192. * @hidden
  39193. */
  39194. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39195. /**
  39196. * Add orientation input support to the input manager.
  39197. * @returns the current input manager
  39198. */
  39199. addDeviceOrientation(): FreeCameraInputsManager;
  39200. }
  39201. }
  39202. /**
  39203. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39204. * Screen rotation is taken into account.
  39205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39206. */
  39207. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39208. private _camera;
  39209. private _screenOrientationAngle;
  39210. private _constantTranform;
  39211. private _screenQuaternion;
  39212. private _alpha;
  39213. private _beta;
  39214. private _gamma;
  39215. /**
  39216. * Can be used to detect if a device orientation sensor is availible on a device
  39217. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39218. * @returns a promise that will resolve on orientation change
  39219. */
  39220. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39221. /**
  39222. * @hidden
  39223. */
  39224. _onDeviceOrientationChangedObservable: Observable<void>;
  39225. /**
  39226. * Instantiates a new input
  39227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39228. */
  39229. constructor();
  39230. /**
  39231. * Define the camera controlled by the input.
  39232. */
  39233. camera: FreeCamera;
  39234. /**
  39235. * Attach the input controls to a specific dom element to get the input from.
  39236. * @param element Defines the element the controls should be listened from
  39237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39238. */
  39239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39240. private _orientationChanged;
  39241. private _deviceOrientation;
  39242. /**
  39243. * Detach the current controls from the specified dom element.
  39244. * @param element Defines the element to stop listening the inputs from
  39245. */
  39246. detachControl(element: Nullable<HTMLElement>): void;
  39247. /**
  39248. * Update the current camera state depending on the inputs that have been used this frame.
  39249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39250. */
  39251. checkInputs(): void;
  39252. /**
  39253. * Gets the class name of the current intput.
  39254. * @returns the class name
  39255. */
  39256. getClassName(): string;
  39257. /**
  39258. * Get the friendly name associated with the input class.
  39259. * @returns the input friendly name
  39260. */
  39261. getSimpleName(): string;
  39262. }
  39263. }
  39264. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39265. import { Nullable } from "babylonjs/types";
  39266. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39267. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39268. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39269. /**
  39270. * Manage the gamepad inputs to control a free camera.
  39271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39272. */
  39273. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39274. /**
  39275. * Define the camera the input is attached to.
  39276. */
  39277. camera: FreeCamera;
  39278. /**
  39279. * Define the Gamepad controlling the input
  39280. */
  39281. gamepad: Nullable<Gamepad>;
  39282. /**
  39283. * Defines the gamepad rotation sensiblity.
  39284. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39285. */
  39286. gamepadAngularSensibility: number;
  39287. /**
  39288. * Defines the gamepad move sensiblity.
  39289. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39290. */
  39291. gamepadMoveSensibility: number;
  39292. private _onGamepadConnectedObserver;
  39293. private _onGamepadDisconnectedObserver;
  39294. private _cameraTransform;
  39295. private _deltaTransform;
  39296. private _vector3;
  39297. private _vector2;
  39298. /**
  39299. * Attach the input controls to a specific dom element to get the input from.
  39300. * @param element Defines the element the controls should be listened from
  39301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39302. */
  39303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39304. /**
  39305. * Detach the current controls from the specified dom element.
  39306. * @param element Defines the element to stop listening the inputs from
  39307. */
  39308. detachControl(element: Nullable<HTMLElement>): void;
  39309. /**
  39310. * Update the current camera state depending on the inputs that have been used this frame.
  39311. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39312. */
  39313. checkInputs(): void;
  39314. /**
  39315. * Gets the class name of the current intput.
  39316. * @returns the class name
  39317. */
  39318. getClassName(): string;
  39319. /**
  39320. * Get the friendly name associated with the input class.
  39321. * @returns the input friendly name
  39322. */
  39323. getSimpleName(): string;
  39324. }
  39325. }
  39326. declare module "babylonjs/Misc/virtualJoystick" {
  39327. import { Nullable } from "babylonjs/types";
  39328. import { Vector3 } from "babylonjs/Maths/math.vector";
  39329. /**
  39330. * Defines the potential axis of a Joystick
  39331. */
  39332. export enum JoystickAxis {
  39333. /** X axis */
  39334. X = 0,
  39335. /** Y axis */
  39336. Y = 1,
  39337. /** Z axis */
  39338. Z = 2
  39339. }
  39340. /**
  39341. * Class used to define virtual joystick (used in touch mode)
  39342. */
  39343. export class VirtualJoystick {
  39344. /**
  39345. * Gets or sets a boolean indicating that left and right values must be inverted
  39346. */
  39347. reverseLeftRight: boolean;
  39348. /**
  39349. * Gets or sets a boolean indicating that up and down values must be inverted
  39350. */
  39351. reverseUpDown: boolean;
  39352. /**
  39353. * Gets the offset value for the position (ie. the change of the position value)
  39354. */
  39355. deltaPosition: Vector3;
  39356. /**
  39357. * Gets a boolean indicating if the virtual joystick was pressed
  39358. */
  39359. pressed: boolean;
  39360. /**
  39361. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39362. */
  39363. static Canvas: Nullable<HTMLCanvasElement>;
  39364. private static _globalJoystickIndex;
  39365. private static vjCanvasContext;
  39366. private static vjCanvasWidth;
  39367. private static vjCanvasHeight;
  39368. private static halfWidth;
  39369. private _action;
  39370. private _axisTargetedByLeftAndRight;
  39371. private _axisTargetedByUpAndDown;
  39372. private _joystickSensibility;
  39373. private _inversedSensibility;
  39374. private _joystickPointerID;
  39375. private _joystickColor;
  39376. private _joystickPointerPos;
  39377. private _joystickPreviousPointerPos;
  39378. private _joystickPointerStartPos;
  39379. private _deltaJoystickVector;
  39380. private _leftJoystick;
  39381. private _touches;
  39382. private _onPointerDownHandlerRef;
  39383. private _onPointerMoveHandlerRef;
  39384. private _onPointerUpHandlerRef;
  39385. private _onResize;
  39386. /**
  39387. * Creates a new virtual joystick
  39388. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39389. */
  39390. constructor(leftJoystick?: boolean);
  39391. /**
  39392. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39393. * @param newJoystickSensibility defines the new sensibility
  39394. */
  39395. setJoystickSensibility(newJoystickSensibility: number): void;
  39396. private _onPointerDown;
  39397. private _onPointerMove;
  39398. private _onPointerUp;
  39399. /**
  39400. * Change the color of the virtual joystick
  39401. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39402. */
  39403. setJoystickColor(newColor: string): void;
  39404. /**
  39405. * Defines a callback to call when the joystick is touched
  39406. * @param action defines the callback
  39407. */
  39408. setActionOnTouch(action: () => any): void;
  39409. /**
  39410. * Defines which axis you'd like to control for left & right
  39411. * @param axis defines the axis to use
  39412. */
  39413. setAxisForLeftRight(axis: JoystickAxis): void;
  39414. /**
  39415. * Defines which axis you'd like to control for up & down
  39416. * @param axis defines the axis to use
  39417. */
  39418. setAxisForUpDown(axis: JoystickAxis): void;
  39419. private _drawVirtualJoystick;
  39420. /**
  39421. * Release internal HTML canvas
  39422. */
  39423. releaseCanvas(): void;
  39424. }
  39425. }
  39426. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39427. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39428. import { Nullable } from "babylonjs/types";
  39429. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39430. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39431. module "babylonjs/Cameras/freeCameraInputsManager" {
  39432. interface FreeCameraInputsManager {
  39433. /**
  39434. * Add virtual joystick input support to the input manager.
  39435. * @returns the current input manager
  39436. */
  39437. addVirtualJoystick(): FreeCameraInputsManager;
  39438. }
  39439. }
  39440. /**
  39441. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39443. */
  39444. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39445. /**
  39446. * Defines the camera the input is attached to.
  39447. */
  39448. camera: FreeCamera;
  39449. private _leftjoystick;
  39450. private _rightjoystick;
  39451. /**
  39452. * Gets the left stick of the virtual joystick.
  39453. * @returns The virtual Joystick
  39454. */
  39455. getLeftJoystick(): VirtualJoystick;
  39456. /**
  39457. * Gets the right stick of the virtual joystick.
  39458. * @returns The virtual Joystick
  39459. */
  39460. getRightJoystick(): VirtualJoystick;
  39461. /**
  39462. * Update the current camera state depending on the inputs that have been used this frame.
  39463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39464. */
  39465. checkInputs(): void;
  39466. /**
  39467. * Attach the input controls to a specific dom element to get the input from.
  39468. * @param element Defines the element the controls should be listened from
  39469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39470. */
  39471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39472. /**
  39473. * Detach the current controls from the specified dom element.
  39474. * @param element Defines the element to stop listening the inputs from
  39475. */
  39476. detachControl(element: Nullable<HTMLElement>): void;
  39477. /**
  39478. * Gets the class name of the current intput.
  39479. * @returns the class name
  39480. */
  39481. getClassName(): string;
  39482. /**
  39483. * Get the friendly name associated with the input class.
  39484. * @returns the input friendly name
  39485. */
  39486. getSimpleName(): string;
  39487. }
  39488. }
  39489. declare module "babylonjs/Cameras/Inputs/index" {
  39490. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39491. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39492. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39493. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39494. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39495. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39496. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39497. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39498. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39499. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39500. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39501. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39502. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39503. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39504. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39505. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39506. }
  39507. declare module "babylonjs/Cameras/touchCamera" {
  39508. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39509. import { Scene } from "babylonjs/scene";
  39510. import { Vector3 } from "babylonjs/Maths/math.vector";
  39511. /**
  39512. * This represents a FPS type of camera controlled by touch.
  39513. * This is like a universal camera minus the Gamepad controls.
  39514. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39515. */
  39516. export class TouchCamera extends FreeCamera {
  39517. /**
  39518. * Defines the touch sensibility for rotation.
  39519. * The higher the faster.
  39520. */
  39521. touchAngularSensibility: number;
  39522. /**
  39523. * Defines the touch sensibility for move.
  39524. * The higher the faster.
  39525. */
  39526. touchMoveSensibility: number;
  39527. /**
  39528. * Instantiates a new touch camera.
  39529. * This represents a FPS type of camera controlled by touch.
  39530. * This is like a universal camera minus the Gamepad controls.
  39531. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39532. * @param name Define the name of the camera in the scene
  39533. * @param position Define the start position of the camera in the scene
  39534. * @param scene Define the scene the camera belongs to
  39535. */
  39536. constructor(name: string, position: Vector3, scene: Scene);
  39537. /**
  39538. * Gets the current object class name.
  39539. * @return the class name
  39540. */
  39541. getClassName(): string;
  39542. /** @hidden */
  39543. _setupInputs(): void;
  39544. }
  39545. }
  39546. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39547. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39548. import { Scene } from "babylonjs/scene";
  39549. import { Vector3 } from "babylonjs/Maths/math.vector";
  39550. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39551. import { Axis } from "babylonjs/Maths/math.axis";
  39552. /**
  39553. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39554. * being tilted forward or back and left or right.
  39555. */
  39556. export class DeviceOrientationCamera extends FreeCamera {
  39557. private _initialQuaternion;
  39558. private _quaternionCache;
  39559. private _tmpDragQuaternion;
  39560. private _disablePointerInputWhenUsingDeviceOrientation;
  39561. /**
  39562. * Creates a new device orientation camera
  39563. * @param name The name of the camera
  39564. * @param position The start position camera
  39565. * @param scene The scene the camera belongs to
  39566. */
  39567. constructor(name: string, position: Vector3, scene: Scene);
  39568. /**
  39569. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39570. */
  39571. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39572. private _dragFactor;
  39573. /**
  39574. * Enabled turning on the y axis when the orientation sensor is active
  39575. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39576. */
  39577. enableHorizontalDragging(dragFactor?: number): void;
  39578. /**
  39579. * Gets the current instance class name ("DeviceOrientationCamera").
  39580. * This helps avoiding instanceof at run time.
  39581. * @returns the class name
  39582. */
  39583. getClassName(): string;
  39584. /**
  39585. * @hidden
  39586. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39587. */
  39588. _checkInputs(): void;
  39589. /**
  39590. * Reset the camera to its default orientation on the specified axis only.
  39591. * @param axis The axis to reset
  39592. */
  39593. resetToCurrentRotation(axis?: Axis): void;
  39594. }
  39595. }
  39596. declare module "babylonjs/Gamepads/xboxGamepad" {
  39597. import { Observable } from "babylonjs/Misc/observable";
  39598. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39599. /**
  39600. * Defines supported buttons for XBox360 compatible gamepads
  39601. */
  39602. export enum Xbox360Button {
  39603. /** A */
  39604. A = 0,
  39605. /** B */
  39606. B = 1,
  39607. /** X */
  39608. X = 2,
  39609. /** Y */
  39610. Y = 3,
  39611. /** Start */
  39612. Start = 4,
  39613. /** Back */
  39614. Back = 5,
  39615. /** Left button */
  39616. LB = 6,
  39617. /** Right button */
  39618. RB = 7,
  39619. /** Left stick */
  39620. LeftStick = 8,
  39621. /** Right stick */
  39622. RightStick = 9
  39623. }
  39624. /** Defines values for XBox360 DPad */
  39625. export enum Xbox360Dpad {
  39626. /** Up */
  39627. Up = 0,
  39628. /** Down */
  39629. Down = 1,
  39630. /** Left */
  39631. Left = 2,
  39632. /** Right */
  39633. Right = 3
  39634. }
  39635. /**
  39636. * Defines a XBox360 gamepad
  39637. */
  39638. export class Xbox360Pad extends Gamepad {
  39639. private _leftTrigger;
  39640. private _rightTrigger;
  39641. private _onlefttriggerchanged;
  39642. private _onrighttriggerchanged;
  39643. private _onbuttondown;
  39644. private _onbuttonup;
  39645. private _ondpaddown;
  39646. private _ondpadup;
  39647. /** Observable raised when a button is pressed */
  39648. onButtonDownObservable: Observable<Xbox360Button>;
  39649. /** Observable raised when a button is released */
  39650. onButtonUpObservable: Observable<Xbox360Button>;
  39651. /** Observable raised when a pad is pressed */
  39652. onPadDownObservable: Observable<Xbox360Dpad>;
  39653. /** Observable raised when a pad is released */
  39654. onPadUpObservable: Observable<Xbox360Dpad>;
  39655. private _buttonA;
  39656. private _buttonB;
  39657. private _buttonX;
  39658. private _buttonY;
  39659. private _buttonBack;
  39660. private _buttonStart;
  39661. private _buttonLB;
  39662. private _buttonRB;
  39663. private _buttonLeftStick;
  39664. private _buttonRightStick;
  39665. private _dPadUp;
  39666. private _dPadDown;
  39667. private _dPadLeft;
  39668. private _dPadRight;
  39669. private _isXboxOnePad;
  39670. /**
  39671. * Creates a new XBox360 gamepad object
  39672. * @param id defines the id of this gamepad
  39673. * @param index defines its index
  39674. * @param gamepad defines the internal HTML gamepad object
  39675. * @param xboxOne defines if it is a XBox One gamepad
  39676. */
  39677. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39678. /**
  39679. * Defines the callback to call when left trigger is pressed
  39680. * @param callback defines the callback to use
  39681. */
  39682. onlefttriggerchanged(callback: (value: number) => void): void;
  39683. /**
  39684. * Defines the callback to call when right trigger is pressed
  39685. * @param callback defines the callback to use
  39686. */
  39687. onrighttriggerchanged(callback: (value: number) => void): void;
  39688. /**
  39689. * Gets the left trigger value
  39690. */
  39691. /**
  39692. * Sets the left trigger value
  39693. */
  39694. leftTrigger: number;
  39695. /**
  39696. * Gets the right trigger value
  39697. */
  39698. /**
  39699. * Sets the right trigger value
  39700. */
  39701. rightTrigger: number;
  39702. /**
  39703. * Defines the callback to call when a button is pressed
  39704. * @param callback defines the callback to use
  39705. */
  39706. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39707. /**
  39708. * Defines the callback to call when a button is released
  39709. * @param callback defines the callback to use
  39710. */
  39711. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39712. /**
  39713. * Defines the callback to call when a pad is pressed
  39714. * @param callback defines the callback to use
  39715. */
  39716. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39717. /**
  39718. * Defines the callback to call when a pad is released
  39719. * @param callback defines the callback to use
  39720. */
  39721. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39722. private _setButtonValue;
  39723. private _setDPadValue;
  39724. /**
  39725. * Gets the value of the `A` button
  39726. */
  39727. /**
  39728. * Sets the value of the `A` button
  39729. */
  39730. buttonA: number;
  39731. /**
  39732. * Gets the value of the `B` button
  39733. */
  39734. /**
  39735. * Sets the value of the `B` button
  39736. */
  39737. buttonB: number;
  39738. /**
  39739. * Gets the value of the `X` button
  39740. */
  39741. /**
  39742. * Sets the value of the `X` button
  39743. */
  39744. buttonX: number;
  39745. /**
  39746. * Gets the value of the `Y` button
  39747. */
  39748. /**
  39749. * Sets the value of the `Y` button
  39750. */
  39751. buttonY: number;
  39752. /**
  39753. * Gets the value of the `Start` button
  39754. */
  39755. /**
  39756. * Sets the value of the `Start` button
  39757. */
  39758. buttonStart: number;
  39759. /**
  39760. * Gets the value of the `Back` button
  39761. */
  39762. /**
  39763. * Sets the value of the `Back` button
  39764. */
  39765. buttonBack: number;
  39766. /**
  39767. * Gets the value of the `Left` button
  39768. */
  39769. /**
  39770. * Sets the value of the `Left` button
  39771. */
  39772. buttonLB: number;
  39773. /**
  39774. * Gets the value of the `Right` button
  39775. */
  39776. /**
  39777. * Sets the value of the `Right` button
  39778. */
  39779. buttonRB: number;
  39780. /**
  39781. * Gets the value of the Left joystick
  39782. */
  39783. /**
  39784. * Sets the value of the Left joystick
  39785. */
  39786. buttonLeftStick: number;
  39787. /**
  39788. * Gets the value of the Right joystick
  39789. */
  39790. /**
  39791. * Sets the value of the Right joystick
  39792. */
  39793. buttonRightStick: number;
  39794. /**
  39795. * Gets the value of D-pad up
  39796. */
  39797. /**
  39798. * Sets the value of D-pad up
  39799. */
  39800. dPadUp: number;
  39801. /**
  39802. * Gets the value of D-pad down
  39803. */
  39804. /**
  39805. * Sets the value of D-pad down
  39806. */
  39807. dPadDown: number;
  39808. /**
  39809. * Gets the value of D-pad left
  39810. */
  39811. /**
  39812. * Sets the value of D-pad left
  39813. */
  39814. dPadLeft: number;
  39815. /**
  39816. * Gets the value of D-pad right
  39817. */
  39818. /**
  39819. * Sets the value of D-pad right
  39820. */
  39821. dPadRight: number;
  39822. /**
  39823. * Force the gamepad to synchronize with device values
  39824. */
  39825. update(): void;
  39826. /**
  39827. * Disposes the gamepad
  39828. */
  39829. dispose(): void;
  39830. }
  39831. }
  39832. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39833. import { Observable } from "babylonjs/Misc/observable";
  39834. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39835. /**
  39836. * Defines supported buttons for DualShock compatible gamepads
  39837. */
  39838. export enum DualShockButton {
  39839. /** Cross */
  39840. Cross = 0,
  39841. /** Circle */
  39842. Circle = 1,
  39843. /** Square */
  39844. Square = 2,
  39845. /** Triangle */
  39846. Triangle = 3,
  39847. /** Options */
  39848. Options = 4,
  39849. /** Share */
  39850. Share = 5,
  39851. /** L1 */
  39852. L1 = 6,
  39853. /** R1 */
  39854. R1 = 7,
  39855. /** Left stick */
  39856. LeftStick = 8,
  39857. /** Right stick */
  39858. RightStick = 9
  39859. }
  39860. /** Defines values for DualShock DPad */
  39861. export enum DualShockDpad {
  39862. /** Up */
  39863. Up = 0,
  39864. /** Down */
  39865. Down = 1,
  39866. /** Left */
  39867. Left = 2,
  39868. /** Right */
  39869. Right = 3
  39870. }
  39871. /**
  39872. * Defines a DualShock gamepad
  39873. */
  39874. export class DualShockPad extends Gamepad {
  39875. private _leftTrigger;
  39876. private _rightTrigger;
  39877. private _onlefttriggerchanged;
  39878. private _onrighttriggerchanged;
  39879. private _onbuttondown;
  39880. private _onbuttonup;
  39881. private _ondpaddown;
  39882. private _ondpadup;
  39883. /** Observable raised when a button is pressed */
  39884. onButtonDownObservable: Observable<DualShockButton>;
  39885. /** Observable raised when a button is released */
  39886. onButtonUpObservable: Observable<DualShockButton>;
  39887. /** Observable raised when a pad is pressed */
  39888. onPadDownObservable: Observable<DualShockDpad>;
  39889. /** Observable raised when a pad is released */
  39890. onPadUpObservable: Observable<DualShockDpad>;
  39891. private _buttonCross;
  39892. private _buttonCircle;
  39893. private _buttonSquare;
  39894. private _buttonTriangle;
  39895. private _buttonShare;
  39896. private _buttonOptions;
  39897. private _buttonL1;
  39898. private _buttonR1;
  39899. private _buttonLeftStick;
  39900. private _buttonRightStick;
  39901. private _dPadUp;
  39902. private _dPadDown;
  39903. private _dPadLeft;
  39904. private _dPadRight;
  39905. /**
  39906. * Creates a new DualShock gamepad object
  39907. * @param id defines the id of this gamepad
  39908. * @param index defines its index
  39909. * @param gamepad defines the internal HTML gamepad object
  39910. */
  39911. constructor(id: string, index: number, gamepad: any);
  39912. /**
  39913. * Defines the callback to call when left trigger is pressed
  39914. * @param callback defines the callback to use
  39915. */
  39916. onlefttriggerchanged(callback: (value: number) => void): void;
  39917. /**
  39918. * Defines the callback to call when right trigger is pressed
  39919. * @param callback defines the callback to use
  39920. */
  39921. onrighttriggerchanged(callback: (value: number) => void): void;
  39922. /**
  39923. * Gets the left trigger value
  39924. */
  39925. /**
  39926. * Sets the left trigger value
  39927. */
  39928. leftTrigger: number;
  39929. /**
  39930. * Gets the right trigger value
  39931. */
  39932. /**
  39933. * Sets the right trigger value
  39934. */
  39935. rightTrigger: number;
  39936. /**
  39937. * Defines the callback to call when a button is pressed
  39938. * @param callback defines the callback to use
  39939. */
  39940. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39941. /**
  39942. * Defines the callback to call when a button is released
  39943. * @param callback defines the callback to use
  39944. */
  39945. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39946. /**
  39947. * Defines the callback to call when a pad is pressed
  39948. * @param callback defines the callback to use
  39949. */
  39950. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39951. /**
  39952. * Defines the callback to call when a pad is released
  39953. * @param callback defines the callback to use
  39954. */
  39955. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39956. private _setButtonValue;
  39957. private _setDPadValue;
  39958. /**
  39959. * Gets the value of the `Cross` button
  39960. */
  39961. /**
  39962. * Sets the value of the `Cross` button
  39963. */
  39964. buttonCross: number;
  39965. /**
  39966. * Gets the value of the `Circle` button
  39967. */
  39968. /**
  39969. * Sets the value of the `Circle` button
  39970. */
  39971. buttonCircle: number;
  39972. /**
  39973. * Gets the value of the `Square` button
  39974. */
  39975. /**
  39976. * Sets the value of the `Square` button
  39977. */
  39978. buttonSquare: number;
  39979. /**
  39980. * Gets the value of the `Triangle` button
  39981. */
  39982. /**
  39983. * Sets the value of the `Triangle` button
  39984. */
  39985. buttonTriangle: number;
  39986. /**
  39987. * Gets the value of the `Options` button
  39988. */
  39989. /**
  39990. * Sets the value of the `Options` button
  39991. */
  39992. buttonOptions: number;
  39993. /**
  39994. * Gets the value of the `Share` button
  39995. */
  39996. /**
  39997. * Sets the value of the `Share` button
  39998. */
  39999. buttonShare: number;
  40000. /**
  40001. * Gets the value of the `L1` button
  40002. */
  40003. /**
  40004. * Sets the value of the `L1` button
  40005. */
  40006. buttonL1: number;
  40007. /**
  40008. * Gets the value of the `R1` button
  40009. */
  40010. /**
  40011. * Sets the value of the `R1` button
  40012. */
  40013. buttonR1: number;
  40014. /**
  40015. * Gets the value of the Left joystick
  40016. */
  40017. /**
  40018. * Sets the value of the Left joystick
  40019. */
  40020. buttonLeftStick: number;
  40021. /**
  40022. * Gets the value of the Right joystick
  40023. */
  40024. /**
  40025. * Sets the value of the Right joystick
  40026. */
  40027. buttonRightStick: number;
  40028. /**
  40029. * Gets the value of D-pad up
  40030. */
  40031. /**
  40032. * Sets the value of D-pad up
  40033. */
  40034. dPadUp: number;
  40035. /**
  40036. * Gets the value of D-pad down
  40037. */
  40038. /**
  40039. * Sets the value of D-pad down
  40040. */
  40041. dPadDown: number;
  40042. /**
  40043. * Gets the value of D-pad left
  40044. */
  40045. /**
  40046. * Sets the value of D-pad left
  40047. */
  40048. dPadLeft: number;
  40049. /**
  40050. * Gets the value of D-pad right
  40051. */
  40052. /**
  40053. * Sets the value of D-pad right
  40054. */
  40055. dPadRight: number;
  40056. /**
  40057. * Force the gamepad to synchronize with device values
  40058. */
  40059. update(): void;
  40060. /**
  40061. * Disposes the gamepad
  40062. */
  40063. dispose(): void;
  40064. }
  40065. }
  40066. declare module "babylonjs/Gamepads/gamepadManager" {
  40067. import { Observable } from "babylonjs/Misc/observable";
  40068. import { Nullable } from "babylonjs/types";
  40069. import { Scene } from "babylonjs/scene";
  40070. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40071. /**
  40072. * Manager for handling gamepads
  40073. */
  40074. export class GamepadManager {
  40075. private _scene?;
  40076. private _babylonGamepads;
  40077. private _oneGamepadConnected;
  40078. /** @hidden */
  40079. _isMonitoring: boolean;
  40080. private _gamepadEventSupported;
  40081. private _gamepadSupport;
  40082. /**
  40083. * observable to be triggered when the gamepad controller has been connected
  40084. */
  40085. onGamepadConnectedObservable: Observable<Gamepad>;
  40086. /**
  40087. * observable to be triggered when the gamepad controller has been disconnected
  40088. */
  40089. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40090. private _onGamepadConnectedEvent;
  40091. private _onGamepadDisconnectedEvent;
  40092. /**
  40093. * Initializes the gamepad manager
  40094. * @param _scene BabylonJS scene
  40095. */
  40096. constructor(_scene?: Scene | undefined);
  40097. /**
  40098. * The gamepads in the game pad manager
  40099. */
  40100. readonly gamepads: Gamepad[];
  40101. /**
  40102. * Get the gamepad controllers based on type
  40103. * @param type The type of gamepad controller
  40104. * @returns Nullable gamepad
  40105. */
  40106. getGamepadByType(type?: number): Nullable<Gamepad>;
  40107. /**
  40108. * Disposes the gamepad manager
  40109. */
  40110. dispose(): void;
  40111. private _addNewGamepad;
  40112. private _startMonitoringGamepads;
  40113. private _stopMonitoringGamepads;
  40114. /** @hidden */
  40115. _checkGamepadsStatus(): void;
  40116. private _updateGamepadObjects;
  40117. }
  40118. }
  40119. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40120. import { Nullable } from "babylonjs/types";
  40121. import { Scene } from "babylonjs/scene";
  40122. import { ISceneComponent } from "babylonjs/sceneComponent";
  40123. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40124. module "babylonjs/scene" {
  40125. interface Scene {
  40126. /** @hidden */
  40127. _gamepadManager: Nullable<GamepadManager>;
  40128. /**
  40129. * Gets the gamepad manager associated with the scene
  40130. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40131. */
  40132. gamepadManager: GamepadManager;
  40133. }
  40134. }
  40135. module "babylonjs/Cameras/freeCameraInputsManager" {
  40136. /**
  40137. * Interface representing a free camera inputs manager
  40138. */
  40139. interface FreeCameraInputsManager {
  40140. /**
  40141. * Adds gamepad input support to the FreeCameraInputsManager.
  40142. * @returns the FreeCameraInputsManager
  40143. */
  40144. addGamepad(): FreeCameraInputsManager;
  40145. }
  40146. }
  40147. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40148. /**
  40149. * Interface representing an arc rotate camera inputs manager
  40150. */
  40151. interface ArcRotateCameraInputsManager {
  40152. /**
  40153. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40154. * @returns the camera inputs manager
  40155. */
  40156. addGamepad(): ArcRotateCameraInputsManager;
  40157. }
  40158. }
  40159. /**
  40160. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40161. */
  40162. export class GamepadSystemSceneComponent implements ISceneComponent {
  40163. /**
  40164. * The component name helpfull to identify the component in the list of scene components.
  40165. */
  40166. readonly name: string;
  40167. /**
  40168. * The scene the component belongs to.
  40169. */
  40170. scene: Scene;
  40171. /**
  40172. * Creates a new instance of the component for the given scene
  40173. * @param scene Defines the scene to register the component in
  40174. */
  40175. constructor(scene: Scene);
  40176. /**
  40177. * Registers the component in a given scene
  40178. */
  40179. register(): void;
  40180. /**
  40181. * Rebuilds the elements related to this component in case of
  40182. * context lost for instance.
  40183. */
  40184. rebuild(): void;
  40185. /**
  40186. * Disposes the component and the associated ressources
  40187. */
  40188. dispose(): void;
  40189. private _beforeCameraUpdate;
  40190. }
  40191. }
  40192. declare module "babylonjs/Cameras/universalCamera" {
  40193. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40194. import { Scene } from "babylonjs/scene";
  40195. import { Vector3 } from "babylonjs/Maths/math.vector";
  40196. import "babylonjs/Gamepads/gamepadSceneComponent";
  40197. /**
  40198. * 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,
  40199. * which still works and will still be found in many Playgrounds.
  40200. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40201. */
  40202. export class UniversalCamera extends TouchCamera {
  40203. /**
  40204. * Defines the gamepad rotation sensiblity.
  40205. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40206. */
  40207. gamepadAngularSensibility: number;
  40208. /**
  40209. * Defines the gamepad move sensiblity.
  40210. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40211. */
  40212. gamepadMoveSensibility: number;
  40213. /**
  40214. * 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,
  40215. * which still works and will still be found in many Playgrounds.
  40216. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40217. * @param name Define the name of the camera in the scene
  40218. * @param position Define the start position of the camera in the scene
  40219. * @param scene Define the scene the camera belongs to
  40220. */
  40221. constructor(name: string, position: Vector3, scene: Scene);
  40222. /**
  40223. * Gets the current object class name.
  40224. * @return the class name
  40225. */
  40226. getClassName(): string;
  40227. }
  40228. }
  40229. declare module "babylonjs/Cameras/gamepadCamera" {
  40230. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40231. import { Scene } from "babylonjs/scene";
  40232. import { Vector3 } from "babylonjs/Maths/math.vector";
  40233. /**
  40234. * This represents a FPS type of camera. This is only here for back compat purpose.
  40235. * Please use the UniversalCamera instead as both are identical.
  40236. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40237. */
  40238. export class GamepadCamera extends UniversalCamera {
  40239. /**
  40240. * Instantiates a new Gamepad Camera
  40241. * This represents a FPS type of camera. This is only here for back compat purpose.
  40242. * Please use the UniversalCamera instead as both are identical.
  40243. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40244. * @param name Define the name of the camera in the scene
  40245. * @param position Define the start position of the camera in the scene
  40246. * @param scene Define the scene the camera belongs to
  40247. */
  40248. constructor(name: string, position: Vector3, scene: Scene);
  40249. /**
  40250. * Gets the current object class name.
  40251. * @return the class name
  40252. */
  40253. getClassName(): string;
  40254. }
  40255. }
  40256. declare module "babylonjs/Shaders/pass.fragment" {
  40257. /** @hidden */
  40258. export var passPixelShader: {
  40259. name: string;
  40260. shader: string;
  40261. };
  40262. }
  40263. declare module "babylonjs/Shaders/passCube.fragment" {
  40264. /** @hidden */
  40265. export var passCubePixelShader: {
  40266. name: string;
  40267. shader: string;
  40268. };
  40269. }
  40270. declare module "babylonjs/PostProcesses/passPostProcess" {
  40271. import { Nullable } from "babylonjs/types";
  40272. import { Camera } from "babylonjs/Cameras/camera";
  40273. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40274. import { Engine } from "babylonjs/Engines/engine";
  40275. import "babylonjs/Shaders/pass.fragment";
  40276. import "babylonjs/Shaders/passCube.fragment";
  40277. /**
  40278. * PassPostProcess which produces an output the same as it's input
  40279. */
  40280. export class PassPostProcess extends PostProcess {
  40281. /**
  40282. * Creates the PassPostProcess
  40283. * @param name The name of the effect.
  40284. * @param options The required width/height ratio to downsize to before computing the render pass.
  40285. * @param camera The camera to apply the render pass to.
  40286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40287. * @param engine The engine which the post process will be applied. (default: current engine)
  40288. * @param reusable If the post process can be reused on the same frame. (default: false)
  40289. * @param textureType The type of texture to be used when performing the post processing.
  40290. * @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)
  40291. */
  40292. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40293. }
  40294. /**
  40295. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40296. */
  40297. export class PassCubePostProcess extends PostProcess {
  40298. private _face;
  40299. /**
  40300. * Gets or sets the cube face to display.
  40301. * * 0 is +X
  40302. * * 1 is -X
  40303. * * 2 is +Y
  40304. * * 3 is -Y
  40305. * * 4 is +Z
  40306. * * 5 is -Z
  40307. */
  40308. face: number;
  40309. /**
  40310. * Creates the PassCubePostProcess
  40311. * @param name The name of the effect.
  40312. * @param options The required width/height ratio to downsize to before computing the render pass.
  40313. * @param camera The camera to apply the render pass to.
  40314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40315. * @param engine The engine which the post process will be applied. (default: current engine)
  40316. * @param reusable If the post process can be reused on the same frame. (default: false)
  40317. * @param textureType The type of texture to be used when performing the post processing.
  40318. * @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)
  40319. */
  40320. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40321. }
  40322. }
  40323. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40324. /** @hidden */
  40325. export var anaglyphPixelShader: {
  40326. name: string;
  40327. shader: string;
  40328. };
  40329. }
  40330. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40331. import { Engine } from "babylonjs/Engines/engine";
  40332. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40333. import { Camera } from "babylonjs/Cameras/camera";
  40334. import "babylonjs/Shaders/anaglyph.fragment";
  40335. /**
  40336. * Postprocess used to generate anaglyphic rendering
  40337. */
  40338. export class AnaglyphPostProcess extends PostProcess {
  40339. private _passedProcess;
  40340. /**
  40341. * Creates a new AnaglyphPostProcess
  40342. * @param name defines postprocess name
  40343. * @param options defines creation options or target ratio scale
  40344. * @param rigCameras defines cameras using this postprocess
  40345. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40346. * @param engine defines hosting engine
  40347. * @param reusable defines if the postprocess will be reused multiple times per frame
  40348. */
  40349. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40350. }
  40351. }
  40352. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40353. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40354. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40355. import { Scene } from "babylonjs/scene";
  40356. import { Vector3 } from "babylonjs/Maths/math.vector";
  40357. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40358. /**
  40359. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40360. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40361. */
  40362. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40363. /**
  40364. * Creates a new AnaglyphArcRotateCamera
  40365. * @param name defines camera name
  40366. * @param alpha defines alpha angle (in radians)
  40367. * @param beta defines beta angle (in radians)
  40368. * @param radius defines radius
  40369. * @param target defines camera target
  40370. * @param interaxialDistance defines distance between each color axis
  40371. * @param scene defines the hosting scene
  40372. */
  40373. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40374. /**
  40375. * Gets camera class name
  40376. * @returns AnaglyphArcRotateCamera
  40377. */
  40378. getClassName(): string;
  40379. }
  40380. }
  40381. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40382. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40383. import { Scene } from "babylonjs/scene";
  40384. import { Vector3 } from "babylonjs/Maths/math.vector";
  40385. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40386. /**
  40387. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40388. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40389. */
  40390. export class AnaglyphFreeCamera extends FreeCamera {
  40391. /**
  40392. * Creates a new AnaglyphFreeCamera
  40393. * @param name defines camera name
  40394. * @param position defines initial position
  40395. * @param interaxialDistance defines distance between each color axis
  40396. * @param scene defines the hosting scene
  40397. */
  40398. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40399. /**
  40400. * Gets camera class name
  40401. * @returns AnaglyphFreeCamera
  40402. */
  40403. getClassName(): string;
  40404. }
  40405. }
  40406. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40407. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40408. import { Scene } from "babylonjs/scene";
  40409. import { Vector3 } from "babylonjs/Maths/math.vector";
  40410. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40411. /**
  40412. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40413. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40414. */
  40415. export class AnaglyphGamepadCamera extends GamepadCamera {
  40416. /**
  40417. * Creates a new AnaglyphGamepadCamera
  40418. * @param name defines camera name
  40419. * @param position defines initial position
  40420. * @param interaxialDistance defines distance between each color axis
  40421. * @param scene defines the hosting scene
  40422. */
  40423. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40424. /**
  40425. * Gets camera class name
  40426. * @returns AnaglyphGamepadCamera
  40427. */
  40428. getClassName(): string;
  40429. }
  40430. }
  40431. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40432. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40433. import { Scene } from "babylonjs/scene";
  40434. import { Vector3 } from "babylonjs/Maths/math.vector";
  40435. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40436. /**
  40437. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40438. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40439. */
  40440. export class AnaglyphUniversalCamera extends UniversalCamera {
  40441. /**
  40442. * Creates a new AnaglyphUniversalCamera
  40443. * @param name defines camera name
  40444. * @param position defines initial position
  40445. * @param interaxialDistance defines distance between each color axis
  40446. * @param scene defines the hosting scene
  40447. */
  40448. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40449. /**
  40450. * Gets camera class name
  40451. * @returns AnaglyphUniversalCamera
  40452. */
  40453. getClassName(): string;
  40454. }
  40455. }
  40456. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40457. /** @hidden */
  40458. export var stereoscopicInterlacePixelShader: {
  40459. name: string;
  40460. shader: string;
  40461. };
  40462. }
  40463. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40464. import { Camera } from "babylonjs/Cameras/camera";
  40465. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40466. import { Engine } from "babylonjs/Engines/engine";
  40467. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40468. /**
  40469. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40470. */
  40471. export class StereoscopicInterlacePostProcess extends PostProcess {
  40472. private _stepSize;
  40473. private _passedProcess;
  40474. /**
  40475. * Initializes a StereoscopicInterlacePostProcess
  40476. * @param name The name of the effect.
  40477. * @param rigCameras The rig cameras to be appled to the post process
  40478. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40480. * @param engine The engine which the post process will be applied. (default: current engine)
  40481. * @param reusable If the post process can be reused on the same frame. (default: false)
  40482. */
  40483. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40484. }
  40485. }
  40486. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40487. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40488. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40489. import { Scene } from "babylonjs/scene";
  40490. import { Vector3 } from "babylonjs/Maths/math.vector";
  40491. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40492. /**
  40493. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40494. * @see http://doc.babylonjs.com/features/cameras
  40495. */
  40496. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40497. /**
  40498. * Creates a new StereoscopicArcRotateCamera
  40499. * @param name defines camera name
  40500. * @param alpha defines alpha angle (in radians)
  40501. * @param beta defines beta angle (in radians)
  40502. * @param radius defines radius
  40503. * @param target defines camera target
  40504. * @param interaxialDistance defines distance between each color axis
  40505. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40506. * @param scene defines the hosting scene
  40507. */
  40508. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40509. /**
  40510. * Gets camera class name
  40511. * @returns StereoscopicArcRotateCamera
  40512. */
  40513. getClassName(): string;
  40514. }
  40515. }
  40516. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40517. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40518. import { Scene } from "babylonjs/scene";
  40519. import { Vector3 } from "babylonjs/Maths/math.vector";
  40520. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40521. /**
  40522. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40523. * @see http://doc.babylonjs.com/features/cameras
  40524. */
  40525. export class StereoscopicFreeCamera extends FreeCamera {
  40526. /**
  40527. * Creates a new StereoscopicFreeCamera
  40528. * @param name defines camera name
  40529. * @param position defines initial position
  40530. * @param interaxialDistance defines distance between each color axis
  40531. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40532. * @param scene defines the hosting scene
  40533. */
  40534. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40535. /**
  40536. * Gets camera class name
  40537. * @returns StereoscopicFreeCamera
  40538. */
  40539. getClassName(): string;
  40540. }
  40541. }
  40542. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40543. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40544. import { Scene } from "babylonjs/scene";
  40545. import { Vector3 } from "babylonjs/Maths/math.vector";
  40546. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40547. /**
  40548. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40549. * @see http://doc.babylonjs.com/features/cameras
  40550. */
  40551. export class StereoscopicGamepadCamera extends GamepadCamera {
  40552. /**
  40553. * Creates a new StereoscopicGamepadCamera
  40554. * @param name defines camera name
  40555. * @param position defines initial position
  40556. * @param interaxialDistance defines distance between each color axis
  40557. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40558. * @param scene defines the hosting scene
  40559. */
  40560. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40561. /**
  40562. * Gets camera class name
  40563. * @returns StereoscopicGamepadCamera
  40564. */
  40565. getClassName(): string;
  40566. }
  40567. }
  40568. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40569. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40570. import { Scene } from "babylonjs/scene";
  40571. import { Vector3 } from "babylonjs/Maths/math.vector";
  40572. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40573. /**
  40574. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40575. * @see http://doc.babylonjs.com/features/cameras
  40576. */
  40577. export class StereoscopicUniversalCamera extends UniversalCamera {
  40578. /**
  40579. * Creates a new StereoscopicUniversalCamera
  40580. * @param name defines camera name
  40581. * @param position defines initial position
  40582. * @param interaxialDistance defines distance between each color axis
  40583. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40584. * @param scene defines the hosting scene
  40585. */
  40586. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40587. /**
  40588. * Gets camera class name
  40589. * @returns StereoscopicUniversalCamera
  40590. */
  40591. getClassName(): string;
  40592. }
  40593. }
  40594. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40595. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40596. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40597. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40598. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40599. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40600. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40601. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40602. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40603. }
  40604. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40605. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40606. import { Scene } from "babylonjs/scene";
  40607. import { Vector3 } from "babylonjs/Maths/math.vector";
  40608. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40609. /**
  40610. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40611. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40612. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40613. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40614. */
  40615. export class VirtualJoysticksCamera extends FreeCamera {
  40616. /**
  40617. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40618. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40619. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40620. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40621. * @param name Define the name of the camera in the scene
  40622. * @param position Define the start position of the camera in the scene
  40623. * @param scene Define the scene the camera belongs to
  40624. */
  40625. constructor(name: string, position: Vector3, scene: Scene);
  40626. /**
  40627. * Gets the current object class name.
  40628. * @return the class name
  40629. */
  40630. getClassName(): string;
  40631. }
  40632. }
  40633. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40634. import { Matrix } from "babylonjs/Maths/math.vector";
  40635. /**
  40636. * This represents all the required metrics to create a VR camera.
  40637. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40638. */
  40639. export class VRCameraMetrics {
  40640. /**
  40641. * Define the horizontal resolution off the screen.
  40642. */
  40643. hResolution: number;
  40644. /**
  40645. * Define the vertical resolution off the screen.
  40646. */
  40647. vResolution: number;
  40648. /**
  40649. * Define the horizontal screen size.
  40650. */
  40651. hScreenSize: number;
  40652. /**
  40653. * Define the vertical screen size.
  40654. */
  40655. vScreenSize: number;
  40656. /**
  40657. * Define the vertical screen center position.
  40658. */
  40659. vScreenCenter: number;
  40660. /**
  40661. * Define the distance of the eyes to the screen.
  40662. */
  40663. eyeToScreenDistance: number;
  40664. /**
  40665. * Define the distance between both lenses
  40666. */
  40667. lensSeparationDistance: number;
  40668. /**
  40669. * Define the distance between both viewer's eyes.
  40670. */
  40671. interpupillaryDistance: number;
  40672. /**
  40673. * Define the distortion factor of the VR postprocess.
  40674. * Please, touch with care.
  40675. */
  40676. distortionK: number[];
  40677. /**
  40678. * Define the chromatic aberration correction factors for the VR post process.
  40679. */
  40680. chromaAbCorrection: number[];
  40681. /**
  40682. * Define the scale factor of the post process.
  40683. * The smaller the better but the slower.
  40684. */
  40685. postProcessScaleFactor: number;
  40686. /**
  40687. * Define an offset for the lens center.
  40688. */
  40689. lensCenterOffset: number;
  40690. /**
  40691. * Define if the current vr camera should compensate the distortion of the lense or not.
  40692. */
  40693. compensateDistortion: boolean;
  40694. /**
  40695. * Defines if multiview should be enabled when rendering (Default: false)
  40696. */
  40697. multiviewEnabled: boolean;
  40698. /**
  40699. * Gets the rendering aspect ratio based on the provided resolutions.
  40700. */
  40701. readonly aspectRatio: number;
  40702. /**
  40703. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40704. */
  40705. readonly aspectRatioFov: number;
  40706. /**
  40707. * @hidden
  40708. */
  40709. readonly leftHMatrix: Matrix;
  40710. /**
  40711. * @hidden
  40712. */
  40713. readonly rightHMatrix: Matrix;
  40714. /**
  40715. * @hidden
  40716. */
  40717. readonly leftPreViewMatrix: Matrix;
  40718. /**
  40719. * @hidden
  40720. */
  40721. readonly rightPreViewMatrix: Matrix;
  40722. /**
  40723. * Get the default VRMetrics based on the most generic setup.
  40724. * @returns the default vr metrics
  40725. */
  40726. static GetDefault(): VRCameraMetrics;
  40727. }
  40728. }
  40729. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40730. /** @hidden */
  40731. export var vrDistortionCorrectionPixelShader: {
  40732. name: string;
  40733. shader: string;
  40734. };
  40735. }
  40736. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40737. import { Camera } from "babylonjs/Cameras/camera";
  40738. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40739. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40740. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40741. /**
  40742. * VRDistortionCorrectionPostProcess used for mobile VR
  40743. */
  40744. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40745. private _isRightEye;
  40746. private _distortionFactors;
  40747. private _postProcessScaleFactor;
  40748. private _lensCenterOffset;
  40749. private _scaleIn;
  40750. private _scaleFactor;
  40751. private _lensCenter;
  40752. /**
  40753. * Initializes the VRDistortionCorrectionPostProcess
  40754. * @param name The name of the effect.
  40755. * @param camera The camera to apply the render pass to.
  40756. * @param isRightEye If this is for the right eye distortion
  40757. * @param vrMetrics All the required metrics for the VR camera
  40758. */
  40759. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40760. }
  40761. }
  40762. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40763. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40764. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40765. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40766. import { Scene } from "babylonjs/scene";
  40767. import { Vector3 } from "babylonjs/Maths/math.vector";
  40768. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40769. import "babylonjs/Cameras/RigModes/vrRigMode";
  40770. /**
  40771. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40772. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40773. */
  40774. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40775. /**
  40776. * Creates a new VRDeviceOrientationArcRotateCamera
  40777. * @param name defines camera name
  40778. * @param alpha defines the camera rotation along the logitudinal axis
  40779. * @param beta defines the camera rotation along the latitudinal axis
  40780. * @param radius defines the camera distance from its target
  40781. * @param target defines the camera target
  40782. * @param scene defines the scene the camera belongs to
  40783. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40784. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40785. */
  40786. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40787. /**
  40788. * Gets camera class name
  40789. * @returns VRDeviceOrientationArcRotateCamera
  40790. */
  40791. getClassName(): string;
  40792. }
  40793. }
  40794. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40795. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40796. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40797. import { Scene } from "babylonjs/scene";
  40798. import { Vector3 } from "babylonjs/Maths/math.vector";
  40799. import "babylonjs/Cameras/RigModes/vrRigMode";
  40800. /**
  40801. * Camera used to simulate VR rendering (based on FreeCamera)
  40802. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40803. */
  40804. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40805. /**
  40806. * Creates a new VRDeviceOrientationFreeCamera
  40807. * @param name defines camera name
  40808. * @param position defines the start position of the camera
  40809. * @param scene defines the scene the camera belongs to
  40810. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40811. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40812. */
  40813. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40814. /**
  40815. * Gets camera class name
  40816. * @returns VRDeviceOrientationFreeCamera
  40817. */
  40818. getClassName(): string;
  40819. }
  40820. }
  40821. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40822. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40823. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40824. import { Scene } from "babylonjs/scene";
  40825. import { Vector3 } from "babylonjs/Maths/math.vector";
  40826. import "babylonjs/Gamepads/gamepadSceneComponent";
  40827. /**
  40828. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40829. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40830. */
  40831. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40832. /**
  40833. * Creates a new VRDeviceOrientationGamepadCamera
  40834. * @param name defines camera name
  40835. * @param position defines the start position of the camera
  40836. * @param scene defines the scene the camera belongs to
  40837. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40838. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40839. */
  40840. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40841. /**
  40842. * Gets camera class name
  40843. * @returns VRDeviceOrientationGamepadCamera
  40844. */
  40845. getClassName(): string;
  40846. }
  40847. }
  40848. declare module "babylonjs/Materials/pushMaterial" {
  40849. import { Nullable } from "babylonjs/types";
  40850. import { Scene } from "babylonjs/scene";
  40851. import { Matrix } from "babylonjs/Maths/math.vector";
  40852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40853. import { Mesh } from "babylonjs/Meshes/mesh";
  40854. import { Material } from "babylonjs/Materials/material";
  40855. import { Effect } from "babylonjs/Materials/effect";
  40856. /**
  40857. * Base class of materials working in push mode in babylon JS
  40858. * @hidden
  40859. */
  40860. export class PushMaterial extends Material {
  40861. protected _activeEffect: Effect;
  40862. protected _normalMatrix: Matrix;
  40863. /**
  40864. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40865. * This means that the material can keep using a previous shader while a new one is being compiled.
  40866. * This is mostly used when shader parallel compilation is supported (true by default)
  40867. */
  40868. allowShaderHotSwapping: boolean;
  40869. constructor(name: string, scene: Scene);
  40870. getEffect(): Effect;
  40871. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40872. /**
  40873. * Binds the given world matrix to the active effect
  40874. *
  40875. * @param world the matrix to bind
  40876. */
  40877. bindOnlyWorldMatrix(world: Matrix): void;
  40878. /**
  40879. * Binds the given normal matrix to the active effect
  40880. *
  40881. * @param normalMatrix the matrix to bind
  40882. */
  40883. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40884. bind(world: Matrix, mesh?: Mesh): void;
  40885. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40886. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40887. }
  40888. }
  40889. declare module "babylonjs/Materials/materialFlags" {
  40890. /**
  40891. * This groups all the flags used to control the materials channel.
  40892. */
  40893. export class MaterialFlags {
  40894. private static _DiffuseTextureEnabled;
  40895. /**
  40896. * Are diffuse textures enabled in the application.
  40897. */
  40898. static DiffuseTextureEnabled: boolean;
  40899. private static _AmbientTextureEnabled;
  40900. /**
  40901. * Are ambient textures enabled in the application.
  40902. */
  40903. static AmbientTextureEnabled: boolean;
  40904. private static _OpacityTextureEnabled;
  40905. /**
  40906. * Are opacity textures enabled in the application.
  40907. */
  40908. static OpacityTextureEnabled: boolean;
  40909. private static _ReflectionTextureEnabled;
  40910. /**
  40911. * Are reflection textures enabled in the application.
  40912. */
  40913. static ReflectionTextureEnabled: boolean;
  40914. private static _EmissiveTextureEnabled;
  40915. /**
  40916. * Are emissive textures enabled in the application.
  40917. */
  40918. static EmissiveTextureEnabled: boolean;
  40919. private static _SpecularTextureEnabled;
  40920. /**
  40921. * Are specular textures enabled in the application.
  40922. */
  40923. static SpecularTextureEnabled: boolean;
  40924. private static _BumpTextureEnabled;
  40925. /**
  40926. * Are bump textures enabled in the application.
  40927. */
  40928. static BumpTextureEnabled: boolean;
  40929. private static _LightmapTextureEnabled;
  40930. /**
  40931. * Are lightmap textures enabled in the application.
  40932. */
  40933. static LightmapTextureEnabled: boolean;
  40934. private static _RefractionTextureEnabled;
  40935. /**
  40936. * Are refraction textures enabled in the application.
  40937. */
  40938. static RefractionTextureEnabled: boolean;
  40939. private static _ColorGradingTextureEnabled;
  40940. /**
  40941. * Are color grading textures enabled in the application.
  40942. */
  40943. static ColorGradingTextureEnabled: boolean;
  40944. private static _FresnelEnabled;
  40945. /**
  40946. * Are fresnels enabled in the application.
  40947. */
  40948. static FresnelEnabled: boolean;
  40949. private static _ClearCoatTextureEnabled;
  40950. /**
  40951. * Are clear coat textures enabled in the application.
  40952. */
  40953. static ClearCoatTextureEnabled: boolean;
  40954. private static _ClearCoatBumpTextureEnabled;
  40955. /**
  40956. * Are clear coat bump textures enabled in the application.
  40957. */
  40958. static ClearCoatBumpTextureEnabled: boolean;
  40959. private static _ClearCoatTintTextureEnabled;
  40960. /**
  40961. * Are clear coat tint textures enabled in the application.
  40962. */
  40963. static ClearCoatTintTextureEnabled: boolean;
  40964. private static _SheenTextureEnabled;
  40965. /**
  40966. * Are sheen textures enabled in the application.
  40967. */
  40968. static SheenTextureEnabled: boolean;
  40969. private static _AnisotropicTextureEnabled;
  40970. /**
  40971. * Are anisotropic textures enabled in the application.
  40972. */
  40973. static AnisotropicTextureEnabled: boolean;
  40974. private static _ThicknessTextureEnabled;
  40975. /**
  40976. * Are thickness textures enabled in the application.
  40977. */
  40978. static ThicknessTextureEnabled: boolean;
  40979. }
  40980. }
  40981. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40982. /** @hidden */
  40983. export var defaultFragmentDeclaration: {
  40984. name: string;
  40985. shader: string;
  40986. };
  40987. }
  40988. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40989. /** @hidden */
  40990. export var defaultUboDeclaration: {
  40991. name: string;
  40992. shader: string;
  40993. };
  40994. }
  40995. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40996. /** @hidden */
  40997. export var lightFragmentDeclaration: {
  40998. name: string;
  40999. shader: string;
  41000. };
  41001. }
  41002. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41003. /** @hidden */
  41004. export var lightUboDeclaration: {
  41005. name: string;
  41006. shader: string;
  41007. };
  41008. }
  41009. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41010. /** @hidden */
  41011. export var lightsFragmentFunctions: {
  41012. name: string;
  41013. shader: string;
  41014. };
  41015. }
  41016. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41017. /** @hidden */
  41018. export var shadowsFragmentFunctions: {
  41019. name: string;
  41020. shader: string;
  41021. };
  41022. }
  41023. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41024. /** @hidden */
  41025. export var fresnelFunction: {
  41026. name: string;
  41027. shader: string;
  41028. };
  41029. }
  41030. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41031. /** @hidden */
  41032. export var reflectionFunction: {
  41033. name: string;
  41034. shader: string;
  41035. };
  41036. }
  41037. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41038. /** @hidden */
  41039. export var bumpFragmentFunctions: {
  41040. name: string;
  41041. shader: string;
  41042. };
  41043. }
  41044. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41045. /** @hidden */
  41046. export var logDepthDeclaration: {
  41047. name: string;
  41048. shader: string;
  41049. };
  41050. }
  41051. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41052. /** @hidden */
  41053. export var bumpFragment: {
  41054. name: string;
  41055. shader: string;
  41056. };
  41057. }
  41058. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41059. /** @hidden */
  41060. export var depthPrePass: {
  41061. name: string;
  41062. shader: string;
  41063. };
  41064. }
  41065. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41066. /** @hidden */
  41067. export var lightFragment: {
  41068. name: string;
  41069. shader: string;
  41070. };
  41071. }
  41072. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41073. /** @hidden */
  41074. export var logDepthFragment: {
  41075. name: string;
  41076. shader: string;
  41077. };
  41078. }
  41079. declare module "babylonjs/Shaders/default.fragment" {
  41080. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41081. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41082. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41083. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41084. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41085. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41086. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41087. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41088. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41089. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41090. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41091. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41092. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41093. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41094. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41095. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41096. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41097. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41098. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41099. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41100. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41101. /** @hidden */
  41102. export var defaultPixelShader: {
  41103. name: string;
  41104. shader: string;
  41105. };
  41106. }
  41107. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41108. /** @hidden */
  41109. export var defaultVertexDeclaration: {
  41110. name: string;
  41111. shader: string;
  41112. };
  41113. }
  41114. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41115. /** @hidden */
  41116. export var bumpVertexDeclaration: {
  41117. name: string;
  41118. shader: string;
  41119. };
  41120. }
  41121. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41122. /** @hidden */
  41123. export var bumpVertex: {
  41124. name: string;
  41125. shader: string;
  41126. };
  41127. }
  41128. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41129. /** @hidden */
  41130. export var fogVertex: {
  41131. name: string;
  41132. shader: string;
  41133. };
  41134. }
  41135. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41136. /** @hidden */
  41137. export var shadowsVertex: {
  41138. name: string;
  41139. shader: string;
  41140. };
  41141. }
  41142. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41143. /** @hidden */
  41144. export var pointCloudVertex: {
  41145. name: string;
  41146. shader: string;
  41147. };
  41148. }
  41149. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41150. /** @hidden */
  41151. export var logDepthVertex: {
  41152. name: string;
  41153. shader: string;
  41154. };
  41155. }
  41156. declare module "babylonjs/Shaders/default.vertex" {
  41157. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41158. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41159. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41160. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41161. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41162. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41163. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41164. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41165. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41166. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41167. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41168. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41169. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41170. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41171. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41172. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41173. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41174. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41175. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41176. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41177. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41178. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41179. /** @hidden */
  41180. export var defaultVertexShader: {
  41181. name: string;
  41182. shader: string;
  41183. };
  41184. }
  41185. declare module "babylonjs/Materials/standardMaterial" {
  41186. import { SmartArray } from "babylonjs/Misc/smartArray";
  41187. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41188. import { Nullable } from "babylonjs/types";
  41189. import { Scene } from "babylonjs/scene";
  41190. import { Matrix } from "babylonjs/Maths/math.vector";
  41191. import { Color3 } from "babylonjs/Maths/math.color";
  41192. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41194. import { Mesh } from "babylonjs/Meshes/mesh";
  41195. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41196. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41197. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41198. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41199. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41201. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41202. import "babylonjs/Shaders/default.fragment";
  41203. import "babylonjs/Shaders/default.vertex";
  41204. /** @hidden */
  41205. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41206. MAINUV1: boolean;
  41207. MAINUV2: boolean;
  41208. DIFFUSE: boolean;
  41209. DIFFUSEDIRECTUV: number;
  41210. AMBIENT: boolean;
  41211. AMBIENTDIRECTUV: number;
  41212. OPACITY: boolean;
  41213. OPACITYDIRECTUV: number;
  41214. OPACITYRGB: boolean;
  41215. REFLECTION: boolean;
  41216. EMISSIVE: boolean;
  41217. EMISSIVEDIRECTUV: number;
  41218. SPECULAR: boolean;
  41219. SPECULARDIRECTUV: number;
  41220. BUMP: boolean;
  41221. BUMPDIRECTUV: number;
  41222. PARALLAX: boolean;
  41223. PARALLAXOCCLUSION: boolean;
  41224. SPECULAROVERALPHA: boolean;
  41225. CLIPPLANE: boolean;
  41226. CLIPPLANE2: boolean;
  41227. CLIPPLANE3: boolean;
  41228. CLIPPLANE4: boolean;
  41229. ALPHATEST: boolean;
  41230. DEPTHPREPASS: boolean;
  41231. ALPHAFROMDIFFUSE: boolean;
  41232. POINTSIZE: boolean;
  41233. FOG: boolean;
  41234. SPECULARTERM: boolean;
  41235. DIFFUSEFRESNEL: boolean;
  41236. OPACITYFRESNEL: boolean;
  41237. REFLECTIONFRESNEL: boolean;
  41238. REFRACTIONFRESNEL: boolean;
  41239. EMISSIVEFRESNEL: boolean;
  41240. FRESNEL: boolean;
  41241. NORMAL: boolean;
  41242. UV1: boolean;
  41243. UV2: boolean;
  41244. VERTEXCOLOR: boolean;
  41245. VERTEXALPHA: boolean;
  41246. NUM_BONE_INFLUENCERS: number;
  41247. BonesPerMesh: number;
  41248. BONETEXTURE: boolean;
  41249. INSTANCES: boolean;
  41250. GLOSSINESS: boolean;
  41251. ROUGHNESS: boolean;
  41252. EMISSIVEASILLUMINATION: boolean;
  41253. LINKEMISSIVEWITHDIFFUSE: boolean;
  41254. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41255. LIGHTMAP: boolean;
  41256. LIGHTMAPDIRECTUV: number;
  41257. OBJECTSPACE_NORMALMAP: boolean;
  41258. USELIGHTMAPASSHADOWMAP: boolean;
  41259. REFLECTIONMAP_3D: boolean;
  41260. REFLECTIONMAP_SPHERICAL: boolean;
  41261. REFLECTIONMAP_PLANAR: boolean;
  41262. REFLECTIONMAP_CUBIC: boolean;
  41263. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41264. REFLECTIONMAP_PROJECTION: boolean;
  41265. REFLECTIONMAP_SKYBOX: boolean;
  41266. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41267. REFLECTIONMAP_EXPLICIT: boolean;
  41268. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41269. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41270. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41271. INVERTCUBICMAP: boolean;
  41272. LOGARITHMICDEPTH: boolean;
  41273. REFRACTION: boolean;
  41274. REFRACTIONMAP_3D: boolean;
  41275. REFLECTIONOVERALPHA: boolean;
  41276. TWOSIDEDLIGHTING: boolean;
  41277. SHADOWFLOAT: boolean;
  41278. MORPHTARGETS: boolean;
  41279. MORPHTARGETS_NORMAL: boolean;
  41280. MORPHTARGETS_TANGENT: boolean;
  41281. MORPHTARGETS_UV: boolean;
  41282. NUM_MORPH_INFLUENCERS: number;
  41283. NONUNIFORMSCALING: boolean;
  41284. PREMULTIPLYALPHA: boolean;
  41285. IMAGEPROCESSING: boolean;
  41286. VIGNETTE: boolean;
  41287. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41288. VIGNETTEBLENDMODEOPAQUE: boolean;
  41289. TONEMAPPING: boolean;
  41290. TONEMAPPING_ACES: boolean;
  41291. CONTRAST: boolean;
  41292. COLORCURVES: boolean;
  41293. COLORGRADING: boolean;
  41294. COLORGRADING3D: boolean;
  41295. SAMPLER3DGREENDEPTH: boolean;
  41296. SAMPLER3DBGRMAP: boolean;
  41297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41298. MULTIVIEW: boolean;
  41299. /**
  41300. * If the reflection texture on this material is in linear color space
  41301. * @hidden
  41302. */
  41303. IS_REFLECTION_LINEAR: boolean;
  41304. /**
  41305. * If the refraction texture on this material is in linear color space
  41306. * @hidden
  41307. */
  41308. IS_REFRACTION_LINEAR: boolean;
  41309. EXPOSURE: boolean;
  41310. constructor();
  41311. setReflectionMode(modeToEnable: string): void;
  41312. }
  41313. /**
  41314. * This is the default material used in Babylon. It is the best trade off between quality
  41315. * and performances.
  41316. * @see http://doc.babylonjs.com/babylon101/materials
  41317. */
  41318. export class StandardMaterial extends PushMaterial {
  41319. private _diffuseTexture;
  41320. /**
  41321. * The basic texture of the material as viewed under a light.
  41322. */
  41323. diffuseTexture: Nullable<BaseTexture>;
  41324. private _ambientTexture;
  41325. /**
  41326. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41327. */
  41328. ambientTexture: Nullable<BaseTexture>;
  41329. private _opacityTexture;
  41330. /**
  41331. * Define the transparency of the material from a texture.
  41332. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41333. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41334. */
  41335. opacityTexture: Nullable<BaseTexture>;
  41336. private _reflectionTexture;
  41337. /**
  41338. * Define the texture used to display the reflection.
  41339. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41340. */
  41341. reflectionTexture: Nullable<BaseTexture>;
  41342. private _emissiveTexture;
  41343. /**
  41344. * Define texture of the material as if self lit.
  41345. * This will be mixed in the final result even in the absence of light.
  41346. */
  41347. emissiveTexture: Nullable<BaseTexture>;
  41348. private _specularTexture;
  41349. /**
  41350. * Define how the color and intensity of the highlight given by the light in the material.
  41351. */
  41352. specularTexture: Nullable<BaseTexture>;
  41353. private _bumpTexture;
  41354. /**
  41355. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41356. * 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.
  41357. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41358. */
  41359. bumpTexture: Nullable<BaseTexture>;
  41360. private _lightmapTexture;
  41361. /**
  41362. * Complex lighting can be computationally expensive to compute at runtime.
  41363. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41364. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41365. */
  41366. lightmapTexture: Nullable<BaseTexture>;
  41367. private _refractionTexture;
  41368. /**
  41369. * Define the texture used to display the refraction.
  41370. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41371. */
  41372. refractionTexture: Nullable<BaseTexture>;
  41373. /**
  41374. * The color of the material lit by the environmental background lighting.
  41375. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41376. */
  41377. ambientColor: Color3;
  41378. /**
  41379. * The basic color of the material as viewed under a light.
  41380. */
  41381. diffuseColor: Color3;
  41382. /**
  41383. * Define how the color and intensity of the highlight given by the light in the material.
  41384. */
  41385. specularColor: Color3;
  41386. /**
  41387. * Define the color of the material as if self lit.
  41388. * This will be mixed in the final result even in the absence of light.
  41389. */
  41390. emissiveColor: Color3;
  41391. /**
  41392. * Defines how sharp are the highlights in the material.
  41393. * The bigger the value the sharper giving a more glossy feeling to the result.
  41394. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41395. */
  41396. specularPower: number;
  41397. private _useAlphaFromDiffuseTexture;
  41398. /**
  41399. * Does the transparency come from the diffuse texture alpha channel.
  41400. */
  41401. useAlphaFromDiffuseTexture: boolean;
  41402. private _useEmissiveAsIllumination;
  41403. /**
  41404. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41405. */
  41406. useEmissiveAsIllumination: boolean;
  41407. private _linkEmissiveWithDiffuse;
  41408. /**
  41409. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41410. * the emissive level when the final color is close to one.
  41411. */
  41412. linkEmissiveWithDiffuse: boolean;
  41413. private _useSpecularOverAlpha;
  41414. /**
  41415. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41416. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41417. */
  41418. useSpecularOverAlpha: boolean;
  41419. private _useReflectionOverAlpha;
  41420. /**
  41421. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41422. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41423. */
  41424. useReflectionOverAlpha: boolean;
  41425. private _disableLighting;
  41426. /**
  41427. * Does lights from the scene impacts this material.
  41428. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41429. */
  41430. disableLighting: boolean;
  41431. private _useObjectSpaceNormalMap;
  41432. /**
  41433. * Allows using an object space normal map (instead of tangent space).
  41434. */
  41435. useObjectSpaceNormalMap: boolean;
  41436. private _useParallax;
  41437. /**
  41438. * Is parallax enabled or not.
  41439. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41440. */
  41441. useParallax: boolean;
  41442. private _useParallaxOcclusion;
  41443. /**
  41444. * Is parallax occlusion enabled or not.
  41445. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41446. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41447. */
  41448. useParallaxOcclusion: boolean;
  41449. /**
  41450. * 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.
  41451. */
  41452. parallaxScaleBias: number;
  41453. private _roughness;
  41454. /**
  41455. * Helps to define how blurry the reflections should appears in the material.
  41456. */
  41457. roughness: number;
  41458. /**
  41459. * In case of refraction, define the value of the index of refraction.
  41460. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41461. */
  41462. indexOfRefraction: number;
  41463. /**
  41464. * Invert the refraction texture alongside the y axis.
  41465. * It can be useful with procedural textures or probe for instance.
  41466. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41467. */
  41468. invertRefractionY: boolean;
  41469. /**
  41470. * Defines the alpha limits in alpha test mode.
  41471. */
  41472. alphaCutOff: number;
  41473. private _useLightmapAsShadowmap;
  41474. /**
  41475. * In case of light mapping, define whether the map contains light or shadow informations.
  41476. */
  41477. useLightmapAsShadowmap: boolean;
  41478. private _diffuseFresnelParameters;
  41479. /**
  41480. * Define the diffuse fresnel parameters of the material.
  41481. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41482. */
  41483. diffuseFresnelParameters: FresnelParameters;
  41484. private _opacityFresnelParameters;
  41485. /**
  41486. * Define the opacity fresnel parameters of the material.
  41487. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41488. */
  41489. opacityFresnelParameters: FresnelParameters;
  41490. private _reflectionFresnelParameters;
  41491. /**
  41492. * Define the reflection fresnel parameters of the material.
  41493. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41494. */
  41495. reflectionFresnelParameters: FresnelParameters;
  41496. private _refractionFresnelParameters;
  41497. /**
  41498. * Define the refraction fresnel parameters of the material.
  41499. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41500. */
  41501. refractionFresnelParameters: FresnelParameters;
  41502. private _emissiveFresnelParameters;
  41503. /**
  41504. * Define the emissive fresnel parameters of the material.
  41505. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41506. */
  41507. emissiveFresnelParameters: FresnelParameters;
  41508. private _useReflectionFresnelFromSpecular;
  41509. /**
  41510. * If true automatically deducts the fresnels values from the material specularity.
  41511. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41512. */
  41513. useReflectionFresnelFromSpecular: boolean;
  41514. private _useGlossinessFromSpecularMapAlpha;
  41515. /**
  41516. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41517. */
  41518. useGlossinessFromSpecularMapAlpha: boolean;
  41519. private _maxSimultaneousLights;
  41520. /**
  41521. * Defines the maximum number of lights that can be used in the material
  41522. */
  41523. maxSimultaneousLights: number;
  41524. private _invertNormalMapX;
  41525. /**
  41526. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41527. */
  41528. invertNormalMapX: boolean;
  41529. private _invertNormalMapY;
  41530. /**
  41531. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41532. */
  41533. invertNormalMapY: boolean;
  41534. private _twoSidedLighting;
  41535. /**
  41536. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41537. */
  41538. twoSidedLighting: boolean;
  41539. /**
  41540. * Default configuration related to image processing available in the standard Material.
  41541. */
  41542. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41543. /**
  41544. * Gets the image processing configuration used either in this material.
  41545. */
  41546. /**
  41547. * Sets the Default image processing configuration used either in the this material.
  41548. *
  41549. * If sets to null, the scene one is in use.
  41550. */
  41551. imageProcessingConfiguration: ImageProcessingConfiguration;
  41552. /**
  41553. * Keep track of the image processing observer to allow dispose and replace.
  41554. */
  41555. private _imageProcessingObserver;
  41556. /**
  41557. * Attaches a new image processing configuration to the Standard Material.
  41558. * @param configuration
  41559. */
  41560. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41561. /**
  41562. * Gets wether the color curves effect is enabled.
  41563. */
  41564. /**
  41565. * Sets wether the color curves effect is enabled.
  41566. */
  41567. cameraColorCurvesEnabled: boolean;
  41568. /**
  41569. * Gets wether the color grading effect is enabled.
  41570. */
  41571. /**
  41572. * Gets wether the color grading effect is enabled.
  41573. */
  41574. cameraColorGradingEnabled: boolean;
  41575. /**
  41576. * Gets wether tonemapping is enabled or not.
  41577. */
  41578. /**
  41579. * Sets wether tonemapping is enabled or not
  41580. */
  41581. cameraToneMappingEnabled: boolean;
  41582. /**
  41583. * The camera exposure used on this material.
  41584. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41585. * This corresponds to a photographic exposure.
  41586. */
  41587. /**
  41588. * The camera exposure used on this material.
  41589. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41590. * This corresponds to a photographic exposure.
  41591. */
  41592. cameraExposure: number;
  41593. /**
  41594. * Gets The camera contrast used on this material.
  41595. */
  41596. /**
  41597. * Sets The camera contrast used on this material.
  41598. */
  41599. cameraContrast: number;
  41600. /**
  41601. * Gets the Color Grading 2D Lookup Texture.
  41602. */
  41603. /**
  41604. * Sets the Color Grading 2D Lookup Texture.
  41605. */
  41606. cameraColorGradingTexture: Nullable<BaseTexture>;
  41607. /**
  41608. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41609. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41610. * 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;
  41611. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41612. */
  41613. /**
  41614. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41615. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41616. * 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;
  41617. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41618. */
  41619. cameraColorCurves: Nullable<ColorCurves>;
  41620. /**
  41621. * Custom callback helping to override the default shader used in the material.
  41622. */
  41623. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41624. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41625. protected _worldViewProjectionMatrix: Matrix;
  41626. protected _globalAmbientColor: Color3;
  41627. protected _useLogarithmicDepth: boolean;
  41628. protected _rebuildInParallel: boolean;
  41629. /**
  41630. * Instantiates a new standard material.
  41631. * This is the default material used in Babylon. It is the best trade off between quality
  41632. * and performances.
  41633. * @see http://doc.babylonjs.com/babylon101/materials
  41634. * @param name Define the name of the material in the scene
  41635. * @param scene Define the scene the material belong to
  41636. */
  41637. constructor(name: string, scene: Scene);
  41638. /**
  41639. * Gets a boolean indicating that current material needs to register RTT
  41640. */
  41641. readonly hasRenderTargetTextures: boolean;
  41642. /**
  41643. * Gets the current class name of the material e.g. "StandardMaterial"
  41644. * Mainly use in serialization.
  41645. * @returns the class name
  41646. */
  41647. getClassName(): string;
  41648. /**
  41649. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41650. * You can try switching to logarithmic depth.
  41651. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41652. */
  41653. useLogarithmicDepth: boolean;
  41654. /**
  41655. * Specifies if the material will require alpha blending
  41656. * @returns a boolean specifying if alpha blending is needed
  41657. */
  41658. needAlphaBlending(): boolean;
  41659. /**
  41660. * Specifies if this material should be rendered in alpha test mode
  41661. * @returns a boolean specifying if an alpha test is needed.
  41662. */
  41663. needAlphaTesting(): boolean;
  41664. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41665. /**
  41666. * Get the texture used for alpha test purpose.
  41667. * @returns the diffuse texture in case of the standard material.
  41668. */
  41669. getAlphaTestTexture(): Nullable<BaseTexture>;
  41670. /**
  41671. * Get if the submesh is ready to be used and all its information available.
  41672. * Child classes can use it to update shaders
  41673. * @param mesh defines the mesh to check
  41674. * @param subMesh defines which submesh to check
  41675. * @param useInstances specifies that instances should be used
  41676. * @returns a boolean indicating that the submesh is ready or not
  41677. */
  41678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41679. /**
  41680. * Builds the material UBO layouts.
  41681. * Used internally during the effect preparation.
  41682. */
  41683. buildUniformLayout(): void;
  41684. /**
  41685. * Unbinds the material from the mesh
  41686. */
  41687. unbind(): void;
  41688. /**
  41689. * Binds the submesh to this material by preparing the effect and shader to draw
  41690. * @param world defines the world transformation matrix
  41691. * @param mesh defines the mesh containing the submesh
  41692. * @param subMesh defines the submesh to bind the material to
  41693. */
  41694. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41695. /**
  41696. * Get the list of animatables in the material.
  41697. * @returns the list of animatables object used in the material
  41698. */
  41699. getAnimatables(): IAnimatable[];
  41700. /**
  41701. * Gets the active textures from the material
  41702. * @returns an array of textures
  41703. */
  41704. getActiveTextures(): BaseTexture[];
  41705. /**
  41706. * Specifies if the material uses a texture
  41707. * @param texture defines the texture to check against the material
  41708. * @returns a boolean specifying if the material uses the texture
  41709. */
  41710. hasTexture(texture: BaseTexture): boolean;
  41711. /**
  41712. * Disposes the material
  41713. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41714. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41715. */
  41716. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41717. /**
  41718. * Makes a duplicate of the material, and gives it a new name
  41719. * @param name defines the new name for the duplicated material
  41720. * @returns the cloned material
  41721. */
  41722. clone(name: string): StandardMaterial;
  41723. /**
  41724. * Serializes this material in a JSON representation
  41725. * @returns the serialized material object
  41726. */
  41727. serialize(): any;
  41728. /**
  41729. * Creates a standard material from parsed material data
  41730. * @param source defines the JSON representation of the material
  41731. * @param scene defines the hosting scene
  41732. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41733. * @returns a new standard material
  41734. */
  41735. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41736. /**
  41737. * Are diffuse textures enabled in the application.
  41738. */
  41739. static DiffuseTextureEnabled: boolean;
  41740. /**
  41741. * Are ambient textures enabled in the application.
  41742. */
  41743. static AmbientTextureEnabled: boolean;
  41744. /**
  41745. * Are opacity textures enabled in the application.
  41746. */
  41747. static OpacityTextureEnabled: boolean;
  41748. /**
  41749. * Are reflection textures enabled in the application.
  41750. */
  41751. static ReflectionTextureEnabled: boolean;
  41752. /**
  41753. * Are emissive textures enabled in the application.
  41754. */
  41755. static EmissiveTextureEnabled: boolean;
  41756. /**
  41757. * Are specular textures enabled in the application.
  41758. */
  41759. static SpecularTextureEnabled: boolean;
  41760. /**
  41761. * Are bump textures enabled in the application.
  41762. */
  41763. static BumpTextureEnabled: boolean;
  41764. /**
  41765. * Are lightmap textures enabled in the application.
  41766. */
  41767. static LightmapTextureEnabled: boolean;
  41768. /**
  41769. * Are refraction textures enabled in the application.
  41770. */
  41771. static RefractionTextureEnabled: boolean;
  41772. /**
  41773. * Are color grading textures enabled in the application.
  41774. */
  41775. static ColorGradingTextureEnabled: boolean;
  41776. /**
  41777. * Are fresnels enabled in the application.
  41778. */
  41779. static FresnelEnabled: boolean;
  41780. }
  41781. }
  41782. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41783. import { Scene } from "babylonjs/scene";
  41784. import { Texture } from "babylonjs/Materials/Textures/texture";
  41785. /**
  41786. * A class extending Texture allowing drawing on a texture
  41787. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41788. */
  41789. export class DynamicTexture extends Texture {
  41790. private _generateMipMaps;
  41791. private _canvas;
  41792. private _context;
  41793. private _engine;
  41794. /**
  41795. * Creates a DynamicTexture
  41796. * @param name defines the name of the texture
  41797. * @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
  41798. * @param scene defines the scene where you want the texture
  41799. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41800. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41801. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41802. */
  41803. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41804. /**
  41805. * Get the current class name of the texture useful for serialization or dynamic coding.
  41806. * @returns "DynamicTexture"
  41807. */
  41808. getClassName(): string;
  41809. /**
  41810. * Gets the current state of canRescale
  41811. */
  41812. readonly canRescale: boolean;
  41813. private _recreate;
  41814. /**
  41815. * Scales the texture
  41816. * @param ratio the scale factor to apply to both width and height
  41817. */
  41818. scale(ratio: number): void;
  41819. /**
  41820. * Resizes the texture
  41821. * @param width the new width
  41822. * @param height the new height
  41823. */
  41824. scaleTo(width: number, height: number): void;
  41825. /**
  41826. * Gets the context of the canvas used by the texture
  41827. * @returns the canvas context of the dynamic texture
  41828. */
  41829. getContext(): CanvasRenderingContext2D;
  41830. /**
  41831. * Clears the texture
  41832. */
  41833. clear(): void;
  41834. /**
  41835. * Updates the texture
  41836. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41837. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41838. */
  41839. update(invertY?: boolean, premulAlpha?: boolean): void;
  41840. /**
  41841. * Draws text onto the texture
  41842. * @param text defines the text to be drawn
  41843. * @param x defines the placement of the text from the left
  41844. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41845. * @param font defines the font to be used with font-style, font-size, font-name
  41846. * @param color defines the color used for the text
  41847. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41848. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41849. * @param update defines whether texture is immediately update (default is true)
  41850. */
  41851. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41852. /**
  41853. * Clones the texture
  41854. * @returns the clone of the texture.
  41855. */
  41856. clone(): DynamicTexture;
  41857. /**
  41858. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41859. * @returns a serialized dynamic texture object
  41860. */
  41861. serialize(): any;
  41862. /** @hidden */
  41863. _rebuild(): void;
  41864. }
  41865. }
  41866. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41867. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41868. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41869. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41870. /** @hidden */
  41871. export var imageProcessingPixelShader: {
  41872. name: string;
  41873. shader: string;
  41874. };
  41875. }
  41876. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41877. import { Nullable } from "babylonjs/types";
  41878. import { Color4 } from "babylonjs/Maths/math.color";
  41879. import { Camera } from "babylonjs/Cameras/camera";
  41880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41881. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41882. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41883. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41884. import { Engine } from "babylonjs/Engines/engine";
  41885. import "babylonjs/Shaders/imageProcessing.fragment";
  41886. import "babylonjs/Shaders/postprocess.vertex";
  41887. /**
  41888. * ImageProcessingPostProcess
  41889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41890. */
  41891. export class ImageProcessingPostProcess extends PostProcess {
  41892. /**
  41893. * Default configuration related to image processing available in the PBR Material.
  41894. */
  41895. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41896. /**
  41897. * Gets the image processing configuration used either in this material.
  41898. */
  41899. /**
  41900. * Sets the Default image processing configuration used either in the this material.
  41901. *
  41902. * If sets to null, the scene one is in use.
  41903. */
  41904. imageProcessingConfiguration: ImageProcessingConfiguration;
  41905. /**
  41906. * Keep track of the image processing observer to allow dispose and replace.
  41907. */
  41908. private _imageProcessingObserver;
  41909. /**
  41910. * Attaches a new image processing configuration to the PBR Material.
  41911. * @param configuration
  41912. */
  41913. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41914. /**
  41915. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41916. */
  41917. /**
  41918. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41919. */
  41920. colorCurves: Nullable<ColorCurves>;
  41921. /**
  41922. * Gets wether the color curves effect is enabled.
  41923. */
  41924. /**
  41925. * Sets wether the color curves effect is enabled.
  41926. */
  41927. colorCurvesEnabled: boolean;
  41928. /**
  41929. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41930. */
  41931. /**
  41932. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41933. */
  41934. colorGradingTexture: Nullable<BaseTexture>;
  41935. /**
  41936. * Gets wether the color grading effect is enabled.
  41937. */
  41938. /**
  41939. * Gets wether the color grading effect is enabled.
  41940. */
  41941. colorGradingEnabled: boolean;
  41942. /**
  41943. * Gets exposure used in the effect.
  41944. */
  41945. /**
  41946. * Sets exposure used in the effect.
  41947. */
  41948. exposure: number;
  41949. /**
  41950. * Gets wether tonemapping is enabled or not.
  41951. */
  41952. /**
  41953. * Sets wether tonemapping is enabled or not
  41954. */
  41955. toneMappingEnabled: boolean;
  41956. /**
  41957. * Gets the type of tone mapping effect.
  41958. */
  41959. /**
  41960. * Sets the type of tone mapping effect.
  41961. */
  41962. toneMappingType: number;
  41963. /**
  41964. * Gets contrast used in the effect.
  41965. */
  41966. /**
  41967. * Sets contrast used in the effect.
  41968. */
  41969. contrast: number;
  41970. /**
  41971. * Gets Vignette stretch size.
  41972. */
  41973. /**
  41974. * Sets Vignette stretch size.
  41975. */
  41976. vignetteStretch: number;
  41977. /**
  41978. * Gets Vignette centre X Offset.
  41979. */
  41980. /**
  41981. * Sets Vignette centre X Offset.
  41982. */
  41983. vignetteCentreX: number;
  41984. /**
  41985. * Gets Vignette centre Y Offset.
  41986. */
  41987. /**
  41988. * Sets Vignette centre Y Offset.
  41989. */
  41990. vignetteCentreY: number;
  41991. /**
  41992. * Gets Vignette weight or intensity of the vignette effect.
  41993. */
  41994. /**
  41995. * Sets Vignette weight or intensity of the vignette effect.
  41996. */
  41997. vignetteWeight: number;
  41998. /**
  41999. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42000. * if vignetteEnabled is set to true.
  42001. */
  42002. /**
  42003. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42004. * if vignetteEnabled is set to true.
  42005. */
  42006. vignetteColor: Color4;
  42007. /**
  42008. * Gets Camera field of view used by the Vignette effect.
  42009. */
  42010. /**
  42011. * Sets Camera field of view used by the Vignette effect.
  42012. */
  42013. vignetteCameraFov: number;
  42014. /**
  42015. * Gets the vignette blend mode allowing different kind of effect.
  42016. */
  42017. /**
  42018. * Sets the vignette blend mode allowing different kind of effect.
  42019. */
  42020. vignetteBlendMode: number;
  42021. /**
  42022. * Gets wether the vignette effect is enabled.
  42023. */
  42024. /**
  42025. * Sets wether the vignette effect is enabled.
  42026. */
  42027. vignetteEnabled: boolean;
  42028. private _fromLinearSpace;
  42029. /**
  42030. * Gets wether the input of the processing is in Gamma or Linear Space.
  42031. */
  42032. /**
  42033. * Sets wether the input of the processing is in Gamma or Linear Space.
  42034. */
  42035. fromLinearSpace: boolean;
  42036. /**
  42037. * Defines cache preventing GC.
  42038. */
  42039. private _defines;
  42040. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42041. /**
  42042. * "ImageProcessingPostProcess"
  42043. * @returns "ImageProcessingPostProcess"
  42044. */
  42045. getClassName(): string;
  42046. protected _updateParameters(): void;
  42047. dispose(camera?: Camera): void;
  42048. }
  42049. }
  42050. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42051. import { Scene } from "babylonjs/scene";
  42052. import { Color3 } from "babylonjs/Maths/math.color";
  42053. import { Mesh } from "babylonjs/Meshes/mesh";
  42054. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42055. import { Nullable } from "babylonjs/types";
  42056. /**
  42057. * Class containing static functions to help procedurally build meshes
  42058. */
  42059. export class GroundBuilder {
  42060. /**
  42061. * Creates a ground mesh
  42062. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42063. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42065. * @param name defines the name of the mesh
  42066. * @param options defines the options used to create the mesh
  42067. * @param scene defines the hosting scene
  42068. * @returns the ground mesh
  42069. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42070. */
  42071. static CreateGround(name: string, options: {
  42072. width?: number;
  42073. height?: number;
  42074. subdivisions?: number;
  42075. subdivisionsX?: number;
  42076. subdivisionsY?: number;
  42077. updatable?: boolean;
  42078. }, scene: any): Mesh;
  42079. /**
  42080. * Creates a tiled ground mesh
  42081. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42082. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42083. * * 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
  42084. * * 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
  42085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42086. * @param name defines the name of the mesh
  42087. * @param options defines the options used to create the mesh
  42088. * @param scene defines the hosting scene
  42089. * @returns the tiled ground mesh
  42090. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42091. */
  42092. static CreateTiledGround(name: string, options: {
  42093. xmin: number;
  42094. zmin: number;
  42095. xmax: number;
  42096. zmax: number;
  42097. subdivisions?: {
  42098. w: number;
  42099. h: number;
  42100. };
  42101. precision?: {
  42102. w: number;
  42103. h: number;
  42104. };
  42105. updatable?: boolean;
  42106. }, scene?: Nullable<Scene>): Mesh;
  42107. /**
  42108. * Creates a ground mesh from a height map
  42109. * * The parameter `url` sets the URL of the height map image resource.
  42110. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42111. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42112. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42113. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42114. * * 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.
  42115. * * 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).
  42116. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42118. * @param name defines the name of the mesh
  42119. * @param url defines the url to the height map
  42120. * @param options defines the options used to create the mesh
  42121. * @param scene defines the hosting scene
  42122. * @returns the ground mesh
  42123. * @see https://doc.babylonjs.com/babylon101/height_map
  42124. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42125. */
  42126. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42127. width?: number;
  42128. height?: number;
  42129. subdivisions?: number;
  42130. minHeight?: number;
  42131. maxHeight?: number;
  42132. colorFilter?: Color3;
  42133. alphaFilter?: number;
  42134. updatable?: boolean;
  42135. onReady?: (mesh: GroundMesh) => void;
  42136. }, scene?: Nullable<Scene>): GroundMesh;
  42137. }
  42138. }
  42139. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42140. import { Vector4 } from "babylonjs/Maths/math.vector";
  42141. import { Mesh } from "babylonjs/Meshes/mesh";
  42142. /**
  42143. * Class containing static functions to help procedurally build meshes
  42144. */
  42145. export class TorusBuilder {
  42146. /**
  42147. * Creates a torus mesh
  42148. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42149. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42150. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42152. * * 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
  42153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42154. * @param name defines the name of the mesh
  42155. * @param options defines the options used to create the mesh
  42156. * @param scene defines the hosting scene
  42157. * @returns the torus mesh
  42158. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42159. */
  42160. static CreateTorus(name: string, options: {
  42161. diameter?: number;
  42162. thickness?: number;
  42163. tessellation?: number;
  42164. updatable?: boolean;
  42165. sideOrientation?: number;
  42166. frontUVs?: Vector4;
  42167. backUVs?: Vector4;
  42168. }, scene: any): Mesh;
  42169. }
  42170. }
  42171. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42172. import { Vector4 } from "babylonjs/Maths/math.vector";
  42173. import { Color4 } from "babylonjs/Maths/math.color";
  42174. import { Mesh } from "babylonjs/Meshes/mesh";
  42175. /**
  42176. * Class containing static functions to help procedurally build meshes
  42177. */
  42178. export class CylinderBuilder {
  42179. /**
  42180. * Creates a cylinder or a cone mesh
  42181. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42182. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42183. * * 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.
  42184. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42185. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42186. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42187. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42188. * * 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).
  42189. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42190. * * 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).
  42191. * * 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
  42192. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42193. * * 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
  42194. * * 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.
  42195. * * If `enclose` is false, a ring surface is one element.
  42196. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42197. * * 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
  42198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42199. * * 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
  42200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42201. * @param name defines the name of the mesh
  42202. * @param options defines the options used to create the mesh
  42203. * @param scene defines the hosting scene
  42204. * @returns the cylinder mesh
  42205. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42206. */
  42207. static CreateCylinder(name: string, options: {
  42208. height?: number;
  42209. diameterTop?: number;
  42210. diameterBottom?: number;
  42211. diameter?: number;
  42212. tessellation?: number;
  42213. subdivisions?: number;
  42214. arc?: number;
  42215. faceColors?: Color4[];
  42216. faceUV?: Vector4[];
  42217. updatable?: boolean;
  42218. hasRings?: boolean;
  42219. enclose?: boolean;
  42220. cap?: number;
  42221. sideOrientation?: number;
  42222. frontUVs?: Vector4;
  42223. backUVs?: Vector4;
  42224. }, scene: any): Mesh;
  42225. }
  42226. }
  42227. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42228. import { Observable } from "babylonjs/Misc/observable";
  42229. import { Nullable } from "babylonjs/types";
  42230. import { Camera } from "babylonjs/Cameras/camera";
  42231. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42232. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42233. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42234. import { Scene } from "babylonjs/scene";
  42235. import { Vector3 } from "babylonjs/Maths/math.vector";
  42236. import { Color3 } from "babylonjs/Maths/math.color";
  42237. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42239. import { Mesh } from "babylonjs/Meshes/mesh";
  42240. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42241. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42242. import "babylonjs/Meshes/Builders/groundBuilder";
  42243. import "babylonjs/Meshes/Builders/torusBuilder";
  42244. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42245. import "babylonjs/Gamepads/gamepadSceneComponent";
  42246. import "babylonjs/Animations/animatable";
  42247. /**
  42248. * Options to modify the vr teleportation behavior.
  42249. */
  42250. export interface VRTeleportationOptions {
  42251. /**
  42252. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42253. */
  42254. floorMeshName?: string;
  42255. /**
  42256. * A list of meshes to be used as the teleportation floor. (default: empty)
  42257. */
  42258. floorMeshes?: Mesh[];
  42259. }
  42260. /**
  42261. * Options to modify the vr experience helper's behavior.
  42262. */
  42263. export interface VRExperienceHelperOptions extends WebVROptions {
  42264. /**
  42265. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42266. */
  42267. createDeviceOrientationCamera?: boolean;
  42268. /**
  42269. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42270. */
  42271. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42272. /**
  42273. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42274. */
  42275. laserToggle?: boolean;
  42276. /**
  42277. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42278. */
  42279. floorMeshes?: Mesh[];
  42280. /**
  42281. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42282. */
  42283. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42284. }
  42285. /**
  42286. * Event containing information after VR has been entered
  42287. */
  42288. export class OnAfterEnteringVRObservableEvent {
  42289. /**
  42290. * If entering vr was successful
  42291. */
  42292. success: boolean;
  42293. }
  42294. /**
  42295. * Helps to quickly add VR support to an existing scene.
  42296. * See http://doc.babylonjs.com/how_to/webvr_helper
  42297. */
  42298. export class VRExperienceHelper {
  42299. /** Options to modify the vr experience helper's behavior. */
  42300. webVROptions: VRExperienceHelperOptions;
  42301. private _scene;
  42302. private _position;
  42303. private _btnVR;
  42304. private _btnVRDisplayed;
  42305. private _webVRsupported;
  42306. private _webVRready;
  42307. private _webVRrequesting;
  42308. private _webVRpresenting;
  42309. private _hasEnteredVR;
  42310. private _fullscreenVRpresenting;
  42311. private _canvas;
  42312. private _webVRCamera;
  42313. private _vrDeviceOrientationCamera;
  42314. private _deviceOrientationCamera;
  42315. private _existingCamera;
  42316. private _onKeyDown;
  42317. private _onVrDisplayPresentChange;
  42318. private _onVRDisplayChanged;
  42319. private _onVRRequestPresentStart;
  42320. private _onVRRequestPresentComplete;
  42321. /**
  42322. * 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)
  42323. */
  42324. enableGazeEvenWhenNoPointerLock: boolean;
  42325. /**
  42326. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42327. */
  42328. exitVROnDoubleTap: boolean;
  42329. /**
  42330. * Observable raised right before entering VR.
  42331. */
  42332. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42333. /**
  42334. * Observable raised when entering VR has completed.
  42335. */
  42336. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42337. /**
  42338. * Observable raised when exiting VR.
  42339. */
  42340. onExitingVRObservable: Observable<VRExperienceHelper>;
  42341. /**
  42342. * Observable raised when controller mesh is loaded.
  42343. */
  42344. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42345. /** Return this.onEnteringVRObservable
  42346. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42347. */
  42348. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42349. /** Return this.onExitingVRObservable
  42350. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42351. */
  42352. readonly onExitingVR: Observable<VRExperienceHelper>;
  42353. /** Return this.onControllerMeshLoadedObservable
  42354. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42355. */
  42356. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42357. private _rayLength;
  42358. private _useCustomVRButton;
  42359. private _teleportationRequested;
  42360. private _teleportActive;
  42361. private _floorMeshName;
  42362. private _floorMeshesCollection;
  42363. private _rotationAllowed;
  42364. private _teleportBackwardsVector;
  42365. private _teleportationTarget;
  42366. private _isDefaultTeleportationTarget;
  42367. private _postProcessMove;
  42368. private _teleportationFillColor;
  42369. private _teleportationBorderColor;
  42370. private _rotationAngle;
  42371. private _haloCenter;
  42372. private _cameraGazer;
  42373. private _padSensibilityUp;
  42374. private _padSensibilityDown;
  42375. private _leftController;
  42376. private _rightController;
  42377. /**
  42378. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42379. */
  42380. onNewMeshSelected: Observable<AbstractMesh>;
  42381. /**
  42382. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42383. * This observable will provide the mesh and the controller used to select the mesh
  42384. */
  42385. onMeshSelectedWithController: Observable<{
  42386. mesh: AbstractMesh;
  42387. controller: WebVRController;
  42388. }>;
  42389. /**
  42390. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42391. */
  42392. onNewMeshPicked: Observable<PickingInfo>;
  42393. private _circleEase;
  42394. /**
  42395. * Observable raised before camera teleportation
  42396. */
  42397. onBeforeCameraTeleport: Observable<Vector3>;
  42398. /**
  42399. * Observable raised after camera teleportation
  42400. */
  42401. onAfterCameraTeleport: Observable<Vector3>;
  42402. /**
  42403. * Observable raised when current selected mesh gets unselected
  42404. */
  42405. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42406. private _raySelectionPredicate;
  42407. /**
  42408. * To be optionaly changed by user to define custom ray selection
  42409. */
  42410. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42411. /**
  42412. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42413. */
  42414. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42415. /**
  42416. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42417. */
  42418. teleportationEnabled: boolean;
  42419. private _defaultHeight;
  42420. private _teleportationInitialized;
  42421. private _interactionsEnabled;
  42422. private _interactionsRequested;
  42423. private _displayGaze;
  42424. private _displayLaserPointer;
  42425. /**
  42426. * The mesh used to display where the user is going to teleport.
  42427. */
  42428. /**
  42429. * Sets the mesh to be used to display where the user is going to teleport.
  42430. */
  42431. teleportationTarget: Mesh;
  42432. /**
  42433. * 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
  42434. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42435. * See http://doc.babylonjs.com/resources/baking_transformations
  42436. */
  42437. gazeTrackerMesh: Mesh;
  42438. /**
  42439. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42440. */
  42441. updateGazeTrackerScale: boolean;
  42442. /**
  42443. * If the gaze trackers color should be updated when selecting meshes
  42444. */
  42445. updateGazeTrackerColor: boolean;
  42446. /**
  42447. * If the controller laser color should be updated when selecting meshes
  42448. */
  42449. updateControllerLaserColor: boolean;
  42450. /**
  42451. * The gaze tracking mesh corresponding to the left controller
  42452. */
  42453. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42454. /**
  42455. * The gaze tracking mesh corresponding to the right controller
  42456. */
  42457. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42458. /**
  42459. * If the ray of the gaze should be displayed.
  42460. */
  42461. /**
  42462. * Sets if the ray of the gaze should be displayed.
  42463. */
  42464. displayGaze: boolean;
  42465. /**
  42466. * If the ray of the LaserPointer should be displayed.
  42467. */
  42468. /**
  42469. * Sets if the ray of the LaserPointer should be displayed.
  42470. */
  42471. displayLaserPointer: boolean;
  42472. /**
  42473. * The deviceOrientationCamera used as the camera when not in VR.
  42474. */
  42475. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42476. /**
  42477. * Based on the current WebVR support, returns the current VR camera used.
  42478. */
  42479. readonly currentVRCamera: Nullable<Camera>;
  42480. /**
  42481. * The webVRCamera which is used when in VR.
  42482. */
  42483. readonly webVRCamera: WebVRFreeCamera;
  42484. /**
  42485. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42486. */
  42487. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42488. /**
  42489. * The html button that is used to trigger entering into VR.
  42490. */
  42491. readonly vrButton: Nullable<HTMLButtonElement>;
  42492. private readonly _teleportationRequestInitiated;
  42493. /**
  42494. * Defines wether or not Pointer lock should be requested when switching to
  42495. * full screen.
  42496. */
  42497. requestPointerLockOnFullScreen: boolean;
  42498. /**
  42499. * Instantiates a VRExperienceHelper.
  42500. * Helps to quickly add VR support to an existing scene.
  42501. * @param scene The scene the VRExperienceHelper belongs to.
  42502. * @param webVROptions Options to modify the vr experience helper's behavior.
  42503. */
  42504. constructor(scene: Scene,
  42505. /** Options to modify the vr experience helper's behavior. */
  42506. webVROptions?: VRExperienceHelperOptions);
  42507. private _onDefaultMeshLoaded;
  42508. private _onResize;
  42509. private _onFullscreenChange;
  42510. /**
  42511. * Gets a value indicating if we are currently in VR mode.
  42512. */
  42513. readonly isInVRMode: boolean;
  42514. private onVrDisplayPresentChange;
  42515. private onVRDisplayChanged;
  42516. private moveButtonToBottomRight;
  42517. private displayVRButton;
  42518. private updateButtonVisibility;
  42519. private _cachedAngularSensibility;
  42520. /**
  42521. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42522. * Otherwise, will use the fullscreen API.
  42523. */
  42524. enterVR(): void;
  42525. /**
  42526. * Attempt to exit VR, or fullscreen.
  42527. */
  42528. exitVR(): void;
  42529. /**
  42530. * The position of the vr experience helper.
  42531. */
  42532. /**
  42533. * Sets the position of the vr experience helper.
  42534. */
  42535. position: Vector3;
  42536. /**
  42537. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42538. */
  42539. enableInteractions(): void;
  42540. private readonly _noControllerIsActive;
  42541. private beforeRender;
  42542. private _isTeleportationFloor;
  42543. /**
  42544. * Adds a floor mesh to be used for teleportation.
  42545. * @param floorMesh the mesh to be used for teleportation.
  42546. */
  42547. addFloorMesh(floorMesh: Mesh): void;
  42548. /**
  42549. * Removes a floor mesh from being used for teleportation.
  42550. * @param floorMesh the mesh to be removed.
  42551. */
  42552. removeFloorMesh(floorMesh: Mesh): void;
  42553. /**
  42554. * Enables interactions and teleportation using the VR controllers and gaze.
  42555. * @param vrTeleportationOptions options to modify teleportation behavior.
  42556. */
  42557. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42558. private _onNewGamepadConnected;
  42559. private _tryEnableInteractionOnController;
  42560. private _onNewGamepadDisconnected;
  42561. private _enableInteractionOnController;
  42562. private _checkTeleportWithRay;
  42563. private _checkRotate;
  42564. private _checkTeleportBackwards;
  42565. private _enableTeleportationOnController;
  42566. private _createTeleportationCircles;
  42567. private _displayTeleportationTarget;
  42568. private _hideTeleportationTarget;
  42569. private _rotateCamera;
  42570. private _moveTeleportationSelectorTo;
  42571. private _workingVector;
  42572. private _workingQuaternion;
  42573. private _workingMatrix;
  42574. /**
  42575. * Teleports the users feet to the desired location
  42576. * @param location The location where the user's feet should be placed
  42577. */
  42578. teleportCamera(location: Vector3): void;
  42579. private _convertNormalToDirectionOfRay;
  42580. private _castRayAndSelectObject;
  42581. private _notifySelectedMeshUnselected;
  42582. /**
  42583. * Sets the color of the laser ray from the vr controllers.
  42584. * @param color new color for the ray.
  42585. */
  42586. changeLaserColor(color: Color3): void;
  42587. /**
  42588. * Sets the color of the ray from the vr headsets gaze.
  42589. * @param color new color for the ray.
  42590. */
  42591. changeGazeColor(color: Color3): void;
  42592. /**
  42593. * Exits VR and disposes of the vr experience helper
  42594. */
  42595. dispose(): void;
  42596. /**
  42597. * Gets the name of the VRExperienceHelper class
  42598. * @returns "VRExperienceHelper"
  42599. */
  42600. getClassName(): string;
  42601. }
  42602. }
  42603. declare module "babylonjs/Cameras/VR/index" {
  42604. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42605. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42606. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42607. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42608. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42609. export * from "babylonjs/Cameras/VR/webVRCamera";
  42610. }
  42611. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42612. import { Observable } from "babylonjs/Misc/observable";
  42613. import { Nullable } from "babylonjs/types";
  42614. import { IDisposable, Scene } from "babylonjs/scene";
  42615. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42616. /**
  42617. * Manages an XRSession to work with Babylon's engine
  42618. * @see https://doc.babylonjs.com/how_to/webxr
  42619. */
  42620. export class WebXRSessionManager implements IDisposable {
  42621. private scene;
  42622. /**
  42623. * Fires every time a new xrFrame arrives which can be used to update the camera
  42624. */
  42625. onXRFrameObservable: Observable<any>;
  42626. /**
  42627. * Fires when the xr session is ended either by the device or manually done
  42628. */
  42629. onXRSessionEnded: Observable<any>;
  42630. /**
  42631. * Underlying xr session
  42632. */
  42633. session: XRSession;
  42634. /**
  42635. * Type of reference space used when creating the session
  42636. */
  42637. referenceSpace: XRReferenceSpace;
  42638. /** @hidden */
  42639. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42640. /**
  42641. * Current XR frame
  42642. */
  42643. currentFrame: Nullable<XRFrame>;
  42644. private _xrNavigator;
  42645. private baseLayer;
  42646. /**
  42647. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42648. * @param scene The scene which the session should be created for
  42649. */
  42650. constructor(scene: Scene);
  42651. /**
  42652. * Initializes the manager
  42653. * After initialization enterXR can be called to start an XR session
  42654. * @returns Promise which resolves after it is initialized
  42655. */
  42656. initializeAsync(): Promise<void>;
  42657. /**
  42658. * Initializes an xr session
  42659. * @param xrSessionMode mode to initialize
  42660. * @returns a promise which will resolve once the session has been initialized
  42661. */
  42662. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42663. /**
  42664. * Sets the reference space on the xr session
  42665. * @param referenceSpace space to set
  42666. * @returns a promise that will resolve once the reference space has been set
  42667. */
  42668. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42669. /**
  42670. * Updates the render state of the session
  42671. * @param state state to set
  42672. * @returns a promise that resolves once the render state has been updated
  42673. */
  42674. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42675. /**
  42676. * Starts rendering to the xr layer
  42677. * @returns a promise that will resolve once rendering has started
  42678. */
  42679. startRenderingToXRAsync(): Promise<void>;
  42680. /**
  42681. * Stops the xrSession and restores the renderloop
  42682. * @returns Promise which resolves after it exits XR
  42683. */
  42684. exitXRAsync(): Promise<unknown>;
  42685. /**
  42686. * Checks if a session would be supported for the creation options specified
  42687. * @param sessionMode session mode to check if supported eg. immersive-vr
  42688. * @returns true if supported
  42689. */
  42690. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42691. /**
  42692. * @hidden
  42693. * Converts the render layer of xrSession to a render target
  42694. * @param session session to create render target for
  42695. * @param scene scene the new render target should be created for
  42696. */
  42697. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42698. /**
  42699. * Disposes of the session manager
  42700. */
  42701. dispose(): void;
  42702. }
  42703. }
  42704. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42705. import { Scene } from "babylonjs/scene";
  42706. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42707. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42708. /**
  42709. * WebXR Camera which holds the views for the xrSession
  42710. * @see https://doc.babylonjs.com/how_to/webxr
  42711. */
  42712. export class WebXRCamera extends FreeCamera {
  42713. private static _TmpMatrix;
  42714. /**
  42715. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42716. * @param name the name of the camera
  42717. * @param scene the scene to add the camera to
  42718. */
  42719. constructor(name: string, scene: Scene);
  42720. private _updateNumberOfRigCameras;
  42721. /** @hidden */
  42722. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42723. /**
  42724. * Updates the cameras position from the current pose information of the XR session
  42725. * @param xrSessionManager the session containing pose information
  42726. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42727. */
  42728. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42729. }
  42730. }
  42731. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42732. import { Nullable } from "babylonjs/types";
  42733. import { IDisposable } from "babylonjs/scene";
  42734. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42735. /**
  42736. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42737. */
  42738. export class WebXRManagedOutputCanvas implements IDisposable {
  42739. private helper;
  42740. private _canvas;
  42741. /**
  42742. * xrpresent context of the canvas which can be used to display/mirror xr content
  42743. */
  42744. canvasContext: WebGLRenderingContext;
  42745. /**
  42746. * xr layer for the canvas
  42747. */
  42748. xrLayer: Nullable<XRWebGLLayer>;
  42749. /**
  42750. * Initializes the xr layer for the session
  42751. * @param xrSession xr session
  42752. * @returns a promise that will resolve once the XR Layer has been created
  42753. */
  42754. initializeXRLayerAsync(xrSession: any): any;
  42755. /**
  42756. * Initializes the canvas to be added/removed upon entering/exiting xr
  42757. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42758. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42759. */
  42760. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42761. /**
  42762. * Disposes of the object
  42763. */
  42764. dispose(): void;
  42765. private _setManagedOutputCanvas;
  42766. private _addCanvas;
  42767. private _removeCanvas;
  42768. }
  42769. }
  42770. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42771. import { Observable } from "babylonjs/Misc/observable";
  42772. import { IDisposable, Scene } from "babylonjs/scene";
  42773. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42775. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42776. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42777. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42778. /**
  42779. * States of the webXR experience
  42780. */
  42781. export enum WebXRState {
  42782. /**
  42783. * Transitioning to being in XR mode
  42784. */
  42785. ENTERING_XR = 0,
  42786. /**
  42787. * Transitioning to non XR mode
  42788. */
  42789. EXITING_XR = 1,
  42790. /**
  42791. * In XR mode and presenting
  42792. */
  42793. IN_XR = 2,
  42794. /**
  42795. * Not entered XR mode
  42796. */
  42797. NOT_IN_XR = 3
  42798. }
  42799. /**
  42800. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42801. * @see https://doc.babylonjs.com/how_to/webxr
  42802. */
  42803. export class WebXRExperienceHelper implements IDisposable {
  42804. private scene;
  42805. /**
  42806. * 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
  42807. */
  42808. container: AbstractMesh;
  42809. /**
  42810. * Camera used to render xr content
  42811. */
  42812. camera: WebXRCamera;
  42813. /**
  42814. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42815. */
  42816. state: WebXRState;
  42817. private _setState;
  42818. private static _TmpVector;
  42819. /**
  42820. * Fires when the state of the experience helper has changed
  42821. */
  42822. onStateChangedObservable: Observable<WebXRState>;
  42823. /** Session manager used to keep track of xr session */
  42824. sessionManager: WebXRSessionManager;
  42825. private _nonVRCamera;
  42826. private _originalSceneAutoClear;
  42827. private _supported;
  42828. /**
  42829. * Creates the experience helper
  42830. * @param scene the scene to attach the experience helper to
  42831. * @returns a promise for the experience helper
  42832. */
  42833. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42834. /**
  42835. * Creates a WebXRExperienceHelper
  42836. * @param scene The scene the helper should be created in
  42837. */
  42838. private constructor();
  42839. /**
  42840. * Exits XR mode and returns the scene to its original state
  42841. * @returns promise that resolves after xr mode has exited
  42842. */
  42843. exitXRAsync(): Promise<unknown>;
  42844. /**
  42845. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42846. * @param sessionCreationOptions options for the XR session
  42847. * @param referenceSpaceType frame of reference of the XR session
  42848. * @param outputCanvas the output canvas that will be used to enter XR mode
  42849. * @returns promise that resolves after xr mode has entered
  42850. */
  42851. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42852. /**
  42853. * Updates the global position of the camera by moving the camera's container
  42854. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42855. * @param position The desired global position of the camera
  42856. */
  42857. setPositionOfCameraUsingContainer(position: Vector3): void;
  42858. /**
  42859. * Rotates the xr camera by rotating the camera's container around the camera's position
  42860. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42861. * @param rotation the desired quaternion rotation to apply to the camera
  42862. */
  42863. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42864. /**
  42865. * Disposes of the experience helper
  42866. */
  42867. dispose(): void;
  42868. }
  42869. }
  42870. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42871. import { Nullable } from "babylonjs/types";
  42872. import { Observable } from "babylonjs/Misc/observable";
  42873. import { IDisposable, Scene } from "babylonjs/scene";
  42874. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42875. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42876. /**
  42877. * Button which can be used to enter a different mode of XR
  42878. */
  42879. export class WebXREnterExitUIButton {
  42880. /** button element */
  42881. element: HTMLElement;
  42882. /** XR initialization options for the button */
  42883. sessionMode: XRSessionMode;
  42884. /** Reference space type */
  42885. referenceSpaceType: XRReferenceSpaceType;
  42886. /**
  42887. * Creates a WebXREnterExitUIButton
  42888. * @param element button element
  42889. * @param sessionMode XR initialization session mode
  42890. * @param referenceSpaceType the type of reference space to be used
  42891. */
  42892. constructor(
  42893. /** button element */
  42894. element: HTMLElement,
  42895. /** XR initialization options for the button */
  42896. sessionMode: XRSessionMode,
  42897. /** Reference space type */
  42898. referenceSpaceType: XRReferenceSpaceType);
  42899. /**
  42900. * Overwritable function which can be used to update the button's visuals when the state changes
  42901. * @param activeButton the current active button in the UI
  42902. */
  42903. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42904. }
  42905. /**
  42906. * Options to create the webXR UI
  42907. */
  42908. export class WebXREnterExitUIOptions {
  42909. /**
  42910. * Context to enter xr with
  42911. */
  42912. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42913. /**
  42914. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42915. */
  42916. customButtons?: Array<WebXREnterExitUIButton>;
  42917. }
  42918. /**
  42919. * UI to allow the user to enter/exit XR mode
  42920. */
  42921. export class WebXREnterExitUI implements IDisposable {
  42922. private scene;
  42923. private _overlay;
  42924. private _buttons;
  42925. private _activeButton;
  42926. /**
  42927. * Fired every time the active button is changed.
  42928. *
  42929. * When xr is entered via a button that launches xr that button will be the callback parameter
  42930. *
  42931. * When exiting xr the callback parameter will be null)
  42932. */
  42933. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42934. /**
  42935. * Creates UI to allow the user to enter/exit XR mode
  42936. * @param scene the scene to add the ui to
  42937. * @param helper the xr experience helper to enter/exit xr with
  42938. * @param options options to configure the UI
  42939. * @returns the created ui
  42940. */
  42941. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42942. private constructor();
  42943. private _updateButtons;
  42944. /**
  42945. * Disposes of the object
  42946. */
  42947. dispose(): void;
  42948. }
  42949. }
  42950. declare module "babylonjs/Cameras/XR/webXRController" {
  42951. import { Nullable } from "babylonjs/types";
  42952. import { Observable } from "babylonjs/Misc/observable";
  42953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42954. import { Ray } from "babylonjs/Culling/ray";
  42955. import { Scene } from "babylonjs/scene";
  42956. /**
  42957. * Represents an XR input
  42958. */
  42959. export class WebXRController {
  42960. private scene;
  42961. /** The underlying input source for the controller */
  42962. inputSource: XRInputSource;
  42963. private parentContainer;
  42964. /**
  42965. * 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
  42966. */
  42967. grip?: AbstractMesh;
  42968. /**
  42969. * Pointer which can be used to select objects or attach a visible laser to
  42970. */
  42971. pointer: AbstractMesh;
  42972. /**
  42973. * Event that fires when the controller is removed/disposed
  42974. */
  42975. onDisposeObservable: Observable<{}>;
  42976. private _tmpMatrix;
  42977. private _tmpQuaternion;
  42978. private _tmpVector;
  42979. /**
  42980. * Creates the controller
  42981. * @see https://doc.babylonjs.com/how_to/webxr
  42982. * @param scene the scene which the controller should be associated to
  42983. * @param inputSource the underlying input source for the controller
  42984. * @param parentContainer parent that the controller meshes should be children of
  42985. */
  42986. constructor(scene: Scene,
  42987. /** The underlying input source for the controller */
  42988. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42989. /**
  42990. * Updates the controller pose based on the given XRFrame
  42991. * @param xrFrame xr frame to update the pose with
  42992. * @param referenceSpace reference space to use
  42993. */
  42994. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42995. /**
  42996. * Gets a world space ray coming from the controller
  42997. * @param result the resulting ray
  42998. */
  42999. getWorldPointerRayToRef(result: Ray): void;
  43000. /**
  43001. * Disposes of the object
  43002. */
  43003. dispose(): void;
  43004. }
  43005. }
  43006. declare module "babylonjs/Cameras/XR/webXRInput" {
  43007. import { Observable } from "babylonjs/Misc/observable";
  43008. import { IDisposable } from "babylonjs/scene";
  43009. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43010. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43011. /**
  43012. * XR input used to track XR inputs such as controllers/rays
  43013. */
  43014. export class WebXRInput implements IDisposable {
  43015. /**
  43016. * Base experience the input listens to
  43017. */
  43018. baseExperience: WebXRExperienceHelper;
  43019. /**
  43020. * XR controllers being tracked
  43021. */
  43022. controllers: Array<WebXRController>;
  43023. private _frameObserver;
  43024. private _stateObserver;
  43025. /**
  43026. * Event when a controller has been connected/added
  43027. */
  43028. onControllerAddedObservable: Observable<WebXRController>;
  43029. /**
  43030. * Event when a controller has been removed/disconnected
  43031. */
  43032. onControllerRemovedObservable: Observable<WebXRController>;
  43033. /**
  43034. * Initializes the WebXRInput
  43035. * @param baseExperience experience helper which the input should be created for
  43036. */
  43037. constructor(
  43038. /**
  43039. * Base experience the input listens to
  43040. */
  43041. baseExperience: WebXRExperienceHelper);
  43042. private _onInputSourcesChange;
  43043. private _addAndRemoveControllers;
  43044. /**
  43045. * Disposes of the object
  43046. */
  43047. dispose(): void;
  43048. }
  43049. }
  43050. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43052. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43053. /**
  43054. * Enables teleportation
  43055. */
  43056. export class WebXRControllerTeleportation {
  43057. private _teleportationFillColor;
  43058. private _teleportationBorderColor;
  43059. private _tmpRay;
  43060. private _tmpVector;
  43061. /**
  43062. * Creates a WebXRControllerTeleportation
  43063. * @param input input manager to add teleportation to
  43064. * @param floorMeshes floormeshes which can be teleported to
  43065. */
  43066. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43067. }
  43068. }
  43069. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43070. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43071. /**
  43072. * Handles pointer input automatically for the pointer of XR controllers
  43073. */
  43074. export class WebXRControllerPointerSelection {
  43075. private static _idCounter;
  43076. private _tmpRay;
  43077. /**
  43078. * Creates a WebXRControllerPointerSelection
  43079. * @param input input manager to setup pointer selection
  43080. */
  43081. constructor(input: WebXRInput);
  43082. private _convertNormalToDirectionOfRay;
  43083. private _updatePointerDistance;
  43084. }
  43085. }
  43086. declare module "babylonjs/Loading/sceneLoader" {
  43087. import { Observable } from "babylonjs/Misc/observable";
  43088. import { Nullable } from "babylonjs/types";
  43089. import { Scene } from "babylonjs/scene";
  43090. import { Engine } from "babylonjs/Engines/engine";
  43091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43092. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43093. import { AssetContainer } from "babylonjs/assetContainer";
  43094. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43095. import { Skeleton } from "babylonjs/Bones/skeleton";
  43096. /**
  43097. * Class used to represent data loading progression
  43098. */
  43099. export class SceneLoaderProgressEvent {
  43100. /** defines if data length to load can be evaluated */
  43101. readonly lengthComputable: boolean;
  43102. /** defines the loaded data length */
  43103. readonly loaded: number;
  43104. /** defines the data length to load */
  43105. readonly total: number;
  43106. /**
  43107. * Create a new progress event
  43108. * @param lengthComputable defines if data length to load can be evaluated
  43109. * @param loaded defines the loaded data length
  43110. * @param total defines the data length to load
  43111. */
  43112. constructor(
  43113. /** defines if data length to load can be evaluated */
  43114. lengthComputable: boolean,
  43115. /** defines the loaded data length */
  43116. loaded: number,
  43117. /** defines the data length to load */
  43118. total: number);
  43119. /**
  43120. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43121. * @param event defines the source event
  43122. * @returns a new SceneLoaderProgressEvent
  43123. */
  43124. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43125. }
  43126. /**
  43127. * Interface used by SceneLoader plugins to define supported file extensions
  43128. */
  43129. export interface ISceneLoaderPluginExtensions {
  43130. /**
  43131. * Defines the list of supported extensions
  43132. */
  43133. [extension: string]: {
  43134. isBinary: boolean;
  43135. };
  43136. }
  43137. /**
  43138. * Interface used by SceneLoader plugin factory
  43139. */
  43140. export interface ISceneLoaderPluginFactory {
  43141. /**
  43142. * Defines the name of the factory
  43143. */
  43144. name: string;
  43145. /**
  43146. * Function called to create a new plugin
  43147. * @return the new plugin
  43148. */
  43149. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43150. /**
  43151. * Boolean indicating if the plugin can direct load specific data
  43152. */
  43153. canDirectLoad?: (data: string) => boolean;
  43154. }
  43155. /**
  43156. * Interface used to define a SceneLoader plugin
  43157. */
  43158. export interface ISceneLoaderPlugin {
  43159. /**
  43160. * The friendly name of this plugin.
  43161. */
  43162. name: string;
  43163. /**
  43164. * The file extensions supported by this plugin.
  43165. */
  43166. extensions: string | ISceneLoaderPluginExtensions;
  43167. /**
  43168. * Import meshes into a scene.
  43169. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43170. * @param scene The scene to import into
  43171. * @param data The data to import
  43172. * @param rootUrl The root url for scene and resources
  43173. * @param meshes The meshes array to import into
  43174. * @param particleSystems The particle systems array to import into
  43175. * @param skeletons The skeletons array to import into
  43176. * @param onError The callback when import fails
  43177. * @returns True if successful or false otherwise
  43178. */
  43179. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43180. /**
  43181. * Load into a scene.
  43182. * @param scene The scene to load into
  43183. * @param data The data to import
  43184. * @param rootUrl The root url for scene and resources
  43185. * @param onError The callback when import fails
  43186. * @returns true if successful or false otherwise
  43187. */
  43188. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43189. /**
  43190. * The callback that returns true if the data can be directly loaded.
  43191. */
  43192. canDirectLoad?: (data: string) => boolean;
  43193. /**
  43194. * The callback that allows custom handling of the root url based on the response url.
  43195. */
  43196. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43197. /**
  43198. * Load into an asset container.
  43199. * @param scene The scene to load into
  43200. * @param data The data to import
  43201. * @param rootUrl The root url for scene and resources
  43202. * @param onError The callback when import fails
  43203. * @returns The loaded asset container
  43204. */
  43205. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43206. }
  43207. /**
  43208. * Interface used to define an async SceneLoader plugin
  43209. */
  43210. export interface ISceneLoaderPluginAsync {
  43211. /**
  43212. * The friendly name of this plugin.
  43213. */
  43214. name: string;
  43215. /**
  43216. * The file extensions supported by this plugin.
  43217. */
  43218. extensions: string | ISceneLoaderPluginExtensions;
  43219. /**
  43220. * Import meshes into a scene.
  43221. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43222. * @param scene The scene to import into
  43223. * @param data The data to import
  43224. * @param rootUrl The root url for scene and resources
  43225. * @param onProgress The callback when the load progresses
  43226. * @param fileName Defines the name of the file to load
  43227. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43228. */
  43229. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43230. meshes: AbstractMesh[];
  43231. particleSystems: IParticleSystem[];
  43232. skeletons: Skeleton[];
  43233. animationGroups: AnimationGroup[];
  43234. }>;
  43235. /**
  43236. * Load into a scene.
  43237. * @param scene The scene to load into
  43238. * @param data The data to import
  43239. * @param rootUrl The root url for scene and resources
  43240. * @param onProgress The callback when the load progresses
  43241. * @param fileName Defines the name of the file to load
  43242. * @returns Nothing
  43243. */
  43244. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43245. /**
  43246. * The callback that returns true if the data can be directly loaded.
  43247. */
  43248. canDirectLoad?: (data: string) => boolean;
  43249. /**
  43250. * The callback that allows custom handling of the root url based on the response url.
  43251. */
  43252. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43253. /**
  43254. * Load into an asset container.
  43255. * @param scene The scene to load into
  43256. * @param data The data to import
  43257. * @param rootUrl The root url for scene and resources
  43258. * @param onProgress The callback when the load progresses
  43259. * @param fileName Defines the name of the file to load
  43260. * @returns The loaded asset container
  43261. */
  43262. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43263. }
  43264. /**
  43265. * Class used to load scene from various file formats using registered plugins
  43266. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43267. */
  43268. export class SceneLoader {
  43269. /**
  43270. * No logging while loading
  43271. */
  43272. static readonly NO_LOGGING: number;
  43273. /**
  43274. * Minimal logging while loading
  43275. */
  43276. static readonly MINIMAL_LOGGING: number;
  43277. /**
  43278. * Summary logging while loading
  43279. */
  43280. static readonly SUMMARY_LOGGING: number;
  43281. /**
  43282. * Detailled logging while loading
  43283. */
  43284. static readonly DETAILED_LOGGING: number;
  43285. /**
  43286. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43287. */
  43288. static ForceFullSceneLoadingForIncremental: boolean;
  43289. /**
  43290. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43291. */
  43292. static ShowLoadingScreen: boolean;
  43293. /**
  43294. * Defines the current logging level (while loading the scene)
  43295. * @ignorenaming
  43296. */
  43297. static loggingLevel: number;
  43298. /**
  43299. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43300. */
  43301. static CleanBoneMatrixWeights: boolean;
  43302. /**
  43303. * Event raised when a plugin is used to load a scene
  43304. */
  43305. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43306. private static _registeredPlugins;
  43307. private static _getDefaultPlugin;
  43308. private static _getPluginForExtension;
  43309. private static _getPluginForDirectLoad;
  43310. private static _getPluginForFilename;
  43311. private static _getDirectLoad;
  43312. private static _loadData;
  43313. private static _getFileInfo;
  43314. /**
  43315. * Gets a plugin that can load the given extension
  43316. * @param extension defines the extension to load
  43317. * @returns a plugin or null if none works
  43318. */
  43319. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43320. /**
  43321. * Gets a boolean indicating that the given extension can be loaded
  43322. * @param extension defines the extension to load
  43323. * @returns true if the extension is supported
  43324. */
  43325. static IsPluginForExtensionAvailable(extension: string): boolean;
  43326. /**
  43327. * Adds a new plugin to the list of registered plugins
  43328. * @param plugin defines the plugin to add
  43329. */
  43330. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43331. /**
  43332. * Import meshes into a scene
  43333. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43334. * @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)
  43335. * @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)
  43336. * @param scene the instance of BABYLON.Scene to append to
  43337. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43338. * @param onProgress a callback with a progress event for each file being loaded
  43339. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43340. * @param pluginExtension the extension used to determine the plugin
  43341. * @returns The loaded plugin
  43342. */
  43343. 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>;
  43344. /**
  43345. * Import meshes into a scene
  43346. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43347. * @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)
  43348. * @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)
  43349. * @param scene the instance of BABYLON.Scene to append to
  43350. * @param onProgress a callback with a progress event for each file being loaded
  43351. * @param pluginExtension the extension used to determine the plugin
  43352. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43353. */
  43354. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43355. meshes: AbstractMesh[];
  43356. particleSystems: IParticleSystem[];
  43357. skeletons: Skeleton[];
  43358. animationGroups: AnimationGroup[];
  43359. }>;
  43360. /**
  43361. * Load a scene
  43362. * @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)
  43363. * @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)
  43364. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43365. * @param onSuccess a callback with the scene when import succeeds
  43366. * @param onProgress a callback with a progress event for each file being loaded
  43367. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43368. * @param pluginExtension the extension used to determine the plugin
  43369. * @returns The loaded plugin
  43370. */
  43371. 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>;
  43372. /**
  43373. * Load a scene
  43374. * @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)
  43375. * @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)
  43376. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43377. * @param onProgress a callback with a progress event for each file being loaded
  43378. * @param pluginExtension the extension used to determine the plugin
  43379. * @returns The loaded scene
  43380. */
  43381. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43382. /**
  43383. * Append a scene
  43384. * @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)
  43385. * @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)
  43386. * @param scene is the instance of BABYLON.Scene to append to
  43387. * @param onSuccess a callback with the scene when import succeeds
  43388. * @param onProgress a callback with a progress event for each file being loaded
  43389. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43390. * @param pluginExtension the extension used to determine the plugin
  43391. * @returns The loaded plugin
  43392. */
  43393. 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>;
  43394. /**
  43395. * Append a scene
  43396. * @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)
  43397. * @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)
  43398. * @param scene is the instance of BABYLON.Scene to append to
  43399. * @param onProgress a callback with a progress event for each file being loaded
  43400. * @param pluginExtension the extension used to determine the plugin
  43401. * @returns The given scene
  43402. */
  43403. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43404. /**
  43405. * Load a scene into an asset container
  43406. * @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)
  43407. * @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)
  43408. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43409. * @param onSuccess a callback with the scene when import succeeds
  43410. * @param onProgress a callback with a progress event for each file being loaded
  43411. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43412. * @param pluginExtension the extension used to determine the plugin
  43413. * @returns The loaded plugin
  43414. */
  43415. 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>;
  43416. /**
  43417. * Load a scene into an asset container
  43418. * @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)
  43419. * @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)
  43420. * @param scene is the instance of Scene to append to
  43421. * @param onProgress a callback with a progress event for each file being loaded
  43422. * @param pluginExtension the extension used to determine the plugin
  43423. * @returns The loaded asset container
  43424. */
  43425. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43426. }
  43427. }
  43428. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43429. import { Scene } from "babylonjs/scene";
  43430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43431. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43432. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43433. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43434. /**
  43435. * Generic Controller
  43436. */
  43437. export class GenericController extends WebVRController {
  43438. /**
  43439. * Base Url for the controller model.
  43440. */
  43441. static readonly MODEL_BASE_URL: string;
  43442. /**
  43443. * File name for the controller model.
  43444. */
  43445. static readonly MODEL_FILENAME: string;
  43446. /**
  43447. * Creates a new GenericController from a gamepad
  43448. * @param vrGamepad the gamepad that the controller should be created from
  43449. */
  43450. constructor(vrGamepad: any);
  43451. /**
  43452. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43453. * @param scene scene in which to add meshes
  43454. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43455. */
  43456. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43457. /**
  43458. * Called once for each button that changed state since the last frame
  43459. * @param buttonIdx Which button index changed
  43460. * @param state New state of the button
  43461. * @param changes Which properties on the state changed since last frame
  43462. */
  43463. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43464. }
  43465. }
  43466. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43467. import { Observable } from "babylonjs/Misc/observable";
  43468. import { Scene } from "babylonjs/scene";
  43469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43470. import { Ray } from "babylonjs/Culling/ray";
  43471. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43472. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43473. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43474. /**
  43475. * Defines the WindowsMotionController object that the state of the windows motion controller
  43476. */
  43477. export class WindowsMotionController extends WebVRController {
  43478. /**
  43479. * The base url used to load the left and right controller models
  43480. */
  43481. static MODEL_BASE_URL: string;
  43482. /**
  43483. * The name of the left controller model file
  43484. */
  43485. static MODEL_LEFT_FILENAME: string;
  43486. /**
  43487. * The name of the right controller model file
  43488. */
  43489. static MODEL_RIGHT_FILENAME: string;
  43490. /**
  43491. * The controller name prefix for this controller type
  43492. */
  43493. static readonly GAMEPAD_ID_PREFIX: string;
  43494. /**
  43495. * The controller id pattern for this controller type
  43496. */
  43497. private static readonly GAMEPAD_ID_PATTERN;
  43498. private _loadedMeshInfo;
  43499. private readonly _mapping;
  43500. /**
  43501. * Fired when the trackpad on this controller is clicked
  43502. */
  43503. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43504. /**
  43505. * Fired when the trackpad on this controller is modified
  43506. */
  43507. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43508. /**
  43509. * The current x and y values of this controller's trackpad
  43510. */
  43511. trackpad: StickValues;
  43512. /**
  43513. * Creates a new WindowsMotionController from a gamepad
  43514. * @param vrGamepad the gamepad that the controller should be created from
  43515. */
  43516. constructor(vrGamepad: any);
  43517. /**
  43518. * Fired when the trigger on this controller is modified
  43519. */
  43520. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43521. /**
  43522. * Fired when the menu button on this controller is modified
  43523. */
  43524. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43525. /**
  43526. * Fired when the grip button on this controller is modified
  43527. */
  43528. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43529. /**
  43530. * Fired when the thumbstick button on this controller is modified
  43531. */
  43532. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43533. /**
  43534. * Fired when the touchpad button on this controller is modified
  43535. */
  43536. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43537. /**
  43538. * Fired when the touchpad values on this controller are modified
  43539. */
  43540. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43541. private _updateTrackpad;
  43542. /**
  43543. * Called once per frame by the engine.
  43544. */
  43545. update(): void;
  43546. /**
  43547. * Called once for each button that changed state since the last frame
  43548. * @param buttonIdx Which button index changed
  43549. * @param state New state of the button
  43550. * @param changes Which properties on the state changed since last frame
  43551. */
  43552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43553. /**
  43554. * Moves the buttons on the controller mesh based on their current state
  43555. * @param buttonName the name of the button to move
  43556. * @param buttonValue the value of the button which determines the buttons new position
  43557. */
  43558. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43559. /**
  43560. * Moves the axis on the controller mesh based on its current state
  43561. * @param axis the index of the axis
  43562. * @param axisValue the value of the axis which determines the meshes new position
  43563. * @hidden
  43564. */
  43565. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43566. /**
  43567. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43568. * @param scene scene in which to add meshes
  43569. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43570. */
  43571. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43572. /**
  43573. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43574. * can be transformed by button presses and axes values, based on this._mapping.
  43575. *
  43576. * @param scene scene in which the meshes exist
  43577. * @param meshes list of meshes that make up the controller model to process
  43578. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43579. */
  43580. private processModel;
  43581. private createMeshInfo;
  43582. /**
  43583. * Gets the ray of the controller in the direction the controller is pointing
  43584. * @param length the length the resulting ray should be
  43585. * @returns a ray in the direction the controller is pointing
  43586. */
  43587. getForwardRay(length?: number): Ray;
  43588. /**
  43589. * Disposes of the controller
  43590. */
  43591. dispose(): void;
  43592. }
  43593. }
  43594. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43595. import { Observable } from "babylonjs/Misc/observable";
  43596. import { Scene } from "babylonjs/scene";
  43597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43598. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43599. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43600. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43601. /**
  43602. * Oculus Touch Controller
  43603. */
  43604. export class OculusTouchController extends WebVRController {
  43605. /**
  43606. * Base Url for the controller model.
  43607. */
  43608. static MODEL_BASE_URL: string;
  43609. /**
  43610. * File name for the left controller model.
  43611. */
  43612. static MODEL_LEFT_FILENAME: string;
  43613. /**
  43614. * File name for the right controller model.
  43615. */
  43616. static MODEL_RIGHT_FILENAME: string;
  43617. /**
  43618. * Base Url for the Quest controller model.
  43619. */
  43620. static QUEST_MODEL_BASE_URL: string;
  43621. /**
  43622. * @hidden
  43623. * If the controllers are running on a device that needs the updated Quest controller models
  43624. */
  43625. static _IsQuest: boolean;
  43626. /**
  43627. * Fired when the secondary trigger on this controller is modified
  43628. */
  43629. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43630. /**
  43631. * Fired when the thumb rest on this controller is modified
  43632. */
  43633. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43634. /**
  43635. * Creates a new OculusTouchController from a gamepad
  43636. * @param vrGamepad the gamepad that the controller should be created from
  43637. */
  43638. constructor(vrGamepad: any);
  43639. /**
  43640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43641. * @param scene scene in which to add meshes
  43642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43643. */
  43644. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43645. /**
  43646. * Fired when the A button on this controller is modified
  43647. */
  43648. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43649. /**
  43650. * Fired when the B button on this controller is modified
  43651. */
  43652. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43653. /**
  43654. * Fired when the X button on this controller is modified
  43655. */
  43656. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43657. /**
  43658. * Fired when the Y button on this controller is modified
  43659. */
  43660. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43661. /**
  43662. * Called once for each button that changed state since the last frame
  43663. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43664. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43665. * 2) secondary trigger (same)
  43666. * 3) A (right) X (left), touch, pressed = value
  43667. * 4) B / Y
  43668. * 5) thumb rest
  43669. * @param buttonIdx Which button index changed
  43670. * @param state New state of the button
  43671. * @param changes Which properties on the state changed since last frame
  43672. */
  43673. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43674. }
  43675. }
  43676. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43677. import { Scene } from "babylonjs/scene";
  43678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43679. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43680. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43681. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43682. import { Observable } from "babylonjs/Misc/observable";
  43683. /**
  43684. * Vive Controller
  43685. */
  43686. export class ViveController extends WebVRController {
  43687. /**
  43688. * Base Url for the controller model.
  43689. */
  43690. static MODEL_BASE_URL: string;
  43691. /**
  43692. * File name for the controller model.
  43693. */
  43694. static MODEL_FILENAME: string;
  43695. /**
  43696. * Creates a new ViveController from a gamepad
  43697. * @param vrGamepad the gamepad that the controller should be created from
  43698. */
  43699. constructor(vrGamepad: any);
  43700. /**
  43701. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43702. * @param scene scene in which to add meshes
  43703. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43704. */
  43705. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43706. /**
  43707. * Fired when the left button on this controller is modified
  43708. */
  43709. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43710. /**
  43711. * Fired when the right button on this controller is modified
  43712. */
  43713. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43714. /**
  43715. * Fired when the menu button on this controller is modified
  43716. */
  43717. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43718. /**
  43719. * Called once for each button that changed state since the last frame
  43720. * Vive mapping:
  43721. * 0: touchpad
  43722. * 1: trigger
  43723. * 2: left AND right buttons
  43724. * 3: menu button
  43725. * @param buttonIdx Which button index changed
  43726. * @param state New state of the button
  43727. * @param changes Which properties on the state changed since last frame
  43728. */
  43729. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43730. }
  43731. }
  43732. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43733. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43734. /**
  43735. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43736. */
  43737. export class WebXRControllerModelLoader {
  43738. /**
  43739. * Creates the WebXRControllerModelLoader
  43740. * @param input xr input that creates the controllers
  43741. */
  43742. constructor(input: WebXRInput);
  43743. }
  43744. }
  43745. declare module "babylonjs/Cameras/XR/index" {
  43746. export * from "babylonjs/Cameras/XR/webXRCamera";
  43747. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43748. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43749. export * from "babylonjs/Cameras/XR/webXRInput";
  43750. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43751. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43752. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43753. export * from "babylonjs/Cameras/XR/webXRController";
  43754. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43755. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43756. }
  43757. declare module "babylonjs/Cameras/RigModes/index" {
  43758. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43759. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43760. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43761. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43762. }
  43763. declare module "babylonjs/Cameras/index" {
  43764. export * from "babylonjs/Cameras/Inputs/index";
  43765. export * from "babylonjs/Cameras/cameraInputsManager";
  43766. export * from "babylonjs/Cameras/camera";
  43767. export * from "babylonjs/Cameras/targetCamera";
  43768. export * from "babylonjs/Cameras/freeCamera";
  43769. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43770. export * from "babylonjs/Cameras/touchCamera";
  43771. export * from "babylonjs/Cameras/arcRotateCamera";
  43772. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43773. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43774. export * from "babylonjs/Cameras/flyCamera";
  43775. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43776. export * from "babylonjs/Cameras/followCamera";
  43777. export * from "babylonjs/Cameras/followCameraInputsManager";
  43778. export * from "babylonjs/Cameras/gamepadCamera";
  43779. export * from "babylonjs/Cameras/Stereoscopic/index";
  43780. export * from "babylonjs/Cameras/universalCamera";
  43781. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43782. export * from "babylonjs/Cameras/VR/index";
  43783. export * from "babylonjs/Cameras/XR/index";
  43784. export * from "babylonjs/Cameras/RigModes/index";
  43785. }
  43786. declare module "babylonjs/Collisions/index" {
  43787. export * from "babylonjs/Collisions/collider";
  43788. export * from "babylonjs/Collisions/collisionCoordinator";
  43789. export * from "babylonjs/Collisions/pickingInfo";
  43790. export * from "babylonjs/Collisions/intersectionInfo";
  43791. export * from "babylonjs/Collisions/meshCollisionData";
  43792. }
  43793. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43794. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43795. import { Vector3 } from "babylonjs/Maths/math.vector";
  43796. import { Ray } from "babylonjs/Culling/ray";
  43797. import { Plane } from "babylonjs/Maths/math.plane";
  43798. /**
  43799. * Contains an array of blocks representing the octree
  43800. */
  43801. export interface IOctreeContainer<T> {
  43802. /**
  43803. * Blocks within the octree
  43804. */
  43805. blocks: Array<OctreeBlock<T>>;
  43806. }
  43807. /**
  43808. * Class used to store a cell in an octree
  43809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43810. */
  43811. export class OctreeBlock<T> {
  43812. /**
  43813. * Gets the content of the current block
  43814. */
  43815. entries: T[];
  43816. /**
  43817. * Gets the list of block children
  43818. */
  43819. blocks: Array<OctreeBlock<T>>;
  43820. private _depth;
  43821. private _maxDepth;
  43822. private _capacity;
  43823. private _minPoint;
  43824. private _maxPoint;
  43825. private _boundingVectors;
  43826. private _creationFunc;
  43827. /**
  43828. * Creates a new block
  43829. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43830. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43831. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43832. * @param depth defines the current depth of this block in the octree
  43833. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43834. * @param creationFunc defines a callback to call when an element is added to the block
  43835. */
  43836. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43837. /**
  43838. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43839. */
  43840. readonly capacity: number;
  43841. /**
  43842. * Gets the minimum vector (in world space) of the block's bounding box
  43843. */
  43844. readonly minPoint: Vector3;
  43845. /**
  43846. * Gets the maximum vector (in world space) of the block's bounding box
  43847. */
  43848. readonly maxPoint: Vector3;
  43849. /**
  43850. * Add a new element to this block
  43851. * @param entry defines the element to add
  43852. */
  43853. addEntry(entry: T): void;
  43854. /**
  43855. * Remove an element from this block
  43856. * @param entry defines the element to remove
  43857. */
  43858. removeEntry(entry: T): void;
  43859. /**
  43860. * Add an array of elements to this block
  43861. * @param entries defines the array of elements to add
  43862. */
  43863. addEntries(entries: T[]): void;
  43864. /**
  43865. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43866. * @param frustumPlanes defines the frustum planes to test
  43867. * @param selection defines the array to store current content if selection is positive
  43868. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43869. */
  43870. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43871. /**
  43872. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43873. * @param sphereCenter defines the bounding sphere center
  43874. * @param sphereRadius defines the bounding sphere radius
  43875. * @param selection defines the array to store current content if selection is positive
  43876. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43877. */
  43878. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43879. /**
  43880. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43881. * @param ray defines the ray to test with
  43882. * @param selection defines the array to store current content if selection is positive
  43883. */
  43884. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43885. /**
  43886. * Subdivide the content into child blocks (this block will then be empty)
  43887. */
  43888. createInnerBlocks(): void;
  43889. /**
  43890. * @hidden
  43891. */
  43892. 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;
  43893. }
  43894. }
  43895. declare module "babylonjs/Culling/Octrees/octree" {
  43896. import { SmartArray } from "babylonjs/Misc/smartArray";
  43897. import { Vector3 } from "babylonjs/Maths/math.vector";
  43898. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43900. import { Ray } from "babylonjs/Culling/ray";
  43901. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43902. import { Plane } from "babylonjs/Maths/math.plane";
  43903. /**
  43904. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43905. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43906. */
  43907. export class Octree<T> {
  43908. /** 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.) */
  43909. maxDepth: number;
  43910. /**
  43911. * Blocks within the octree containing objects
  43912. */
  43913. blocks: Array<OctreeBlock<T>>;
  43914. /**
  43915. * Content stored in the octree
  43916. */
  43917. dynamicContent: T[];
  43918. private _maxBlockCapacity;
  43919. private _selectionContent;
  43920. private _creationFunc;
  43921. /**
  43922. * Creates a octree
  43923. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43924. * @param creationFunc function to be used to instatiate the octree
  43925. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43926. * @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.)
  43927. */
  43928. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43929. /** 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.) */
  43930. maxDepth?: number);
  43931. /**
  43932. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43933. * @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);
  43934. * @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);
  43935. * @param entries meshes to be added to the octree blocks
  43936. */
  43937. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43938. /**
  43939. * Adds a mesh to the octree
  43940. * @param entry Mesh to add to the octree
  43941. */
  43942. addMesh(entry: T): void;
  43943. /**
  43944. * Remove an element from the octree
  43945. * @param entry defines the element to remove
  43946. */
  43947. removeMesh(entry: T): void;
  43948. /**
  43949. * Selects an array of meshes within the frustum
  43950. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43951. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43952. * @returns array of meshes within the frustum
  43953. */
  43954. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43955. /**
  43956. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43957. * @param sphereCenter defines the bounding sphere center
  43958. * @param sphereRadius defines the bounding sphere radius
  43959. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43960. * @returns an array of objects that intersect the sphere
  43961. */
  43962. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43963. /**
  43964. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43965. * @param ray defines the ray to test with
  43966. * @returns array of intersected objects
  43967. */
  43968. intersectsRay(ray: Ray): SmartArray<T>;
  43969. /**
  43970. * Adds a mesh into the octree block if it intersects the block
  43971. */
  43972. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43973. /**
  43974. * Adds a submesh into the octree block if it intersects the block
  43975. */
  43976. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43977. }
  43978. }
  43979. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43980. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43981. import { Scene } from "babylonjs/scene";
  43982. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43984. import { Ray } from "babylonjs/Culling/ray";
  43985. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43986. import { Collider } from "babylonjs/Collisions/collider";
  43987. module "babylonjs/scene" {
  43988. interface Scene {
  43989. /**
  43990. * @hidden
  43991. * Backing Filed
  43992. */
  43993. _selectionOctree: Octree<AbstractMesh>;
  43994. /**
  43995. * Gets the octree used to boost mesh selection (picking)
  43996. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43997. */
  43998. selectionOctree: Octree<AbstractMesh>;
  43999. /**
  44000. * Creates or updates the octree used to boost selection (picking)
  44001. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44002. * @param maxCapacity defines the maximum capacity per leaf
  44003. * @param maxDepth defines the maximum depth of the octree
  44004. * @returns an octree of AbstractMesh
  44005. */
  44006. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44007. }
  44008. }
  44009. module "babylonjs/Meshes/abstractMesh" {
  44010. interface AbstractMesh {
  44011. /**
  44012. * @hidden
  44013. * Backing Field
  44014. */
  44015. _submeshesOctree: Octree<SubMesh>;
  44016. /**
  44017. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44018. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44019. * @param maxCapacity defines the maximum size of each block (64 by default)
  44020. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44021. * @returns the new octree
  44022. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44024. */
  44025. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44026. }
  44027. }
  44028. /**
  44029. * Defines the octree scene component responsible to manage any octrees
  44030. * in a given scene.
  44031. */
  44032. export class OctreeSceneComponent {
  44033. /**
  44034. * The component name help to identify the component in the list of scene components.
  44035. */
  44036. readonly name: string;
  44037. /**
  44038. * The scene the component belongs to.
  44039. */
  44040. scene: Scene;
  44041. /**
  44042. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44043. */
  44044. readonly checksIsEnabled: boolean;
  44045. /**
  44046. * Creates a new instance of the component for the given scene
  44047. * @param scene Defines the scene to register the component in
  44048. */
  44049. constructor(scene: Scene);
  44050. /**
  44051. * Registers the component in a given scene
  44052. */
  44053. register(): void;
  44054. /**
  44055. * Return the list of active meshes
  44056. * @returns the list of active meshes
  44057. */
  44058. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44059. /**
  44060. * Return the list of active sub meshes
  44061. * @param mesh The mesh to get the candidates sub meshes from
  44062. * @returns the list of active sub meshes
  44063. */
  44064. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44065. private _tempRay;
  44066. /**
  44067. * Return the list of sub meshes intersecting with a given local ray
  44068. * @param mesh defines the mesh to find the submesh for
  44069. * @param localRay defines the ray in local space
  44070. * @returns the list of intersecting sub meshes
  44071. */
  44072. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44073. /**
  44074. * Return the list of sub meshes colliding with a collider
  44075. * @param mesh defines the mesh to find the submesh for
  44076. * @param collider defines the collider to evaluate the collision against
  44077. * @returns the list of colliding sub meshes
  44078. */
  44079. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44080. /**
  44081. * Rebuilds the elements related to this component in case of
  44082. * context lost for instance.
  44083. */
  44084. rebuild(): void;
  44085. /**
  44086. * Disposes the component and the associated ressources.
  44087. */
  44088. dispose(): void;
  44089. }
  44090. }
  44091. declare module "babylonjs/Culling/Octrees/index" {
  44092. export * from "babylonjs/Culling/Octrees/octree";
  44093. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44094. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44095. }
  44096. declare module "babylonjs/Culling/index" {
  44097. export * from "babylonjs/Culling/boundingBox";
  44098. export * from "babylonjs/Culling/boundingInfo";
  44099. export * from "babylonjs/Culling/boundingSphere";
  44100. export * from "babylonjs/Culling/Octrees/index";
  44101. export * from "babylonjs/Culling/ray";
  44102. }
  44103. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44104. import { IDisposable, Scene } from "babylonjs/scene";
  44105. import { Nullable } from "babylonjs/types";
  44106. import { Observable } from "babylonjs/Misc/observable";
  44107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44108. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44109. import { Camera } from "babylonjs/Cameras/camera";
  44110. /**
  44111. * Renders a layer on top of an existing scene
  44112. */
  44113. export class UtilityLayerRenderer implements IDisposable {
  44114. /** the original scene that will be rendered on top of */
  44115. originalScene: Scene;
  44116. private _pointerCaptures;
  44117. private _lastPointerEvents;
  44118. private static _DefaultUtilityLayer;
  44119. private static _DefaultKeepDepthUtilityLayer;
  44120. private _sharedGizmoLight;
  44121. private _renderCamera;
  44122. /**
  44123. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44124. * @returns the camera that is used when rendering the utility layer
  44125. */
  44126. getRenderCamera(): Nullable<Camera>;
  44127. /**
  44128. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44129. * @param cam the camera that should be used when rendering the utility layer
  44130. */
  44131. setRenderCamera(cam: Nullable<Camera>): void;
  44132. /**
  44133. * @hidden
  44134. * Light which used by gizmos to get light shading
  44135. */
  44136. _getSharedGizmoLight(): HemisphericLight;
  44137. /**
  44138. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44139. */
  44140. pickUtilitySceneFirst: boolean;
  44141. /**
  44142. * 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)
  44143. */
  44144. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44145. /**
  44146. * 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)
  44147. */
  44148. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44149. /**
  44150. * The scene that is rendered on top of the original scene
  44151. */
  44152. utilityLayerScene: Scene;
  44153. /**
  44154. * If the utility layer should automatically be rendered on top of existing scene
  44155. */
  44156. shouldRender: boolean;
  44157. /**
  44158. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44159. */
  44160. onlyCheckPointerDownEvents: boolean;
  44161. /**
  44162. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44163. */
  44164. processAllEvents: boolean;
  44165. /**
  44166. * Observable raised when the pointer move from the utility layer scene to the main scene
  44167. */
  44168. onPointerOutObservable: Observable<number>;
  44169. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44170. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44171. private _afterRenderObserver;
  44172. private _sceneDisposeObserver;
  44173. private _originalPointerObserver;
  44174. /**
  44175. * Instantiates a UtilityLayerRenderer
  44176. * @param originalScene the original scene that will be rendered on top of
  44177. * @param handleEvents boolean indicating if the utility layer should handle events
  44178. */
  44179. constructor(
  44180. /** the original scene that will be rendered on top of */
  44181. originalScene: Scene, handleEvents?: boolean);
  44182. private _notifyObservers;
  44183. /**
  44184. * Renders the utility layers scene on top of the original scene
  44185. */
  44186. render(): void;
  44187. /**
  44188. * Disposes of the renderer
  44189. */
  44190. dispose(): void;
  44191. private _updateCamera;
  44192. }
  44193. }
  44194. declare module "babylonjs/Gizmos/gizmo" {
  44195. import { Nullable } from "babylonjs/types";
  44196. import { IDisposable } from "babylonjs/scene";
  44197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44198. import { Mesh } from "babylonjs/Meshes/mesh";
  44199. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44200. /**
  44201. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44202. */
  44203. export class Gizmo implements IDisposable {
  44204. /** The utility layer the gizmo will be added to */
  44205. gizmoLayer: UtilityLayerRenderer;
  44206. /**
  44207. * The root mesh of the gizmo
  44208. */
  44209. _rootMesh: Mesh;
  44210. private _attachedMesh;
  44211. /**
  44212. * Ratio for the scale of the gizmo (Default: 1)
  44213. */
  44214. scaleRatio: number;
  44215. /**
  44216. * If a custom mesh has been set (Default: false)
  44217. */
  44218. protected _customMeshSet: boolean;
  44219. /**
  44220. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44221. * * When set, interactions will be enabled
  44222. */
  44223. attachedMesh: Nullable<AbstractMesh>;
  44224. /**
  44225. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44226. * @param mesh The mesh to replace the default mesh of the gizmo
  44227. */
  44228. setCustomMesh(mesh: Mesh): void;
  44229. /**
  44230. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44231. */
  44232. updateGizmoRotationToMatchAttachedMesh: boolean;
  44233. /**
  44234. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44235. */
  44236. updateGizmoPositionToMatchAttachedMesh: boolean;
  44237. /**
  44238. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44239. */
  44240. updateScale: boolean;
  44241. protected _interactionsEnabled: boolean;
  44242. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44243. private _beforeRenderObserver;
  44244. private _tempVector;
  44245. /**
  44246. * Creates a gizmo
  44247. * @param gizmoLayer The utility layer the gizmo will be added to
  44248. */
  44249. constructor(
  44250. /** The utility layer the gizmo will be added to */
  44251. gizmoLayer?: UtilityLayerRenderer);
  44252. /**
  44253. * Updates the gizmo to match the attached mesh's position/rotation
  44254. */
  44255. protected _update(): void;
  44256. /**
  44257. * Disposes of the gizmo
  44258. */
  44259. dispose(): void;
  44260. }
  44261. }
  44262. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44263. import { Observable } from "babylonjs/Misc/observable";
  44264. import { Nullable } from "babylonjs/types";
  44265. import { Vector3 } from "babylonjs/Maths/math.vector";
  44266. import { Color3 } from "babylonjs/Maths/math.color";
  44267. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44269. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44270. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44271. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44272. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44273. import { Scene } from "babylonjs/scene";
  44274. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44275. /**
  44276. * Single plane drag gizmo
  44277. */
  44278. export class PlaneDragGizmo extends Gizmo {
  44279. /**
  44280. * Drag behavior responsible for the gizmos dragging interactions
  44281. */
  44282. dragBehavior: PointerDragBehavior;
  44283. private _pointerObserver;
  44284. /**
  44285. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44286. */
  44287. snapDistance: number;
  44288. /**
  44289. * Event that fires each time the gizmo snaps to a new location.
  44290. * * snapDistance is the the change in distance
  44291. */
  44292. onSnapObservable: Observable<{
  44293. snapDistance: number;
  44294. }>;
  44295. private _plane;
  44296. private _coloredMaterial;
  44297. private _hoverMaterial;
  44298. private _isEnabled;
  44299. private _parent;
  44300. /** @hidden */
  44301. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44302. /** @hidden */
  44303. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44304. /**
  44305. * Creates a PlaneDragGizmo
  44306. * @param gizmoLayer The utility layer the gizmo will be added to
  44307. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44308. * @param color The color of the gizmo
  44309. */
  44310. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44311. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44312. /**
  44313. * If the gizmo is enabled
  44314. */
  44315. isEnabled: boolean;
  44316. /**
  44317. * Disposes of the gizmo
  44318. */
  44319. dispose(): void;
  44320. }
  44321. }
  44322. declare module "babylonjs/Gizmos/positionGizmo" {
  44323. import { Observable } from "babylonjs/Misc/observable";
  44324. import { Nullable } from "babylonjs/types";
  44325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44326. import { Mesh } from "babylonjs/Meshes/mesh";
  44327. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44328. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44329. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44330. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44331. /**
  44332. * Gizmo that enables dragging a mesh along 3 axis
  44333. */
  44334. export class PositionGizmo extends Gizmo {
  44335. /**
  44336. * Internal gizmo used for interactions on the x axis
  44337. */
  44338. xGizmo: AxisDragGizmo;
  44339. /**
  44340. * Internal gizmo used for interactions on the y axis
  44341. */
  44342. yGizmo: AxisDragGizmo;
  44343. /**
  44344. * Internal gizmo used for interactions on the z axis
  44345. */
  44346. zGizmo: AxisDragGizmo;
  44347. /**
  44348. * Internal gizmo used for interactions on the yz plane
  44349. */
  44350. xPlaneGizmo: PlaneDragGizmo;
  44351. /**
  44352. * Internal gizmo used for interactions on the xz plane
  44353. */
  44354. yPlaneGizmo: PlaneDragGizmo;
  44355. /**
  44356. * Internal gizmo used for interactions on the xy plane
  44357. */
  44358. zPlaneGizmo: PlaneDragGizmo;
  44359. /**
  44360. * private variables
  44361. */
  44362. private _meshAttached;
  44363. private _updateGizmoRotationToMatchAttachedMesh;
  44364. private _snapDistance;
  44365. private _scaleRatio;
  44366. /** Fires an event when any of it's sub gizmos are dragged */
  44367. onDragStartObservable: Observable<unknown>;
  44368. /** Fires an event when any of it's sub gizmos are released from dragging */
  44369. onDragEndObservable: Observable<unknown>;
  44370. /**
  44371. * If set to true, planar drag is enabled
  44372. */
  44373. private _planarGizmoEnabled;
  44374. attachedMesh: Nullable<AbstractMesh>;
  44375. /**
  44376. * Creates a PositionGizmo
  44377. * @param gizmoLayer The utility layer the gizmo will be added to
  44378. */
  44379. constructor(gizmoLayer?: UtilityLayerRenderer);
  44380. /**
  44381. * If the planar drag gizmo is enabled
  44382. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44383. */
  44384. planarGizmoEnabled: boolean;
  44385. updateGizmoRotationToMatchAttachedMesh: boolean;
  44386. /**
  44387. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44388. */
  44389. snapDistance: number;
  44390. /**
  44391. * Ratio for the scale of the gizmo (Default: 1)
  44392. */
  44393. scaleRatio: number;
  44394. /**
  44395. * Disposes of the gizmo
  44396. */
  44397. dispose(): void;
  44398. /**
  44399. * CustomMeshes are not supported by this gizmo
  44400. * @param mesh The mesh to replace the default mesh of the gizmo
  44401. */
  44402. setCustomMesh(mesh: Mesh): void;
  44403. }
  44404. }
  44405. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44406. import { Observable } from "babylonjs/Misc/observable";
  44407. import { Nullable } from "babylonjs/types";
  44408. import { Vector3 } from "babylonjs/Maths/math.vector";
  44409. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44411. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44412. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44413. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44414. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44415. import { Scene } from "babylonjs/scene";
  44416. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44417. import { Color3 } from "babylonjs/Maths/math.color";
  44418. /**
  44419. * Single axis drag gizmo
  44420. */
  44421. export class AxisDragGizmo extends Gizmo {
  44422. /**
  44423. * Drag behavior responsible for the gizmos dragging interactions
  44424. */
  44425. dragBehavior: PointerDragBehavior;
  44426. private _pointerObserver;
  44427. /**
  44428. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44429. */
  44430. snapDistance: number;
  44431. /**
  44432. * Event that fires each time the gizmo snaps to a new location.
  44433. * * snapDistance is the the change in distance
  44434. */
  44435. onSnapObservable: Observable<{
  44436. snapDistance: number;
  44437. }>;
  44438. private _isEnabled;
  44439. private _parent;
  44440. private _arrow;
  44441. private _coloredMaterial;
  44442. private _hoverMaterial;
  44443. /** @hidden */
  44444. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44445. /** @hidden */
  44446. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44447. /**
  44448. * Creates an AxisDragGizmo
  44449. * @param gizmoLayer The utility layer the gizmo will be added to
  44450. * @param dragAxis The axis which the gizmo will be able to drag on
  44451. * @param color The color of the gizmo
  44452. */
  44453. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44454. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44455. /**
  44456. * If the gizmo is enabled
  44457. */
  44458. isEnabled: boolean;
  44459. /**
  44460. * Disposes of the gizmo
  44461. */
  44462. dispose(): void;
  44463. }
  44464. }
  44465. declare module "babylonjs/Debug/axesViewer" {
  44466. import { Vector3 } from "babylonjs/Maths/math.vector";
  44467. import { Nullable } from "babylonjs/types";
  44468. import { Scene } from "babylonjs/scene";
  44469. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44470. /**
  44471. * The Axes viewer will show 3 axes in a specific point in space
  44472. */
  44473. export class AxesViewer {
  44474. private _xAxis;
  44475. private _yAxis;
  44476. private _zAxis;
  44477. private _scaleLinesFactor;
  44478. private _instanced;
  44479. /**
  44480. * Gets the hosting scene
  44481. */
  44482. scene: Scene;
  44483. /**
  44484. * Gets or sets a number used to scale line length
  44485. */
  44486. scaleLines: number;
  44487. /** Gets the node hierarchy used to render x-axis */
  44488. readonly xAxis: TransformNode;
  44489. /** Gets the node hierarchy used to render y-axis */
  44490. readonly yAxis: TransformNode;
  44491. /** Gets the node hierarchy used to render z-axis */
  44492. readonly zAxis: TransformNode;
  44493. /**
  44494. * Creates a new AxesViewer
  44495. * @param scene defines the hosting scene
  44496. * @param scaleLines defines a number used to scale line length (1 by default)
  44497. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44498. * @param xAxis defines the node hierarchy used to render the x-axis
  44499. * @param yAxis defines the node hierarchy used to render the y-axis
  44500. * @param zAxis defines the node hierarchy used to render the z-axis
  44501. */
  44502. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44503. /**
  44504. * Force the viewer to update
  44505. * @param position defines the position of the viewer
  44506. * @param xaxis defines the x axis of the viewer
  44507. * @param yaxis defines the y axis of the viewer
  44508. * @param zaxis defines the z axis of the viewer
  44509. */
  44510. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44511. /**
  44512. * Creates an instance of this axes viewer.
  44513. * @returns a new axes viewer with instanced meshes
  44514. */
  44515. createInstance(): AxesViewer;
  44516. /** Releases resources */
  44517. dispose(): void;
  44518. private static _SetRenderingGroupId;
  44519. }
  44520. }
  44521. declare module "babylonjs/Debug/boneAxesViewer" {
  44522. import { Nullable } from "babylonjs/types";
  44523. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44524. import { Vector3 } from "babylonjs/Maths/math.vector";
  44525. import { Mesh } from "babylonjs/Meshes/mesh";
  44526. import { Bone } from "babylonjs/Bones/bone";
  44527. import { Scene } from "babylonjs/scene";
  44528. /**
  44529. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44530. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44531. */
  44532. export class BoneAxesViewer extends AxesViewer {
  44533. /**
  44534. * Gets or sets the target mesh where to display the axes viewer
  44535. */
  44536. mesh: Nullable<Mesh>;
  44537. /**
  44538. * Gets or sets the target bone where to display the axes viewer
  44539. */
  44540. bone: Nullable<Bone>;
  44541. /** Gets current position */
  44542. pos: Vector3;
  44543. /** Gets direction of X axis */
  44544. xaxis: Vector3;
  44545. /** Gets direction of Y axis */
  44546. yaxis: Vector3;
  44547. /** Gets direction of Z axis */
  44548. zaxis: Vector3;
  44549. /**
  44550. * Creates a new BoneAxesViewer
  44551. * @param scene defines the hosting scene
  44552. * @param bone defines the target bone
  44553. * @param mesh defines the target mesh
  44554. * @param scaleLines defines a scaling factor for line length (1 by default)
  44555. */
  44556. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44557. /**
  44558. * Force the viewer to update
  44559. */
  44560. update(): void;
  44561. /** Releases resources */
  44562. dispose(): void;
  44563. }
  44564. }
  44565. declare module "babylonjs/Debug/debugLayer" {
  44566. import { Scene } from "babylonjs/scene";
  44567. /**
  44568. * Interface used to define scene explorer extensibility option
  44569. */
  44570. export interface IExplorerExtensibilityOption {
  44571. /**
  44572. * Define the option label
  44573. */
  44574. label: string;
  44575. /**
  44576. * Defines the action to execute on click
  44577. */
  44578. action: (entity: any) => void;
  44579. }
  44580. /**
  44581. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44582. */
  44583. export interface IExplorerExtensibilityGroup {
  44584. /**
  44585. * Defines a predicate to test if a given type mut be extended
  44586. */
  44587. predicate: (entity: any) => boolean;
  44588. /**
  44589. * Gets the list of options added to a type
  44590. */
  44591. entries: IExplorerExtensibilityOption[];
  44592. }
  44593. /**
  44594. * Interface used to define the options to use to create the Inspector
  44595. */
  44596. export interface IInspectorOptions {
  44597. /**
  44598. * Display in overlay mode (default: false)
  44599. */
  44600. overlay?: boolean;
  44601. /**
  44602. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44603. */
  44604. globalRoot?: HTMLElement;
  44605. /**
  44606. * Display the Scene explorer
  44607. */
  44608. showExplorer?: boolean;
  44609. /**
  44610. * Display the property inspector
  44611. */
  44612. showInspector?: boolean;
  44613. /**
  44614. * Display in embed mode (both panes on the right)
  44615. */
  44616. embedMode?: boolean;
  44617. /**
  44618. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44619. */
  44620. handleResize?: boolean;
  44621. /**
  44622. * Allow the panes to popup (default: true)
  44623. */
  44624. enablePopup?: boolean;
  44625. /**
  44626. * Allow the panes to be closed by users (default: true)
  44627. */
  44628. enableClose?: boolean;
  44629. /**
  44630. * Optional list of extensibility entries
  44631. */
  44632. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44633. /**
  44634. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44635. */
  44636. inspectorURL?: string;
  44637. }
  44638. module "babylonjs/scene" {
  44639. interface Scene {
  44640. /**
  44641. * @hidden
  44642. * Backing field
  44643. */
  44644. _debugLayer: DebugLayer;
  44645. /**
  44646. * Gets the debug layer (aka Inspector) associated with the scene
  44647. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44648. */
  44649. debugLayer: DebugLayer;
  44650. }
  44651. }
  44652. /**
  44653. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44654. * what is happening in your scene
  44655. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44656. */
  44657. export class DebugLayer {
  44658. /**
  44659. * Define the url to get the inspector script from.
  44660. * By default it uses the babylonjs CDN.
  44661. * @ignoreNaming
  44662. */
  44663. static InspectorURL: string;
  44664. private _scene;
  44665. private BJSINSPECTOR;
  44666. private _onPropertyChangedObservable?;
  44667. /**
  44668. * Observable triggered when a property is changed through the inspector.
  44669. */
  44670. readonly onPropertyChangedObservable: any;
  44671. /**
  44672. * Instantiates a new debug layer.
  44673. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44674. * what is happening in your scene
  44675. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44676. * @param scene Defines the scene to inspect
  44677. */
  44678. constructor(scene: Scene);
  44679. /** Creates the inspector window. */
  44680. private _createInspector;
  44681. /**
  44682. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44683. * @param entity defines the entity to select
  44684. * @param lineContainerTitle defines the specific block to highlight
  44685. */
  44686. select(entity: any, lineContainerTitle?: string): void;
  44687. /** Get the inspector from bundle or global */
  44688. private _getGlobalInspector;
  44689. /**
  44690. * Get if the inspector is visible or not.
  44691. * @returns true if visible otherwise, false
  44692. */
  44693. isVisible(): boolean;
  44694. /**
  44695. * Hide the inspector and close its window.
  44696. */
  44697. hide(): void;
  44698. /**
  44699. * Launch the debugLayer.
  44700. * @param config Define the configuration of the inspector
  44701. * @return a promise fulfilled when the debug layer is visible
  44702. */
  44703. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44704. }
  44705. }
  44706. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44707. import { Nullable } from "babylonjs/types";
  44708. import { Scene } from "babylonjs/scene";
  44709. import { Vector4 } from "babylonjs/Maths/math.vector";
  44710. import { Color4 } from "babylonjs/Maths/math.color";
  44711. import { Mesh } from "babylonjs/Meshes/mesh";
  44712. /**
  44713. * Class containing static functions to help procedurally build meshes
  44714. */
  44715. export class BoxBuilder {
  44716. /**
  44717. * Creates a box mesh
  44718. * * The parameter `size` sets the size (float) of each box side (default 1)
  44719. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44720. * * 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)
  44721. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44723. * * 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
  44724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44725. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44726. * @param name defines the name of the mesh
  44727. * @param options defines the options used to create the mesh
  44728. * @param scene defines the hosting scene
  44729. * @returns the box mesh
  44730. */
  44731. static CreateBox(name: string, options: {
  44732. size?: number;
  44733. width?: number;
  44734. height?: number;
  44735. depth?: number;
  44736. faceUV?: Vector4[];
  44737. faceColors?: Color4[];
  44738. sideOrientation?: number;
  44739. frontUVs?: Vector4;
  44740. backUVs?: Vector4;
  44741. wrap?: boolean;
  44742. topBaseAt?: number;
  44743. bottomBaseAt?: number;
  44744. updatable?: boolean;
  44745. }, scene?: Nullable<Scene>): Mesh;
  44746. }
  44747. }
  44748. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44749. import { Vector4 } from "babylonjs/Maths/math.vector";
  44750. import { Mesh } from "babylonjs/Meshes/mesh";
  44751. import { Scene } from "babylonjs/scene";
  44752. import { Nullable } from "babylonjs/types";
  44753. /**
  44754. * Class containing static functions to help procedurally build meshes
  44755. */
  44756. export class SphereBuilder {
  44757. /**
  44758. * Creates a sphere mesh
  44759. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44760. * * 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`)
  44761. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44762. * * 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
  44763. * * 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)
  44764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44765. * * 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
  44766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44767. * @param name defines the name of the mesh
  44768. * @param options defines the options used to create the mesh
  44769. * @param scene defines the hosting scene
  44770. * @returns the sphere mesh
  44771. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44772. */
  44773. static CreateSphere(name: string, options: {
  44774. segments?: number;
  44775. diameter?: number;
  44776. diameterX?: number;
  44777. diameterY?: number;
  44778. diameterZ?: number;
  44779. arc?: number;
  44780. slice?: number;
  44781. sideOrientation?: number;
  44782. frontUVs?: Vector4;
  44783. backUVs?: Vector4;
  44784. updatable?: boolean;
  44785. }, scene?: Nullable<Scene>): Mesh;
  44786. }
  44787. }
  44788. declare module "babylonjs/Debug/physicsViewer" {
  44789. import { Nullable } from "babylonjs/types";
  44790. import { Scene } from "babylonjs/scene";
  44791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44792. import { Mesh } from "babylonjs/Meshes/mesh";
  44793. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44794. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44795. /**
  44796. * Used to show the physics impostor around the specific mesh
  44797. */
  44798. export class PhysicsViewer {
  44799. /** @hidden */
  44800. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44801. /** @hidden */
  44802. protected _meshes: Array<Nullable<AbstractMesh>>;
  44803. /** @hidden */
  44804. protected _scene: Nullable<Scene>;
  44805. /** @hidden */
  44806. protected _numMeshes: number;
  44807. /** @hidden */
  44808. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44809. private _renderFunction;
  44810. private _utilityLayer;
  44811. private _debugBoxMesh;
  44812. private _debugSphereMesh;
  44813. private _debugCylinderMesh;
  44814. private _debugMaterial;
  44815. private _debugMeshMeshes;
  44816. /**
  44817. * Creates a new PhysicsViewer
  44818. * @param scene defines the hosting scene
  44819. */
  44820. constructor(scene: Scene);
  44821. /** @hidden */
  44822. protected _updateDebugMeshes(): void;
  44823. /**
  44824. * Renders a specified physic impostor
  44825. * @param impostor defines the impostor to render
  44826. * @param targetMesh defines the mesh represented by the impostor
  44827. * @returns the new debug mesh used to render the impostor
  44828. */
  44829. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44830. /**
  44831. * Hides a specified physic impostor
  44832. * @param impostor defines the impostor to hide
  44833. */
  44834. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44835. private _getDebugMaterial;
  44836. private _getDebugBoxMesh;
  44837. private _getDebugSphereMesh;
  44838. private _getDebugCylinderMesh;
  44839. private _getDebugMeshMesh;
  44840. private _getDebugMesh;
  44841. /** Releases all resources */
  44842. dispose(): void;
  44843. }
  44844. }
  44845. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44846. import { Vector3 } from "babylonjs/Maths/math.vector";
  44847. import { Color4 } from "babylonjs/Maths/math.color";
  44848. import { Nullable } from "babylonjs/types";
  44849. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44850. import { Scene } from "babylonjs/scene";
  44851. /**
  44852. * Class containing static functions to help procedurally build meshes
  44853. */
  44854. export class LinesBuilder {
  44855. /**
  44856. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44857. * * 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
  44858. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44859. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44860. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44861. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44862. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44863. * * 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
  44864. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44867. * @param name defines the name of the new line system
  44868. * @param options defines the options used to create the line system
  44869. * @param scene defines the hosting scene
  44870. * @returns a new line system mesh
  44871. */
  44872. static CreateLineSystem(name: string, options: {
  44873. lines: Vector3[][];
  44874. updatable?: boolean;
  44875. instance?: Nullable<LinesMesh>;
  44876. colors?: Nullable<Color4[][]>;
  44877. useVertexAlpha?: boolean;
  44878. }, scene: Nullable<Scene>): LinesMesh;
  44879. /**
  44880. * Creates a line mesh
  44881. * 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
  44882. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44883. * * The parameter `points` is an array successive Vector3
  44884. * * 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
  44885. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44886. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44887. * * When updating an instance, remember that only point positions can change, not the number of points
  44888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44890. * @param name defines the name of the new line system
  44891. * @param options defines the options used to create the line system
  44892. * @param scene defines the hosting scene
  44893. * @returns a new line mesh
  44894. */
  44895. static CreateLines(name: string, options: {
  44896. points: Vector3[];
  44897. updatable?: boolean;
  44898. instance?: Nullable<LinesMesh>;
  44899. colors?: Color4[];
  44900. useVertexAlpha?: boolean;
  44901. }, scene?: Nullable<Scene>): LinesMesh;
  44902. /**
  44903. * Creates a dashed line mesh
  44904. * * 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
  44905. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44906. * * The parameter `points` is an array successive Vector3
  44907. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44908. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44909. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44910. * * 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
  44911. * * When updating an instance, remember that only point positions can change, not the number of points
  44912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44913. * @param name defines the name of the mesh
  44914. * @param options defines the options used to create the mesh
  44915. * @param scene defines the hosting scene
  44916. * @returns the dashed line mesh
  44917. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44918. */
  44919. static CreateDashedLines(name: string, options: {
  44920. points: Vector3[];
  44921. dashSize?: number;
  44922. gapSize?: number;
  44923. dashNb?: number;
  44924. updatable?: boolean;
  44925. instance?: LinesMesh;
  44926. }, scene?: Nullable<Scene>): LinesMesh;
  44927. }
  44928. }
  44929. declare module "babylonjs/Debug/rayHelper" {
  44930. import { Nullable } from "babylonjs/types";
  44931. import { Ray } from "babylonjs/Culling/ray";
  44932. import { Vector3 } from "babylonjs/Maths/math.vector";
  44933. import { Color3 } from "babylonjs/Maths/math.color";
  44934. import { Scene } from "babylonjs/scene";
  44935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44936. import "babylonjs/Meshes/Builders/linesBuilder";
  44937. /**
  44938. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44939. * in order to better appreciate the issue one might have.
  44940. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44941. */
  44942. export class RayHelper {
  44943. /**
  44944. * Defines the ray we are currently tryin to visualize.
  44945. */
  44946. ray: Nullable<Ray>;
  44947. private _renderPoints;
  44948. private _renderLine;
  44949. private _renderFunction;
  44950. private _scene;
  44951. private _updateToMeshFunction;
  44952. private _attachedToMesh;
  44953. private _meshSpaceDirection;
  44954. private _meshSpaceOrigin;
  44955. /**
  44956. * Helper function to create a colored helper in a scene in one line.
  44957. * @param ray Defines the ray we are currently tryin to visualize
  44958. * @param scene Defines the scene the ray is used in
  44959. * @param color Defines the color we want to see the ray in
  44960. * @returns The newly created ray helper.
  44961. */
  44962. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44963. /**
  44964. * Instantiate a new ray helper.
  44965. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44966. * in order to better appreciate the issue one might have.
  44967. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44968. * @param ray Defines the ray we are currently tryin to visualize
  44969. */
  44970. constructor(ray: Ray);
  44971. /**
  44972. * Shows the ray we are willing to debug.
  44973. * @param scene Defines the scene the ray needs to be rendered in
  44974. * @param color Defines the color the ray needs to be rendered in
  44975. */
  44976. show(scene: Scene, color?: Color3): void;
  44977. /**
  44978. * Hides the ray we are debugging.
  44979. */
  44980. hide(): void;
  44981. private _render;
  44982. /**
  44983. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44984. * @param mesh Defines the mesh we want the helper attached to
  44985. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44986. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44987. * @param length Defines the length of the ray
  44988. */
  44989. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44990. /**
  44991. * Detach the ray helper from the mesh it has previously been attached to.
  44992. */
  44993. detachFromMesh(): void;
  44994. private _updateToMesh;
  44995. /**
  44996. * Dispose the helper and release its associated resources.
  44997. */
  44998. dispose(): void;
  44999. }
  45000. }
  45001. declare module "babylonjs/Debug/skeletonViewer" {
  45002. import { Color3 } from "babylonjs/Maths/math.color";
  45003. import { Scene } from "babylonjs/scene";
  45004. import { Nullable } from "babylonjs/types";
  45005. import { Skeleton } from "babylonjs/Bones/skeleton";
  45006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45007. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45008. /**
  45009. * Class used to render a debug view of a given skeleton
  45010. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45011. */
  45012. export class SkeletonViewer {
  45013. /** defines the skeleton to render */
  45014. skeleton: Skeleton;
  45015. /** defines the mesh attached to the skeleton */
  45016. mesh: AbstractMesh;
  45017. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45018. autoUpdateBonesMatrices: boolean;
  45019. /** defines the rendering group id to use with the viewer */
  45020. renderingGroupId: number;
  45021. /** Gets or sets the color used to render the skeleton */
  45022. color: Color3;
  45023. private _scene;
  45024. private _debugLines;
  45025. private _debugMesh;
  45026. private _isEnabled;
  45027. private _renderFunction;
  45028. private _utilityLayer;
  45029. /**
  45030. * Returns the mesh used to render the bones
  45031. */
  45032. readonly debugMesh: Nullable<LinesMesh>;
  45033. /**
  45034. * Creates a new SkeletonViewer
  45035. * @param skeleton defines the skeleton to render
  45036. * @param mesh defines the mesh attached to the skeleton
  45037. * @param scene defines the hosting scene
  45038. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45039. * @param renderingGroupId defines the rendering group id to use with the viewer
  45040. */
  45041. constructor(
  45042. /** defines the skeleton to render */
  45043. skeleton: Skeleton,
  45044. /** defines the mesh attached to the skeleton */
  45045. mesh: AbstractMesh, scene: Scene,
  45046. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45047. autoUpdateBonesMatrices?: boolean,
  45048. /** defines the rendering group id to use with the viewer */
  45049. renderingGroupId?: number);
  45050. /** Gets or sets a boolean indicating if the viewer is enabled */
  45051. isEnabled: boolean;
  45052. private _getBonePosition;
  45053. private _getLinesForBonesWithLength;
  45054. private _getLinesForBonesNoLength;
  45055. /** Update the viewer to sync with current skeleton state */
  45056. update(): void;
  45057. /** Release associated resources */
  45058. dispose(): void;
  45059. }
  45060. }
  45061. declare module "babylonjs/Debug/index" {
  45062. export * from "babylonjs/Debug/axesViewer";
  45063. export * from "babylonjs/Debug/boneAxesViewer";
  45064. export * from "babylonjs/Debug/debugLayer";
  45065. export * from "babylonjs/Debug/physicsViewer";
  45066. export * from "babylonjs/Debug/rayHelper";
  45067. export * from "babylonjs/Debug/skeletonViewer";
  45068. }
  45069. declare module "babylonjs/Engines/nullEngine" {
  45070. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45071. import { Scene } from "babylonjs/scene";
  45072. import { Engine } from "babylonjs/Engines/engine";
  45073. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45074. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45075. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45076. import { Effect } from "babylonjs/Materials/effect";
  45077. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45078. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45079. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45080. /**
  45081. * Options to create the null engine
  45082. */
  45083. export class NullEngineOptions {
  45084. /**
  45085. * Render width (Default: 512)
  45086. */
  45087. renderWidth: number;
  45088. /**
  45089. * Render height (Default: 256)
  45090. */
  45091. renderHeight: number;
  45092. /**
  45093. * Texture size (Default: 512)
  45094. */
  45095. textureSize: number;
  45096. /**
  45097. * If delta time between frames should be constant
  45098. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45099. */
  45100. deterministicLockstep: boolean;
  45101. /**
  45102. * Maximum about of steps between frames (Default: 4)
  45103. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45104. */
  45105. lockstepMaxSteps: number;
  45106. }
  45107. /**
  45108. * The null engine class provides support for headless version of babylon.js.
  45109. * This can be used in server side scenario or for testing purposes
  45110. */
  45111. export class NullEngine extends Engine {
  45112. private _options;
  45113. /**
  45114. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45115. */
  45116. isDeterministicLockStep(): boolean;
  45117. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45118. getLockstepMaxSteps(): number;
  45119. /**
  45120. * Sets hardware scaling, used to save performance if needed
  45121. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45122. */
  45123. getHardwareScalingLevel(): number;
  45124. constructor(options?: NullEngineOptions);
  45125. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45126. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45127. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45128. getRenderWidth(useScreen?: boolean): number;
  45129. getRenderHeight(useScreen?: boolean): number;
  45130. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45131. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45132. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45133. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45134. bindSamplers(effect: Effect): void;
  45135. enableEffect(effect: Effect): void;
  45136. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45137. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45138. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45139. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45140. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45141. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45142. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45143. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45144. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45145. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45146. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45147. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45148. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45149. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45150. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45151. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45152. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45153. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45154. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45155. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45156. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45157. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45158. bindBuffers(vertexBuffers: {
  45159. [key: string]: VertexBuffer;
  45160. }, indexBuffer: DataBuffer, effect: Effect): void;
  45161. wipeCaches(bruteForce?: boolean): void;
  45162. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45163. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45164. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45165. /** @hidden */
  45166. _createTexture(): WebGLTexture;
  45167. /** @hidden */
  45168. _releaseTexture(texture: InternalTexture): void;
  45169. 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;
  45170. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45171. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45172. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45173. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45174. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45175. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45176. areAllEffectsReady(): boolean;
  45177. /**
  45178. * @hidden
  45179. * Get the current error code of the webGL context
  45180. * @returns the error code
  45181. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45182. */
  45183. getError(): number;
  45184. /** @hidden */
  45185. _getUnpackAlignement(): number;
  45186. /** @hidden */
  45187. _unpackFlipY(value: boolean): void;
  45188. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45189. /**
  45190. * Updates a dynamic vertex buffer.
  45191. * @param vertexBuffer the vertex buffer to update
  45192. * @param data the data used to update the vertex buffer
  45193. * @param byteOffset the byte offset of the data (optional)
  45194. * @param byteLength the byte length of the data (optional)
  45195. */
  45196. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45197. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45198. /** @hidden */
  45199. _bindTexture(channel: number, texture: InternalTexture): void;
  45200. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45201. releaseEffects(): void;
  45202. displayLoadingUI(): void;
  45203. hideLoadingUI(): void;
  45204. /** @hidden */
  45205. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45206. /** @hidden */
  45207. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45208. /** @hidden */
  45209. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45210. /** @hidden */
  45211. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45212. }
  45213. }
  45214. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45215. import { Nullable, int } from "babylonjs/types";
  45216. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45217. /** @hidden */
  45218. export class _OcclusionDataStorage {
  45219. /** @hidden */
  45220. occlusionInternalRetryCounter: number;
  45221. /** @hidden */
  45222. isOcclusionQueryInProgress: boolean;
  45223. /** @hidden */
  45224. isOccluded: boolean;
  45225. /** @hidden */
  45226. occlusionRetryCount: number;
  45227. /** @hidden */
  45228. occlusionType: number;
  45229. /** @hidden */
  45230. occlusionQueryAlgorithmType: number;
  45231. }
  45232. module "babylonjs/Engines/engine" {
  45233. interface Engine {
  45234. /**
  45235. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45236. * @return the new query
  45237. */
  45238. createQuery(): WebGLQuery;
  45239. /**
  45240. * Delete and release a webGL query
  45241. * @param query defines the query to delete
  45242. * @return the current engine
  45243. */
  45244. deleteQuery(query: WebGLQuery): Engine;
  45245. /**
  45246. * Check if a given query has resolved and got its value
  45247. * @param query defines the query to check
  45248. * @returns true if the query got its value
  45249. */
  45250. isQueryResultAvailable(query: WebGLQuery): boolean;
  45251. /**
  45252. * Gets the value of a given query
  45253. * @param query defines the query to check
  45254. * @returns the value of the query
  45255. */
  45256. getQueryResult(query: WebGLQuery): number;
  45257. /**
  45258. * Initiates an occlusion query
  45259. * @param algorithmType defines the algorithm to use
  45260. * @param query defines the query to use
  45261. * @returns the current engine
  45262. * @see http://doc.babylonjs.com/features/occlusionquery
  45263. */
  45264. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45265. /**
  45266. * Ends an occlusion query
  45267. * @see http://doc.babylonjs.com/features/occlusionquery
  45268. * @param algorithmType defines the algorithm to use
  45269. * @returns the current engine
  45270. */
  45271. endOcclusionQuery(algorithmType: number): Engine;
  45272. /**
  45273. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45274. * Please note that only one query can be issued at a time
  45275. * @returns a time token used to track the time span
  45276. */
  45277. startTimeQuery(): Nullable<_TimeToken>;
  45278. /**
  45279. * Ends a time query
  45280. * @param token defines the token used to measure the time span
  45281. * @returns the time spent (in ns)
  45282. */
  45283. endTimeQuery(token: _TimeToken): int;
  45284. /** @hidden */
  45285. _currentNonTimestampToken: Nullable<_TimeToken>;
  45286. /** @hidden */
  45287. _createTimeQuery(): WebGLQuery;
  45288. /** @hidden */
  45289. _deleteTimeQuery(query: WebGLQuery): void;
  45290. /** @hidden */
  45291. _getGlAlgorithmType(algorithmType: number): number;
  45292. /** @hidden */
  45293. _getTimeQueryResult(query: WebGLQuery): any;
  45294. /** @hidden */
  45295. _getTimeQueryAvailability(query: WebGLQuery): any;
  45296. }
  45297. }
  45298. module "babylonjs/Meshes/abstractMesh" {
  45299. interface AbstractMesh {
  45300. /**
  45301. * Backing filed
  45302. * @hidden
  45303. */
  45304. __occlusionDataStorage: _OcclusionDataStorage;
  45305. /**
  45306. * Access property
  45307. * @hidden
  45308. */
  45309. _occlusionDataStorage: _OcclusionDataStorage;
  45310. /**
  45311. * 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.
  45312. * The default value is -1 which means don't break the query and wait till the result
  45313. * @see http://doc.babylonjs.com/features/occlusionquery
  45314. */
  45315. occlusionRetryCount: number;
  45316. /**
  45317. * 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:
  45318. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45319. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45320. * * 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.
  45321. * @see http://doc.babylonjs.com/features/occlusionquery
  45322. */
  45323. occlusionType: number;
  45324. /**
  45325. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45326. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45327. * * 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.
  45328. * @see http://doc.babylonjs.com/features/occlusionquery
  45329. */
  45330. occlusionQueryAlgorithmType: number;
  45331. /**
  45332. * 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
  45333. * @see http://doc.babylonjs.com/features/occlusionquery
  45334. */
  45335. isOccluded: boolean;
  45336. /**
  45337. * Flag to check the progress status of the query
  45338. * @see http://doc.babylonjs.com/features/occlusionquery
  45339. */
  45340. isOcclusionQueryInProgress: boolean;
  45341. }
  45342. }
  45343. }
  45344. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45345. import { Nullable } from "babylonjs/types";
  45346. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45347. /** @hidden */
  45348. export var _forceTransformFeedbackToBundle: boolean;
  45349. module "babylonjs/Engines/engine" {
  45350. interface Engine {
  45351. /**
  45352. * Creates a webGL transform feedback object
  45353. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45354. * @returns the webGL transform feedback object
  45355. */
  45356. createTransformFeedback(): WebGLTransformFeedback;
  45357. /**
  45358. * Delete a webGL transform feedback object
  45359. * @param value defines the webGL transform feedback object to delete
  45360. */
  45361. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45362. /**
  45363. * Bind a webGL transform feedback object to the webgl context
  45364. * @param value defines the webGL transform feedback object to bind
  45365. */
  45366. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45367. /**
  45368. * Begins a transform feedback operation
  45369. * @param usePoints defines if points or triangles must be used
  45370. */
  45371. beginTransformFeedback(usePoints: boolean): void;
  45372. /**
  45373. * Ends a transform feedback operation
  45374. */
  45375. endTransformFeedback(): void;
  45376. /**
  45377. * Specify the varyings to use with transform feedback
  45378. * @param program defines the associated webGL program
  45379. * @param value defines the list of strings representing the varying names
  45380. */
  45381. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45382. /**
  45383. * Bind a webGL buffer for a transform feedback operation
  45384. * @param value defines the webGL buffer to bind
  45385. */
  45386. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45387. }
  45388. }
  45389. }
  45390. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45391. import { Scene } from "babylonjs/scene";
  45392. import { Engine } from "babylonjs/Engines/engine";
  45393. import { Texture } from "babylonjs/Materials/Textures/texture";
  45394. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45395. import "babylonjs/Engines/Extensions/engine.multiRender";
  45396. /**
  45397. * Creation options of the multi render target texture.
  45398. */
  45399. export interface IMultiRenderTargetOptions {
  45400. /**
  45401. * Define if the texture needs to create mip maps after render.
  45402. */
  45403. generateMipMaps?: boolean;
  45404. /**
  45405. * Define the types of all the draw buffers we want to create
  45406. */
  45407. types?: number[];
  45408. /**
  45409. * Define the sampling modes of all the draw buffers we want to create
  45410. */
  45411. samplingModes?: number[];
  45412. /**
  45413. * Define if a depth buffer is required
  45414. */
  45415. generateDepthBuffer?: boolean;
  45416. /**
  45417. * Define if a stencil buffer is required
  45418. */
  45419. generateStencilBuffer?: boolean;
  45420. /**
  45421. * Define if a depth texture is required instead of a depth buffer
  45422. */
  45423. generateDepthTexture?: boolean;
  45424. /**
  45425. * Define the number of desired draw buffers
  45426. */
  45427. textureCount?: number;
  45428. /**
  45429. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45430. */
  45431. doNotChangeAspectRatio?: boolean;
  45432. /**
  45433. * Define the default type of the buffers we are creating
  45434. */
  45435. defaultType?: number;
  45436. }
  45437. /**
  45438. * A multi render target, like a render target provides the ability to render to a texture.
  45439. * Unlike the render target, it can render to several draw buffers in one draw.
  45440. * This is specially interesting in deferred rendering or for any effects requiring more than
  45441. * just one color from a single pass.
  45442. */
  45443. export class MultiRenderTarget extends RenderTargetTexture {
  45444. private _internalTextures;
  45445. private _textures;
  45446. private _multiRenderTargetOptions;
  45447. /**
  45448. * Get if draw buffers are currently supported by the used hardware and browser.
  45449. */
  45450. readonly isSupported: boolean;
  45451. /**
  45452. * Get the list of textures generated by the multi render target.
  45453. */
  45454. readonly textures: Texture[];
  45455. /**
  45456. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45457. */
  45458. readonly depthTexture: Texture;
  45459. /**
  45460. * Set the wrapping mode on U of all the textures we are rendering to.
  45461. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45462. */
  45463. wrapU: number;
  45464. /**
  45465. * Set the wrapping mode on V of all the textures we are rendering to.
  45466. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45467. */
  45468. wrapV: number;
  45469. /**
  45470. * Instantiate a new multi render target texture.
  45471. * A multi render target, like a render target provides the ability to render to a texture.
  45472. * Unlike the render target, it can render to several draw buffers in one draw.
  45473. * This is specially interesting in deferred rendering or for any effects requiring more than
  45474. * just one color from a single pass.
  45475. * @param name Define the name of the texture
  45476. * @param size Define the size of the buffers to render to
  45477. * @param count Define the number of target we are rendering into
  45478. * @param scene Define the scene the texture belongs to
  45479. * @param options Define the options used to create the multi render target
  45480. */
  45481. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45482. /** @hidden */
  45483. _rebuild(): void;
  45484. private _createInternalTextures;
  45485. private _createTextures;
  45486. /**
  45487. * Define the number of samples used if MSAA is enabled.
  45488. */
  45489. samples: number;
  45490. /**
  45491. * Resize all the textures in the multi render target.
  45492. * Be carrefull as it will recreate all the data in the new texture.
  45493. * @param size Define the new size
  45494. */
  45495. resize(size: any): void;
  45496. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45497. /**
  45498. * Dispose the render targets and their associated resources
  45499. */
  45500. dispose(): void;
  45501. /**
  45502. * Release all the underlying texture used as draw buffers.
  45503. */
  45504. releaseInternalTextures(): void;
  45505. }
  45506. }
  45507. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45508. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45509. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45510. import { Nullable } from "babylonjs/types";
  45511. module "babylonjs/Engines/engine" {
  45512. interface Engine {
  45513. /**
  45514. * Unbind a list of render target textures from the webGL context
  45515. * This is used only when drawBuffer extension or webGL2 are active
  45516. * @param textures defines the render target textures to unbind
  45517. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45518. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45519. */
  45520. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45521. /**
  45522. * Create a multi render target texture
  45523. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45524. * @param size defines the size of the texture
  45525. * @param options defines the creation options
  45526. * @returns the cube texture as an InternalTexture
  45527. */
  45528. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45529. /**
  45530. * Update the sample count for a given multiple render target texture
  45531. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45532. * @param textures defines the textures to update
  45533. * @param samples defines the sample count to set
  45534. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45535. */
  45536. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45537. }
  45538. }
  45539. }
  45540. declare module "babylonjs/Engines/Extensions/index" {
  45541. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45542. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45543. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45544. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45545. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45546. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45547. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45548. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45549. }
  45550. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45552. /** @hidden */
  45553. export var rgbdEncodePixelShader: {
  45554. name: string;
  45555. shader: string;
  45556. };
  45557. }
  45558. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45560. /** @hidden */
  45561. export var rgbdDecodePixelShader: {
  45562. name: string;
  45563. shader: string;
  45564. };
  45565. }
  45566. declare module "babylonjs/Misc/environmentTextureTools" {
  45567. import { Nullable } from "babylonjs/types";
  45568. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45570. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45571. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45572. import "babylonjs/Shaders/rgbdEncode.fragment";
  45573. import "babylonjs/Shaders/rgbdDecode.fragment";
  45574. /**
  45575. * Raw texture data and descriptor sufficient for WebGL texture upload
  45576. */
  45577. export interface EnvironmentTextureInfo {
  45578. /**
  45579. * Version of the environment map
  45580. */
  45581. version: number;
  45582. /**
  45583. * Width of image
  45584. */
  45585. width: number;
  45586. /**
  45587. * Irradiance information stored in the file.
  45588. */
  45589. irradiance: any;
  45590. /**
  45591. * Specular information stored in the file.
  45592. */
  45593. specular: any;
  45594. }
  45595. /**
  45596. * Defines One Image in the file. It requires only the position in the file
  45597. * as well as the length.
  45598. */
  45599. interface BufferImageData {
  45600. /**
  45601. * Length of the image data.
  45602. */
  45603. length: number;
  45604. /**
  45605. * Position of the data from the null terminator delimiting the end of the JSON.
  45606. */
  45607. position: number;
  45608. }
  45609. /**
  45610. * Defines the specular data enclosed in the file.
  45611. * This corresponds to the version 1 of the data.
  45612. */
  45613. export interface EnvironmentTextureSpecularInfoV1 {
  45614. /**
  45615. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45616. */
  45617. specularDataPosition?: number;
  45618. /**
  45619. * This contains all the images data needed to reconstruct the cubemap.
  45620. */
  45621. mipmaps: Array<BufferImageData>;
  45622. /**
  45623. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45624. */
  45625. lodGenerationScale: number;
  45626. }
  45627. /**
  45628. * Sets of helpers addressing the serialization and deserialization of environment texture
  45629. * stored in a BabylonJS env file.
  45630. * Those files are usually stored as .env files.
  45631. */
  45632. export class EnvironmentTextureTools {
  45633. /**
  45634. * Magic number identifying the env file.
  45635. */
  45636. private static _MagicBytes;
  45637. /**
  45638. * Gets the environment info from an env file.
  45639. * @param data The array buffer containing the .env bytes.
  45640. * @returns the environment file info (the json header) if successfully parsed.
  45641. */
  45642. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45643. /**
  45644. * Creates an environment texture from a loaded cube texture.
  45645. * @param texture defines the cube texture to convert in env file
  45646. * @return a promise containing the environment data if succesfull.
  45647. */
  45648. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45649. /**
  45650. * Creates a JSON representation of the spherical data.
  45651. * @param texture defines the texture containing the polynomials
  45652. * @return the JSON representation of the spherical info
  45653. */
  45654. private static _CreateEnvTextureIrradiance;
  45655. /**
  45656. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45657. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45658. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45659. * @return the views described by info providing access to the underlying buffer
  45660. */
  45661. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45662. /**
  45663. * Uploads the texture info contained in the env file to the GPU.
  45664. * @param texture defines the internal texture to upload to
  45665. * @param arrayBuffer defines the buffer cotaining the data to load
  45666. * @param info defines the texture info retrieved through the GetEnvInfo method
  45667. * @returns a promise
  45668. */
  45669. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45670. /**
  45671. * Uploads the levels of image data to the GPU.
  45672. * @param texture defines the internal texture to upload to
  45673. * @param imageData defines the array buffer views of image data [mipmap][face]
  45674. * @returns a promise
  45675. */
  45676. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45677. /**
  45678. * Uploads spherical polynomials information to the texture.
  45679. * @param texture defines the texture we are trying to upload the information to
  45680. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45681. */
  45682. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45683. /** @hidden */
  45684. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45685. }
  45686. }
  45687. declare module "babylonjs/Maths/math.vertexFormat" {
  45688. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45689. /**
  45690. * Contains position and normal vectors for a vertex
  45691. */
  45692. export class PositionNormalVertex {
  45693. /** the position of the vertex (defaut: 0,0,0) */
  45694. position: Vector3;
  45695. /** the normal of the vertex (defaut: 0,1,0) */
  45696. normal: Vector3;
  45697. /**
  45698. * Creates a PositionNormalVertex
  45699. * @param position the position of the vertex (defaut: 0,0,0)
  45700. * @param normal the normal of the vertex (defaut: 0,1,0)
  45701. */
  45702. constructor(
  45703. /** the position of the vertex (defaut: 0,0,0) */
  45704. position?: Vector3,
  45705. /** the normal of the vertex (defaut: 0,1,0) */
  45706. normal?: Vector3);
  45707. /**
  45708. * Clones the PositionNormalVertex
  45709. * @returns the cloned PositionNormalVertex
  45710. */
  45711. clone(): PositionNormalVertex;
  45712. }
  45713. /**
  45714. * Contains position, normal and uv vectors for a vertex
  45715. */
  45716. export class PositionNormalTextureVertex {
  45717. /** the position of the vertex (defaut: 0,0,0) */
  45718. position: Vector3;
  45719. /** the normal of the vertex (defaut: 0,1,0) */
  45720. normal: Vector3;
  45721. /** the uv of the vertex (default: 0,0) */
  45722. uv: Vector2;
  45723. /**
  45724. * Creates a PositionNormalTextureVertex
  45725. * @param position the position of the vertex (defaut: 0,0,0)
  45726. * @param normal the normal of the vertex (defaut: 0,1,0)
  45727. * @param uv the uv of the vertex (default: 0,0)
  45728. */
  45729. constructor(
  45730. /** the position of the vertex (defaut: 0,0,0) */
  45731. position?: Vector3,
  45732. /** the normal of the vertex (defaut: 0,1,0) */
  45733. normal?: Vector3,
  45734. /** the uv of the vertex (default: 0,0) */
  45735. uv?: Vector2);
  45736. /**
  45737. * Clones the PositionNormalTextureVertex
  45738. * @returns the cloned PositionNormalTextureVertex
  45739. */
  45740. clone(): PositionNormalTextureVertex;
  45741. }
  45742. }
  45743. declare module "babylonjs/Maths/math" {
  45744. export * from "babylonjs/Maths/math.axis";
  45745. export * from "babylonjs/Maths/math.color";
  45746. export * from "babylonjs/Maths/math.constants";
  45747. export * from "babylonjs/Maths/math.frustum";
  45748. export * from "babylonjs/Maths/math.path";
  45749. export * from "babylonjs/Maths/math.plane";
  45750. export * from "babylonjs/Maths/math.size";
  45751. export * from "babylonjs/Maths/math.vector";
  45752. export * from "babylonjs/Maths/math.vertexFormat";
  45753. export * from "babylonjs/Maths/math.viewport";
  45754. }
  45755. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45756. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45757. /** @hidden */
  45758. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45759. private _genericAttributeLocation;
  45760. private _varyingLocationCount;
  45761. private _varyingLocationMap;
  45762. private _replacements;
  45763. private _textureCount;
  45764. private _uniforms;
  45765. lineProcessor(line: string): string;
  45766. attributeProcessor(attribute: string): string;
  45767. varyingProcessor(varying: string, isFragment: boolean): string;
  45768. uniformProcessor(uniform: string): string;
  45769. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45770. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45771. }
  45772. }
  45773. declare module "babylonjs/Engines/nativeEngine" {
  45774. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45775. import { Engine } from "babylonjs/Engines/engine";
  45776. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45777. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45779. import { Effect } from "babylonjs/Materials/effect";
  45780. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45781. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45782. import { Scene } from "babylonjs/scene";
  45783. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45784. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45785. /**
  45786. * Container for accessors for natively-stored mesh data buffers.
  45787. */
  45788. class NativeDataBuffer extends DataBuffer {
  45789. /**
  45790. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45791. */
  45792. nativeIndexBuffer?: any;
  45793. /**
  45794. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45795. */
  45796. nativeVertexBuffer?: any;
  45797. }
  45798. /** @hidden */
  45799. export class NativeEngine extends Engine {
  45800. private readonly _native;
  45801. getHardwareScalingLevel(): number;
  45802. constructor();
  45803. /**
  45804. * Can be used to override the current requestAnimationFrame requester.
  45805. * @hidden
  45806. */
  45807. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45808. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45809. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45810. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45811. recordVertexArrayObject(vertexBuffers: {
  45812. [key: string]: VertexBuffer;
  45813. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45814. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45815. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45816. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45817. /**
  45818. * Draw a list of indexed primitives
  45819. * @param fillMode defines the primitive to use
  45820. * @param indexStart defines the starting index
  45821. * @param indexCount defines the number of index to draw
  45822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45823. */
  45824. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45825. /**
  45826. * Draw a list of unindexed primitives
  45827. * @param fillMode defines the primitive to use
  45828. * @param verticesStart defines the index of first vertex to draw
  45829. * @param verticesCount defines the count of vertices to draw
  45830. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45831. */
  45832. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45833. createPipelineContext(): IPipelineContext;
  45834. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45835. /** @hidden */
  45836. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45837. /** @hidden */
  45838. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45839. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45840. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45841. protected _setProgram(program: WebGLProgram): void;
  45842. _releaseEffect(effect: Effect): void;
  45843. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45844. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45845. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45846. bindSamplers(effect: Effect): void;
  45847. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45848. getRenderWidth(useScreen?: boolean): number;
  45849. getRenderHeight(useScreen?: boolean): number;
  45850. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45851. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45852. /**
  45853. * Set the z offset to apply to current rendering
  45854. * @param value defines the offset to apply
  45855. */
  45856. setZOffset(value: number): void;
  45857. /**
  45858. * Gets the current value of the zOffset
  45859. * @returns the current zOffset state
  45860. */
  45861. getZOffset(): number;
  45862. /**
  45863. * Enable or disable depth buffering
  45864. * @param enable defines the state to set
  45865. */
  45866. setDepthBuffer(enable: boolean): void;
  45867. /**
  45868. * Gets a boolean indicating if depth writing is enabled
  45869. * @returns the current depth writing state
  45870. */
  45871. getDepthWrite(): boolean;
  45872. /**
  45873. * Enable or disable depth writing
  45874. * @param enable defines the state to set
  45875. */
  45876. setDepthWrite(enable: boolean): void;
  45877. /**
  45878. * Enable or disable color writing
  45879. * @param enable defines the state to set
  45880. */
  45881. setColorWrite(enable: boolean): void;
  45882. /**
  45883. * Gets a boolean indicating if color writing is enabled
  45884. * @returns the current color writing state
  45885. */
  45886. getColorWrite(): boolean;
  45887. /**
  45888. * Sets alpha constants used by some alpha blending modes
  45889. * @param r defines the red component
  45890. * @param g defines the green component
  45891. * @param b defines the blue component
  45892. * @param a defines the alpha component
  45893. */
  45894. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45895. /**
  45896. * Sets the current alpha mode
  45897. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45898. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45899. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45900. */
  45901. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45902. /**
  45903. * Gets the current alpha mode
  45904. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45905. * @returns the current alpha mode
  45906. */
  45907. getAlphaMode(): number;
  45908. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45909. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45910. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45911. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45912. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45913. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45914. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45915. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45916. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45917. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45918. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45919. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45920. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45921. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45922. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45923. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45924. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45925. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45926. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45927. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45928. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45929. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45930. wipeCaches(bruteForce?: boolean): void;
  45931. _createTexture(): WebGLTexture;
  45932. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45933. /**
  45934. * Usually called from BABYLON.Texture.ts.
  45935. * Passed information to create a WebGLTexture
  45936. * @param urlArg defines a value which contains one of the following:
  45937. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45938. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45939. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45940. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45941. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45942. * @param scene needed for loading to the correct scene
  45943. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45944. * @param onLoad optional callback to be called upon successful completion
  45945. * @param onError optional callback to be called upon failure
  45946. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45947. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45948. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45949. * @param forcedExtension defines the extension to use to pick the right loader
  45950. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45951. */
  45952. 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;
  45953. /**
  45954. * Creates a cube texture
  45955. * @param rootUrl defines the url where the files to load is located
  45956. * @param scene defines the current scene
  45957. * @param files defines the list of files to load (1 per face)
  45958. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45959. * @param onLoad defines an optional callback raised when the texture is loaded
  45960. * @param onError defines an optional callback raised if there is an issue to load the texture
  45961. * @param format defines the format of the data
  45962. * @param forcedExtension defines the extension to use to pick the right loader
  45963. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45964. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45965. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45966. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45967. * @returns the cube texture as an InternalTexture
  45968. */
  45969. 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;
  45970. private _getSamplingFilter;
  45971. private static _GetNativeTextureFormat;
  45972. createRenderTargetTexture(size: number | {
  45973. width: number;
  45974. height: number;
  45975. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45976. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45977. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45978. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45979. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45980. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45981. /**
  45982. * Updates a dynamic vertex buffer.
  45983. * @param vertexBuffer the vertex buffer to update
  45984. * @param data the data used to update the vertex buffer
  45985. * @param byteOffset the byte offset of the data (optional)
  45986. * @param byteLength the byte length of the data (optional)
  45987. */
  45988. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  45989. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  45990. private _updateAnisotropicLevel;
  45991. private _getAddressMode;
  45992. /** @hidden */
  45993. _bindTexture(channel: number, texture: InternalTexture): void;
  45994. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  45995. releaseEffects(): void;
  45996. /** @hidden */
  45997. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45998. /** @hidden */
  45999. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46000. /** @hidden */
  46001. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46002. /** @hidden */
  46003. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46004. }
  46005. }
  46006. declare module "babylonjs/Engines/index" {
  46007. export * from "babylonjs/Engines/constants";
  46008. export * from "babylonjs/Engines/engine";
  46009. export * from "babylonjs/Engines/engineStore";
  46010. export * from "babylonjs/Engines/nullEngine";
  46011. export * from "babylonjs/Engines/Extensions/index";
  46012. export * from "babylonjs/Engines/IPipelineContext";
  46013. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46014. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46015. export * from "babylonjs/Engines/nativeEngine";
  46016. }
  46017. declare module "babylonjs/Events/clipboardEvents" {
  46018. /**
  46019. * Gather the list of clipboard event types as constants.
  46020. */
  46021. export class ClipboardEventTypes {
  46022. /**
  46023. * The clipboard event is fired when a copy command is active (pressed).
  46024. */
  46025. static readonly COPY: number;
  46026. /**
  46027. * The clipboard event is fired when a cut command is active (pressed).
  46028. */
  46029. static readonly CUT: number;
  46030. /**
  46031. * The clipboard event is fired when a paste command is active (pressed).
  46032. */
  46033. static readonly PASTE: number;
  46034. }
  46035. /**
  46036. * This class is used to store clipboard related info for the onClipboardObservable event.
  46037. */
  46038. export class ClipboardInfo {
  46039. /**
  46040. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46041. */
  46042. type: number;
  46043. /**
  46044. * Defines the related dom event
  46045. */
  46046. event: ClipboardEvent;
  46047. /**
  46048. *Creates an instance of ClipboardInfo.
  46049. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46050. * @param event Defines the related dom event
  46051. */
  46052. constructor(
  46053. /**
  46054. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46055. */
  46056. type: number,
  46057. /**
  46058. * Defines the related dom event
  46059. */
  46060. event: ClipboardEvent);
  46061. /**
  46062. * Get the clipboard event's type from the keycode.
  46063. * @param keyCode Defines the keyCode for the current keyboard event.
  46064. * @return {number}
  46065. */
  46066. static GetTypeFromCharacter(keyCode: number): number;
  46067. }
  46068. }
  46069. declare module "babylonjs/Events/index" {
  46070. export * from "babylonjs/Events/keyboardEvents";
  46071. export * from "babylonjs/Events/pointerEvents";
  46072. export * from "babylonjs/Events/clipboardEvents";
  46073. }
  46074. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46075. import { Scene } from "babylonjs/scene";
  46076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46077. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46078. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46079. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46080. /**
  46081. * Google Daydream controller
  46082. */
  46083. export class DaydreamController extends WebVRController {
  46084. /**
  46085. * Base Url for the controller model.
  46086. */
  46087. static MODEL_BASE_URL: string;
  46088. /**
  46089. * File name for the controller model.
  46090. */
  46091. static MODEL_FILENAME: string;
  46092. /**
  46093. * Gamepad Id prefix used to identify Daydream Controller.
  46094. */
  46095. static readonly GAMEPAD_ID_PREFIX: string;
  46096. /**
  46097. * Creates a new DaydreamController from a gamepad
  46098. * @param vrGamepad the gamepad that the controller should be created from
  46099. */
  46100. constructor(vrGamepad: any);
  46101. /**
  46102. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46103. * @param scene scene in which to add meshes
  46104. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46105. */
  46106. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46107. /**
  46108. * Called once for each button that changed state since the last frame
  46109. * @param buttonIdx Which button index changed
  46110. * @param state New state of the button
  46111. * @param changes Which properties on the state changed since last frame
  46112. */
  46113. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46114. }
  46115. }
  46116. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46117. import { Scene } from "babylonjs/scene";
  46118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46119. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46120. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46121. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46122. /**
  46123. * Gear VR Controller
  46124. */
  46125. export class GearVRController extends WebVRController {
  46126. /**
  46127. * Base Url for the controller model.
  46128. */
  46129. static MODEL_BASE_URL: string;
  46130. /**
  46131. * File name for the controller model.
  46132. */
  46133. static MODEL_FILENAME: string;
  46134. /**
  46135. * Gamepad Id prefix used to identify this controller.
  46136. */
  46137. static readonly GAMEPAD_ID_PREFIX: string;
  46138. private readonly _buttonIndexToObservableNameMap;
  46139. /**
  46140. * Creates a new GearVRController from a gamepad
  46141. * @param vrGamepad the gamepad that the controller should be created from
  46142. */
  46143. constructor(vrGamepad: any);
  46144. /**
  46145. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46146. * @param scene scene in which to add meshes
  46147. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46148. */
  46149. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46150. /**
  46151. * Called once for each button that changed state since the last frame
  46152. * @param buttonIdx Which button index changed
  46153. * @param state New state of the button
  46154. * @param changes Which properties on the state changed since last frame
  46155. */
  46156. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46157. }
  46158. }
  46159. declare module "babylonjs/Gamepads/Controllers/index" {
  46160. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46161. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46162. export * from "babylonjs/Gamepads/Controllers/genericController";
  46163. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46164. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46165. export * from "babylonjs/Gamepads/Controllers/viveController";
  46166. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46167. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46168. }
  46169. declare module "babylonjs/Gamepads/index" {
  46170. export * from "babylonjs/Gamepads/Controllers/index";
  46171. export * from "babylonjs/Gamepads/gamepad";
  46172. export * from "babylonjs/Gamepads/gamepadManager";
  46173. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46174. export * from "babylonjs/Gamepads/xboxGamepad";
  46175. export * from "babylonjs/Gamepads/dualShockGamepad";
  46176. }
  46177. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46178. import { Scene } from "babylonjs/scene";
  46179. import { Vector4 } from "babylonjs/Maths/math.vector";
  46180. import { Color4 } from "babylonjs/Maths/math.color";
  46181. import { Mesh } from "babylonjs/Meshes/mesh";
  46182. import { Nullable } from "babylonjs/types";
  46183. /**
  46184. * Class containing static functions to help procedurally build meshes
  46185. */
  46186. export class PolyhedronBuilder {
  46187. /**
  46188. * Creates a polyhedron mesh
  46189. * * 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
  46190. * * The parameter `size` (positive float, default 1) sets the polygon size
  46191. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46192. * * 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`
  46193. * * 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
  46194. * * 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)`)
  46195. * * 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
  46196. * * 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
  46197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46198. * * 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
  46199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46200. * @param name defines the name of the mesh
  46201. * @param options defines the options used to create the mesh
  46202. * @param scene defines the hosting scene
  46203. * @returns the polyhedron mesh
  46204. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46205. */
  46206. static CreatePolyhedron(name: string, options: {
  46207. type?: number;
  46208. size?: number;
  46209. sizeX?: number;
  46210. sizeY?: number;
  46211. sizeZ?: number;
  46212. custom?: any;
  46213. faceUV?: Vector4[];
  46214. faceColors?: Color4[];
  46215. flat?: boolean;
  46216. updatable?: boolean;
  46217. sideOrientation?: number;
  46218. frontUVs?: Vector4;
  46219. backUVs?: Vector4;
  46220. }, scene?: Nullable<Scene>): Mesh;
  46221. }
  46222. }
  46223. declare module "babylonjs/Gizmos/scaleGizmo" {
  46224. import { Observable } from "babylonjs/Misc/observable";
  46225. import { Nullable } from "babylonjs/types";
  46226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46227. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46228. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46229. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46230. /**
  46231. * Gizmo that enables scaling a mesh along 3 axis
  46232. */
  46233. export class ScaleGizmo extends Gizmo {
  46234. /**
  46235. * Internal gizmo used for interactions on the x axis
  46236. */
  46237. xGizmo: AxisScaleGizmo;
  46238. /**
  46239. * Internal gizmo used for interactions on the y axis
  46240. */
  46241. yGizmo: AxisScaleGizmo;
  46242. /**
  46243. * Internal gizmo used for interactions on the z axis
  46244. */
  46245. zGizmo: AxisScaleGizmo;
  46246. /**
  46247. * Internal gizmo used to scale all axis equally
  46248. */
  46249. uniformScaleGizmo: AxisScaleGizmo;
  46250. private _meshAttached;
  46251. private _updateGizmoRotationToMatchAttachedMesh;
  46252. private _snapDistance;
  46253. private _scaleRatio;
  46254. private _uniformScalingMesh;
  46255. private _octahedron;
  46256. /** Fires an event when any of it's sub gizmos are dragged */
  46257. onDragStartObservable: Observable<unknown>;
  46258. /** Fires an event when any of it's sub gizmos are released from dragging */
  46259. onDragEndObservable: Observable<unknown>;
  46260. attachedMesh: Nullable<AbstractMesh>;
  46261. /**
  46262. * Creates a ScaleGizmo
  46263. * @param gizmoLayer The utility layer the gizmo will be added to
  46264. */
  46265. constructor(gizmoLayer?: UtilityLayerRenderer);
  46266. updateGizmoRotationToMatchAttachedMesh: boolean;
  46267. /**
  46268. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46269. */
  46270. snapDistance: number;
  46271. /**
  46272. * Ratio for the scale of the gizmo (Default: 1)
  46273. */
  46274. scaleRatio: number;
  46275. /**
  46276. * Disposes of the gizmo
  46277. */
  46278. dispose(): void;
  46279. }
  46280. }
  46281. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46282. import { Observable } from "babylonjs/Misc/observable";
  46283. import { Nullable } from "babylonjs/types";
  46284. import { Vector3 } from "babylonjs/Maths/math.vector";
  46285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46286. import { Mesh } from "babylonjs/Meshes/mesh";
  46287. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46288. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46289. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46290. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46291. import { Color3 } from "babylonjs/Maths/math.color";
  46292. /**
  46293. * Single axis scale gizmo
  46294. */
  46295. export class AxisScaleGizmo extends Gizmo {
  46296. /**
  46297. * Drag behavior responsible for the gizmos dragging interactions
  46298. */
  46299. dragBehavior: PointerDragBehavior;
  46300. private _pointerObserver;
  46301. /**
  46302. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46303. */
  46304. snapDistance: number;
  46305. /**
  46306. * Event that fires each time the gizmo snaps to a new location.
  46307. * * snapDistance is the the change in distance
  46308. */
  46309. onSnapObservable: Observable<{
  46310. snapDistance: number;
  46311. }>;
  46312. /**
  46313. * If the scaling operation should be done on all axis (default: false)
  46314. */
  46315. uniformScaling: boolean;
  46316. private _isEnabled;
  46317. private _parent;
  46318. private _arrow;
  46319. private _coloredMaterial;
  46320. private _hoverMaterial;
  46321. /**
  46322. * Creates an AxisScaleGizmo
  46323. * @param gizmoLayer The utility layer the gizmo will be added to
  46324. * @param dragAxis The axis which the gizmo will be able to scale on
  46325. * @param color The color of the gizmo
  46326. */
  46327. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46328. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46329. /**
  46330. * If the gizmo is enabled
  46331. */
  46332. isEnabled: boolean;
  46333. /**
  46334. * Disposes of the gizmo
  46335. */
  46336. dispose(): void;
  46337. /**
  46338. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46339. * @param mesh The mesh to replace the default mesh of the gizmo
  46340. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46341. */
  46342. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46343. }
  46344. }
  46345. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46346. import { Observable } from "babylonjs/Misc/observable";
  46347. import { Nullable } from "babylonjs/types";
  46348. import { Vector3 } from "babylonjs/Maths/math.vector";
  46349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46350. import { Mesh } from "babylonjs/Meshes/mesh";
  46351. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46352. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46353. import { Color3 } from "babylonjs/Maths/math.color";
  46354. import "babylonjs/Meshes/Builders/boxBuilder";
  46355. /**
  46356. * Bounding box gizmo
  46357. */
  46358. export class BoundingBoxGizmo extends Gizmo {
  46359. private _lineBoundingBox;
  46360. private _rotateSpheresParent;
  46361. private _scaleBoxesParent;
  46362. private _boundingDimensions;
  46363. private _renderObserver;
  46364. private _pointerObserver;
  46365. private _scaleDragSpeed;
  46366. private _tmpQuaternion;
  46367. private _tmpVector;
  46368. private _tmpRotationMatrix;
  46369. /**
  46370. * 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)
  46371. */
  46372. ignoreChildren: boolean;
  46373. /**
  46374. * 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)
  46375. */
  46376. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46377. /**
  46378. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46379. */
  46380. rotationSphereSize: number;
  46381. /**
  46382. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46383. */
  46384. scaleBoxSize: number;
  46385. /**
  46386. * 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)
  46387. */
  46388. fixedDragMeshScreenSize: boolean;
  46389. /**
  46390. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46391. */
  46392. fixedDragMeshScreenSizeDistanceFactor: number;
  46393. /**
  46394. * Fired when a rotation sphere or scale box is dragged
  46395. */
  46396. onDragStartObservable: Observable<{}>;
  46397. /**
  46398. * Fired when a scale box is dragged
  46399. */
  46400. onScaleBoxDragObservable: Observable<{}>;
  46401. /**
  46402. * Fired when a scale box drag is ended
  46403. */
  46404. onScaleBoxDragEndObservable: Observable<{}>;
  46405. /**
  46406. * Fired when a rotation sphere is dragged
  46407. */
  46408. onRotationSphereDragObservable: Observable<{}>;
  46409. /**
  46410. * Fired when a rotation sphere drag is ended
  46411. */
  46412. onRotationSphereDragEndObservable: Observable<{}>;
  46413. /**
  46414. * 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)
  46415. */
  46416. scalePivot: Nullable<Vector3>;
  46417. /**
  46418. * Mesh used as a pivot to rotate the attached mesh
  46419. */
  46420. private _anchorMesh;
  46421. private _existingMeshScale;
  46422. private _dragMesh;
  46423. private pointerDragBehavior;
  46424. private coloredMaterial;
  46425. private hoverColoredMaterial;
  46426. /**
  46427. * Sets the color of the bounding box gizmo
  46428. * @param color the color to set
  46429. */
  46430. setColor(color: Color3): void;
  46431. /**
  46432. * Creates an BoundingBoxGizmo
  46433. * @param gizmoLayer The utility layer the gizmo will be added to
  46434. * @param color The color of the gizmo
  46435. */
  46436. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46437. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46438. private _selectNode;
  46439. /**
  46440. * Updates the bounding box information for the Gizmo
  46441. */
  46442. updateBoundingBox(): void;
  46443. private _updateRotationSpheres;
  46444. private _updateScaleBoxes;
  46445. /**
  46446. * Enables rotation on the specified axis and disables rotation on the others
  46447. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46448. */
  46449. setEnabledRotationAxis(axis: string): void;
  46450. /**
  46451. * Enables/disables scaling
  46452. * @param enable if scaling should be enabled
  46453. */
  46454. setEnabledScaling(enable: boolean): void;
  46455. private _updateDummy;
  46456. /**
  46457. * Enables a pointer drag behavior on the bounding box of the gizmo
  46458. */
  46459. enableDragBehavior(): void;
  46460. /**
  46461. * Disposes of the gizmo
  46462. */
  46463. dispose(): void;
  46464. /**
  46465. * 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)
  46466. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46467. * @returns the bounding box mesh with the passed in mesh as a child
  46468. */
  46469. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46470. /**
  46471. * CustomMeshes are not supported by this gizmo
  46472. * @param mesh The mesh to replace the default mesh of the gizmo
  46473. */
  46474. setCustomMesh(mesh: Mesh): void;
  46475. }
  46476. }
  46477. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46478. import { Observable } from "babylonjs/Misc/observable";
  46479. import { Nullable } from "babylonjs/types";
  46480. import { Vector3 } from "babylonjs/Maths/math.vector";
  46481. import { Color3 } from "babylonjs/Maths/math.color";
  46482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46483. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46484. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46485. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46486. import "babylonjs/Meshes/Builders/linesBuilder";
  46487. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46488. /**
  46489. * Single plane rotation gizmo
  46490. */
  46491. export class PlaneRotationGizmo extends Gizmo {
  46492. /**
  46493. * Drag behavior responsible for the gizmos dragging interactions
  46494. */
  46495. dragBehavior: PointerDragBehavior;
  46496. private _pointerObserver;
  46497. /**
  46498. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46499. */
  46500. snapDistance: number;
  46501. /**
  46502. * Event that fires each time the gizmo snaps to a new location.
  46503. * * snapDistance is the the change in distance
  46504. */
  46505. onSnapObservable: Observable<{
  46506. snapDistance: number;
  46507. }>;
  46508. private _isEnabled;
  46509. private _parent;
  46510. /**
  46511. * Creates a PlaneRotationGizmo
  46512. * @param gizmoLayer The utility layer the gizmo will be added to
  46513. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46514. * @param color The color of the gizmo
  46515. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46516. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46517. */
  46518. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46519. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46520. /**
  46521. * If the gizmo is enabled
  46522. */
  46523. isEnabled: boolean;
  46524. /**
  46525. * Disposes of the gizmo
  46526. */
  46527. dispose(): void;
  46528. }
  46529. }
  46530. declare module "babylonjs/Gizmos/rotationGizmo" {
  46531. import { Observable } from "babylonjs/Misc/observable";
  46532. import { Nullable } from "babylonjs/types";
  46533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46534. import { Mesh } from "babylonjs/Meshes/mesh";
  46535. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46536. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46537. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46538. /**
  46539. * Gizmo that enables rotating a mesh along 3 axis
  46540. */
  46541. export class RotationGizmo extends Gizmo {
  46542. /**
  46543. * Internal gizmo used for interactions on the x axis
  46544. */
  46545. xGizmo: PlaneRotationGizmo;
  46546. /**
  46547. * Internal gizmo used for interactions on the y axis
  46548. */
  46549. yGizmo: PlaneRotationGizmo;
  46550. /**
  46551. * Internal gizmo used for interactions on the z axis
  46552. */
  46553. zGizmo: PlaneRotationGizmo;
  46554. /** Fires an event when any of it's sub gizmos are dragged */
  46555. onDragStartObservable: Observable<unknown>;
  46556. /** Fires an event when any of it's sub gizmos are released from dragging */
  46557. onDragEndObservable: Observable<unknown>;
  46558. private _meshAttached;
  46559. attachedMesh: Nullable<AbstractMesh>;
  46560. /**
  46561. * Creates a RotationGizmo
  46562. * @param gizmoLayer The utility layer the gizmo will be added to
  46563. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46564. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46565. */
  46566. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46567. updateGizmoRotationToMatchAttachedMesh: boolean;
  46568. /**
  46569. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46570. */
  46571. snapDistance: number;
  46572. /**
  46573. * Ratio for the scale of the gizmo (Default: 1)
  46574. */
  46575. scaleRatio: number;
  46576. /**
  46577. * Disposes of the gizmo
  46578. */
  46579. dispose(): void;
  46580. /**
  46581. * CustomMeshes are not supported by this gizmo
  46582. * @param mesh The mesh to replace the default mesh of the gizmo
  46583. */
  46584. setCustomMesh(mesh: Mesh): void;
  46585. }
  46586. }
  46587. declare module "babylonjs/Gizmos/gizmoManager" {
  46588. import { Observable } from "babylonjs/Misc/observable";
  46589. import { Nullable } from "babylonjs/types";
  46590. import { Scene, IDisposable } from "babylonjs/scene";
  46591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46592. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46593. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46594. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46595. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46596. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46597. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46598. /**
  46599. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46600. */
  46601. export class GizmoManager implements IDisposable {
  46602. private scene;
  46603. /**
  46604. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46605. */
  46606. gizmos: {
  46607. positionGizmo: Nullable<PositionGizmo>;
  46608. rotationGizmo: Nullable<RotationGizmo>;
  46609. scaleGizmo: Nullable<ScaleGizmo>;
  46610. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46611. };
  46612. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46613. clearGizmoOnEmptyPointerEvent: boolean;
  46614. /** Fires an event when the manager is attached to a mesh */
  46615. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46616. private _gizmosEnabled;
  46617. private _pointerObserver;
  46618. private _attachedMesh;
  46619. private _boundingBoxColor;
  46620. private _defaultUtilityLayer;
  46621. private _defaultKeepDepthUtilityLayer;
  46622. /**
  46623. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46624. */
  46625. boundingBoxDragBehavior: SixDofDragBehavior;
  46626. /**
  46627. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46628. */
  46629. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46630. /**
  46631. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46632. */
  46633. usePointerToAttachGizmos: boolean;
  46634. /**
  46635. * Utility layer that the bounding box gizmo belongs to
  46636. */
  46637. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46638. /**
  46639. * Utility layer that all gizmos besides bounding box belong to
  46640. */
  46641. readonly utilityLayer: UtilityLayerRenderer;
  46642. /**
  46643. * Instatiates a gizmo manager
  46644. * @param scene the scene to overlay the gizmos on top of
  46645. */
  46646. constructor(scene: Scene);
  46647. /**
  46648. * Attaches a set of gizmos to the specified mesh
  46649. * @param mesh The mesh the gizmo's should be attached to
  46650. */
  46651. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46652. /**
  46653. * If the position gizmo is enabled
  46654. */
  46655. positionGizmoEnabled: boolean;
  46656. /**
  46657. * If the rotation gizmo is enabled
  46658. */
  46659. rotationGizmoEnabled: boolean;
  46660. /**
  46661. * If the scale gizmo is enabled
  46662. */
  46663. scaleGizmoEnabled: boolean;
  46664. /**
  46665. * If the boundingBox gizmo is enabled
  46666. */
  46667. boundingBoxGizmoEnabled: boolean;
  46668. /**
  46669. * Disposes of the gizmo manager
  46670. */
  46671. dispose(): void;
  46672. }
  46673. }
  46674. declare module "babylonjs/Lights/directionalLight" {
  46675. import { Camera } from "babylonjs/Cameras/camera";
  46676. import { Scene } from "babylonjs/scene";
  46677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46679. import { Light } from "babylonjs/Lights/light";
  46680. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46681. import { Effect } from "babylonjs/Materials/effect";
  46682. /**
  46683. * A directional light is defined by a direction (what a surprise!).
  46684. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46685. * 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.
  46686. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46687. */
  46688. export class DirectionalLight extends ShadowLight {
  46689. private _shadowFrustumSize;
  46690. /**
  46691. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46692. */
  46693. /**
  46694. * Specifies a fix frustum size for the shadow generation.
  46695. */
  46696. shadowFrustumSize: number;
  46697. private _shadowOrthoScale;
  46698. /**
  46699. * Gets the shadow projection scale against the optimal computed one.
  46700. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46701. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46702. */
  46703. /**
  46704. * Sets the shadow projection scale against the optimal computed one.
  46705. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46706. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46707. */
  46708. shadowOrthoScale: number;
  46709. /**
  46710. * Automatically compute the projection matrix to best fit (including all the casters)
  46711. * on each frame.
  46712. */
  46713. autoUpdateExtends: boolean;
  46714. private _orthoLeft;
  46715. private _orthoRight;
  46716. private _orthoTop;
  46717. private _orthoBottom;
  46718. /**
  46719. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46720. * The directional light is emitted from everywhere in the given direction.
  46721. * It can cast shadows.
  46722. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46723. * @param name The friendly name of the light
  46724. * @param direction The direction of the light
  46725. * @param scene The scene the light belongs to
  46726. */
  46727. constructor(name: string, direction: Vector3, scene: Scene);
  46728. /**
  46729. * Returns the string "DirectionalLight".
  46730. * @return The class name
  46731. */
  46732. getClassName(): string;
  46733. /**
  46734. * Returns the integer 1.
  46735. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46736. */
  46737. getTypeID(): number;
  46738. /**
  46739. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46740. * Returns the DirectionalLight Shadow projection matrix.
  46741. */
  46742. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46743. /**
  46744. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46745. * Returns the DirectionalLight Shadow projection matrix.
  46746. */
  46747. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46748. /**
  46749. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46750. * Returns the DirectionalLight Shadow projection matrix.
  46751. */
  46752. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46753. protected _buildUniformLayout(): void;
  46754. /**
  46755. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46756. * @param effect The effect to update
  46757. * @param lightIndex The index of the light in the effect to update
  46758. * @returns The directional light
  46759. */
  46760. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46761. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46762. /**
  46763. * Gets the minZ used for shadow according to both the scene and the light.
  46764. *
  46765. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46766. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46767. * @param activeCamera The camera we are returning the min for
  46768. * @returns the depth min z
  46769. */
  46770. getDepthMinZ(activeCamera: Camera): number;
  46771. /**
  46772. * Gets the maxZ used for shadow according to both the scene and the light.
  46773. *
  46774. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46775. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46776. * @param activeCamera The camera we are returning the max for
  46777. * @returns the depth max z
  46778. */
  46779. getDepthMaxZ(activeCamera: Camera): number;
  46780. /**
  46781. * Prepares the list of defines specific to the light type.
  46782. * @param defines the list of defines
  46783. * @param lightIndex defines the index of the light for the effect
  46784. */
  46785. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46786. }
  46787. }
  46788. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46789. import { Mesh } from "babylonjs/Meshes/mesh";
  46790. /**
  46791. * Class containing static functions to help procedurally build meshes
  46792. */
  46793. export class HemisphereBuilder {
  46794. /**
  46795. * Creates a hemisphere mesh
  46796. * @param name defines the name of the mesh
  46797. * @param options defines the options used to create the mesh
  46798. * @param scene defines the hosting scene
  46799. * @returns the hemisphere mesh
  46800. */
  46801. static CreateHemisphere(name: string, options: {
  46802. segments?: number;
  46803. diameter?: number;
  46804. sideOrientation?: number;
  46805. }, scene: any): Mesh;
  46806. }
  46807. }
  46808. declare module "babylonjs/Lights/spotLight" {
  46809. import { Nullable } from "babylonjs/types";
  46810. import { Scene } from "babylonjs/scene";
  46811. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46813. import { Effect } from "babylonjs/Materials/effect";
  46814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46815. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46816. /**
  46817. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46818. * These values define a cone of light starting from the position, emitting toward the direction.
  46819. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46820. * and the exponent defines the speed of the decay of the light with distance (reach).
  46821. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46822. */
  46823. export class SpotLight extends ShadowLight {
  46824. private _angle;
  46825. private _innerAngle;
  46826. private _cosHalfAngle;
  46827. private _lightAngleScale;
  46828. private _lightAngleOffset;
  46829. /**
  46830. * Gets the cone angle of the spot light in Radians.
  46831. */
  46832. /**
  46833. * Sets the cone angle of the spot light in Radians.
  46834. */
  46835. angle: number;
  46836. /**
  46837. * Only used in gltf falloff mode, this defines the angle where
  46838. * the directional falloff will start before cutting at angle which could be seen
  46839. * as outer angle.
  46840. */
  46841. /**
  46842. * Only used in gltf falloff mode, this defines the angle where
  46843. * the directional falloff will start before cutting at angle which could be seen
  46844. * as outer angle.
  46845. */
  46846. innerAngle: number;
  46847. private _shadowAngleScale;
  46848. /**
  46849. * Allows scaling the angle of the light for shadow generation only.
  46850. */
  46851. /**
  46852. * Allows scaling the angle of the light for shadow generation only.
  46853. */
  46854. shadowAngleScale: number;
  46855. /**
  46856. * The light decay speed with the distance from the emission spot.
  46857. */
  46858. exponent: number;
  46859. private _projectionTextureMatrix;
  46860. /**
  46861. * Allows reading the projecton texture
  46862. */
  46863. readonly projectionTextureMatrix: Matrix;
  46864. protected _projectionTextureLightNear: number;
  46865. /**
  46866. * Gets the near clip of the Spotlight for texture projection.
  46867. */
  46868. /**
  46869. * Sets the near clip of the Spotlight for texture projection.
  46870. */
  46871. projectionTextureLightNear: number;
  46872. protected _projectionTextureLightFar: number;
  46873. /**
  46874. * Gets the far clip of the Spotlight for texture projection.
  46875. */
  46876. /**
  46877. * Sets the far clip of the Spotlight for texture projection.
  46878. */
  46879. projectionTextureLightFar: number;
  46880. protected _projectionTextureUpDirection: Vector3;
  46881. /**
  46882. * Gets the Up vector of the Spotlight for texture projection.
  46883. */
  46884. /**
  46885. * Sets the Up vector of the Spotlight for texture projection.
  46886. */
  46887. projectionTextureUpDirection: Vector3;
  46888. private _projectionTexture;
  46889. /**
  46890. * Gets the projection texture of the light.
  46891. */
  46892. /**
  46893. * Sets the projection texture of the light.
  46894. */
  46895. projectionTexture: Nullable<BaseTexture>;
  46896. private _projectionTextureViewLightDirty;
  46897. private _projectionTextureProjectionLightDirty;
  46898. private _projectionTextureDirty;
  46899. private _projectionTextureViewTargetVector;
  46900. private _projectionTextureViewLightMatrix;
  46901. private _projectionTextureProjectionLightMatrix;
  46902. private _projectionTextureScalingMatrix;
  46903. /**
  46904. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46905. * It can cast shadows.
  46906. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46907. * @param name The light friendly name
  46908. * @param position The position of the spot light in the scene
  46909. * @param direction The direction of the light in the scene
  46910. * @param angle The cone angle of the light in Radians
  46911. * @param exponent The light decay speed with the distance from the emission spot
  46912. * @param scene The scene the lights belongs to
  46913. */
  46914. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46915. /**
  46916. * Returns the string "SpotLight".
  46917. * @returns the class name
  46918. */
  46919. getClassName(): string;
  46920. /**
  46921. * Returns the integer 2.
  46922. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46923. */
  46924. getTypeID(): number;
  46925. /**
  46926. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46927. */
  46928. protected _setDirection(value: Vector3): void;
  46929. /**
  46930. * Overrides the position setter to recompute the projection texture view light Matrix.
  46931. */
  46932. protected _setPosition(value: Vector3): void;
  46933. /**
  46934. * 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.
  46935. * Returns the SpotLight.
  46936. */
  46937. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46938. protected _computeProjectionTextureViewLightMatrix(): void;
  46939. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46940. /**
  46941. * Main function for light texture projection matrix computing.
  46942. */
  46943. protected _computeProjectionTextureMatrix(): void;
  46944. protected _buildUniformLayout(): void;
  46945. private _computeAngleValues;
  46946. /**
  46947. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46948. * @param effect The effect to update
  46949. * @param lightIndex The index of the light in the effect to update
  46950. * @returns The spot light
  46951. */
  46952. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46953. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46954. /**
  46955. * Disposes the light and the associated resources.
  46956. */
  46957. dispose(): void;
  46958. /**
  46959. * Prepares the list of defines specific to the light type.
  46960. * @param defines the list of defines
  46961. * @param lightIndex defines the index of the light for the effect
  46962. */
  46963. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46964. }
  46965. }
  46966. declare module "babylonjs/Gizmos/lightGizmo" {
  46967. import { Nullable } from "babylonjs/types";
  46968. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46969. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46970. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46971. import { Light } from "babylonjs/Lights/light";
  46972. /**
  46973. * Gizmo that enables viewing a light
  46974. */
  46975. export class LightGizmo extends Gizmo {
  46976. private _lightMesh;
  46977. private _material;
  46978. private cachedPosition;
  46979. private cachedForward;
  46980. /**
  46981. * Creates a LightGizmo
  46982. * @param gizmoLayer The utility layer the gizmo will be added to
  46983. */
  46984. constructor(gizmoLayer?: UtilityLayerRenderer);
  46985. private _light;
  46986. /**
  46987. * The light that the gizmo is attached to
  46988. */
  46989. light: Nullable<Light>;
  46990. /**
  46991. * Gets the material used to render the light gizmo
  46992. */
  46993. readonly material: StandardMaterial;
  46994. /**
  46995. * @hidden
  46996. * Updates the gizmo to match the attached mesh's position/rotation
  46997. */
  46998. protected _update(): void;
  46999. private static _Scale;
  47000. /**
  47001. * Creates the lines for a light mesh
  47002. */
  47003. private static _createLightLines;
  47004. /**
  47005. * Disposes of the light gizmo
  47006. */
  47007. dispose(): void;
  47008. private static _CreateHemisphericLightMesh;
  47009. private static _CreatePointLightMesh;
  47010. private static _CreateSpotLightMesh;
  47011. private static _CreateDirectionalLightMesh;
  47012. }
  47013. }
  47014. declare module "babylonjs/Gizmos/index" {
  47015. export * from "babylonjs/Gizmos/axisDragGizmo";
  47016. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47017. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47018. export * from "babylonjs/Gizmos/gizmo";
  47019. export * from "babylonjs/Gizmos/gizmoManager";
  47020. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47021. export * from "babylonjs/Gizmos/positionGizmo";
  47022. export * from "babylonjs/Gizmos/rotationGizmo";
  47023. export * from "babylonjs/Gizmos/scaleGizmo";
  47024. export * from "babylonjs/Gizmos/lightGizmo";
  47025. export * from "babylonjs/Gizmos/planeDragGizmo";
  47026. }
  47027. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47028. /** @hidden */
  47029. export var backgroundFragmentDeclaration: {
  47030. name: string;
  47031. shader: string;
  47032. };
  47033. }
  47034. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47035. /** @hidden */
  47036. export var backgroundUboDeclaration: {
  47037. name: string;
  47038. shader: string;
  47039. };
  47040. }
  47041. declare module "babylonjs/Shaders/background.fragment" {
  47042. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47043. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47044. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47045. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47046. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47047. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47048. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47049. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47050. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47051. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47052. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47053. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47054. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47055. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47056. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47057. /** @hidden */
  47058. export var backgroundPixelShader: {
  47059. name: string;
  47060. shader: string;
  47061. };
  47062. }
  47063. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47064. /** @hidden */
  47065. export var backgroundVertexDeclaration: {
  47066. name: string;
  47067. shader: string;
  47068. };
  47069. }
  47070. declare module "babylonjs/Shaders/background.vertex" {
  47071. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47072. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47073. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47074. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47075. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47076. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47077. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47078. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47079. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47080. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47081. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47082. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47083. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47084. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47085. /** @hidden */
  47086. export var backgroundVertexShader: {
  47087. name: string;
  47088. shader: string;
  47089. };
  47090. }
  47091. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47092. import { Nullable, int, float } from "babylonjs/types";
  47093. import { Scene } from "babylonjs/scene";
  47094. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47095. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47097. import { Mesh } from "babylonjs/Meshes/mesh";
  47098. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47099. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47100. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47102. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47103. import { Color3 } from "babylonjs/Maths/math.color";
  47104. import "babylonjs/Shaders/background.fragment";
  47105. import "babylonjs/Shaders/background.vertex";
  47106. /**
  47107. * Background material used to create an efficient environement around your scene.
  47108. */
  47109. export class BackgroundMaterial extends PushMaterial {
  47110. /**
  47111. * Standard reflectance value at parallel view angle.
  47112. */
  47113. static StandardReflectance0: number;
  47114. /**
  47115. * Standard reflectance value at grazing angle.
  47116. */
  47117. static StandardReflectance90: number;
  47118. protected _primaryColor: Color3;
  47119. /**
  47120. * Key light Color (multiply against the environement texture)
  47121. */
  47122. primaryColor: Color3;
  47123. protected __perceptualColor: Nullable<Color3>;
  47124. /**
  47125. * Experimental Internal Use Only.
  47126. *
  47127. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47128. * This acts as a helper to set the primary color to a more "human friendly" value.
  47129. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47130. * output color as close as possible from the chosen value.
  47131. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47132. * part of lighting setup.)
  47133. */
  47134. _perceptualColor: Nullable<Color3>;
  47135. protected _primaryColorShadowLevel: float;
  47136. /**
  47137. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47138. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47139. */
  47140. primaryColorShadowLevel: float;
  47141. protected _primaryColorHighlightLevel: float;
  47142. /**
  47143. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47144. * The primary color is used at the level chosen to define what the white area would look.
  47145. */
  47146. primaryColorHighlightLevel: float;
  47147. protected _reflectionTexture: Nullable<BaseTexture>;
  47148. /**
  47149. * Reflection Texture used in the material.
  47150. * Should be author in a specific way for the best result (refer to the documentation).
  47151. */
  47152. reflectionTexture: Nullable<BaseTexture>;
  47153. protected _reflectionBlur: float;
  47154. /**
  47155. * Reflection Texture level of blur.
  47156. *
  47157. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47158. * texture twice.
  47159. */
  47160. reflectionBlur: float;
  47161. protected _diffuseTexture: Nullable<BaseTexture>;
  47162. /**
  47163. * Diffuse Texture used in the material.
  47164. * Should be author in a specific way for the best result (refer to the documentation).
  47165. */
  47166. diffuseTexture: Nullable<BaseTexture>;
  47167. protected _shadowLights: Nullable<IShadowLight[]>;
  47168. /**
  47169. * Specify the list of lights casting shadow on the material.
  47170. * All scene shadow lights will be included if null.
  47171. */
  47172. shadowLights: Nullable<IShadowLight[]>;
  47173. protected _shadowLevel: float;
  47174. /**
  47175. * Helps adjusting the shadow to a softer level if required.
  47176. * 0 means black shadows and 1 means no shadows.
  47177. */
  47178. shadowLevel: float;
  47179. protected _sceneCenter: Vector3;
  47180. /**
  47181. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47182. * It is usually zero but might be interesting to modify according to your setup.
  47183. */
  47184. sceneCenter: Vector3;
  47185. protected _opacityFresnel: boolean;
  47186. /**
  47187. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47188. * This helps ensuring a nice transition when the camera goes under the ground.
  47189. */
  47190. opacityFresnel: boolean;
  47191. protected _reflectionFresnel: boolean;
  47192. /**
  47193. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47194. * This helps adding a mirror texture on the ground.
  47195. */
  47196. reflectionFresnel: boolean;
  47197. protected _reflectionFalloffDistance: number;
  47198. /**
  47199. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47200. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47201. */
  47202. reflectionFalloffDistance: number;
  47203. protected _reflectionAmount: number;
  47204. /**
  47205. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47206. */
  47207. reflectionAmount: number;
  47208. protected _reflectionReflectance0: number;
  47209. /**
  47210. * This specifies the weight of the reflection at grazing angle.
  47211. */
  47212. reflectionReflectance0: number;
  47213. protected _reflectionReflectance90: number;
  47214. /**
  47215. * This specifies the weight of the reflection at a perpendicular point of view.
  47216. */
  47217. reflectionReflectance90: number;
  47218. /**
  47219. * Sets the reflection reflectance fresnel values according to the default standard
  47220. * empirically know to work well :-)
  47221. */
  47222. reflectionStandardFresnelWeight: number;
  47223. protected _useRGBColor: boolean;
  47224. /**
  47225. * Helps to directly use the maps channels instead of their level.
  47226. */
  47227. useRGBColor: boolean;
  47228. protected _enableNoise: boolean;
  47229. /**
  47230. * This helps reducing the banding effect that could occur on the background.
  47231. */
  47232. enableNoise: boolean;
  47233. /**
  47234. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47235. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47236. * Recommended to be keep at 1.0 except for special cases.
  47237. */
  47238. fovMultiplier: number;
  47239. private _fovMultiplier;
  47240. /**
  47241. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47242. */
  47243. useEquirectangularFOV: boolean;
  47244. private _maxSimultaneousLights;
  47245. /**
  47246. * Number of Simultaneous lights allowed on the material.
  47247. */
  47248. maxSimultaneousLights: int;
  47249. /**
  47250. * Default configuration related to image processing available in the Background Material.
  47251. */
  47252. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47253. /**
  47254. * Keep track of the image processing observer to allow dispose and replace.
  47255. */
  47256. private _imageProcessingObserver;
  47257. /**
  47258. * Attaches a new image processing configuration to the PBR Material.
  47259. * @param configuration (if null the scene configuration will be use)
  47260. */
  47261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47262. /**
  47263. * Gets the image processing configuration used either in this material.
  47264. */
  47265. /**
  47266. * Sets the Default image processing configuration used either in the this material.
  47267. *
  47268. * If sets to null, the scene one is in use.
  47269. */
  47270. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47271. /**
  47272. * Gets wether the color curves effect is enabled.
  47273. */
  47274. /**
  47275. * Sets wether the color curves effect is enabled.
  47276. */
  47277. cameraColorCurvesEnabled: boolean;
  47278. /**
  47279. * Gets wether the color grading effect is enabled.
  47280. */
  47281. /**
  47282. * Gets wether the color grading effect is enabled.
  47283. */
  47284. cameraColorGradingEnabled: boolean;
  47285. /**
  47286. * Gets wether tonemapping is enabled or not.
  47287. */
  47288. /**
  47289. * Sets wether tonemapping is enabled or not
  47290. */
  47291. cameraToneMappingEnabled: boolean;
  47292. /**
  47293. * The camera exposure used on this material.
  47294. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47295. * This corresponds to a photographic exposure.
  47296. */
  47297. /**
  47298. * The camera exposure used on this material.
  47299. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47300. * This corresponds to a photographic exposure.
  47301. */
  47302. cameraExposure: float;
  47303. /**
  47304. * Gets The camera contrast used on this material.
  47305. */
  47306. /**
  47307. * Sets The camera contrast used on this material.
  47308. */
  47309. cameraContrast: float;
  47310. /**
  47311. * Gets the Color Grading 2D Lookup Texture.
  47312. */
  47313. /**
  47314. * Sets the Color Grading 2D Lookup Texture.
  47315. */
  47316. cameraColorGradingTexture: Nullable<BaseTexture>;
  47317. /**
  47318. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47319. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47320. * 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;
  47321. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47322. */
  47323. /**
  47324. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47325. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47326. * 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;
  47327. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47328. */
  47329. cameraColorCurves: Nullable<ColorCurves>;
  47330. /**
  47331. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47332. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47333. */
  47334. switchToBGR: boolean;
  47335. private _renderTargets;
  47336. private _reflectionControls;
  47337. private _white;
  47338. private _primaryShadowColor;
  47339. private _primaryHighlightColor;
  47340. /**
  47341. * Instantiates a Background Material in the given scene
  47342. * @param name The friendly name of the material
  47343. * @param scene The scene to add the material to
  47344. */
  47345. constructor(name: string, scene: Scene);
  47346. /**
  47347. * Gets a boolean indicating that current material needs to register RTT
  47348. */
  47349. readonly hasRenderTargetTextures: boolean;
  47350. /**
  47351. * The entire material has been created in order to prevent overdraw.
  47352. * @returns false
  47353. */
  47354. needAlphaTesting(): boolean;
  47355. /**
  47356. * The entire material has been created in order to prevent overdraw.
  47357. * @returns true if blending is enable
  47358. */
  47359. needAlphaBlending(): boolean;
  47360. /**
  47361. * Checks wether the material is ready to be rendered for a given mesh.
  47362. * @param mesh The mesh to render
  47363. * @param subMesh The submesh to check against
  47364. * @param useInstances Specify wether or not the material is used with instances
  47365. * @returns true if all the dependencies are ready (Textures, Effects...)
  47366. */
  47367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47368. /**
  47369. * Compute the primary color according to the chosen perceptual color.
  47370. */
  47371. private _computePrimaryColorFromPerceptualColor;
  47372. /**
  47373. * Compute the highlights and shadow colors according to their chosen levels.
  47374. */
  47375. private _computePrimaryColors;
  47376. /**
  47377. * Build the uniform buffer used in the material.
  47378. */
  47379. buildUniformLayout(): void;
  47380. /**
  47381. * Unbind the material.
  47382. */
  47383. unbind(): void;
  47384. /**
  47385. * Bind only the world matrix to the material.
  47386. * @param world The world matrix to bind.
  47387. */
  47388. bindOnlyWorldMatrix(world: Matrix): void;
  47389. /**
  47390. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47391. * @param world The world matrix to bind.
  47392. * @param subMesh The submesh to bind for.
  47393. */
  47394. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47395. /**
  47396. * Checks to see if a texture is used in the material.
  47397. * @param texture - Base texture to use.
  47398. * @returns - Boolean specifying if a texture is used in the material.
  47399. */
  47400. hasTexture(texture: BaseTexture): boolean;
  47401. /**
  47402. * Dispose the material.
  47403. * @param forceDisposeEffect Force disposal of the associated effect.
  47404. * @param forceDisposeTextures Force disposal of the associated textures.
  47405. */
  47406. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47407. /**
  47408. * Clones the material.
  47409. * @param name The cloned name.
  47410. * @returns The cloned material.
  47411. */
  47412. clone(name: string): BackgroundMaterial;
  47413. /**
  47414. * Serializes the current material to its JSON representation.
  47415. * @returns The JSON representation.
  47416. */
  47417. serialize(): any;
  47418. /**
  47419. * Gets the class name of the material
  47420. * @returns "BackgroundMaterial"
  47421. */
  47422. getClassName(): string;
  47423. /**
  47424. * Parse a JSON input to create back a background material.
  47425. * @param source The JSON data to parse
  47426. * @param scene The scene to create the parsed material in
  47427. * @param rootUrl The root url of the assets the material depends upon
  47428. * @returns the instantiated BackgroundMaterial.
  47429. */
  47430. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47431. }
  47432. }
  47433. declare module "babylonjs/Helpers/environmentHelper" {
  47434. import { Observable } from "babylonjs/Misc/observable";
  47435. import { Nullable } from "babylonjs/types";
  47436. import { Scene } from "babylonjs/scene";
  47437. import { Vector3 } from "babylonjs/Maths/math.vector";
  47438. import { Color3 } from "babylonjs/Maths/math.color";
  47439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47440. import { Mesh } from "babylonjs/Meshes/mesh";
  47441. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47442. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47443. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47444. import "babylonjs/Meshes/Builders/planeBuilder";
  47445. import "babylonjs/Meshes/Builders/boxBuilder";
  47446. /**
  47447. * Represents the different options available during the creation of
  47448. * a Environment helper.
  47449. *
  47450. * This can control the default ground, skybox and image processing setup of your scene.
  47451. */
  47452. export interface IEnvironmentHelperOptions {
  47453. /**
  47454. * Specifies wether or not to create a ground.
  47455. * True by default.
  47456. */
  47457. createGround: boolean;
  47458. /**
  47459. * Specifies the ground size.
  47460. * 15 by default.
  47461. */
  47462. groundSize: number;
  47463. /**
  47464. * The texture used on the ground for the main color.
  47465. * Comes from the BabylonJS CDN by default.
  47466. *
  47467. * Remarks: Can be either a texture or a url.
  47468. */
  47469. groundTexture: string | BaseTexture;
  47470. /**
  47471. * The color mixed in the ground texture by default.
  47472. * BabylonJS clearColor by default.
  47473. */
  47474. groundColor: Color3;
  47475. /**
  47476. * Specifies the ground opacity.
  47477. * 1 by default.
  47478. */
  47479. groundOpacity: number;
  47480. /**
  47481. * Enables the ground to receive shadows.
  47482. * True by default.
  47483. */
  47484. enableGroundShadow: boolean;
  47485. /**
  47486. * Helps preventing the shadow to be fully black on the ground.
  47487. * 0.5 by default.
  47488. */
  47489. groundShadowLevel: number;
  47490. /**
  47491. * Creates a mirror texture attach to the ground.
  47492. * false by default.
  47493. */
  47494. enableGroundMirror: boolean;
  47495. /**
  47496. * Specifies the ground mirror size ratio.
  47497. * 0.3 by default as the default kernel is 64.
  47498. */
  47499. groundMirrorSizeRatio: number;
  47500. /**
  47501. * Specifies the ground mirror blur kernel size.
  47502. * 64 by default.
  47503. */
  47504. groundMirrorBlurKernel: number;
  47505. /**
  47506. * Specifies the ground mirror visibility amount.
  47507. * 1 by default
  47508. */
  47509. groundMirrorAmount: number;
  47510. /**
  47511. * Specifies the ground mirror reflectance weight.
  47512. * This uses the standard weight of the background material to setup the fresnel effect
  47513. * of the mirror.
  47514. * 1 by default.
  47515. */
  47516. groundMirrorFresnelWeight: number;
  47517. /**
  47518. * Specifies the ground mirror Falloff distance.
  47519. * This can helps reducing the size of the reflection.
  47520. * 0 by Default.
  47521. */
  47522. groundMirrorFallOffDistance: number;
  47523. /**
  47524. * Specifies the ground mirror texture type.
  47525. * Unsigned Int by Default.
  47526. */
  47527. groundMirrorTextureType: number;
  47528. /**
  47529. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47530. * the shown objects.
  47531. */
  47532. groundYBias: number;
  47533. /**
  47534. * Specifies wether or not to create a skybox.
  47535. * True by default.
  47536. */
  47537. createSkybox: boolean;
  47538. /**
  47539. * Specifies the skybox size.
  47540. * 20 by default.
  47541. */
  47542. skyboxSize: number;
  47543. /**
  47544. * The texture used on the skybox for the main color.
  47545. * Comes from the BabylonJS CDN by default.
  47546. *
  47547. * Remarks: Can be either a texture or a url.
  47548. */
  47549. skyboxTexture: string | BaseTexture;
  47550. /**
  47551. * The color mixed in the skybox texture by default.
  47552. * BabylonJS clearColor by default.
  47553. */
  47554. skyboxColor: Color3;
  47555. /**
  47556. * The background rotation around the Y axis of the scene.
  47557. * This helps aligning the key lights of your scene with the background.
  47558. * 0 by default.
  47559. */
  47560. backgroundYRotation: number;
  47561. /**
  47562. * Compute automatically the size of the elements to best fit with the scene.
  47563. */
  47564. sizeAuto: boolean;
  47565. /**
  47566. * Default position of the rootMesh if autoSize is not true.
  47567. */
  47568. rootPosition: Vector3;
  47569. /**
  47570. * Sets up the image processing in the scene.
  47571. * true by default.
  47572. */
  47573. setupImageProcessing: boolean;
  47574. /**
  47575. * The texture used as your environment texture in the scene.
  47576. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47577. *
  47578. * Remarks: Can be either a texture or a url.
  47579. */
  47580. environmentTexture: string | BaseTexture;
  47581. /**
  47582. * The value of the exposure to apply to the scene.
  47583. * 0.6 by default if setupImageProcessing is true.
  47584. */
  47585. cameraExposure: number;
  47586. /**
  47587. * The value of the contrast to apply to the scene.
  47588. * 1.6 by default if setupImageProcessing is true.
  47589. */
  47590. cameraContrast: number;
  47591. /**
  47592. * Specifies wether or not tonemapping should be enabled in the scene.
  47593. * true by default if setupImageProcessing is true.
  47594. */
  47595. toneMappingEnabled: boolean;
  47596. }
  47597. /**
  47598. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47599. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47600. * It also helps with the default setup of your imageProcessing configuration.
  47601. */
  47602. export class EnvironmentHelper {
  47603. /**
  47604. * Default ground texture URL.
  47605. */
  47606. private static _groundTextureCDNUrl;
  47607. /**
  47608. * Default skybox texture URL.
  47609. */
  47610. private static _skyboxTextureCDNUrl;
  47611. /**
  47612. * Default environment texture URL.
  47613. */
  47614. private static _environmentTextureCDNUrl;
  47615. /**
  47616. * Creates the default options for the helper.
  47617. */
  47618. private static _getDefaultOptions;
  47619. private _rootMesh;
  47620. /**
  47621. * Gets the root mesh created by the helper.
  47622. */
  47623. readonly rootMesh: Mesh;
  47624. private _skybox;
  47625. /**
  47626. * Gets the skybox created by the helper.
  47627. */
  47628. readonly skybox: Nullable<Mesh>;
  47629. private _skyboxTexture;
  47630. /**
  47631. * Gets the skybox texture created by the helper.
  47632. */
  47633. readonly skyboxTexture: Nullable<BaseTexture>;
  47634. private _skyboxMaterial;
  47635. /**
  47636. * Gets the skybox material created by the helper.
  47637. */
  47638. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47639. private _ground;
  47640. /**
  47641. * Gets the ground mesh created by the helper.
  47642. */
  47643. readonly ground: Nullable<Mesh>;
  47644. private _groundTexture;
  47645. /**
  47646. * Gets the ground texture created by the helper.
  47647. */
  47648. readonly groundTexture: Nullable<BaseTexture>;
  47649. private _groundMirror;
  47650. /**
  47651. * Gets the ground mirror created by the helper.
  47652. */
  47653. readonly groundMirror: Nullable<MirrorTexture>;
  47654. /**
  47655. * Gets the ground mirror render list to helps pushing the meshes
  47656. * you wish in the ground reflection.
  47657. */
  47658. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47659. private _groundMaterial;
  47660. /**
  47661. * Gets the ground material created by the helper.
  47662. */
  47663. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47664. /**
  47665. * Stores the creation options.
  47666. */
  47667. private readonly _scene;
  47668. private _options;
  47669. /**
  47670. * This observable will be notified with any error during the creation of the environment,
  47671. * mainly texture creation errors.
  47672. */
  47673. onErrorObservable: Observable<{
  47674. message?: string;
  47675. exception?: any;
  47676. }>;
  47677. /**
  47678. * constructor
  47679. * @param options Defines the options we want to customize the helper
  47680. * @param scene The scene to add the material to
  47681. */
  47682. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47683. /**
  47684. * Updates the background according to the new options
  47685. * @param options
  47686. */
  47687. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47688. /**
  47689. * Sets the primary color of all the available elements.
  47690. * @param color the main color to affect to the ground and the background
  47691. */
  47692. setMainColor(color: Color3): void;
  47693. /**
  47694. * Setup the image processing according to the specified options.
  47695. */
  47696. private _setupImageProcessing;
  47697. /**
  47698. * Setup the environment texture according to the specified options.
  47699. */
  47700. private _setupEnvironmentTexture;
  47701. /**
  47702. * Setup the background according to the specified options.
  47703. */
  47704. private _setupBackground;
  47705. /**
  47706. * Get the scene sizes according to the setup.
  47707. */
  47708. private _getSceneSize;
  47709. /**
  47710. * Setup the ground according to the specified options.
  47711. */
  47712. private _setupGround;
  47713. /**
  47714. * Setup the ground material according to the specified options.
  47715. */
  47716. private _setupGroundMaterial;
  47717. /**
  47718. * Setup the ground diffuse texture according to the specified options.
  47719. */
  47720. private _setupGroundDiffuseTexture;
  47721. /**
  47722. * Setup the ground mirror texture according to the specified options.
  47723. */
  47724. private _setupGroundMirrorTexture;
  47725. /**
  47726. * Setup the ground to receive the mirror texture.
  47727. */
  47728. private _setupMirrorInGroundMaterial;
  47729. /**
  47730. * Setup the skybox according to the specified options.
  47731. */
  47732. private _setupSkybox;
  47733. /**
  47734. * Setup the skybox material according to the specified options.
  47735. */
  47736. private _setupSkyboxMaterial;
  47737. /**
  47738. * Setup the skybox reflection texture according to the specified options.
  47739. */
  47740. private _setupSkyboxReflectionTexture;
  47741. private _errorHandler;
  47742. /**
  47743. * Dispose all the elements created by the Helper.
  47744. */
  47745. dispose(): void;
  47746. }
  47747. }
  47748. declare module "babylonjs/Helpers/photoDome" {
  47749. import { Observable } from "babylonjs/Misc/observable";
  47750. import { Nullable } from "babylonjs/types";
  47751. import { Scene } from "babylonjs/scene";
  47752. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47753. import { Mesh } from "babylonjs/Meshes/mesh";
  47754. import { Texture } from "babylonjs/Materials/Textures/texture";
  47755. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47756. import "babylonjs/Meshes/Builders/sphereBuilder";
  47757. /**
  47758. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47759. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47760. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47761. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47762. */
  47763. export class PhotoDome extends TransformNode {
  47764. /**
  47765. * Define the image as a Monoscopic panoramic 360 image.
  47766. */
  47767. static readonly MODE_MONOSCOPIC: number;
  47768. /**
  47769. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47770. */
  47771. static readonly MODE_TOPBOTTOM: number;
  47772. /**
  47773. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47774. */
  47775. static readonly MODE_SIDEBYSIDE: number;
  47776. private _useDirectMapping;
  47777. /**
  47778. * The texture being displayed on the sphere
  47779. */
  47780. protected _photoTexture: Texture;
  47781. /**
  47782. * Gets or sets the texture being displayed on the sphere
  47783. */
  47784. photoTexture: Texture;
  47785. /**
  47786. * Observable raised when an error occured while loading the 360 image
  47787. */
  47788. onLoadErrorObservable: Observable<string>;
  47789. /**
  47790. * The skybox material
  47791. */
  47792. protected _material: BackgroundMaterial;
  47793. /**
  47794. * The surface used for the skybox
  47795. */
  47796. protected _mesh: Mesh;
  47797. /**
  47798. * Gets the mesh used for the skybox.
  47799. */
  47800. readonly mesh: Mesh;
  47801. /**
  47802. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47803. * Also see the options.resolution property.
  47804. */
  47805. fovMultiplier: number;
  47806. private _imageMode;
  47807. /**
  47808. * Gets or set the current video mode for the video. It can be:
  47809. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47810. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47811. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47812. */
  47813. imageMode: number;
  47814. /**
  47815. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47816. * @param name Element's name, child elements will append suffixes for their own names.
  47817. * @param urlsOfPhoto defines the url of the photo to display
  47818. * @param options defines an object containing optional or exposed sub element properties
  47819. * @param onError defines a callback called when an error occured while loading the texture
  47820. */
  47821. constructor(name: string, urlOfPhoto: string, options: {
  47822. resolution?: number;
  47823. size?: number;
  47824. useDirectMapping?: boolean;
  47825. faceForward?: boolean;
  47826. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47827. private _onBeforeCameraRenderObserver;
  47828. private _changeImageMode;
  47829. /**
  47830. * Releases resources associated with this node.
  47831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47833. */
  47834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47835. }
  47836. }
  47837. declare module "babylonjs/Misc/rgbdTextureTools" {
  47838. import "babylonjs/Shaders/rgbdDecode.fragment";
  47839. import { Texture } from "babylonjs/Materials/Textures/texture";
  47840. /**
  47841. * Class used to host RGBD texture specific utilities
  47842. */
  47843. export class RGBDTextureTools {
  47844. /**
  47845. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47846. * @param texture the texture to expand.
  47847. */
  47848. static ExpandRGBDTexture(texture: Texture): void;
  47849. }
  47850. }
  47851. declare module "babylonjs/Misc/brdfTextureTools" {
  47852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47853. import { Scene } from "babylonjs/scene";
  47854. /**
  47855. * Class used to host texture specific utilities
  47856. */
  47857. export class BRDFTextureTools {
  47858. /**
  47859. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47860. * @param scene defines the hosting scene
  47861. * @returns the environment BRDF texture
  47862. */
  47863. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47864. private static _environmentBRDFBase64Texture;
  47865. }
  47866. }
  47867. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47868. import { Nullable } from "babylonjs/types";
  47869. import { Color3 } from "babylonjs/Maths/math.color";
  47870. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47871. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47872. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47873. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47874. import { Engine } from "babylonjs/Engines/engine";
  47875. import { Scene } from "babylonjs/scene";
  47876. /**
  47877. * @hidden
  47878. */
  47879. export interface IMaterialClearCoatDefines {
  47880. CLEARCOAT: boolean;
  47881. CLEARCOAT_DEFAULTIOR: boolean;
  47882. CLEARCOAT_TEXTURE: boolean;
  47883. CLEARCOAT_TEXTUREDIRECTUV: number;
  47884. CLEARCOAT_BUMP: boolean;
  47885. CLEARCOAT_BUMPDIRECTUV: number;
  47886. CLEARCOAT_TINT: boolean;
  47887. CLEARCOAT_TINT_TEXTURE: boolean;
  47888. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47889. /** @hidden */
  47890. _areTexturesDirty: boolean;
  47891. }
  47892. /**
  47893. * Define the code related to the clear coat parameters of the pbr material.
  47894. */
  47895. export class PBRClearCoatConfiguration {
  47896. /**
  47897. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47898. * The default fits with a polyurethane material.
  47899. */
  47900. private static readonly _DefaultIndexOfRefraction;
  47901. private _isEnabled;
  47902. /**
  47903. * Defines if the clear coat is enabled in the material.
  47904. */
  47905. isEnabled: boolean;
  47906. /**
  47907. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47908. */
  47909. intensity: number;
  47910. /**
  47911. * Defines the clear coat layer roughness.
  47912. */
  47913. roughness: number;
  47914. private _indexOfRefraction;
  47915. /**
  47916. * Defines the index of refraction of the clear coat.
  47917. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47918. * The default fits with a polyurethane material.
  47919. * Changing the default value is more performance intensive.
  47920. */
  47921. indexOfRefraction: number;
  47922. private _texture;
  47923. /**
  47924. * Stores the clear coat values in a texture.
  47925. */
  47926. texture: Nullable<BaseTexture>;
  47927. private _bumpTexture;
  47928. /**
  47929. * Define the clear coat specific bump texture.
  47930. */
  47931. bumpTexture: Nullable<BaseTexture>;
  47932. private _isTintEnabled;
  47933. /**
  47934. * Defines if the clear coat tint is enabled in the material.
  47935. */
  47936. isTintEnabled: boolean;
  47937. /**
  47938. * Defines the clear coat tint of the material.
  47939. * This is only use if tint is enabled
  47940. */
  47941. tintColor: Color3;
  47942. /**
  47943. * Defines the distance at which the tint color should be found in the
  47944. * clear coat media.
  47945. * This is only use if tint is enabled
  47946. */
  47947. tintColorAtDistance: number;
  47948. /**
  47949. * Defines the clear coat layer thickness.
  47950. * This is only use if tint is enabled
  47951. */
  47952. tintThickness: number;
  47953. private _tintTexture;
  47954. /**
  47955. * Stores the clear tint values in a texture.
  47956. * rgb is tint
  47957. * a is a thickness factor
  47958. */
  47959. tintTexture: Nullable<BaseTexture>;
  47960. /** @hidden */
  47961. private _internalMarkAllSubMeshesAsTexturesDirty;
  47962. /** @hidden */
  47963. _markAllSubMeshesAsTexturesDirty(): void;
  47964. /**
  47965. * Instantiate a new istance of clear coat configuration.
  47966. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47967. */
  47968. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47969. /**
  47970. * Gets wehter the submesh is ready to be used or not.
  47971. * @param defines the list of "defines" to update.
  47972. * @param scene defines the scene the material belongs to.
  47973. * @param engine defines the engine the material belongs to.
  47974. * @param disableBumpMap defines wether the material disables bump or not.
  47975. * @returns - boolean indicating that the submesh is ready or not.
  47976. */
  47977. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47978. /**
  47979. * Checks to see if a texture is used in the material.
  47980. * @param defines the list of "defines" to update.
  47981. * @param scene defines the scene to the material belongs to.
  47982. */
  47983. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47984. /**
  47985. * Binds the material data.
  47986. * @param uniformBuffer defines the Uniform buffer to fill in.
  47987. * @param scene defines the scene the material belongs to.
  47988. * @param engine defines the engine the material belongs to.
  47989. * @param disableBumpMap defines wether the material disables bump or not.
  47990. * @param isFrozen defines wether the material is frozen or not.
  47991. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47992. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47993. */
  47994. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47995. /**
  47996. * Checks to see if a texture is used in the material.
  47997. * @param texture - Base texture to use.
  47998. * @returns - Boolean specifying if a texture is used in the material.
  47999. */
  48000. hasTexture(texture: BaseTexture): boolean;
  48001. /**
  48002. * Returns an array of the actively used textures.
  48003. * @param activeTextures Array of BaseTextures
  48004. */
  48005. getActiveTextures(activeTextures: BaseTexture[]): void;
  48006. /**
  48007. * Returns the animatable textures.
  48008. * @param animatables Array of animatable textures.
  48009. */
  48010. getAnimatables(animatables: IAnimatable[]): void;
  48011. /**
  48012. * Disposes the resources of the material.
  48013. * @param forceDisposeTextures - Forces the disposal of all textures.
  48014. */
  48015. dispose(forceDisposeTextures?: boolean): void;
  48016. /**
  48017. * Get the current class name of the texture useful for serialization or dynamic coding.
  48018. * @returns "PBRClearCoatConfiguration"
  48019. */
  48020. getClassName(): string;
  48021. /**
  48022. * Add fallbacks to the effect fallbacks list.
  48023. * @param defines defines the Base texture to use.
  48024. * @param fallbacks defines the current fallback list.
  48025. * @param currentRank defines the current fallback rank.
  48026. * @returns the new fallback rank.
  48027. */
  48028. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48029. /**
  48030. * Add the required uniforms to the current list.
  48031. * @param uniforms defines the current uniform list.
  48032. */
  48033. static AddUniforms(uniforms: string[]): void;
  48034. /**
  48035. * Add the required samplers to the current list.
  48036. * @param samplers defines the current sampler list.
  48037. */
  48038. static AddSamplers(samplers: string[]): void;
  48039. /**
  48040. * Add the required uniforms to the current buffer.
  48041. * @param uniformBuffer defines the current uniform buffer.
  48042. */
  48043. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48044. /**
  48045. * Makes a duplicate of the current configuration into another one.
  48046. * @param clearCoatConfiguration define the config where to copy the info
  48047. */
  48048. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48049. /**
  48050. * Serializes this clear coat configuration.
  48051. * @returns - An object with the serialized config.
  48052. */
  48053. serialize(): any;
  48054. /**
  48055. * Parses a anisotropy Configuration from a serialized object.
  48056. * @param source - Serialized object.
  48057. * @param scene Defines the scene we are parsing for
  48058. * @param rootUrl Defines the rootUrl to load from
  48059. */
  48060. parse(source: any, scene: Scene, rootUrl: string): void;
  48061. }
  48062. }
  48063. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48064. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48065. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48067. import { Vector2 } from "babylonjs/Maths/math.vector";
  48068. import { Scene } from "babylonjs/scene";
  48069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48070. import { Nullable } from "babylonjs/types";
  48071. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48072. /**
  48073. * @hidden
  48074. */
  48075. export interface IMaterialAnisotropicDefines {
  48076. ANISOTROPIC: boolean;
  48077. ANISOTROPIC_TEXTURE: boolean;
  48078. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48079. MAINUV1: boolean;
  48080. _areTexturesDirty: boolean;
  48081. _needUVs: boolean;
  48082. }
  48083. /**
  48084. * Define the code related to the anisotropic parameters of the pbr material.
  48085. */
  48086. export class PBRAnisotropicConfiguration {
  48087. private _isEnabled;
  48088. /**
  48089. * Defines if the anisotropy is enabled in the material.
  48090. */
  48091. isEnabled: boolean;
  48092. /**
  48093. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48094. */
  48095. intensity: number;
  48096. /**
  48097. * Defines if the effect is along the tangents, bitangents or in between.
  48098. * By default, the effect is "strectching" the highlights along the tangents.
  48099. */
  48100. direction: Vector2;
  48101. private _texture;
  48102. /**
  48103. * Stores the anisotropy values in a texture.
  48104. * rg is direction (like normal from -1 to 1)
  48105. * b is a intensity
  48106. */
  48107. texture: Nullable<BaseTexture>;
  48108. /** @hidden */
  48109. private _internalMarkAllSubMeshesAsTexturesDirty;
  48110. /** @hidden */
  48111. _markAllSubMeshesAsTexturesDirty(): void;
  48112. /**
  48113. * Instantiate a new istance of anisotropy configuration.
  48114. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48115. */
  48116. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48117. /**
  48118. * Specifies that the submesh is ready to be used.
  48119. * @param defines the list of "defines" to update.
  48120. * @param scene defines the scene the material belongs to.
  48121. * @returns - boolean indicating that the submesh is ready or not.
  48122. */
  48123. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48124. /**
  48125. * Checks to see if a texture is used in the material.
  48126. * @param defines the list of "defines" to update.
  48127. * @param mesh the mesh we are preparing the defines for.
  48128. * @param scene defines the scene the material belongs to.
  48129. */
  48130. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48131. /**
  48132. * Binds the material data.
  48133. * @param uniformBuffer defines the Uniform buffer to fill in.
  48134. * @param scene defines the scene the material belongs to.
  48135. * @param isFrozen defines wether the material is frozen or not.
  48136. */
  48137. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48138. /**
  48139. * Checks to see if a texture is used in the material.
  48140. * @param texture - Base texture to use.
  48141. * @returns - Boolean specifying if a texture is used in the material.
  48142. */
  48143. hasTexture(texture: BaseTexture): boolean;
  48144. /**
  48145. * Returns an array of the actively used textures.
  48146. * @param activeTextures Array of BaseTextures
  48147. */
  48148. getActiveTextures(activeTextures: BaseTexture[]): void;
  48149. /**
  48150. * Returns the animatable textures.
  48151. * @param animatables Array of animatable textures.
  48152. */
  48153. getAnimatables(animatables: IAnimatable[]): void;
  48154. /**
  48155. * Disposes the resources of the material.
  48156. * @param forceDisposeTextures - Forces the disposal of all textures.
  48157. */
  48158. dispose(forceDisposeTextures?: boolean): void;
  48159. /**
  48160. * Get the current class name of the texture useful for serialization or dynamic coding.
  48161. * @returns "PBRAnisotropicConfiguration"
  48162. */
  48163. getClassName(): string;
  48164. /**
  48165. * Add fallbacks to the effect fallbacks list.
  48166. * @param defines defines the Base texture to use.
  48167. * @param fallbacks defines the current fallback list.
  48168. * @param currentRank defines the current fallback rank.
  48169. * @returns the new fallback rank.
  48170. */
  48171. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48172. /**
  48173. * Add the required uniforms to the current list.
  48174. * @param uniforms defines the current uniform list.
  48175. */
  48176. static AddUniforms(uniforms: string[]): void;
  48177. /**
  48178. * Add the required uniforms to the current buffer.
  48179. * @param uniformBuffer defines the current uniform buffer.
  48180. */
  48181. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48182. /**
  48183. * Add the required samplers to the current list.
  48184. * @param samplers defines the current sampler list.
  48185. */
  48186. static AddSamplers(samplers: string[]): void;
  48187. /**
  48188. * Makes a duplicate of the current configuration into another one.
  48189. * @param anisotropicConfiguration define the config where to copy the info
  48190. */
  48191. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48192. /**
  48193. * Serializes this anisotropy configuration.
  48194. * @returns - An object with the serialized config.
  48195. */
  48196. serialize(): any;
  48197. /**
  48198. * Parses a anisotropy Configuration from a serialized object.
  48199. * @param source - Serialized object.
  48200. * @param scene Defines the scene we are parsing for
  48201. * @param rootUrl Defines the rootUrl to load from
  48202. */
  48203. parse(source: any, scene: Scene, rootUrl: string): void;
  48204. }
  48205. }
  48206. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48207. import { Scene } from "babylonjs/scene";
  48208. /**
  48209. * @hidden
  48210. */
  48211. export interface IMaterialBRDFDefines {
  48212. BRDF_V_HEIGHT_CORRELATED: boolean;
  48213. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48214. SPHERICAL_HARMONICS: boolean;
  48215. /** @hidden */
  48216. _areMiscDirty: boolean;
  48217. }
  48218. /**
  48219. * Define the code related to the BRDF parameters of the pbr material.
  48220. */
  48221. export class PBRBRDFConfiguration {
  48222. /**
  48223. * Default value used for the energy conservation.
  48224. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48225. */
  48226. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48227. /**
  48228. * Default value used for the Smith Visibility Height Correlated mode.
  48229. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48230. */
  48231. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48232. /**
  48233. * Default value used for the IBL diffuse part.
  48234. * This can help switching back to the polynomials mode globally which is a tiny bit
  48235. * less GPU intensive at the drawback of a lower quality.
  48236. */
  48237. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48238. private _useEnergyConservation;
  48239. /**
  48240. * Defines if the material uses energy conservation.
  48241. */
  48242. useEnergyConservation: boolean;
  48243. private _useSmithVisibilityHeightCorrelated;
  48244. /**
  48245. * LEGACY Mode set to false
  48246. * Defines if the material uses height smith correlated visibility term.
  48247. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48248. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48249. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48250. * Not relying on height correlated will also disable energy conservation.
  48251. */
  48252. useSmithVisibilityHeightCorrelated: boolean;
  48253. private _useSphericalHarmonics;
  48254. /**
  48255. * LEGACY Mode set to false
  48256. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48257. * diffuse part of the IBL.
  48258. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48259. * to the ground truth.
  48260. */
  48261. useSphericalHarmonics: boolean;
  48262. /** @hidden */
  48263. private _internalMarkAllSubMeshesAsMiscDirty;
  48264. /** @hidden */
  48265. _markAllSubMeshesAsMiscDirty(): void;
  48266. /**
  48267. * Instantiate a new istance of clear coat configuration.
  48268. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48269. */
  48270. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48271. /**
  48272. * Checks to see if a texture is used in the material.
  48273. * @param defines the list of "defines" to update.
  48274. */
  48275. prepareDefines(defines: IMaterialBRDFDefines): void;
  48276. /**
  48277. * Get the current class name of the texture useful for serialization or dynamic coding.
  48278. * @returns "PBRClearCoatConfiguration"
  48279. */
  48280. getClassName(): string;
  48281. /**
  48282. * Makes a duplicate of the current configuration into another one.
  48283. * @param brdfConfiguration define the config where to copy the info
  48284. */
  48285. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48286. /**
  48287. * Serializes this BRDF configuration.
  48288. * @returns - An object with the serialized config.
  48289. */
  48290. serialize(): any;
  48291. /**
  48292. * Parses a anisotropy Configuration from a serialized object.
  48293. * @param source - Serialized object.
  48294. * @param scene Defines the scene we are parsing for
  48295. * @param rootUrl Defines the rootUrl to load from
  48296. */
  48297. parse(source: any, scene: Scene, rootUrl: string): void;
  48298. }
  48299. }
  48300. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48301. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48302. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48303. import { Color3 } from "babylonjs/Maths/math.color";
  48304. import { Scene } from "babylonjs/scene";
  48305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48306. import { Nullable } from "babylonjs/types";
  48307. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48308. /**
  48309. * @hidden
  48310. */
  48311. export interface IMaterialSheenDefines {
  48312. SHEEN: boolean;
  48313. SHEEN_TEXTURE: boolean;
  48314. SHEEN_TEXTUREDIRECTUV: number;
  48315. SHEEN_LINKWITHALBEDO: boolean;
  48316. /** @hidden */
  48317. _areTexturesDirty: boolean;
  48318. }
  48319. /**
  48320. * Define the code related to the Sheen parameters of the pbr material.
  48321. */
  48322. export class PBRSheenConfiguration {
  48323. private _isEnabled;
  48324. /**
  48325. * Defines if the material uses sheen.
  48326. */
  48327. isEnabled: boolean;
  48328. private _linkSheenWithAlbedo;
  48329. /**
  48330. * Defines if the sheen is linked to the sheen color.
  48331. */
  48332. linkSheenWithAlbedo: boolean;
  48333. /**
  48334. * Defines the sheen intensity.
  48335. */
  48336. intensity: number;
  48337. /**
  48338. * Defines the sheen color.
  48339. */
  48340. color: Color3;
  48341. private _texture;
  48342. /**
  48343. * Stores the sheen tint values in a texture.
  48344. * rgb is tint
  48345. * a is a intensity
  48346. */
  48347. texture: Nullable<BaseTexture>;
  48348. /** @hidden */
  48349. private _internalMarkAllSubMeshesAsTexturesDirty;
  48350. /** @hidden */
  48351. _markAllSubMeshesAsTexturesDirty(): void;
  48352. /**
  48353. * Instantiate a new istance of clear coat configuration.
  48354. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48355. */
  48356. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48357. /**
  48358. * Specifies that the submesh is ready to be used.
  48359. * @param defines the list of "defines" to update.
  48360. * @param scene defines the scene the material belongs to.
  48361. * @returns - boolean indicating that the submesh is ready or not.
  48362. */
  48363. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48364. /**
  48365. * Checks to see if a texture is used in the material.
  48366. * @param defines the list of "defines" to update.
  48367. * @param scene defines the scene the material belongs to.
  48368. */
  48369. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48370. /**
  48371. * Binds the material data.
  48372. * @param uniformBuffer defines the Uniform buffer to fill in.
  48373. * @param scene defines the scene the material belongs to.
  48374. * @param isFrozen defines wether the material is frozen or not.
  48375. */
  48376. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48377. /**
  48378. * Checks to see if a texture is used in the material.
  48379. * @param texture - Base texture to use.
  48380. * @returns - Boolean specifying if a texture is used in the material.
  48381. */
  48382. hasTexture(texture: BaseTexture): boolean;
  48383. /**
  48384. * Returns an array of the actively used textures.
  48385. * @param activeTextures Array of BaseTextures
  48386. */
  48387. getActiveTextures(activeTextures: BaseTexture[]): void;
  48388. /**
  48389. * Returns the animatable textures.
  48390. * @param animatables Array of animatable textures.
  48391. */
  48392. getAnimatables(animatables: IAnimatable[]): void;
  48393. /**
  48394. * Disposes the resources of the material.
  48395. * @param forceDisposeTextures - Forces the disposal of all textures.
  48396. */
  48397. dispose(forceDisposeTextures?: boolean): void;
  48398. /**
  48399. * Get the current class name of the texture useful for serialization or dynamic coding.
  48400. * @returns "PBRSheenConfiguration"
  48401. */
  48402. getClassName(): string;
  48403. /**
  48404. * Add fallbacks to the effect fallbacks list.
  48405. * @param defines defines the Base texture to use.
  48406. * @param fallbacks defines the current fallback list.
  48407. * @param currentRank defines the current fallback rank.
  48408. * @returns the new fallback rank.
  48409. */
  48410. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48411. /**
  48412. * Add the required uniforms to the current list.
  48413. * @param uniforms defines the current uniform list.
  48414. */
  48415. static AddUniforms(uniforms: string[]): void;
  48416. /**
  48417. * Add the required uniforms to the current buffer.
  48418. * @param uniformBuffer defines the current uniform buffer.
  48419. */
  48420. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48421. /**
  48422. * Add the required samplers to the current list.
  48423. * @param samplers defines the current sampler list.
  48424. */
  48425. static AddSamplers(samplers: string[]): void;
  48426. /**
  48427. * Makes a duplicate of the current configuration into another one.
  48428. * @param sheenConfiguration define the config where to copy the info
  48429. */
  48430. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48431. /**
  48432. * Serializes this BRDF configuration.
  48433. * @returns - An object with the serialized config.
  48434. */
  48435. serialize(): any;
  48436. /**
  48437. * Parses a anisotropy Configuration from a serialized object.
  48438. * @param source - Serialized object.
  48439. * @param scene Defines the scene we are parsing for
  48440. * @param rootUrl Defines the rootUrl to load from
  48441. */
  48442. parse(source: any, scene: Scene, rootUrl: string): void;
  48443. }
  48444. }
  48445. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48446. import { Nullable } from "babylonjs/types";
  48447. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48448. import { Color3 } from "babylonjs/Maths/math.color";
  48449. import { SmartArray } from "babylonjs/Misc/smartArray";
  48450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48451. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48452. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48453. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48454. import { Engine } from "babylonjs/Engines/engine";
  48455. import { Scene } from "babylonjs/scene";
  48456. /**
  48457. * @hidden
  48458. */
  48459. export interface IMaterialSubSurfaceDefines {
  48460. SUBSURFACE: boolean;
  48461. SS_REFRACTION: boolean;
  48462. SS_TRANSLUCENCY: boolean;
  48463. SS_SCATERRING: boolean;
  48464. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48465. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48466. SS_REFRACTIONMAP_3D: boolean;
  48467. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48468. SS_LODINREFRACTIONALPHA: boolean;
  48469. SS_GAMMAREFRACTION: boolean;
  48470. SS_RGBDREFRACTION: boolean;
  48471. SS_LINEARSPECULARREFRACTION: boolean;
  48472. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48473. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48474. /** @hidden */
  48475. _areTexturesDirty: boolean;
  48476. }
  48477. /**
  48478. * Define the code related to the sub surface parameters of the pbr material.
  48479. */
  48480. export class PBRSubSurfaceConfiguration {
  48481. private _isRefractionEnabled;
  48482. /**
  48483. * Defines if the refraction is enabled in the material.
  48484. */
  48485. isRefractionEnabled: boolean;
  48486. private _isTranslucencyEnabled;
  48487. /**
  48488. * Defines if the translucency is enabled in the material.
  48489. */
  48490. isTranslucencyEnabled: boolean;
  48491. private _isScatteringEnabled;
  48492. /**
  48493. * Defines the refraction intensity of the material.
  48494. * The refraction when enabled replaces the Diffuse part of the material.
  48495. * The intensity helps transitionning between diffuse and refraction.
  48496. */
  48497. refractionIntensity: number;
  48498. /**
  48499. * Defines the translucency intensity of the material.
  48500. * When translucency has been enabled, this defines how much of the "translucency"
  48501. * is addded to the diffuse part of the material.
  48502. */
  48503. translucencyIntensity: number;
  48504. /**
  48505. * Defines the scattering intensity of the material.
  48506. * When scattering has been enabled, this defines how much of the "scattered light"
  48507. * is addded to the diffuse part of the material.
  48508. */
  48509. scatteringIntensity: number;
  48510. private _thicknessTexture;
  48511. /**
  48512. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48513. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48514. * 0 would mean minimumThickness
  48515. * 1 would mean maximumThickness
  48516. * The other channels might be use as a mask to vary the different effects intensity.
  48517. */
  48518. thicknessTexture: Nullable<BaseTexture>;
  48519. private _refractionTexture;
  48520. /**
  48521. * Defines the texture to use for refraction.
  48522. */
  48523. refractionTexture: Nullable<BaseTexture>;
  48524. private _indexOfRefraction;
  48525. /**
  48526. * Defines the index of refraction used in the material.
  48527. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48528. */
  48529. indexOfRefraction: number;
  48530. private _invertRefractionY;
  48531. /**
  48532. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48533. */
  48534. invertRefractionY: boolean;
  48535. private _linkRefractionWithTransparency;
  48536. /**
  48537. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48538. * Materials half opaque for instance using refraction could benefit from this control.
  48539. */
  48540. linkRefractionWithTransparency: boolean;
  48541. /**
  48542. * Defines the minimum thickness stored in the thickness map.
  48543. * If no thickness map is defined, this value will be used to simulate thickness.
  48544. */
  48545. minimumThickness: number;
  48546. /**
  48547. * Defines the maximum thickness stored in the thickness map.
  48548. */
  48549. maximumThickness: number;
  48550. /**
  48551. * Defines the volume tint of the material.
  48552. * This is used for both translucency and scattering.
  48553. */
  48554. tintColor: Color3;
  48555. /**
  48556. * Defines the distance at which the tint color should be found in the media.
  48557. * This is used for refraction only.
  48558. */
  48559. tintColorAtDistance: number;
  48560. /**
  48561. * Defines how far each channel transmit through the media.
  48562. * It is defined as a color to simplify it selection.
  48563. */
  48564. diffusionDistance: Color3;
  48565. private _useMaskFromThicknessTexture;
  48566. /**
  48567. * Stores the intensity of the different subsurface effects in the thickness texture.
  48568. * * the green channel is the translucency intensity.
  48569. * * the blue channel is the scattering intensity.
  48570. * * the alpha channel is the refraction intensity.
  48571. */
  48572. useMaskFromThicknessTexture: boolean;
  48573. /** @hidden */
  48574. private _internalMarkAllSubMeshesAsTexturesDirty;
  48575. /** @hidden */
  48576. _markAllSubMeshesAsTexturesDirty(): void;
  48577. /**
  48578. * Instantiate a new istance of sub surface configuration.
  48579. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48580. */
  48581. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48582. /**
  48583. * Gets wehter the submesh is ready to be used or not.
  48584. * @param defines the list of "defines" to update.
  48585. * @param scene defines the scene the material belongs to.
  48586. * @returns - boolean indicating that the submesh is ready or not.
  48587. */
  48588. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48589. /**
  48590. * Checks to see if a texture is used in the material.
  48591. * @param defines the list of "defines" to update.
  48592. * @param scene defines the scene to the material belongs to.
  48593. */
  48594. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48595. /**
  48596. * Binds the material data.
  48597. * @param uniformBuffer defines the Uniform buffer to fill in.
  48598. * @param scene defines the scene the material belongs to.
  48599. * @param engine defines the engine the material belongs to.
  48600. * @param isFrozen defines wether the material is frozen or not.
  48601. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48602. */
  48603. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48604. /**
  48605. * Unbinds the material from the mesh.
  48606. * @param activeEffect defines the effect that should be unbound from.
  48607. * @returns true if unbound, otherwise false
  48608. */
  48609. unbind(activeEffect: Effect): boolean;
  48610. /**
  48611. * Returns the texture used for refraction or null if none is used.
  48612. * @param scene defines the scene the material belongs to.
  48613. * @returns - Refraction texture if present. If no refraction texture and refraction
  48614. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48615. */
  48616. private _getRefractionTexture;
  48617. /**
  48618. * Returns true if alpha blending should be disabled.
  48619. */
  48620. readonly disableAlphaBlending: boolean;
  48621. /**
  48622. * Fills the list of render target textures.
  48623. * @param renderTargets the list of render targets to update
  48624. */
  48625. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48626. /**
  48627. * Checks to see if a texture is used in the material.
  48628. * @param texture - Base texture to use.
  48629. * @returns - Boolean specifying if a texture is used in the material.
  48630. */
  48631. hasTexture(texture: BaseTexture): boolean;
  48632. /**
  48633. * Gets a boolean indicating that current material needs to register RTT
  48634. * @returns true if this uses a render target otherwise false.
  48635. */
  48636. hasRenderTargetTextures(): boolean;
  48637. /**
  48638. * Returns an array of the actively used textures.
  48639. * @param activeTextures Array of BaseTextures
  48640. */
  48641. getActiveTextures(activeTextures: BaseTexture[]): void;
  48642. /**
  48643. * Returns the animatable textures.
  48644. * @param animatables Array of animatable textures.
  48645. */
  48646. getAnimatables(animatables: IAnimatable[]): void;
  48647. /**
  48648. * Disposes the resources of the material.
  48649. * @param forceDisposeTextures - Forces the disposal of all textures.
  48650. */
  48651. dispose(forceDisposeTextures?: boolean): void;
  48652. /**
  48653. * Get the current class name of the texture useful for serialization or dynamic coding.
  48654. * @returns "PBRSubSurfaceConfiguration"
  48655. */
  48656. getClassName(): string;
  48657. /**
  48658. * Add fallbacks to the effect fallbacks list.
  48659. * @param defines defines the Base texture to use.
  48660. * @param fallbacks defines the current fallback list.
  48661. * @param currentRank defines the current fallback rank.
  48662. * @returns the new fallback rank.
  48663. */
  48664. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48665. /**
  48666. * Add the required uniforms to the current list.
  48667. * @param uniforms defines the current uniform list.
  48668. */
  48669. static AddUniforms(uniforms: string[]): void;
  48670. /**
  48671. * Add the required samplers to the current list.
  48672. * @param samplers defines the current sampler list.
  48673. */
  48674. static AddSamplers(samplers: string[]): void;
  48675. /**
  48676. * Add the required uniforms to the current buffer.
  48677. * @param uniformBuffer defines the current uniform buffer.
  48678. */
  48679. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48680. /**
  48681. * Makes a duplicate of the current configuration into another one.
  48682. * @param configuration define the config where to copy the info
  48683. */
  48684. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48685. /**
  48686. * Serializes this Sub Surface configuration.
  48687. * @returns - An object with the serialized config.
  48688. */
  48689. serialize(): any;
  48690. /**
  48691. * Parses a anisotropy Configuration from a serialized object.
  48692. * @param source - Serialized object.
  48693. * @param scene Defines the scene we are parsing for
  48694. * @param rootUrl Defines the rootUrl to load from
  48695. */
  48696. parse(source: any, scene: Scene, rootUrl: string): void;
  48697. }
  48698. }
  48699. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48700. /** @hidden */
  48701. export var pbrFragmentDeclaration: {
  48702. name: string;
  48703. shader: string;
  48704. };
  48705. }
  48706. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48707. /** @hidden */
  48708. export var pbrUboDeclaration: {
  48709. name: string;
  48710. shader: string;
  48711. };
  48712. }
  48713. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48714. /** @hidden */
  48715. export var pbrFragmentExtraDeclaration: {
  48716. name: string;
  48717. shader: string;
  48718. };
  48719. }
  48720. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48721. /** @hidden */
  48722. export var pbrFragmentSamplersDeclaration: {
  48723. name: string;
  48724. shader: string;
  48725. };
  48726. }
  48727. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48728. /** @hidden */
  48729. export var pbrHelperFunctions: {
  48730. name: string;
  48731. shader: string;
  48732. };
  48733. }
  48734. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48735. /** @hidden */
  48736. export var harmonicsFunctions: {
  48737. name: string;
  48738. shader: string;
  48739. };
  48740. }
  48741. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48742. /** @hidden */
  48743. export var pbrDirectLightingSetupFunctions: {
  48744. name: string;
  48745. shader: string;
  48746. };
  48747. }
  48748. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48749. /** @hidden */
  48750. export var pbrDirectLightingFalloffFunctions: {
  48751. name: string;
  48752. shader: string;
  48753. };
  48754. }
  48755. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48756. /** @hidden */
  48757. export var pbrBRDFFunctions: {
  48758. name: string;
  48759. shader: string;
  48760. };
  48761. }
  48762. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48763. /** @hidden */
  48764. export var pbrDirectLightingFunctions: {
  48765. name: string;
  48766. shader: string;
  48767. };
  48768. }
  48769. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48770. /** @hidden */
  48771. export var pbrIBLFunctions: {
  48772. name: string;
  48773. shader: string;
  48774. };
  48775. }
  48776. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48777. /** @hidden */
  48778. export var pbrDebug: {
  48779. name: string;
  48780. shader: string;
  48781. };
  48782. }
  48783. declare module "babylonjs/Shaders/pbr.fragment" {
  48784. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48785. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48786. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48787. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48788. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48789. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48790. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48791. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48792. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48793. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48794. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48795. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48796. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48797. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48798. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48799. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48800. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48801. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48802. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48803. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48804. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48805. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48806. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48807. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48808. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48809. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48810. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48811. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48812. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48813. /** @hidden */
  48814. export var pbrPixelShader: {
  48815. name: string;
  48816. shader: string;
  48817. };
  48818. }
  48819. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48820. /** @hidden */
  48821. export var pbrVertexDeclaration: {
  48822. name: string;
  48823. shader: string;
  48824. };
  48825. }
  48826. declare module "babylonjs/Shaders/pbr.vertex" {
  48827. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48828. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48829. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48830. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48831. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48832. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48833. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48834. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48835. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48836. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48837. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48840. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48841. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48842. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48843. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48844. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48845. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48846. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48847. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48848. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48849. /** @hidden */
  48850. export var pbrVertexShader: {
  48851. name: string;
  48852. shader: string;
  48853. };
  48854. }
  48855. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48856. import { Nullable } from "babylonjs/types";
  48857. import { Scene } from "babylonjs/scene";
  48858. import { Matrix } from "babylonjs/Maths/math.vector";
  48859. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48861. import { Mesh } from "babylonjs/Meshes/mesh";
  48862. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48863. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48864. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48865. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48866. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48867. import { Color3 } from "babylonjs/Maths/math.color";
  48868. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48869. import { Material } from "babylonjs/Materials/material";
  48870. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48871. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48873. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48874. import "babylonjs/Shaders/pbr.fragment";
  48875. import "babylonjs/Shaders/pbr.vertex";
  48876. /**
  48877. * Manages the defines for the PBR Material.
  48878. * @hidden
  48879. */
  48880. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48881. PBR: boolean;
  48882. MAINUV1: boolean;
  48883. MAINUV2: boolean;
  48884. UV1: boolean;
  48885. UV2: boolean;
  48886. ALBEDO: boolean;
  48887. ALBEDODIRECTUV: number;
  48888. VERTEXCOLOR: boolean;
  48889. AMBIENT: boolean;
  48890. AMBIENTDIRECTUV: number;
  48891. AMBIENTINGRAYSCALE: boolean;
  48892. OPACITY: boolean;
  48893. VERTEXALPHA: boolean;
  48894. OPACITYDIRECTUV: number;
  48895. OPACITYRGB: boolean;
  48896. ALPHATEST: boolean;
  48897. DEPTHPREPASS: boolean;
  48898. ALPHABLEND: boolean;
  48899. ALPHAFROMALBEDO: boolean;
  48900. ALPHATESTVALUE: string;
  48901. SPECULAROVERALPHA: boolean;
  48902. RADIANCEOVERALPHA: boolean;
  48903. ALPHAFRESNEL: boolean;
  48904. LINEARALPHAFRESNEL: boolean;
  48905. PREMULTIPLYALPHA: boolean;
  48906. EMISSIVE: boolean;
  48907. EMISSIVEDIRECTUV: number;
  48908. REFLECTIVITY: boolean;
  48909. REFLECTIVITYDIRECTUV: number;
  48910. SPECULARTERM: boolean;
  48911. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48912. MICROSURFACEAUTOMATIC: boolean;
  48913. LODBASEDMICROSFURACE: boolean;
  48914. MICROSURFACEMAP: boolean;
  48915. MICROSURFACEMAPDIRECTUV: number;
  48916. METALLICWORKFLOW: boolean;
  48917. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48918. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48919. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48920. AOSTOREINMETALMAPRED: boolean;
  48921. ENVIRONMENTBRDF: boolean;
  48922. ENVIRONMENTBRDF_RGBD: boolean;
  48923. NORMAL: boolean;
  48924. TANGENT: boolean;
  48925. BUMP: boolean;
  48926. BUMPDIRECTUV: number;
  48927. OBJECTSPACE_NORMALMAP: boolean;
  48928. PARALLAX: boolean;
  48929. PARALLAXOCCLUSION: boolean;
  48930. NORMALXYSCALE: boolean;
  48931. LIGHTMAP: boolean;
  48932. LIGHTMAPDIRECTUV: number;
  48933. USELIGHTMAPASSHADOWMAP: boolean;
  48934. GAMMALIGHTMAP: boolean;
  48935. RGBDLIGHTMAP: boolean;
  48936. REFLECTION: boolean;
  48937. REFLECTIONMAP_3D: boolean;
  48938. REFLECTIONMAP_SPHERICAL: boolean;
  48939. REFLECTIONMAP_PLANAR: boolean;
  48940. REFLECTIONMAP_CUBIC: boolean;
  48941. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48942. REFLECTIONMAP_PROJECTION: boolean;
  48943. REFLECTIONMAP_SKYBOX: boolean;
  48944. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48945. REFLECTIONMAP_EXPLICIT: boolean;
  48946. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48947. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48948. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48949. INVERTCUBICMAP: boolean;
  48950. USESPHERICALFROMREFLECTIONMAP: boolean;
  48951. USEIRRADIANCEMAP: boolean;
  48952. SPHERICAL_HARMONICS: boolean;
  48953. USESPHERICALINVERTEX: boolean;
  48954. REFLECTIONMAP_OPPOSITEZ: boolean;
  48955. LODINREFLECTIONALPHA: boolean;
  48956. GAMMAREFLECTION: boolean;
  48957. RGBDREFLECTION: boolean;
  48958. LINEARSPECULARREFLECTION: boolean;
  48959. RADIANCEOCCLUSION: boolean;
  48960. HORIZONOCCLUSION: boolean;
  48961. INSTANCES: boolean;
  48962. NUM_BONE_INFLUENCERS: number;
  48963. BonesPerMesh: number;
  48964. BONETEXTURE: boolean;
  48965. NONUNIFORMSCALING: boolean;
  48966. MORPHTARGETS: boolean;
  48967. MORPHTARGETS_NORMAL: boolean;
  48968. MORPHTARGETS_TANGENT: boolean;
  48969. MORPHTARGETS_UV: boolean;
  48970. NUM_MORPH_INFLUENCERS: number;
  48971. IMAGEPROCESSING: boolean;
  48972. VIGNETTE: boolean;
  48973. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48974. VIGNETTEBLENDMODEOPAQUE: boolean;
  48975. TONEMAPPING: boolean;
  48976. TONEMAPPING_ACES: boolean;
  48977. CONTRAST: boolean;
  48978. COLORCURVES: boolean;
  48979. COLORGRADING: boolean;
  48980. COLORGRADING3D: boolean;
  48981. SAMPLER3DGREENDEPTH: boolean;
  48982. SAMPLER3DBGRMAP: boolean;
  48983. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48984. EXPOSURE: boolean;
  48985. MULTIVIEW: boolean;
  48986. USEPHYSICALLIGHTFALLOFF: boolean;
  48987. USEGLTFLIGHTFALLOFF: boolean;
  48988. TWOSIDEDLIGHTING: boolean;
  48989. SHADOWFLOAT: boolean;
  48990. CLIPPLANE: boolean;
  48991. CLIPPLANE2: boolean;
  48992. CLIPPLANE3: boolean;
  48993. CLIPPLANE4: boolean;
  48994. POINTSIZE: boolean;
  48995. FOG: boolean;
  48996. LOGARITHMICDEPTH: boolean;
  48997. FORCENORMALFORWARD: boolean;
  48998. SPECULARAA: boolean;
  48999. CLEARCOAT: boolean;
  49000. CLEARCOAT_DEFAULTIOR: boolean;
  49001. CLEARCOAT_TEXTURE: boolean;
  49002. CLEARCOAT_TEXTUREDIRECTUV: number;
  49003. CLEARCOAT_BUMP: boolean;
  49004. CLEARCOAT_BUMPDIRECTUV: number;
  49005. CLEARCOAT_TINT: boolean;
  49006. CLEARCOAT_TINT_TEXTURE: boolean;
  49007. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49008. ANISOTROPIC: boolean;
  49009. ANISOTROPIC_TEXTURE: boolean;
  49010. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49011. BRDF_V_HEIGHT_CORRELATED: boolean;
  49012. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49013. SHEEN: boolean;
  49014. SHEEN_TEXTURE: boolean;
  49015. SHEEN_TEXTUREDIRECTUV: number;
  49016. SHEEN_LINKWITHALBEDO: boolean;
  49017. SUBSURFACE: boolean;
  49018. SS_REFRACTION: boolean;
  49019. SS_TRANSLUCENCY: boolean;
  49020. SS_SCATERRING: boolean;
  49021. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49022. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49023. SS_REFRACTIONMAP_3D: boolean;
  49024. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49025. SS_LODINREFRACTIONALPHA: boolean;
  49026. SS_GAMMAREFRACTION: boolean;
  49027. SS_RGBDREFRACTION: boolean;
  49028. SS_LINEARSPECULARREFRACTION: boolean;
  49029. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49030. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49031. UNLIT: boolean;
  49032. DEBUGMODE: number;
  49033. /**
  49034. * Initializes the PBR Material defines.
  49035. */
  49036. constructor();
  49037. /**
  49038. * Resets the PBR Material defines.
  49039. */
  49040. reset(): void;
  49041. }
  49042. /**
  49043. * The Physically based material base class of BJS.
  49044. *
  49045. * This offers the main features of a standard PBR material.
  49046. * For more information, please refer to the documentation :
  49047. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49048. */
  49049. export abstract class PBRBaseMaterial extends PushMaterial {
  49050. /**
  49051. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49052. */
  49053. static readonly PBRMATERIAL_OPAQUE: number;
  49054. /**
  49055. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49056. */
  49057. static readonly PBRMATERIAL_ALPHATEST: number;
  49058. /**
  49059. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49060. */
  49061. static readonly PBRMATERIAL_ALPHABLEND: number;
  49062. /**
  49063. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49064. * They are also discarded below the alpha cutoff threshold to improve performances.
  49065. */
  49066. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49067. /**
  49068. * Defines the default value of how much AO map is occluding the analytical lights
  49069. * (point spot...).
  49070. */
  49071. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49072. /**
  49073. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49074. */
  49075. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49076. /**
  49077. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49078. * to enhance interoperability with other engines.
  49079. */
  49080. static readonly LIGHTFALLOFF_GLTF: number;
  49081. /**
  49082. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49083. * to enhance interoperability with other materials.
  49084. */
  49085. static readonly LIGHTFALLOFF_STANDARD: number;
  49086. /**
  49087. * Intensity of the direct lights e.g. the four lights available in your scene.
  49088. * This impacts both the direct diffuse and specular highlights.
  49089. */
  49090. protected _directIntensity: number;
  49091. /**
  49092. * Intensity of the emissive part of the material.
  49093. * This helps controlling the emissive effect without modifying the emissive color.
  49094. */
  49095. protected _emissiveIntensity: number;
  49096. /**
  49097. * Intensity of the environment e.g. how much the environment will light the object
  49098. * either through harmonics for rough material or through the refelction for shiny ones.
  49099. */
  49100. protected _environmentIntensity: number;
  49101. /**
  49102. * This is a special control allowing the reduction of the specular highlights coming from the
  49103. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49104. */
  49105. protected _specularIntensity: number;
  49106. /**
  49107. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49108. */
  49109. private _lightingInfos;
  49110. /**
  49111. * Debug Control allowing disabling the bump map on this material.
  49112. */
  49113. protected _disableBumpMap: boolean;
  49114. /**
  49115. * AKA Diffuse Texture in standard nomenclature.
  49116. */
  49117. protected _albedoTexture: Nullable<BaseTexture>;
  49118. /**
  49119. * AKA Occlusion Texture in other nomenclature.
  49120. */
  49121. protected _ambientTexture: Nullable<BaseTexture>;
  49122. /**
  49123. * AKA Occlusion Texture Intensity in other nomenclature.
  49124. */
  49125. protected _ambientTextureStrength: number;
  49126. /**
  49127. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49128. * 1 means it completely occludes it
  49129. * 0 mean it has no impact
  49130. */
  49131. protected _ambientTextureImpactOnAnalyticalLights: number;
  49132. /**
  49133. * Stores the alpha values in a texture.
  49134. */
  49135. protected _opacityTexture: Nullable<BaseTexture>;
  49136. /**
  49137. * Stores the reflection values in a texture.
  49138. */
  49139. protected _reflectionTexture: Nullable<BaseTexture>;
  49140. /**
  49141. * Stores the emissive values in a texture.
  49142. */
  49143. protected _emissiveTexture: Nullable<BaseTexture>;
  49144. /**
  49145. * AKA Specular texture in other nomenclature.
  49146. */
  49147. protected _reflectivityTexture: Nullable<BaseTexture>;
  49148. /**
  49149. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49150. */
  49151. protected _metallicTexture: Nullable<BaseTexture>;
  49152. /**
  49153. * Specifies the metallic scalar of the metallic/roughness workflow.
  49154. * Can also be used to scale the metalness values of the metallic texture.
  49155. */
  49156. protected _metallic: Nullable<number>;
  49157. /**
  49158. * Specifies the roughness scalar of the metallic/roughness workflow.
  49159. * Can also be used to scale the roughness values of the metallic texture.
  49160. */
  49161. protected _roughness: Nullable<number>;
  49162. /**
  49163. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49164. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49165. */
  49166. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49167. /**
  49168. * Stores surface normal data used to displace a mesh in a texture.
  49169. */
  49170. protected _bumpTexture: Nullable<BaseTexture>;
  49171. /**
  49172. * Stores the pre-calculated light information of a mesh in a texture.
  49173. */
  49174. protected _lightmapTexture: Nullable<BaseTexture>;
  49175. /**
  49176. * The color of a material in ambient lighting.
  49177. */
  49178. protected _ambientColor: Color3;
  49179. /**
  49180. * AKA Diffuse Color in other nomenclature.
  49181. */
  49182. protected _albedoColor: Color3;
  49183. /**
  49184. * AKA Specular Color in other nomenclature.
  49185. */
  49186. protected _reflectivityColor: Color3;
  49187. /**
  49188. * The color applied when light is reflected from a material.
  49189. */
  49190. protected _reflectionColor: Color3;
  49191. /**
  49192. * The color applied when light is emitted from a material.
  49193. */
  49194. protected _emissiveColor: Color3;
  49195. /**
  49196. * AKA Glossiness in other nomenclature.
  49197. */
  49198. protected _microSurface: number;
  49199. /**
  49200. * Specifies that the material will use the light map as a show map.
  49201. */
  49202. protected _useLightmapAsShadowmap: boolean;
  49203. /**
  49204. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49205. * makes the reflect vector face the model (under horizon).
  49206. */
  49207. protected _useHorizonOcclusion: boolean;
  49208. /**
  49209. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49210. * too much the area relying on ambient texture to define their ambient occlusion.
  49211. */
  49212. protected _useRadianceOcclusion: boolean;
  49213. /**
  49214. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49215. */
  49216. protected _useAlphaFromAlbedoTexture: boolean;
  49217. /**
  49218. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49219. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49220. */
  49221. protected _useSpecularOverAlpha: boolean;
  49222. /**
  49223. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49224. */
  49225. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49226. /**
  49227. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49228. */
  49229. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49230. /**
  49231. * Specifies if the metallic texture contains the roughness information in its green channel.
  49232. */
  49233. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49234. /**
  49235. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49236. */
  49237. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49238. /**
  49239. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49240. */
  49241. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49242. /**
  49243. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49244. */
  49245. protected _useAmbientInGrayScale: boolean;
  49246. /**
  49247. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49248. * The material will try to infer what glossiness each pixel should be.
  49249. */
  49250. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49251. /**
  49252. * Defines the falloff type used in this material.
  49253. * It by default is Physical.
  49254. */
  49255. protected _lightFalloff: number;
  49256. /**
  49257. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49258. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49259. */
  49260. protected _useRadianceOverAlpha: boolean;
  49261. /**
  49262. * Allows using an object space normal map (instead of tangent space).
  49263. */
  49264. protected _useObjectSpaceNormalMap: boolean;
  49265. /**
  49266. * Allows using the bump map in parallax mode.
  49267. */
  49268. protected _useParallax: boolean;
  49269. /**
  49270. * Allows using the bump map in parallax occlusion mode.
  49271. */
  49272. protected _useParallaxOcclusion: boolean;
  49273. /**
  49274. * Controls the scale bias of the parallax mode.
  49275. */
  49276. protected _parallaxScaleBias: number;
  49277. /**
  49278. * If sets to true, disables all the lights affecting the material.
  49279. */
  49280. protected _disableLighting: boolean;
  49281. /**
  49282. * Number of Simultaneous lights allowed on the material.
  49283. */
  49284. protected _maxSimultaneousLights: number;
  49285. /**
  49286. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49287. */
  49288. protected _invertNormalMapX: boolean;
  49289. /**
  49290. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49291. */
  49292. protected _invertNormalMapY: boolean;
  49293. /**
  49294. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49295. */
  49296. protected _twoSidedLighting: boolean;
  49297. /**
  49298. * Defines the alpha limits in alpha test mode.
  49299. */
  49300. protected _alphaCutOff: number;
  49301. /**
  49302. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49303. */
  49304. protected _forceAlphaTest: boolean;
  49305. /**
  49306. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49307. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49308. */
  49309. protected _useAlphaFresnel: boolean;
  49310. /**
  49311. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49312. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49313. */
  49314. protected _useLinearAlphaFresnel: boolean;
  49315. /**
  49316. * The transparency mode of the material.
  49317. */
  49318. protected _transparencyMode: Nullable<number>;
  49319. /**
  49320. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49321. * from cos thetav and roughness:
  49322. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49323. */
  49324. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49325. /**
  49326. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49327. */
  49328. protected _forceIrradianceInFragment: boolean;
  49329. /**
  49330. * Force normal to face away from face.
  49331. */
  49332. protected _forceNormalForward: boolean;
  49333. /**
  49334. * Enables specular anti aliasing in the PBR shader.
  49335. * It will both interacts on the Geometry for analytical and IBL lighting.
  49336. * It also prefilter the roughness map based on the bump values.
  49337. */
  49338. protected _enableSpecularAntiAliasing: boolean;
  49339. /**
  49340. * Default configuration related to image processing available in the PBR Material.
  49341. */
  49342. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49343. /**
  49344. * Keep track of the image processing observer to allow dispose and replace.
  49345. */
  49346. private _imageProcessingObserver;
  49347. /**
  49348. * Attaches a new image processing configuration to the PBR Material.
  49349. * @param configuration
  49350. */
  49351. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49352. /**
  49353. * Stores the available render targets.
  49354. */
  49355. private _renderTargets;
  49356. /**
  49357. * Sets the global ambient color for the material used in lighting calculations.
  49358. */
  49359. private _globalAmbientColor;
  49360. /**
  49361. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49362. */
  49363. private _useLogarithmicDepth;
  49364. /**
  49365. * If set to true, no lighting calculations will be applied.
  49366. */
  49367. private _unlit;
  49368. private _debugMode;
  49369. /**
  49370. * @hidden
  49371. * This is reserved for the inspector.
  49372. * Defines the material debug mode.
  49373. * It helps seeing only some components of the material while troubleshooting.
  49374. */
  49375. debugMode: number;
  49376. /**
  49377. * @hidden
  49378. * This is reserved for the inspector.
  49379. * Specify from where on screen the debug mode should start.
  49380. * The value goes from -1 (full screen) to 1 (not visible)
  49381. * It helps with side by side comparison against the final render
  49382. * This defaults to -1
  49383. */
  49384. private debugLimit;
  49385. /**
  49386. * @hidden
  49387. * This is reserved for the inspector.
  49388. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49389. * You can use the factor to better multiply the final value.
  49390. */
  49391. private debugFactor;
  49392. /**
  49393. * Defines the clear coat layer parameters for the material.
  49394. */
  49395. readonly clearCoat: PBRClearCoatConfiguration;
  49396. /**
  49397. * Defines the anisotropic parameters for the material.
  49398. */
  49399. readonly anisotropy: PBRAnisotropicConfiguration;
  49400. /**
  49401. * Defines the BRDF parameters for the material.
  49402. */
  49403. readonly brdf: PBRBRDFConfiguration;
  49404. /**
  49405. * Defines the Sheen parameters for the material.
  49406. */
  49407. readonly sheen: PBRSheenConfiguration;
  49408. /**
  49409. * Defines the SubSurface parameters for the material.
  49410. */
  49411. readonly subSurface: PBRSubSurfaceConfiguration;
  49412. /**
  49413. * Custom callback helping to override the default shader used in the material.
  49414. */
  49415. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49416. protected _rebuildInParallel: boolean;
  49417. /**
  49418. * Instantiates a new PBRMaterial instance.
  49419. *
  49420. * @param name The material name
  49421. * @param scene The scene the material will be use in.
  49422. */
  49423. constructor(name: string, scene: Scene);
  49424. /**
  49425. * Gets a boolean indicating that current material needs to register RTT
  49426. */
  49427. readonly hasRenderTargetTextures: boolean;
  49428. /**
  49429. * Gets the name of the material class.
  49430. */
  49431. getClassName(): string;
  49432. /**
  49433. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49434. */
  49435. /**
  49436. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49437. */
  49438. useLogarithmicDepth: boolean;
  49439. /**
  49440. * Gets the current transparency mode.
  49441. */
  49442. /**
  49443. * Sets the transparency mode of the material.
  49444. *
  49445. * | Value | Type | Description |
  49446. * | ----- | ----------------------------------- | ----------- |
  49447. * | 0 | OPAQUE | |
  49448. * | 1 | ALPHATEST | |
  49449. * | 2 | ALPHABLEND | |
  49450. * | 3 | ALPHATESTANDBLEND | |
  49451. *
  49452. */
  49453. transparencyMode: Nullable<number>;
  49454. /**
  49455. * Returns true if alpha blending should be disabled.
  49456. */
  49457. private readonly _disableAlphaBlending;
  49458. /**
  49459. * Specifies whether or not this material should be rendered in alpha blend mode.
  49460. */
  49461. needAlphaBlending(): boolean;
  49462. /**
  49463. * Specifies if the mesh will require alpha blending.
  49464. * @param mesh - BJS mesh.
  49465. */
  49466. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49467. /**
  49468. * Specifies whether or not this material should be rendered in alpha test mode.
  49469. */
  49470. needAlphaTesting(): boolean;
  49471. /**
  49472. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49473. */
  49474. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49475. /**
  49476. * Gets the texture used for the alpha test.
  49477. */
  49478. getAlphaTestTexture(): Nullable<BaseTexture>;
  49479. /**
  49480. * Specifies that the submesh is ready to be used.
  49481. * @param mesh - BJS mesh.
  49482. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49483. * @param useInstances - Specifies that instances should be used.
  49484. * @returns - boolean indicating that the submesh is ready or not.
  49485. */
  49486. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49487. /**
  49488. * Specifies if the material uses metallic roughness workflow.
  49489. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49490. */
  49491. isMetallicWorkflow(): boolean;
  49492. private _prepareEffect;
  49493. private _prepareDefines;
  49494. /**
  49495. * Force shader compilation
  49496. */
  49497. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49498. clipPlane: boolean;
  49499. }>): void;
  49500. /**
  49501. * Initializes the uniform buffer layout for the shader.
  49502. */
  49503. buildUniformLayout(): void;
  49504. /**
  49505. * Unbinds the material from the mesh
  49506. */
  49507. unbind(): void;
  49508. /**
  49509. * Binds the submesh data.
  49510. * @param world - The world matrix.
  49511. * @param mesh - The BJS mesh.
  49512. * @param subMesh - A submesh of the BJS mesh.
  49513. */
  49514. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49515. /**
  49516. * Returns the animatable textures.
  49517. * @returns - Array of animatable textures.
  49518. */
  49519. getAnimatables(): IAnimatable[];
  49520. /**
  49521. * Returns the texture used for reflections.
  49522. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49523. */
  49524. private _getReflectionTexture;
  49525. /**
  49526. * Returns an array of the actively used textures.
  49527. * @returns - Array of BaseTextures
  49528. */
  49529. getActiveTextures(): BaseTexture[];
  49530. /**
  49531. * Checks to see if a texture is used in the material.
  49532. * @param texture - Base texture to use.
  49533. * @returns - Boolean specifying if a texture is used in the material.
  49534. */
  49535. hasTexture(texture: BaseTexture): boolean;
  49536. /**
  49537. * Disposes the resources of the material.
  49538. * @param forceDisposeEffect - Forces the disposal of effects.
  49539. * @param forceDisposeTextures - Forces the disposal of all textures.
  49540. */
  49541. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49542. }
  49543. }
  49544. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49545. import { Nullable } from "babylonjs/types";
  49546. import { Scene } from "babylonjs/scene";
  49547. import { Color3 } from "babylonjs/Maths/math.color";
  49548. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49549. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49551. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49552. /**
  49553. * The Physically based material of BJS.
  49554. *
  49555. * This offers the main features of a standard PBR material.
  49556. * For more information, please refer to the documentation :
  49557. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49558. */
  49559. export class PBRMaterial extends PBRBaseMaterial {
  49560. /**
  49561. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49562. */
  49563. static readonly PBRMATERIAL_OPAQUE: number;
  49564. /**
  49565. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49566. */
  49567. static readonly PBRMATERIAL_ALPHATEST: number;
  49568. /**
  49569. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49570. */
  49571. static readonly PBRMATERIAL_ALPHABLEND: number;
  49572. /**
  49573. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49574. * They are also discarded below the alpha cutoff threshold to improve performances.
  49575. */
  49576. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49577. /**
  49578. * Defines the default value of how much AO map is occluding the analytical lights
  49579. * (point spot...).
  49580. */
  49581. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49582. /**
  49583. * Intensity of the direct lights e.g. the four lights available in your scene.
  49584. * This impacts both the direct diffuse and specular highlights.
  49585. */
  49586. directIntensity: number;
  49587. /**
  49588. * Intensity of the emissive part of the material.
  49589. * This helps controlling the emissive effect without modifying the emissive color.
  49590. */
  49591. emissiveIntensity: number;
  49592. /**
  49593. * Intensity of the environment e.g. how much the environment will light the object
  49594. * either through harmonics for rough material or through the refelction for shiny ones.
  49595. */
  49596. environmentIntensity: number;
  49597. /**
  49598. * This is a special control allowing the reduction of the specular highlights coming from the
  49599. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49600. */
  49601. specularIntensity: number;
  49602. /**
  49603. * Debug Control allowing disabling the bump map on this material.
  49604. */
  49605. disableBumpMap: boolean;
  49606. /**
  49607. * AKA Diffuse Texture in standard nomenclature.
  49608. */
  49609. albedoTexture: BaseTexture;
  49610. /**
  49611. * AKA Occlusion Texture in other nomenclature.
  49612. */
  49613. ambientTexture: BaseTexture;
  49614. /**
  49615. * AKA Occlusion Texture Intensity in other nomenclature.
  49616. */
  49617. ambientTextureStrength: number;
  49618. /**
  49619. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49620. * 1 means it completely occludes it
  49621. * 0 mean it has no impact
  49622. */
  49623. ambientTextureImpactOnAnalyticalLights: number;
  49624. /**
  49625. * Stores the alpha values in a texture.
  49626. */
  49627. opacityTexture: BaseTexture;
  49628. /**
  49629. * Stores the reflection values in a texture.
  49630. */
  49631. reflectionTexture: Nullable<BaseTexture>;
  49632. /**
  49633. * Stores the emissive values in a texture.
  49634. */
  49635. emissiveTexture: BaseTexture;
  49636. /**
  49637. * AKA Specular texture in other nomenclature.
  49638. */
  49639. reflectivityTexture: BaseTexture;
  49640. /**
  49641. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49642. */
  49643. metallicTexture: BaseTexture;
  49644. /**
  49645. * Specifies the metallic scalar of the metallic/roughness workflow.
  49646. * Can also be used to scale the metalness values of the metallic texture.
  49647. */
  49648. metallic: Nullable<number>;
  49649. /**
  49650. * Specifies the roughness scalar of the metallic/roughness workflow.
  49651. * Can also be used to scale the roughness values of the metallic texture.
  49652. */
  49653. roughness: Nullable<number>;
  49654. /**
  49655. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49656. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49657. */
  49658. microSurfaceTexture: BaseTexture;
  49659. /**
  49660. * Stores surface normal data used to displace a mesh in a texture.
  49661. */
  49662. bumpTexture: BaseTexture;
  49663. /**
  49664. * Stores the pre-calculated light information of a mesh in a texture.
  49665. */
  49666. lightmapTexture: BaseTexture;
  49667. /**
  49668. * Stores the refracted light information in a texture.
  49669. */
  49670. refractionTexture: Nullable<BaseTexture>;
  49671. /**
  49672. * The color of a material in ambient lighting.
  49673. */
  49674. ambientColor: Color3;
  49675. /**
  49676. * AKA Diffuse Color in other nomenclature.
  49677. */
  49678. albedoColor: Color3;
  49679. /**
  49680. * AKA Specular Color in other nomenclature.
  49681. */
  49682. reflectivityColor: Color3;
  49683. /**
  49684. * The color reflected from the material.
  49685. */
  49686. reflectionColor: Color3;
  49687. /**
  49688. * The color emitted from the material.
  49689. */
  49690. emissiveColor: Color3;
  49691. /**
  49692. * AKA Glossiness in other nomenclature.
  49693. */
  49694. microSurface: number;
  49695. /**
  49696. * source material index of refraction (IOR)' / 'destination material IOR.
  49697. */
  49698. indexOfRefraction: number;
  49699. /**
  49700. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49701. */
  49702. invertRefractionY: boolean;
  49703. /**
  49704. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49705. * Materials half opaque for instance using refraction could benefit from this control.
  49706. */
  49707. linkRefractionWithTransparency: boolean;
  49708. /**
  49709. * If true, the light map contains occlusion information instead of lighting info.
  49710. */
  49711. useLightmapAsShadowmap: boolean;
  49712. /**
  49713. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49714. */
  49715. useAlphaFromAlbedoTexture: boolean;
  49716. /**
  49717. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49718. */
  49719. forceAlphaTest: boolean;
  49720. /**
  49721. * Defines the alpha limits in alpha test mode.
  49722. */
  49723. alphaCutOff: number;
  49724. /**
  49725. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49726. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49727. */
  49728. useSpecularOverAlpha: boolean;
  49729. /**
  49730. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49731. */
  49732. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49733. /**
  49734. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49735. */
  49736. useRoughnessFromMetallicTextureAlpha: boolean;
  49737. /**
  49738. * Specifies if the metallic texture contains the roughness information in its green channel.
  49739. */
  49740. useRoughnessFromMetallicTextureGreen: boolean;
  49741. /**
  49742. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49743. */
  49744. useMetallnessFromMetallicTextureBlue: boolean;
  49745. /**
  49746. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49747. */
  49748. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49749. /**
  49750. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49751. */
  49752. useAmbientInGrayScale: boolean;
  49753. /**
  49754. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49755. * The material will try to infer what glossiness each pixel should be.
  49756. */
  49757. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49758. /**
  49759. * BJS is using an harcoded light falloff based on a manually sets up range.
  49760. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49761. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49762. */
  49763. /**
  49764. * BJS is using an harcoded light falloff based on a manually sets up range.
  49765. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49766. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49767. */
  49768. usePhysicalLightFalloff: boolean;
  49769. /**
  49770. * In order to support the falloff compatibility with gltf, a special mode has been added
  49771. * to reproduce the gltf light falloff.
  49772. */
  49773. /**
  49774. * In order to support the falloff compatibility with gltf, a special mode has been added
  49775. * to reproduce the gltf light falloff.
  49776. */
  49777. useGLTFLightFalloff: boolean;
  49778. /**
  49779. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49780. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49781. */
  49782. useRadianceOverAlpha: boolean;
  49783. /**
  49784. * Allows using an object space normal map (instead of tangent space).
  49785. */
  49786. useObjectSpaceNormalMap: boolean;
  49787. /**
  49788. * Allows using the bump map in parallax mode.
  49789. */
  49790. useParallax: boolean;
  49791. /**
  49792. * Allows using the bump map in parallax occlusion mode.
  49793. */
  49794. useParallaxOcclusion: boolean;
  49795. /**
  49796. * Controls the scale bias of the parallax mode.
  49797. */
  49798. parallaxScaleBias: number;
  49799. /**
  49800. * If sets to true, disables all the lights affecting the material.
  49801. */
  49802. disableLighting: boolean;
  49803. /**
  49804. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49805. */
  49806. forceIrradianceInFragment: boolean;
  49807. /**
  49808. * Number of Simultaneous lights allowed on the material.
  49809. */
  49810. maxSimultaneousLights: number;
  49811. /**
  49812. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49813. */
  49814. invertNormalMapX: boolean;
  49815. /**
  49816. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49817. */
  49818. invertNormalMapY: boolean;
  49819. /**
  49820. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49821. */
  49822. twoSidedLighting: boolean;
  49823. /**
  49824. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49825. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49826. */
  49827. useAlphaFresnel: boolean;
  49828. /**
  49829. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49830. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49831. */
  49832. useLinearAlphaFresnel: boolean;
  49833. /**
  49834. * Let user defines the brdf lookup texture used for IBL.
  49835. * A default 8bit version is embedded but you could point at :
  49836. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49837. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49838. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49839. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49840. */
  49841. environmentBRDFTexture: Nullable<BaseTexture>;
  49842. /**
  49843. * Force normal to face away from face.
  49844. */
  49845. forceNormalForward: boolean;
  49846. /**
  49847. * Enables specular anti aliasing in the PBR shader.
  49848. * It will both interacts on the Geometry for analytical and IBL lighting.
  49849. * It also prefilter the roughness map based on the bump values.
  49850. */
  49851. enableSpecularAntiAliasing: boolean;
  49852. /**
  49853. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49854. * makes the reflect vector face the model (under horizon).
  49855. */
  49856. useHorizonOcclusion: boolean;
  49857. /**
  49858. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49859. * too much the area relying on ambient texture to define their ambient occlusion.
  49860. */
  49861. useRadianceOcclusion: boolean;
  49862. /**
  49863. * If set to true, no lighting calculations will be applied.
  49864. */
  49865. unlit: boolean;
  49866. /**
  49867. * Gets the image processing configuration used either in this material.
  49868. */
  49869. /**
  49870. * Sets the Default image processing configuration used either in the this material.
  49871. *
  49872. * If sets to null, the scene one is in use.
  49873. */
  49874. imageProcessingConfiguration: ImageProcessingConfiguration;
  49875. /**
  49876. * Gets wether the color curves effect is enabled.
  49877. */
  49878. /**
  49879. * Sets wether the color curves effect is enabled.
  49880. */
  49881. cameraColorCurvesEnabled: boolean;
  49882. /**
  49883. * Gets wether the color grading effect is enabled.
  49884. */
  49885. /**
  49886. * Gets wether the color grading effect is enabled.
  49887. */
  49888. cameraColorGradingEnabled: boolean;
  49889. /**
  49890. * Gets wether tonemapping is enabled or not.
  49891. */
  49892. /**
  49893. * Sets wether tonemapping is enabled or not
  49894. */
  49895. cameraToneMappingEnabled: boolean;
  49896. /**
  49897. * The camera exposure used on this material.
  49898. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49899. * This corresponds to a photographic exposure.
  49900. */
  49901. /**
  49902. * The camera exposure used on this material.
  49903. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49904. * This corresponds to a photographic exposure.
  49905. */
  49906. cameraExposure: number;
  49907. /**
  49908. * Gets The camera contrast used on this material.
  49909. */
  49910. /**
  49911. * Sets The camera contrast used on this material.
  49912. */
  49913. cameraContrast: number;
  49914. /**
  49915. * Gets the Color Grading 2D Lookup Texture.
  49916. */
  49917. /**
  49918. * Sets the Color Grading 2D Lookup Texture.
  49919. */
  49920. cameraColorGradingTexture: Nullable<BaseTexture>;
  49921. /**
  49922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49924. * 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;
  49925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49926. */
  49927. /**
  49928. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49929. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49930. * 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;
  49931. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49932. */
  49933. cameraColorCurves: Nullable<ColorCurves>;
  49934. /**
  49935. * Instantiates a new PBRMaterial instance.
  49936. *
  49937. * @param name The material name
  49938. * @param scene The scene the material will be use in.
  49939. */
  49940. constructor(name: string, scene: Scene);
  49941. /**
  49942. * Returns the name of this material class.
  49943. */
  49944. getClassName(): string;
  49945. /**
  49946. * Makes a duplicate of the current material.
  49947. * @param name - name to use for the new material.
  49948. */
  49949. clone(name: string): PBRMaterial;
  49950. /**
  49951. * Serializes this PBR Material.
  49952. * @returns - An object with the serialized material.
  49953. */
  49954. serialize(): any;
  49955. /**
  49956. * Parses a PBR Material from a serialized object.
  49957. * @param source - Serialized object.
  49958. * @param scene - BJS scene instance.
  49959. * @param rootUrl - url for the scene object
  49960. * @returns - PBRMaterial
  49961. */
  49962. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49963. }
  49964. }
  49965. declare module "babylonjs/Misc/dds" {
  49966. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49967. import { Engine } from "babylonjs/Engines/engine";
  49968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49969. import { Nullable } from "babylonjs/types";
  49970. import { Scene } from "babylonjs/scene";
  49971. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49972. /**
  49973. * Direct draw surface info
  49974. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49975. */
  49976. export interface DDSInfo {
  49977. /**
  49978. * Width of the texture
  49979. */
  49980. width: number;
  49981. /**
  49982. * Width of the texture
  49983. */
  49984. height: number;
  49985. /**
  49986. * Number of Mipmaps for the texture
  49987. * @see https://en.wikipedia.org/wiki/Mipmap
  49988. */
  49989. mipmapCount: number;
  49990. /**
  49991. * If the textures format is a known fourCC format
  49992. * @see https://www.fourcc.org/
  49993. */
  49994. isFourCC: boolean;
  49995. /**
  49996. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49997. */
  49998. isRGB: boolean;
  49999. /**
  50000. * If the texture is a lumincance format
  50001. */
  50002. isLuminance: boolean;
  50003. /**
  50004. * If this is a cube texture
  50005. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50006. */
  50007. isCube: boolean;
  50008. /**
  50009. * If the texture is a compressed format eg. FOURCC_DXT1
  50010. */
  50011. isCompressed: boolean;
  50012. /**
  50013. * The dxgiFormat of the texture
  50014. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50015. */
  50016. dxgiFormat: number;
  50017. /**
  50018. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50019. */
  50020. textureType: number;
  50021. /**
  50022. * Sphericle polynomial created for the dds texture
  50023. */
  50024. sphericalPolynomial?: SphericalPolynomial;
  50025. }
  50026. /**
  50027. * Class used to provide DDS decompression tools
  50028. */
  50029. export class DDSTools {
  50030. /**
  50031. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50032. */
  50033. static StoreLODInAlphaChannel: boolean;
  50034. /**
  50035. * Gets DDS information from an array buffer
  50036. * @param arrayBuffer defines the array buffer to read data from
  50037. * @returns the DDS information
  50038. */
  50039. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50040. private static _FloatView;
  50041. private static _Int32View;
  50042. private static _ToHalfFloat;
  50043. private static _FromHalfFloat;
  50044. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50045. private static _GetHalfFloatRGBAArrayBuffer;
  50046. private static _GetFloatRGBAArrayBuffer;
  50047. private static _GetFloatAsUIntRGBAArrayBuffer;
  50048. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50049. private static _GetRGBAArrayBuffer;
  50050. private static _ExtractLongWordOrder;
  50051. private static _GetRGBArrayBuffer;
  50052. private static _GetLuminanceArrayBuffer;
  50053. /**
  50054. * Uploads DDS Levels to a Babylon Texture
  50055. * @hidden
  50056. */
  50057. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50058. }
  50059. module "babylonjs/Engines/engine" {
  50060. interface Engine {
  50061. /**
  50062. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50063. * @param rootUrl defines the url where the file to load is located
  50064. * @param scene defines the current scene
  50065. * @param lodScale defines scale to apply to the mip map selection
  50066. * @param lodOffset defines offset to apply to the mip map selection
  50067. * @param onLoad defines an optional callback raised when the texture is loaded
  50068. * @param onError defines an optional callback raised if there is an issue to load the texture
  50069. * @param format defines the format of the data
  50070. * @param forcedExtension defines the extension to use to pick the right loader
  50071. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50072. * @returns the cube texture as an InternalTexture
  50073. */
  50074. 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;
  50075. }
  50076. }
  50077. }
  50078. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50079. import { Nullable } from "babylonjs/types";
  50080. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50081. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50082. /**
  50083. * Implementation of the DDS Texture Loader.
  50084. * @hidden
  50085. */
  50086. export class _DDSTextureLoader implements IInternalTextureLoader {
  50087. /**
  50088. * Defines wether the loader supports cascade loading the different faces.
  50089. */
  50090. readonly supportCascades: boolean;
  50091. /**
  50092. * This returns if the loader support the current file information.
  50093. * @param extension defines the file extension of the file being loaded
  50094. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50095. * @param fallback defines the fallback internal texture if any
  50096. * @param isBase64 defines whether the texture is encoded as a base64
  50097. * @param isBuffer defines whether the texture data are stored as a buffer
  50098. * @returns true if the loader can load the specified file
  50099. */
  50100. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50101. /**
  50102. * Transform the url before loading if required.
  50103. * @param rootUrl the url of the texture
  50104. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50105. * @returns the transformed texture
  50106. */
  50107. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50108. /**
  50109. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50110. * @param rootUrl the url of the texture
  50111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50112. * @returns the fallback texture
  50113. */
  50114. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50115. /**
  50116. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50117. * @param data contains the texture data
  50118. * @param texture defines the BabylonJS internal texture
  50119. * @param createPolynomials will be true if polynomials have been requested
  50120. * @param onLoad defines the callback to trigger once the texture is ready
  50121. * @param onError defines the callback to trigger in case of error
  50122. */
  50123. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50124. /**
  50125. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50126. * @param data contains the texture data
  50127. * @param texture defines the BabylonJS internal texture
  50128. * @param callback defines the method to call once ready to upload
  50129. */
  50130. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50131. }
  50132. }
  50133. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50134. import { Nullable } from "babylonjs/types";
  50135. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50136. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50137. /**
  50138. * Implementation of the ENV Texture Loader.
  50139. * @hidden
  50140. */
  50141. export class _ENVTextureLoader implements IInternalTextureLoader {
  50142. /**
  50143. * Defines wether the loader supports cascade loading the different faces.
  50144. */
  50145. readonly supportCascades: boolean;
  50146. /**
  50147. * This returns if the loader support the current file information.
  50148. * @param extension defines the file extension of the file being loaded
  50149. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50150. * @param fallback defines the fallback internal texture if any
  50151. * @param isBase64 defines whether the texture is encoded as a base64
  50152. * @param isBuffer defines whether the texture data are stored as a buffer
  50153. * @returns true if the loader can load the specified file
  50154. */
  50155. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50156. /**
  50157. * Transform the url before loading if required.
  50158. * @param rootUrl the url of the texture
  50159. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50160. * @returns the transformed texture
  50161. */
  50162. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50163. /**
  50164. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50165. * @param rootUrl the url of the texture
  50166. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50167. * @returns the fallback texture
  50168. */
  50169. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50170. /**
  50171. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50172. * @param data contains the texture data
  50173. * @param texture defines the BabylonJS internal texture
  50174. * @param createPolynomials will be true if polynomials have been requested
  50175. * @param onLoad defines the callback to trigger once the texture is ready
  50176. * @param onError defines the callback to trigger in case of error
  50177. */
  50178. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50179. /**
  50180. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50181. * @param data contains the texture data
  50182. * @param texture defines the BabylonJS internal texture
  50183. * @param callback defines the method to call once ready to upload
  50184. */
  50185. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50186. }
  50187. }
  50188. declare module "babylonjs/Misc/khronosTextureContainer" {
  50189. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50190. /**
  50191. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50192. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50193. */
  50194. export class KhronosTextureContainer {
  50195. /** contents of the KTX container file */
  50196. arrayBuffer: any;
  50197. private static HEADER_LEN;
  50198. private static COMPRESSED_2D;
  50199. private static COMPRESSED_3D;
  50200. private static TEX_2D;
  50201. private static TEX_3D;
  50202. /**
  50203. * Gets the openGL type
  50204. */
  50205. glType: number;
  50206. /**
  50207. * Gets the openGL type size
  50208. */
  50209. glTypeSize: number;
  50210. /**
  50211. * Gets the openGL format
  50212. */
  50213. glFormat: number;
  50214. /**
  50215. * Gets the openGL internal format
  50216. */
  50217. glInternalFormat: number;
  50218. /**
  50219. * Gets the base internal format
  50220. */
  50221. glBaseInternalFormat: number;
  50222. /**
  50223. * Gets image width in pixel
  50224. */
  50225. pixelWidth: number;
  50226. /**
  50227. * Gets image height in pixel
  50228. */
  50229. pixelHeight: number;
  50230. /**
  50231. * Gets image depth in pixels
  50232. */
  50233. pixelDepth: number;
  50234. /**
  50235. * Gets the number of array elements
  50236. */
  50237. numberOfArrayElements: number;
  50238. /**
  50239. * Gets the number of faces
  50240. */
  50241. numberOfFaces: number;
  50242. /**
  50243. * Gets the number of mipmap levels
  50244. */
  50245. numberOfMipmapLevels: number;
  50246. /**
  50247. * Gets the bytes of key value data
  50248. */
  50249. bytesOfKeyValueData: number;
  50250. /**
  50251. * Gets the load type
  50252. */
  50253. loadType: number;
  50254. /**
  50255. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50256. */
  50257. isInvalid: boolean;
  50258. /**
  50259. * Creates a new KhronosTextureContainer
  50260. * @param arrayBuffer contents of the KTX container file
  50261. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50262. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50263. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50264. */
  50265. constructor(
  50266. /** contents of the KTX container file */
  50267. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50268. /**
  50269. * Uploads KTX content to a Babylon Texture.
  50270. * It is assumed that the texture has already been created & is currently bound
  50271. * @hidden
  50272. */
  50273. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50274. private _upload2DCompressedLevels;
  50275. }
  50276. }
  50277. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50278. import { Nullable } from "babylonjs/types";
  50279. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50280. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50281. /**
  50282. * Implementation of the KTX Texture Loader.
  50283. * @hidden
  50284. */
  50285. export class _KTXTextureLoader implements IInternalTextureLoader {
  50286. /**
  50287. * Defines wether the loader supports cascade loading the different faces.
  50288. */
  50289. readonly supportCascades: boolean;
  50290. /**
  50291. * This returns if the loader support the current file information.
  50292. * @param extension defines the file extension of the file being loaded
  50293. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50294. * @param fallback defines the fallback internal texture if any
  50295. * @param isBase64 defines whether the texture is encoded as a base64
  50296. * @param isBuffer defines whether the texture data are stored as a buffer
  50297. * @returns true if the loader can load the specified file
  50298. */
  50299. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50300. /**
  50301. * Transform the url before loading if required.
  50302. * @param rootUrl the url of the texture
  50303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50304. * @returns the transformed texture
  50305. */
  50306. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50307. /**
  50308. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50309. * @param rootUrl the url of the texture
  50310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50311. * @returns the fallback texture
  50312. */
  50313. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50314. /**
  50315. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50316. * @param data contains the texture data
  50317. * @param texture defines the BabylonJS internal texture
  50318. * @param createPolynomials will be true if polynomials have been requested
  50319. * @param onLoad defines the callback to trigger once the texture is ready
  50320. * @param onError defines the callback to trigger in case of error
  50321. */
  50322. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50323. /**
  50324. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50325. * @param data contains the texture data
  50326. * @param texture defines the BabylonJS internal texture
  50327. * @param callback defines the method to call once ready to upload
  50328. */
  50329. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50330. }
  50331. }
  50332. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50333. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50334. import { Scene } from "babylonjs/scene";
  50335. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50336. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50337. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50338. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50339. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50340. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50342. /**
  50343. * Options for the default xr helper
  50344. */
  50345. export class WebXRDefaultExperienceOptions {
  50346. /**
  50347. * Floor meshes that should be used for teleporting
  50348. */
  50349. floorMeshes: Array<AbstractMesh>;
  50350. }
  50351. /**
  50352. * Default experience which provides a similar setup to the previous webVRExperience
  50353. */
  50354. export class WebXRDefaultExperience {
  50355. /**
  50356. * Base experience
  50357. */
  50358. baseExperience: WebXRExperienceHelper;
  50359. /**
  50360. * Input experience extension
  50361. */
  50362. input: WebXRInput;
  50363. /**
  50364. * Loads the controller models
  50365. */
  50366. controllerModelLoader: WebXRControllerModelLoader;
  50367. /**
  50368. * Enables laser pointer and selection
  50369. */
  50370. pointerSelection: WebXRControllerPointerSelection;
  50371. /**
  50372. * Enables teleportation
  50373. */
  50374. teleportation: WebXRControllerTeleportation;
  50375. /**
  50376. * Enables ui for enetering/exiting xr
  50377. */
  50378. enterExitUI: WebXREnterExitUI;
  50379. /**
  50380. * Default output canvas xr should render to
  50381. */
  50382. outputCanvas: WebXRManagedOutputCanvas;
  50383. /**
  50384. * Creates the default xr experience
  50385. * @param scene scene
  50386. * @param options options for basic configuration
  50387. * @returns resulting WebXRDefaultExperience
  50388. */
  50389. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50390. private constructor();
  50391. /**
  50392. * DIsposes of the experience helper
  50393. */
  50394. dispose(): void;
  50395. }
  50396. }
  50397. declare module "babylonjs/Helpers/sceneHelpers" {
  50398. import { Nullable } from "babylonjs/types";
  50399. import { Mesh } from "babylonjs/Meshes/mesh";
  50400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50401. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50402. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50403. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50404. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50405. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50406. import "babylonjs/Meshes/Builders/boxBuilder";
  50407. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50408. /** @hidden */
  50409. export var _forceSceneHelpersToBundle: boolean;
  50410. module "babylonjs/scene" {
  50411. interface Scene {
  50412. /**
  50413. * Creates a default light for the scene.
  50414. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50415. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50416. */
  50417. createDefaultLight(replace?: boolean): void;
  50418. /**
  50419. * Creates a default camera for the scene.
  50420. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50421. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50422. * @param replace has default false, when true replaces the active camera in the scene
  50423. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50424. */
  50425. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50426. /**
  50427. * Creates a default camera and a default light.
  50428. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50429. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50430. * @param replace has the default false, when true replaces the active camera/light in the scene
  50431. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50432. */
  50433. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50434. /**
  50435. * Creates a new sky box
  50436. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50437. * @param environmentTexture defines the texture to use as environment texture
  50438. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50439. * @param scale defines the overall scale of the skybox
  50440. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50441. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50442. * @returns a new mesh holding the sky box
  50443. */
  50444. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50445. /**
  50446. * Creates a new environment
  50447. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50448. * @param options defines the options you can use to configure the environment
  50449. * @returns the new EnvironmentHelper
  50450. */
  50451. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50452. /**
  50453. * Creates a new VREXperienceHelper
  50454. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50455. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50456. * @returns a new VREXperienceHelper
  50457. */
  50458. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50459. /**
  50460. * Creates a new WebXRDefaultExperience
  50461. * @see http://doc.babylonjs.com/how_to/webxr
  50462. * @param options experience options
  50463. * @returns a promise for a new WebXRDefaultExperience
  50464. */
  50465. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50466. }
  50467. }
  50468. }
  50469. declare module "babylonjs/Helpers/videoDome" {
  50470. import { Scene } from "babylonjs/scene";
  50471. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50472. import { Mesh } from "babylonjs/Meshes/mesh";
  50473. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50474. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50475. import "babylonjs/Meshes/Builders/sphereBuilder";
  50476. /**
  50477. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50478. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50479. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50480. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50481. */
  50482. export class VideoDome extends TransformNode {
  50483. /**
  50484. * Define the video source as a Monoscopic panoramic 360 video.
  50485. */
  50486. static readonly MODE_MONOSCOPIC: number;
  50487. /**
  50488. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50489. */
  50490. static readonly MODE_TOPBOTTOM: number;
  50491. /**
  50492. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50493. */
  50494. static readonly MODE_SIDEBYSIDE: number;
  50495. private _halfDome;
  50496. private _useDirectMapping;
  50497. /**
  50498. * The video texture being displayed on the sphere
  50499. */
  50500. protected _videoTexture: VideoTexture;
  50501. /**
  50502. * Gets the video texture being displayed on the sphere
  50503. */
  50504. readonly videoTexture: VideoTexture;
  50505. /**
  50506. * The skybox material
  50507. */
  50508. protected _material: BackgroundMaterial;
  50509. /**
  50510. * The surface used for the skybox
  50511. */
  50512. protected _mesh: Mesh;
  50513. /**
  50514. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50515. */
  50516. private _halfDomeMask;
  50517. /**
  50518. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50519. * Also see the options.resolution property.
  50520. */
  50521. fovMultiplier: number;
  50522. private _videoMode;
  50523. /**
  50524. * Gets or set the current video mode for the video. It can be:
  50525. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50526. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50527. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50528. */
  50529. videoMode: number;
  50530. /**
  50531. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50532. *
  50533. */
  50534. /**
  50535. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50536. */
  50537. halfDome: boolean;
  50538. /**
  50539. * Oberserver used in Stereoscopic VR Mode.
  50540. */
  50541. private _onBeforeCameraRenderObserver;
  50542. /**
  50543. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50544. * @param name Element's name, child elements will append suffixes for their own names.
  50545. * @param urlsOrVideo defines the url(s) or the video element to use
  50546. * @param options An object containing optional or exposed sub element properties
  50547. */
  50548. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50549. resolution?: number;
  50550. clickToPlay?: boolean;
  50551. autoPlay?: boolean;
  50552. loop?: boolean;
  50553. size?: number;
  50554. poster?: string;
  50555. faceForward?: boolean;
  50556. useDirectMapping?: boolean;
  50557. halfDomeMode?: boolean;
  50558. }, scene: Scene);
  50559. private _changeVideoMode;
  50560. /**
  50561. * Releases resources associated with this node.
  50562. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50563. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50564. */
  50565. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50566. }
  50567. }
  50568. declare module "babylonjs/Helpers/index" {
  50569. export * from "babylonjs/Helpers/environmentHelper";
  50570. export * from "babylonjs/Helpers/photoDome";
  50571. export * from "babylonjs/Helpers/sceneHelpers";
  50572. export * from "babylonjs/Helpers/videoDome";
  50573. }
  50574. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50575. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50576. import { IDisposable } from "babylonjs/scene";
  50577. import { Engine } from "babylonjs/Engines/engine";
  50578. /**
  50579. * This class can be used to get instrumentation data from a Babylon engine
  50580. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50581. */
  50582. export class EngineInstrumentation implements IDisposable {
  50583. /**
  50584. * Define the instrumented engine.
  50585. */
  50586. engine: Engine;
  50587. private _captureGPUFrameTime;
  50588. private _gpuFrameTimeToken;
  50589. private _gpuFrameTime;
  50590. private _captureShaderCompilationTime;
  50591. private _shaderCompilationTime;
  50592. private _onBeginFrameObserver;
  50593. private _onEndFrameObserver;
  50594. private _onBeforeShaderCompilationObserver;
  50595. private _onAfterShaderCompilationObserver;
  50596. /**
  50597. * Gets the perf counter used for GPU frame time
  50598. */
  50599. readonly gpuFrameTimeCounter: PerfCounter;
  50600. /**
  50601. * Gets the GPU frame time capture status
  50602. */
  50603. /**
  50604. * Enable or disable the GPU frame time capture
  50605. */
  50606. captureGPUFrameTime: boolean;
  50607. /**
  50608. * Gets the perf counter used for shader compilation time
  50609. */
  50610. readonly shaderCompilationTimeCounter: PerfCounter;
  50611. /**
  50612. * Gets the shader compilation time capture status
  50613. */
  50614. /**
  50615. * Enable or disable the shader compilation time capture
  50616. */
  50617. captureShaderCompilationTime: boolean;
  50618. /**
  50619. * Instantiates a new engine instrumentation.
  50620. * This class can be used to get instrumentation data from a Babylon engine
  50621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50622. * @param engine Defines the engine to instrument
  50623. */
  50624. constructor(
  50625. /**
  50626. * Define the instrumented engine.
  50627. */
  50628. engine: Engine);
  50629. /**
  50630. * Dispose and release associated resources.
  50631. */
  50632. dispose(): void;
  50633. }
  50634. }
  50635. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50636. import { Scene, IDisposable } from "babylonjs/scene";
  50637. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50638. /**
  50639. * This class can be used to get instrumentation data from a Babylon engine
  50640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50641. */
  50642. export class SceneInstrumentation implements IDisposable {
  50643. /**
  50644. * Defines the scene to instrument
  50645. */
  50646. scene: Scene;
  50647. private _captureActiveMeshesEvaluationTime;
  50648. private _activeMeshesEvaluationTime;
  50649. private _captureRenderTargetsRenderTime;
  50650. private _renderTargetsRenderTime;
  50651. private _captureFrameTime;
  50652. private _frameTime;
  50653. private _captureRenderTime;
  50654. private _renderTime;
  50655. private _captureInterFrameTime;
  50656. private _interFrameTime;
  50657. private _captureParticlesRenderTime;
  50658. private _particlesRenderTime;
  50659. private _captureSpritesRenderTime;
  50660. private _spritesRenderTime;
  50661. private _capturePhysicsTime;
  50662. private _physicsTime;
  50663. private _captureAnimationsTime;
  50664. private _animationsTime;
  50665. private _captureCameraRenderTime;
  50666. private _cameraRenderTime;
  50667. private _onBeforeActiveMeshesEvaluationObserver;
  50668. private _onAfterActiveMeshesEvaluationObserver;
  50669. private _onBeforeRenderTargetsRenderObserver;
  50670. private _onAfterRenderTargetsRenderObserver;
  50671. private _onAfterRenderObserver;
  50672. private _onBeforeDrawPhaseObserver;
  50673. private _onAfterDrawPhaseObserver;
  50674. private _onBeforeAnimationsObserver;
  50675. private _onBeforeParticlesRenderingObserver;
  50676. private _onAfterParticlesRenderingObserver;
  50677. private _onBeforeSpritesRenderingObserver;
  50678. private _onAfterSpritesRenderingObserver;
  50679. private _onBeforePhysicsObserver;
  50680. private _onAfterPhysicsObserver;
  50681. private _onAfterAnimationsObserver;
  50682. private _onBeforeCameraRenderObserver;
  50683. private _onAfterCameraRenderObserver;
  50684. /**
  50685. * Gets the perf counter used for active meshes evaluation time
  50686. */
  50687. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50688. /**
  50689. * Gets the active meshes evaluation time capture status
  50690. */
  50691. /**
  50692. * Enable or disable the active meshes evaluation time capture
  50693. */
  50694. captureActiveMeshesEvaluationTime: boolean;
  50695. /**
  50696. * Gets the perf counter used for render targets render time
  50697. */
  50698. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50699. /**
  50700. * Gets the render targets render time capture status
  50701. */
  50702. /**
  50703. * Enable or disable the render targets render time capture
  50704. */
  50705. captureRenderTargetsRenderTime: boolean;
  50706. /**
  50707. * Gets the perf counter used for particles render time
  50708. */
  50709. readonly particlesRenderTimeCounter: PerfCounter;
  50710. /**
  50711. * Gets the particles render time capture status
  50712. */
  50713. /**
  50714. * Enable or disable the particles render time capture
  50715. */
  50716. captureParticlesRenderTime: boolean;
  50717. /**
  50718. * Gets the perf counter used for sprites render time
  50719. */
  50720. readonly spritesRenderTimeCounter: PerfCounter;
  50721. /**
  50722. * Gets the sprites render time capture status
  50723. */
  50724. /**
  50725. * Enable or disable the sprites render time capture
  50726. */
  50727. captureSpritesRenderTime: boolean;
  50728. /**
  50729. * Gets the perf counter used for physics time
  50730. */
  50731. readonly physicsTimeCounter: PerfCounter;
  50732. /**
  50733. * Gets the physics time capture status
  50734. */
  50735. /**
  50736. * Enable or disable the physics time capture
  50737. */
  50738. capturePhysicsTime: boolean;
  50739. /**
  50740. * Gets the perf counter used for animations time
  50741. */
  50742. readonly animationsTimeCounter: PerfCounter;
  50743. /**
  50744. * Gets the animations time capture status
  50745. */
  50746. /**
  50747. * Enable or disable the animations time capture
  50748. */
  50749. captureAnimationsTime: boolean;
  50750. /**
  50751. * Gets the perf counter used for frame time capture
  50752. */
  50753. readonly frameTimeCounter: PerfCounter;
  50754. /**
  50755. * Gets the frame time capture status
  50756. */
  50757. /**
  50758. * Enable or disable the frame time capture
  50759. */
  50760. captureFrameTime: boolean;
  50761. /**
  50762. * Gets the perf counter used for inter-frames time capture
  50763. */
  50764. readonly interFrameTimeCounter: PerfCounter;
  50765. /**
  50766. * Gets the inter-frames time capture status
  50767. */
  50768. /**
  50769. * Enable or disable the inter-frames time capture
  50770. */
  50771. captureInterFrameTime: boolean;
  50772. /**
  50773. * Gets the perf counter used for render time capture
  50774. */
  50775. readonly renderTimeCounter: PerfCounter;
  50776. /**
  50777. * Gets the render time capture status
  50778. */
  50779. /**
  50780. * Enable or disable the render time capture
  50781. */
  50782. captureRenderTime: boolean;
  50783. /**
  50784. * Gets the perf counter used for camera render time capture
  50785. */
  50786. readonly cameraRenderTimeCounter: PerfCounter;
  50787. /**
  50788. * Gets the camera render time capture status
  50789. */
  50790. /**
  50791. * Enable or disable the camera render time capture
  50792. */
  50793. captureCameraRenderTime: boolean;
  50794. /**
  50795. * Gets the perf counter used for draw calls
  50796. */
  50797. readonly drawCallsCounter: PerfCounter;
  50798. /**
  50799. * Instantiates a new scene instrumentation.
  50800. * This class can be used to get instrumentation data from a Babylon engine
  50801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50802. * @param scene Defines the scene to instrument
  50803. */
  50804. constructor(
  50805. /**
  50806. * Defines the scene to instrument
  50807. */
  50808. scene: Scene);
  50809. /**
  50810. * Dispose and release associated resources.
  50811. */
  50812. dispose(): void;
  50813. }
  50814. }
  50815. declare module "babylonjs/Instrumentation/index" {
  50816. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50817. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50818. export * from "babylonjs/Instrumentation/timeToken";
  50819. }
  50820. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50821. /** @hidden */
  50822. export var glowMapGenerationPixelShader: {
  50823. name: string;
  50824. shader: string;
  50825. };
  50826. }
  50827. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50828. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50829. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50830. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50831. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50832. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50833. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50834. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50835. /** @hidden */
  50836. export var glowMapGenerationVertexShader: {
  50837. name: string;
  50838. shader: string;
  50839. };
  50840. }
  50841. declare module "babylonjs/Layers/effectLayer" {
  50842. import { Observable } from "babylonjs/Misc/observable";
  50843. import { Nullable } from "babylonjs/types";
  50844. import { Camera } from "babylonjs/Cameras/camera";
  50845. import { Scene } from "babylonjs/scene";
  50846. import { ISize } from "babylonjs/Maths/math.size";
  50847. import { Color4 } from "babylonjs/Maths/math.color";
  50848. import { Engine } from "babylonjs/Engines/engine";
  50849. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50851. import { Mesh } from "babylonjs/Meshes/mesh";
  50852. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50854. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50855. import { Effect } from "babylonjs/Materials/effect";
  50856. import { Material } from "babylonjs/Materials/material";
  50857. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50858. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50859. /**
  50860. * Effect layer options. This helps customizing the behaviour
  50861. * of the effect layer.
  50862. */
  50863. export interface IEffectLayerOptions {
  50864. /**
  50865. * Multiplication factor apply to the canvas size to compute the render target size
  50866. * used to generated the objects (the smaller the faster).
  50867. */
  50868. mainTextureRatio: number;
  50869. /**
  50870. * Enforces a fixed size texture to ensure effect stability across devices.
  50871. */
  50872. mainTextureFixedSize?: number;
  50873. /**
  50874. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50875. */
  50876. alphaBlendingMode: number;
  50877. /**
  50878. * The camera attached to the layer.
  50879. */
  50880. camera: Nullable<Camera>;
  50881. /**
  50882. * The rendering group to draw the layer in.
  50883. */
  50884. renderingGroupId: number;
  50885. }
  50886. /**
  50887. * The effect layer Helps adding post process effect blended with the main pass.
  50888. *
  50889. * This can be for instance use to generate glow or higlight effects on the scene.
  50890. *
  50891. * The effect layer class can not be used directly and is intented to inherited from to be
  50892. * customized per effects.
  50893. */
  50894. export abstract class EffectLayer {
  50895. private _vertexBuffers;
  50896. private _indexBuffer;
  50897. private _cachedDefines;
  50898. private _effectLayerMapGenerationEffect;
  50899. private _effectLayerOptions;
  50900. private _mergeEffect;
  50901. protected _scene: Scene;
  50902. protected _engine: Engine;
  50903. protected _maxSize: number;
  50904. protected _mainTextureDesiredSize: ISize;
  50905. protected _mainTexture: RenderTargetTexture;
  50906. protected _shouldRender: boolean;
  50907. protected _postProcesses: PostProcess[];
  50908. protected _textures: BaseTexture[];
  50909. protected _emissiveTextureAndColor: {
  50910. texture: Nullable<BaseTexture>;
  50911. color: Color4;
  50912. };
  50913. /**
  50914. * The name of the layer
  50915. */
  50916. name: string;
  50917. /**
  50918. * The clear color of the texture used to generate the glow map.
  50919. */
  50920. neutralColor: Color4;
  50921. /**
  50922. * Specifies wether the highlight layer is enabled or not.
  50923. */
  50924. isEnabled: boolean;
  50925. /**
  50926. * Gets the camera attached to the layer.
  50927. */
  50928. readonly camera: Nullable<Camera>;
  50929. /**
  50930. * Gets the rendering group id the layer should render in.
  50931. */
  50932. renderingGroupId: number;
  50933. /**
  50934. * An event triggered when the effect layer has been disposed.
  50935. */
  50936. onDisposeObservable: Observable<EffectLayer>;
  50937. /**
  50938. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50939. */
  50940. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50941. /**
  50942. * An event triggered when the generated texture is being merged in the scene.
  50943. */
  50944. onBeforeComposeObservable: Observable<EffectLayer>;
  50945. /**
  50946. * An event triggered when the generated texture has been merged in the scene.
  50947. */
  50948. onAfterComposeObservable: Observable<EffectLayer>;
  50949. /**
  50950. * An event triggered when the efffect layer changes its size.
  50951. */
  50952. onSizeChangedObservable: Observable<EffectLayer>;
  50953. /** @hidden */
  50954. static _SceneComponentInitialization: (scene: Scene) => void;
  50955. /**
  50956. * Instantiates a new effect Layer and references it in the scene.
  50957. * @param name The name of the layer
  50958. * @param scene The scene to use the layer in
  50959. */
  50960. constructor(
  50961. /** The Friendly of the effect in the scene */
  50962. name: string, scene: Scene);
  50963. /**
  50964. * Get the effect name of the layer.
  50965. * @return The effect name
  50966. */
  50967. abstract getEffectName(): string;
  50968. /**
  50969. * Checks for the readiness of the element composing the layer.
  50970. * @param subMesh the mesh to check for
  50971. * @param useInstances specify wether or not to use instances to render the mesh
  50972. * @return true if ready otherwise, false
  50973. */
  50974. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50975. /**
  50976. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50977. * @returns true if the effect requires stencil during the main canvas render pass.
  50978. */
  50979. abstract needStencil(): boolean;
  50980. /**
  50981. * Create the merge effect. This is the shader use to blit the information back
  50982. * to the main canvas at the end of the scene rendering.
  50983. * @returns The effect containing the shader used to merge the effect on the main canvas
  50984. */
  50985. protected abstract _createMergeEffect(): Effect;
  50986. /**
  50987. * Creates the render target textures and post processes used in the effect layer.
  50988. */
  50989. protected abstract _createTextureAndPostProcesses(): void;
  50990. /**
  50991. * Implementation specific of rendering the generating effect on the main canvas.
  50992. * @param effect The effect used to render through
  50993. */
  50994. protected abstract _internalRender(effect: Effect): void;
  50995. /**
  50996. * Sets the required values for both the emissive texture and and the main color.
  50997. */
  50998. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50999. /**
  51000. * Free any resources and references associated to a mesh.
  51001. * Internal use
  51002. * @param mesh The mesh to free.
  51003. */
  51004. abstract _disposeMesh(mesh: Mesh): void;
  51005. /**
  51006. * Serializes this layer (Glow or Highlight for example)
  51007. * @returns a serialized layer object
  51008. */
  51009. abstract serialize?(): any;
  51010. /**
  51011. * Initializes the effect layer with the required options.
  51012. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51013. */
  51014. protected _init(options: Partial<IEffectLayerOptions>): void;
  51015. /**
  51016. * Generates the index buffer of the full screen quad blending to the main canvas.
  51017. */
  51018. private _generateIndexBuffer;
  51019. /**
  51020. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51021. */
  51022. private _generateVertexBuffer;
  51023. /**
  51024. * Sets the main texture desired size which is the closest power of two
  51025. * of the engine canvas size.
  51026. */
  51027. private _setMainTextureSize;
  51028. /**
  51029. * Creates the main texture for the effect layer.
  51030. */
  51031. protected _createMainTexture(): void;
  51032. /**
  51033. * Adds specific effects defines.
  51034. * @param defines The defines to add specifics to.
  51035. */
  51036. protected _addCustomEffectDefines(defines: string[]): void;
  51037. /**
  51038. * Checks for the readiness of the element composing the layer.
  51039. * @param subMesh the mesh to check for
  51040. * @param useInstances specify wether or not to use instances to render the mesh
  51041. * @param emissiveTexture the associated emissive texture used to generate the glow
  51042. * @return true if ready otherwise, false
  51043. */
  51044. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51045. /**
  51046. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51047. */
  51048. render(): void;
  51049. /**
  51050. * Determine if a given mesh will be used in the current effect.
  51051. * @param mesh mesh to test
  51052. * @returns true if the mesh will be used
  51053. */
  51054. hasMesh(mesh: AbstractMesh): boolean;
  51055. /**
  51056. * Returns true if the layer contains information to display, otherwise false.
  51057. * @returns true if the glow layer should be rendered
  51058. */
  51059. shouldRender(): boolean;
  51060. /**
  51061. * Returns true if the mesh should render, otherwise false.
  51062. * @param mesh The mesh to render
  51063. * @returns true if it should render otherwise false
  51064. */
  51065. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51066. /**
  51067. * Returns true if the mesh can be rendered, otherwise false.
  51068. * @param mesh The mesh to render
  51069. * @param material The material used on the mesh
  51070. * @returns true if it can be rendered otherwise false
  51071. */
  51072. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51073. /**
  51074. * Returns true if the mesh should render, otherwise false.
  51075. * @param mesh The mesh to render
  51076. * @returns true if it should render otherwise false
  51077. */
  51078. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51079. /**
  51080. * Renders the submesh passed in parameter to the generation map.
  51081. */
  51082. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51083. /**
  51084. * Rebuild the required buffers.
  51085. * @hidden Internal use only.
  51086. */
  51087. _rebuild(): void;
  51088. /**
  51089. * Dispose only the render target textures and post process.
  51090. */
  51091. private _disposeTextureAndPostProcesses;
  51092. /**
  51093. * Dispose the highlight layer and free resources.
  51094. */
  51095. dispose(): void;
  51096. /**
  51097. * Gets the class name of the effect layer
  51098. * @returns the string with the class name of the effect layer
  51099. */
  51100. getClassName(): string;
  51101. /**
  51102. * Creates an effect layer from parsed effect layer data
  51103. * @param parsedEffectLayer defines effect layer data
  51104. * @param scene defines the current scene
  51105. * @param rootUrl defines the root URL containing the effect layer information
  51106. * @returns a parsed effect Layer
  51107. */
  51108. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51109. }
  51110. }
  51111. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51112. import { Scene } from "babylonjs/scene";
  51113. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51114. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51115. import { AbstractScene } from "babylonjs/abstractScene";
  51116. module "babylonjs/abstractScene" {
  51117. interface AbstractScene {
  51118. /**
  51119. * The list of effect layers (highlights/glow) added to the scene
  51120. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51121. * @see http://doc.babylonjs.com/how_to/glow_layer
  51122. */
  51123. effectLayers: Array<EffectLayer>;
  51124. /**
  51125. * Removes the given effect layer from this scene.
  51126. * @param toRemove defines the effect layer to remove
  51127. * @returns the index of the removed effect layer
  51128. */
  51129. removeEffectLayer(toRemove: EffectLayer): number;
  51130. /**
  51131. * Adds the given effect layer to this scene
  51132. * @param newEffectLayer defines the effect layer to add
  51133. */
  51134. addEffectLayer(newEffectLayer: EffectLayer): void;
  51135. }
  51136. }
  51137. /**
  51138. * Defines the layer scene component responsible to manage any effect layers
  51139. * in a given scene.
  51140. */
  51141. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51142. /**
  51143. * The component name helpfull to identify the component in the list of scene components.
  51144. */
  51145. readonly name: string;
  51146. /**
  51147. * The scene the component belongs to.
  51148. */
  51149. scene: Scene;
  51150. private _engine;
  51151. private _renderEffects;
  51152. private _needStencil;
  51153. private _previousStencilState;
  51154. /**
  51155. * Creates a new instance of the component for the given scene
  51156. * @param scene Defines the scene to register the component in
  51157. */
  51158. constructor(scene: Scene);
  51159. /**
  51160. * Registers the component in a given scene
  51161. */
  51162. register(): void;
  51163. /**
  51164. * Rebuilds the elements related to this component in case of
  51165. * context lost for instance.
  51166. */
  51167. rebuild(): void;
  51168. /**
  51169. * Serializes the component data to the specified json object
  51170. * @param serializationObject The object to serialize to
  51171. */
  51172. serialize(serializationObject: any): void;
  51173. /**
  51174. * Adds all the elements from the container to the scene
  51175. * @param container the container holding the elements
  51176. */
  51177. addFromContainer(container: AbstractScene): void;
  51178. /**
  51179. * Removes all the elements in the container from the scene
  51180. * @param container contains the elements to remove
  51181. * @param dispose if the removed element should be disposed (default: false)
  51182. */
  51183. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51184. /**
  51185. * Disposes the component and the associated ressources.
  51186. */
  51187. dispose(): void;
  51188. private _isReadyForMesh;
  51189. private _renderMainTexture;
  51190. private _setStencil;
  51191. private _setStencilBack;
  51192. private _draw;
  51193. private _drawCamera;
  51194. private _drawRenderingGroup;
  51195. }
  51196. }
  51197. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51198. /** @hidden */
  51199. export var glowMapMergePixelShader: {
  51200. name: string;
  51201. shader: string;
  51202. };
  51203. }
  51204. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51205. /** @hidden */
  51206. export var glowMapMergeVertexShader: {
  51207. name: string;
  51208. shader: string;
  51209. };
  51210. }
  51211. declare module "babylonjs/Layers/glowLayer" {
  51212. import { Nullable } from "babylonjs/types";
  51213. import { Camera } from "babylonjs/Cameras/camera";
  51214. import { Scene } from "babylonjs/scene";
  51215. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51217. import { Mesh } from "babylonjs/Meshes/mesh";
  51218. import { Texture } from "babylonjs/Materials/Textures/texture";
  51219. import { Effect } from "babylonjs/Materials/effect";
  51220. import { Material } from "babylonjs/Materials/material";
  51221. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51222. import { Color4 } from "babylonjs/Maths/math.color";
  51223. import "babylonjs/Shaders/glowMapMerge.fragment";
  51224. import "babylonjs/Shaders/glowMapMerge.vertex";
  51225. import "babylonjs/Layers/effectLayerSceneComponent";
  51226. module "babylonjs/abstractScene" {
  51227. interface AbstractScene {
  51228. /**
  51229. * Return a the first highlight layer of the scene with a given name.
  51230. * @param name The name of the highlight layer to look for.
  51231. * @return The highlight layer if found otherwise null.
  51232. */
  51233. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51234. }
  51235. }
  51236. /**
  51237. * Glow layer options. This helps customizing the behaviour
  51238. * of the glow layer.
  51239. */
  51240. export interface IGlowLayerOptions {
  51241. /**
  51242. * Multiplication factor apply to the canvas size to compute the render target size
  51243. * used to generated the glowing objects (the smaller the faster).
  51244. */
  51245. mainTextureRatio: number;
  51246. /**
  51247. * Enforces a fixed size texture to ensure resize independant blur.
  51248. */
  51249. mainTextureFixedSize?: number;
  51250. /**
  51251. * How big is the kernel of the blur texture.
  51252. */
  51253. blurKernelSize: number;
  51254. /**
  51255. * The camera attached to the layer.
  51256. */
  51257. camera: Nullable<Camera>;
  51258. /**
  51259. * Enable MSAA by chosing the number of samples.
  51260. */
  51261. mainTextureSamples?: number;
  51262. /**
  51263. * The rendering group to draw the layer in.
  51264. */
  51265. renderingGroupId: number;
  51266. }
  51267. /**
  51268. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51269. *
  51270. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51271. * glowy meshes to your scene.
  51272. *
  51273. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51274. */
  51275. export class GlowLayer extends EffectLayer {
  51276. /**
  51277. * Effect Name of the layer.
  51278. */
  51279. static readonly EffectName: string;
  51280. /**
  51281. * The default blur kernel size used for the glow.
  51282. */
  51283. static DefaultBlurKernelSize: number;
  51284. /**
  51285. * The default texture size ratio used for the glow.
  51286. */
  51287. static DefaultTextureRatio: number;
  51288. /**
  51289. * Sets the kernel size of the blur.
  51290. */
  51291. /**
  51292. * Gets the kernel size of the blur.
  51293. */
  51294. blurKernelSize: number;
  51295. /**
  51296. * Sets the glow intensity.
  51297. */
  51298. /**
  51299. * Gets the glow intensity.
  51300. */
  51301. intensity: number;
  51302. private _options;
  51303. private _intensity;
  51304. private _horizontalBlurPostprocess1;
  51305. private _verticalBlurPostprocess1;
  51306. private _horizontalBlurPostprocess2;
  51307. private _verticalBlurPostprocess2;
  51308. private _blurTexture1;
  51309. private _blurTexture2;
  51310. private _postProcesses1;
  51311. private _postProcesses2;
  51312. private _includedOnlyMeshes;
  51313. private _excludedMeshes;
  51314. /**
  51315. * Callback used to let the user override the color selection on a per mesh basis
  51316. */
  51317. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51318. /**
  51319. * Callback used to let the user override the texture selection on a per mesh basis
  51320. */
  51321. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51322. /**
  51323. * Instantiates a new glow Layer and references it to the scene.
  51324. * @param name The name of the layer
  51325. * @param scene The scene to use the layer in
  51326. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51327. */
  51328. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51329. /**
  51330. * Get the effect name of the layer.
  51331. * @return The effect name
  51332. */
  51333. getEffectName(): string;
  51334. /**
  51335. * Create the merge effect. This is the shader use to blit the information back
  51336. * to the main canvas at the end of the scene rendering.
  51337. */
  51338. protected _createMergeEffect(): Effect;
  51339. /**
  51340. * Creates the render target textures and post processes used in the glow layer.
  51341. */
  51342. protected _createTextureAndPostProcesses(): void;
  51343. /**
  51344. * Checks for the readiness of the element composing the layer.
  51345. * @param subMesh the mesh to check for
  51346. * @param useInstances specify wether or not to use instances to render the mesh
  51347. * @param emissiveTexture the associated emissive texture used to generate the glow
  51348. * @return true if ready otherwise, false
  51349. */
  51350. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51351. /**
  51352. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51353. */
  51354. needStencil(): boolean;
  51355. /**
  51356. * Returns true if the mesh can be rendered, otherwise false.
  51357. * @param mesh The mesh to render
  51358. * @param material The material used on the mesh
  51359. * @returns true if it can be rendered otherwise false
  51360. */
  51361. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51362. /**
  51363. * Implementation specific of rendering the generating effect on the main canvas.
  51364. * @param effect The effect used to render through
  51365. */
  51366. protected _internalRender(effect: Effect): void;
  51367. /**
  51368. * Sets the required values for both the emissive texture and and the main color.
  51369. */
  51370. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51371. /**
  51372. * Returns true if the mesh should render, otherwise false.
  51373. * @param mesh The mesh to render
  51374. * @returns true if it should render otherwise false
  51375. */
  51376. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51377. /**
  51378. * Adds specific effects defines.
  51379. * @param defines The defines to add specifics to.
  51380. */
  51381. protected _addCustomEffectDefines(defines: string[]): void;
  51382. /**
  51383. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51384. * @param mesh The mesh to exclude from the glow layer
  51385. */
  51386. addExcludedMesh(mesh: Mesh): void;
  51387. /**
  51388. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51389. * @param mesh The mesh to remove
  51390. */
  51391. removeExcludedMesh(mesh: Mesh): void;
  51392. /**
  51393. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51394. * @param mesh The mesh to include in the glow layer
  51395. */
  51396. addIncludedOnlyMesh(mesh: Mesh): void;
  51397. /**
  51398. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51399. * @param mesh The mesh to remove
  51400. */
  51401. removeIncludedOnlyMesh(mesh: Mesh): void;
  51402. /**
  51403. * Determine if a given mesh will be used in the glow layer
  51404. * @param mesh The mesh to test
  51405. * @returns true if the mesh will be highlighted by the current glow layer
  51406. */
  51407. hasMesh(mesh: AbstractMesh): boolean;
  51408. /**
  51409. * Free any resources and references associated to a mesh.
  51410. * Internal use
  51411. * @param mesh The mesh to free.
  51412. * @hidden
  51413. */
  51414. _disposeMesh(mesh: Mesh): void;
  51415. /**
  51416. * Gets the class name of the effect layer
  51417. * @returns the string with the class name of the effect layer
  51418. */
  51419. getClassName(): string;
  51420. /**
  51421. * Serializes this glow layer
  51422. * @returns a serialized glow layer object
  51423. */
  51424. serialize(): any;
  51425. /**
  51426. * Creates a Glow Layer from parsed glow layer data
  51427. * @param parsedGlowLayer defines glow layer data
  51428. * @param scene defines the current scene
  51429. * @param rootUrl defines the root URL containing the glow layer information
  51430. * @returns a parsed Glow Layer
  51431. */
  51432. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51433. }
  51434. }
  51435. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51436. /** @hidden */
  51437. export var glowBlurPostProcessPixelShader: {
  51438. name: string;
  51439. shader: string;
  51440. };
  51441. }
  51442. declare module "babylonjs/Layers/highlightLayer" {
  51443. import { Observable } from "babylonjs/Misc/observable";
  51444. import { Nullable } from "babylonjs/types";
  51445. import { Camera } from "babylonjs/Cameras/camera";
  51446. import { Scene } from "babylonjs/scene";
  51447. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51449. import { Mesh } from "babylonjs/Meshes/mesh";
  51450. import { Effect } from "babylonjs/Materials/effect";
  51451. import { Material } from "babylonjs/Materials/material";
  51452. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51453. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51454. import "babylonjs/Shaders/glowMapMerge.fragment";
  51455. import "babylonjs/Shaders/glowMapMerge.vertex";
  51456. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51457. module "babylonjs/abstractScene" {
  51458. interface AbstractScene {
  51459. /**
  51460. * Return a the first highlight layer of the scene with a given name.
  51461. * @param name The name of the highlight layer to look for.
  51462. * @return The highlight layer if found otherwise null.
  51463. */
  51464. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51465. }
  51466. }
  51467. /**
  51468. * Highlight layer options. This helps customizing the behaviour
  51469. * of the highlight layer.
  51470. */
  51471. export interface IHighlightLayerOptions {
  51472. /**
  51473. * Multiplication factor apply to the canvas size to compute the render target size
  51474. * used to generated the glowing objects (the smaller the faster).
  51475. */
  51476. mainTextureRatio: number;
  51477. /**
  51478. * Enforces a fixed size texture to ensure resize independant blur.
  51479. */
  51480. mainTextureFixedSize?: number;
  51481. /**
  51482. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51483. * of the picture to blur (the smaller the faster).
  51484. */
  51485. blurTextureSizeRatio: number;
  51486. /**
  51487. * How big in texel of the blur texture is the vertical blur.
  51488. */
  51489. blurVerticalSize: number;
  51490. /**
  51491. * How big in texel of the blur texture is the horizontal blur.
  51492. */
  51493. blurHorizontalSize: number;
  51494. /**
  51495. * Alpha blending mode used to apply the blur. Default is combine.
  51496. */
  51497. alphaBlendingMode: number;
  51498. /**
  51499. * The camera attached to the layer.
  51500. */
  51501. camera: Nullable<Camera>;
  51502. /**
  51503. * Should we display highlight as a solid stroke?
  51504. */
  51505. isStroke?: boolean;
  51506. /**
  51507. * The rendering group to draw the layer in.
  51508. */
  51509. renderingGroupId: number;
  51510. }
  51511. /**
  51512. * The highlight layer Helps adding a glow effect around a mesh.
  51513. *
  51514. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51515. * glowy meshes to your scene.
  51516. *
  51517. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51518. */
  51519. export class HighlightLayer extends EffectLayer {
  51520. name: string;
  51521. /**
  51522. * Effect Name of the highlight layer.
  51523. */
  51524. static readonly EffectName: string;
  51525. /**
  51526. * The neutral color used during the preparation of the glow effect.
  51527. * This is black by default as the blend operation is a blend operation.
  51528. */
  51529. static NeutralColor: Color4;
  51530. /**
  51531. * Stencil value used for glowing meshes.
  51532. */
  51533. static GlowingMeshStencilReference: number;
  51534. /**
  51535. * Stencil value used for the other meshes in the scene.
  51536. */
  51537. static NormalMeshStencilReference: number;
  51538. /**
  51539. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51540. */
  51541. innerGlow: boolean;
  51542. /**
  51543. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51544. */
  51545. outerGlow: boolean;
  51546. /**
  51547. * Specifies the horizontal size of the blur.
  51548. */
  51549. /**
  51550. * Gets the horizontal size of the blur.
  51551. */
  51552. blurHorizontalSize: number;
  51553. /**
  51554. * Specifies the vertical size of the blur.
  51555. */
  51556. /**
  51557. * Gets the vertical size of the blur.
  51558. */
  51559. blurVerticalSize: number;
  51560. /**
  51561. * An event triggered when the highlight layer is being blurred.
  51562. */
  51563. onBeforeBlurObservable: Observable<HighlightLayer>;
  51564. /**
  51565. * An event triggered when the highlight layer has been blurred.
  51566. */
  51567. onAfterBlurObservable: Observable<HighlightLayer>;
  51568. private _instanceGlowingMeshStencilReference;
  51569. private _options;
  51570. private _downSamplePostprocess;
  51571. private _horizontalBlurPostprocess;
  51572. private _verticalBlurPostprocess;
  51573. private _blurTexture;
  51574. private _meshes;
  51575. private _excludedMeshes;
  51576. /**
  51577. * Instantiates a new highlight Layer and references it to the scene..
  51578. * @param name The name of the layer
  51579. * @param scene The scene to use the layer in
  51580. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51581. */
  51582. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51583. /**
  51584. * Get the effect name of the layer.
  51585. * @return The effect name
  51586. */
  51587. getEffectName(): string;
  51588. /**
  51589. * Create the merge effect. This is the shader use to blit the information back
  51590. * to the main canvas at the end of the scene rendering.
  51591. */
  51592. protected _createMergeEffect(): Effect;
  51593. /**
  51594. * Creates the render target textures and post processes used in the highlight layer.
  51595. */
  51596. protected _createTextureAndPostProcesses(): void;
  51597. /**
  51598. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51599. */
  51600. needStencil(): boolean;
  51601. /**
  51602. * Checks for the readiness of the element composing the layer.
  51603. * @param subMesh the mesh to check for
  51604. * @param useInstances specify wether or not to use instances to render the mesh
  51605. * @param emissiveTexture the associated emissive texture used to generate the glow
  51606. * @return true if ready otherwise, false
  51607. */
  51608. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51609. /**
  51610. * Implementation specific of rendering the generating effect on the main canvas.
  51611. * @param effect The effect used to render through
  51612. */
  51613. protected _internalRender(effect: Effect): void;
  51614. /**
  51615. * Returns true if the layer contains information to display, otherwise false.
  51616. */
  51617. shouldRender(): boolean;
  51618. /**
  51619. * Returns true if the mesh should render, otherwise false.
  51620. * @param mesh The mesh to render
  51621. * @returns true if it should render otherwise false
  51622. */
  51623. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51624. /**
  51625. * Sets the required values for both the emissive texture and and the main color.
  51626. */
  51627. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51628. /**
  51629. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51630. * @param mesh The mesh to exclude from the highlight layer
  51631. */
  51632. addExcludedMesh(mesh: Mesh): void;
  51633. /**
  51634. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51635. * @param mesh The mesh to highlight
  51636. */
  51637. removeExcludedMesh(mesh: Mesh): void;
  51638. /**
  51639. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51640. * @param mesh mesh to test
  51641. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51642. */
  51643. hasMesh(mesh: AbstractMesh): boolean;
  51644. /**
  51645. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51646. * @param mesh The mesh to highlight
  51647. * @param color The color of the highlight
  51648. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51649. */
  51650. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51651. /**
  51652. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51653. * @param mesh The mesh to highlight
  51654. */
  51655. removeMesh(mesh: Mesh): void;
  51656. /**
  51657. * Force the stencil to the normal expected value for none glowing parts
  51658. */
  51659. private _defaultStencilReference;
  51660. /**
  51661. * Free any resources and references associated to a mesh.
  51662. * Internal use
  51663. * @param mesh The mesh to free.
  51664. * @hidden
  51665. */
  51666. _disposeMesh(mesh: Mesh): void;
  51667. /**
  51668. * Dispose the highlight layer and free resources.
  51669. */
  51670. dispose(): void;
  51671. /**
  51672. * Gets the class name of the effect layer
  51673. * @returns the string with the class name of the effect layer
  51674. */
  51675. getClassName(): string;
  51676. /**
  51677. * Serializes this Highlight layer
  51678. * @returns a serialized Highlight layer object
  51679. */
  51680. serialize(): any;
  51681. /**
  51682. * Creates a Highlight layer from parsed Highlight layer data
  51683. * @param parsedHightlightLayer defines the Highlight layer data
  51684. * @param scene defines the current scene
  51685. * @param rootUrl defines the root URL containing the Highlight layer information
  51686. * @returns a parsed Highlight layer
  51687. */
  51688. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51689. }
  51690. }
  51691. declare module "babylonjs/Layers/layerSceneComponent" {
  51692. import { Scene } from "babylonjs/scene";
  51693. import { ISceneComponent } from "babylonjs/sceneComponent";
  51694. import { Layer } from "babylonjs/Layers/layer";
  51695. import { AbstractScene } from "babylonjs/abstractScene";
  51696. module "babylonjs/abstractScene" {
  51697. interface AbstractScene {
  51698. /**
  51699. * The list of layers (background and foreground) of the scene
  51700. */
  51701. layers: Array<Layer>;
  51702. }
  51703. }
  51704. /**
  51705. * Defines the layer scene component responsible to manage any layers
  51706. * in a given scene.
  51707. */
  51708. export class LayerSceneComponent implements ISceneComponent {
  51709. /**
  51710. * The component name helpfull to identify the component in the list of scene components.
  51711. */
  51712. readonly name: string;
  51713. /**
  51714. * The scene the component belongs to.
  51715. */
  51716. scene: Scene;
  51717. private _engine;
  51718. /**
  51719. * Creates a new instance of the component for the given scene
  51720. * @param scene Defines the scene to register the component in
  51721. */
  51722. constructor(scene: Scene);
  51723. /**
  51724. * Registers the component in a given scene
  51725. */
  51726. register(): void;
  51727. /**
  51728. * Rebuilds the elements related to this component in case of
  51729. * context lost for instance.
  51730. */
  51731. rebuild(): void;
  51732. /**
  51733. * Disposes the component and the associated ressources.
  51734. */
  51735. dispose(): void;
  51736. private _draw;
  51737. private _drawCameraPredicate;
  51738. private _drawCameraBackground;
  51739. private _drawCameraForeground;
  51740. private _drawRenderTargetPredicate;
  51741. private _drawRenderTargetBackground;
  51742. private _drawRenderTargetForeground;
  51743. /**
  51744. * Adds all the elements from the container to the scene
  51745. * @param container the container holding the elements
  51746. */
  51747. addFromContainer(container: AbstractScene): void;
  51748. /**
  51749. * Removes all the elements in the container from the scene
  51750. * @param container contains the elements to remove
  51751. * @param dispose if the removed element should be disposed (default: false)
  51752. */
  51753. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51754. }
  51755. }
  51756. declare module "babylonjs/Shaders/layer.fragment" {
  51757. /** @hidden */
  51758. export var layerPixelShader: {
  51759. name: string;
  51760. shader: string;
  51761. };
  51762. }
  51763. declare module "babylonjs/Shaders/layer.vertex" {
  51764. /** @hidden */
  51765. export var layerVertexShader: {
  51766. name: string;
  51767. shader: string;
  51768. };
  51769. }
  51770. declare module "babylonjs/Layers/layer" {
  51771. import { Observable } from "babylonjs/Misc/observable";
  51772. import { Nullable } from "babylonjs/types";
  51773. import { Scene } from "babylonjs/scene";
  51774. import { Vector2 } from "babylonjs/Maths/math.vector";
  51775. import { Color4 } from "babylonjs/Maths/math.color";
  51776. import { Texture } from "babylonjs/Materials/Textures/texture";
  51777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51778. import "babylonjs/Shaders/layer.fragment";
  51779. import "babylonjs/Shaders/layer.vertex";
  51780. /**
  51781. * This represents a full screen 2d layer.
  51782. * This can be useful to display a picture in the background of your scene for instance.
  51783. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51784. */
  51785. export class Layer {
  51786. /**
  51787. * Define the name of the layer.
  51788. */
  51789. name: string;
  51790. /**
  51791. * Define the texture the layer should display.
  51792. */
  51793. texture: Nullable<Texture>;
  51794. /**
  51795. * Is the layer in background or foreground.
  51796. */
  51797. isBackground: boolean;
  51798. /**
  51799. * Define the color of the layer (instead of texture).
  51800. */
  51801. color: Color4;
  51802. /**
  51803. * Define the scale of the layer in order to zoom in out of the texture.
  51804. */
  51805. scale: Vector2;
  51806. /**
  51807. * Define an offset for the layer in order to shift the texture.
  51808. */
  51809. offset: Vector2;
  51810. /**
  51811. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51812. */
  51813. alphaBlendingMode: number;
  51814. /**
  51815. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51816. * Alpha test will not mix with the background color in case of transparency.
  51817. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51818. */
  51819. alphaTest: boolean;
  51820. /**
  51821. * Define a mask to restrict the layer to only some of the scene cameras.
  51822. */
  51823. layerMask: number;
  51824. /**
  51825. * Define the list of render target the layer is visible into.
  51826. */
  51827. renderTargetTextures: RenderTargetTexture[];
  51828. /**
  51829. * Define if the layer is only used in renderTarget or if it also
  51830. * renders in the main frame buffer of the canvas.
  51831. */
  51832. renderOnlyInRenderTargetTextures: boolean;
  51833. private _scene;
  51834. private _vertexBuffers;
  51835. private _indexBuffer;
  51836. private _effect;
  51837. private _alphaTestEffect;
  51838. /**
  51839. * An event triggered when the layer is disposed.
  51840. */
  51841. onDisposeObservable: Observable<Layer>;
  51842. private _onDisposeObserver;
  51843. /**
  51844. * Back compatibility with callback before the onDisposeObservable existed.
  51845. * The set callback will be triggered when the layer has been disposed.
  51846. */
  51847. onDispose: () => void;
  51848. /**
  51849. * An event triggered before rendering the scene
  51850. */
  51851. onBeforeRenderObservable: Observable<Layer>;
  51852. private _onBeforeRenderObserver;
  51853. /**
  51854. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51855. * The set callback will be triggered just before rendering the layer.
  51856. */
  51857. onBeforeRender: () => void;
  51858. /**
  51859. * An event triggered after rendering the scene
  51860. */
  51861. onAfterRenderObservable: Observable<Layer>;
  51862. private _onAfterRenderObserver;
  51863. /**
  51864. * Back compatibility with callback before the onAfterRenderObservable existed.
  51865. * The set callback will be triggered just after rendering the layer.
  51866. */
  51867. onAfterRender: () => void;
  51868. /**
  51869. * Instantiates a new layer.
  51870. * This represents a full screen 2d layer.
  51871. * This can be useful to display a picture in the background of your scene for instance.
  51872. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51873. * @param name Define the name of the layer in the scene
  51874. * @param imgUrl Define the url of the texture to display in the layer
  51875. * @param scene Define the scene the layer belongs to
  51876. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51877. * @param color Defines a color for the layer
  51878. */
  51879. constructor(
  51880. /**
  51881. * Define the name of the layer.
  51882. */
  51883. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51884. private _createIndexBuffer;
  51885. /** @hidden */
  51886. _rebuild(): void;
  51887. /**
  51888. * Renders the layer in the scene.
  51889. */
  51890. render(): void;
  51891. /**
  51892. * Disposes and releases the associated ressources.
  51893. */
  51894. dispose(): void;
  51895. }
  51896. }
  51897. declare module "babylonjs/Layers/index" {
  51898. export * from "babylonjs/Layers/effectLayer";
  51899. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51900. export * from "babylonjs/Layers/glowLayer";
  51901. export * from "babylonjs/Layers/highlightLayer";
  51902. export * from "babylonjs/Layers/layer";
  51903. export * from "babylonjs/Layers/layerSceneComponent";
  51904. }
  51905. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51906. /** @hidden */
  51907. export var lensFlarePixelShader: {
  51908. name: string;
  51909. shader: string;
  51910. };
  51911. }
  51912. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51913. /** @hidden */
  51914. export var lensFlareVertexShader: {
  51915. name: string;
  51916. shader: string;
  51917. };
  51918. }
  51919. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51920. import { Scene } from "babylonjs/scene";
  51921. import { Vector3 } from "babylonjs/Maths/math.vector";
  51922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51923. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51924. import "babylonjs/Shaders/lensFlare.fragment";
  51925. import "babylonjs/Shaders/lensFlare.vertex";
  51926. import { Viewport } from "babylonjs/Maths/math.viewport";
  51927. /**
  51928. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51929. * It is usually composed of several `lensFlare`.
  51930. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51931. */
  51932. export class LensFlareSystem {
  51933. /**
  51934. * Define the name of the lens flare system
  51935. */
  51936. name: string;
  51937. /**
  51938. * List of lens flares used in this system.
  51939. */
  51940. lensFlares: LensFlare[];
  51941. /**
  51942. * Define a limit from the border the lens flare can be visible.
  51943. */
  51944. borderLimit: number;
  51945. /**
  51946. * Define a viewport border we do not want to see the lens flare in.
  51947. */
  51948. viewportBorder: number;
  51949. /**
  51950. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51951. */
  51952. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51953. /**
  51954. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51955. */
  51956. layerMask: number;
  51957. /**
  51958. * Define the id of the lens flare system in the scene.
  51959. * (equal to name by default)
  51960. */
  51961. id: string;
  51962. private _scene;
  51963. private _emitter;
  51964. private _vertexBuffers;
  51965. private _indexBuffer;
  51966. private _effect;
  51967. private _positionX;
  51968. private _positionY;
  51969. private _isEnabled;
  51970. /** @hidden */
  51971. static _SceneComponentInitialization: (scene: Scene) => void;
  51972. /**
  51973. * Instantiates a lens flare system.
  51974. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51975. * It is usually composed of several `lensFlare`.
  51976. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51977. * @param name Define the name of the lens flare system in the scene
  51978. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51979. * @param scene Define the scene the lens flare system belongs to
  51980. */
  51981. constructor(
  51982. /**
  51983. * Define the name of the lens flare system
  51984. */
  51985. name: string, emitter: any, scene: Scene);
  51986. /**
  51987. * Define if the lens flare system is enabled.
  51988. */
  51989. isEnabled: boolean;
  51990. /**
  51991. * Get the scene the effects belongs to.
  51992. * @returns the scene holding the lens flare system
  51993. */
  51994. getScene(): Scene;
  51995. /**
  51996. * Get the emitter of the lens flare system.
  51997. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51998. * @returns the emitter of the lens flare system
  51999. */
  52000. getEmitter(): any;
  52001. /**
  52002. * Set the emitter of the lens flare system.
  52003. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52004. * @param newEmitter Define the new emitter of the system
  52005. */
  52006. setEmitter(newEmitter: any): void;
  52007. /**
  52008. * Get the lens flare system emitter position.
  52009. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52010. * @returns the position
  52011. */
  52012. getEmitterPosition(): Vector3;
  52013. /**
  52014. * @hidden
  52015. */
  52016. computeEffectivePosition(globalViewport: Viewport): boolean;
  52017. /** @hidden */
  52018. _isVisible(): boolean;
  52019. /**
  52020. * @hidden
  52021. */
  52022. render(): boolean;
  52023. /**
  52024. * Dispose and release the lens flare with its associated resources.
  52025. */
  52026. dispose(): void;
  52027. /**
  52028. * Parse a lens flare system from a JSON repressentation
  52029. * @param parsedLensFlareSystem Define the JSON to parse
  52030. * @param scene Define the scene the parsed system should be instantiated in
  52031. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52032. * @returns the parsed system
  52033. */
  52034. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52035. /**
  52036. * Serialize the current Lens Flare System into a JSON representation.
  52037. * @returns the serialized JSON
  52038. */
  52039. serialize(): any;
  52040. }
  52041. }
  52042. declare module "babylonjs/LensFlares/lensFlare" {
  52043. import { Nullable } from "babylonjs/types";
  52044. import { Color3 } from "babylonjs/Maths/math.color";
  52045. import { Texture } from "babylonjs/Materials/Textures/texture";
  52046. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52047. /**
  52048. * This represents one of the lens effect in a `lensFlareSystem`.
  52049. * It controls one of the indiviual texture used in the effect.
  52050. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52051. */
  52052. export class LensFlare {
  52053. /**
  52054. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52055. */
  52056. size: number;
  52057. /**
  52058. * 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.
  52059. */
  52060. position: number;
  52061. /**
  52062. * Define the lens color.
  52063. */
  52064. color: Color3;
  52065. /**
  52066. * Define the lens texture.
  52067. */
  52068. texture: Nullable<Texture>;
  52069. /**
  52070. * Define the alpha mode to render this particular lens.
  52071. */
  52072. alphaMode: number;
  52073. private _system;
  52074. /**
  52075. * Creates a new Lens Flare.
  52076. * This represents one of the lens effect in a `lensFlareSystem`.
  52077. * It controls one of the indiviual texture used in the effect.
  52078. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52079. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52080. * @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.
  52081. * @param color Define the lens color
  52082. * @param imgUrl Define the lens texture url
  52083. * @param system Define the `lensFlareSystem` this flare is part of
  52084. * @returns The newly created Lens Flare
  52085. */
  52086. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52087. /**
  52088. * Instantiates a new Lens Flare.
  52089. * This represents one of the lens effect in a `lensFlareSystem`.
  52090. * It controls one of the indiviual texture used in the effect.
  52091. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52092. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52093. * @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.
  52094. * @param color Define the lens color
  52095. * @param imgUrl Define the lens texture url
  52096. * @param system Define the `lensFlareSystem` this flare is part of
  52097. */
  52098. constructor(
  52099. /**
  52100. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52101. */
  52102. size: number,
  52103. /**
  52104. * 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.
  52105. */
  52106. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52107. /**
  52108. * Dispose and release the lens flare with its associated resources.
  52109. */
  52110. dispose(): void;
  52111. }
  52112. }
  52113. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52114. import { Nullable } from "babylonjs/types";
  52115. import { Scene } from "babylonjs/scene";
  52116. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52117. import { AbstractScene } from "babylonjs/abstractScene";
  52118. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52119. module "babylonjs/abstractScene" {
  52120. interface AbstractScene {
  52121. /**
  52122. * The list of lens flare system added to the scene
  52123. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52124. */
  52125. lensFlareSystems: Array<LensFlareSystem>;
  52126. /**
  52127. * Removes the given lens flare system from this scene.
  52128. * @param toRemove The lens flare system to remove
  52129. * @returns The index of the removed lens flare system
  52130. */
  52131. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52132. /**
  52133. * Adds the given lens flare system to this scene
  52134. * @param newLensFlareSystem The lens flare system to add
  52135. */
  52136. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52137. /**
  52138. * Gets a lens flare system using its name
  52139. * @param name defines the name to look for
  52140. * @returns the lens flare system or null if not found
  52141. */
  52142. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52143. /**
  52144. * Gets a lens flare system using its id
  52145. * @param id defines the id to look for
  52146. * @returns the lens flare system or null if not found
  52147. */
  52148. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52149. }
  52150. }
  52151. /**
  52152. * Defines the lens flare scene component responsible to manage any lens flares
  52153. * in a given scene.
  52154. */
  52155. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52156. /**
  52157. * The component name helpfull to identify the component in the list of scene components.
  52158. */
  52159. readonly name: string;
  52160. /**
  52161. * The scene the component belongs to.
  52162. */
  52163. scene: Scene;
  52164. /**
  52165. * Creates a new instance of the component for the given scene
  52166. * @param scene Defines the scene to register the component in
  52167. */
  52168. constructor(scene: Scene);
  52169. /**
  52170. * Registers the component in a given scene
  52171. */
  52172. register(): void;
  52173. /**
  52174. * Rebuilds the elements related to this component in case of
  52175. * context lost for instance.
  52176. */
  52177. rebuild(): void;
  52178. /**
  52179. * Adds all the elements from the container to the scene
  52180. * @param container the container holding the elements
  52181. */
  52182. addFromContainer(container: AbstractScene): void;
  52183. /**
  52184. * Removes all the elements in the container from the scene
  52185. * @param container contains the elements to remove
  52186. * @param dispose if the removed element should be disposed (default: false)
  52187. */
  52188. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52189. /**
  52190. * Serializes the component data to the specified json object
  52191. * @param serializationObject The object to serialize to
  52192. */
  52193. serialize(serializationObject: any): void;
  52194. /**
  52195. * Disposes the component and the associated ressources.
  52196. */
  52197. dispose(): void;
  52198. private _draw;
  52199. }
  52200. }
  52201. declare module "babylonjs/LensFlares/index" {
  52202. export * from "babylonjs/LensFlares/lensFlare";
  52203. export * from "babylonjs/LensFlares/lensFlareSystem";
  52204. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52205. }
  52206. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52207. import { Scene } from "babylonjs/scene";
  52208. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52209. import { AbstractScene } from "babylonjs/abstractScene";
  52210. /**
  52211. * Defines the shadow generator component responsible to manage any shadow generators
  52212. * in a given scene.
  52213. */
  52214. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52215. /**
  52216. * The component name helpfull to identify the component in the list of scene components.
  52217. */
  52218. readonly name: string;
  52219. /**
  52220. * The scene the component belongs to.
  52221. */
  52222. scene: Scene;
  52223. /**
  52224. * Creates a new instance of the component for the given scene
  52225. * @param scene Defines the scene to register the component in
  52226. */
  52227. constructor(scene: Scene);
  52228. /**
  52229. * Registers the component in a given scene
  52230. */
  52231. register(): void;
  52232. /**
  52233. * Rebuilds the elements related to this component in case of
  52234. * context lost for instance.
  52235. */
  52236. rebuild(): void;
  52237. /**
  52238. * Serializes the component data to the specified json object
  52239. * @param serializationObject The object to serialize to
  52240. */
  52241. serialize(serializationObject: any): void;
  52242. /**
  52243. * Adds all the elements from the container to the scene
  52244. * @param container the container holding the elements
  52245. */
  52246. addFromContainer(container: AbstractScene): void;
  52247. /**
  52248. * Removes all the elements in the container from the scene
  52249. * @param container contains the elements to remove
  52250. * @param dispose if the removed element should be disposed (default: false)
  52251. */
  52252. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52253. /**
  52254. * Rebuilds the elements related to this component in case of
  52255. * context lost for instance.
  52256. */
  52257. dispose(): void;
  52258. private _gatherRenderTargets;
  52259. }
  52260. }
  52261. declare module "babylonjs/Lights/Shadows/index" {
  52262. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52263. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52264. }
  52265. declare module "babylonjs/Lights/pointLight" {
  52266. import { Scene } from "babylonjs/scene";
  52267. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52269. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52270. import { Effect } from "babylonjs/Materials/effect";
  52271. /**
  52272. * A point light is a light defined by an unique point in world space.
  52273. * The light is emitted in every direction from this point.
  52274. * A good example of a point light is a standard light bulb.
  52275. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52276. */
  52277. export class PointLight extends ShadowLight {
  52278. private _shadowAngle;
  52279. /**
  52280. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52281. * This specifies what angle the shadow will use to be created.
  52282. *
  52283. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52284. */
  52285. /**
  52286. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52287. * This specifies what angle the shadow will use to be created.
  52288. *
  52289. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52290. */
  52291. shadowAngle: number;
  52292. /**
  52293. * Gets the direction if it has been set.
  52294. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52295. */
  52296. /**
  52297. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52298. */
  52299. direction: Vector3;
  52300. /**
  52301. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52302. * A PointLight emits the light in every direction.
  52303. * It can cast shadows.
  52304. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52305. * ```javascript
  52306. * var pointLight = new PointLight("pl", camera.position, scene);
  52307. * ```
  52308. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52309. * @param name The light friendly name
  52310. * @param position The position of the point light in the scene
  52311. * @param scene The scene the lights belongs to
  52312. */
  52313. constructor(name: string, position: Vector3, scene: Scene);
  52314. /**
  52315. * Returns the string "PointLight"
  52316. * @returns the class name
  52317. */
  52318. getClassName(): string;
  52319. /**
  52320. * Returns the integer 0.
  52321. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52322. */
  52323. getTypeID(): number;
  52324. /**
  52325. * Specifies wether or not the shadowmap should be a cube texture.
  52326. * @returns true if the shadowmap needs to be a cube texture.
  52327. */
  52328. needCube(): boolean;
  52329. /**
  52330. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52331. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52332. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52333. */
  52334. getShadowDirection(faceIndex?: number): Vector3;
  52335. /**
  52336. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52337. * - fov = PI / 2
  52338. * - aspect ratio : 1.0
  52339. * - z-near and far equal to the active camera minZ and maxZ.
  52340. * Returns the PointLight.
  52341. */
  52342. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52343. protected _buildUniformLayout(): void;
  52344. /**
  52345. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52346. * @param effect The effect to update
  52347. * @param lightIndex The index of the light in the effect to update
  52348. * @returns The point light
  52349. */
  52350. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52351. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52352. /**
  52353. * Prepares the list of defines specific to the light type.
  52354. * @param defines the list of defines
  52355. * @param lightIndex defines the index of the light for the effect
  52356. */
  52357. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52358. }
  52359. }
  52360. declare module "babylonjs/Lights/index" {
  52361. export * from "babylonjs/Lights/light";
  52362. export * from "babylonjs/Lights/shadowLight";
  52363. export * from "babylonjs/Lights/Shadows/index";
  52364. export * from "babylonjs/Lights/directionalLight";
  52365. export * from "babylonjs/Lights/hemisphericLight";
  52366. export * from "babylonjs/Lights/pointLight";
  52367. export * from "babylonjs/Lights/spotLight";
  52368. }
  52369. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52370. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52371. /**
  52372. * Header information of HDR texture files.
  52373. */
  52374. export interface HDRInfo {
  52375. /**
  52376. * The height of the texture in pixels.
  52377. */
  52378. height: number;
  52379. /**
  52380. * The width of the texture in pixels.
  52381. */
  52382. width: number;
  52383. /**
  52384. * The index of the beginning of the data in the binary file.
  52385. */
  52386. dataPosition: number;
  52387. }
  52388. /**
  52389. * This groups tools to convert HDR texture to native colors array.
  52390. */
  52391. export class HDRTools {
  52392. private static Ldexp;
  52393. private static Rgbe2float;
  52394. private static readStringLine;
  52395. /**
  52396. * Reads header information from an RGBE texture stored in a native array.
  52397. * More information on this format are available here:
  52398. * https://en.wikipedia.org/wiki/RGBE_image_format
  52399. *
  52400. * @param uint8array The binary file stored in native array.
  52401. * @return The header information.
  52402. */
  52403. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52404. /**
  52405. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52406. * This RGBE texture needs to store the information as a panorama.
  52407. *
  52408. * More information on this format are available here:
  52409. * https://en.wikipedia.org/wiki/RGBE_image_format
  52410. *
  52411. * @param buffer The binary file stored in an array buffer.
  52412. * @param size The expected size of the extracted cubemap.
  52413. * @return The Cube Map information.
  52414. */
  52415. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52416. /**
  52417. * Returns the pixels data extracted from an RGBE texture.
  52418. * This pixels will be stored left to right up to down in the R G B order in one array.
  52419. *
  52420. * More information on this format are available here:
  52421. * https://en.wikipedia.org/wiki/RGBE_image_format
  52422. *
  52423. * @param uint8array The binary file stored in an array buffer.
  52424. * @param hdrInfo The header information of the file.
  52425. * @return The pixels data in RGB right to left up to down order.
  52426. */
  52427. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52428. private static RGBE_ReadPixels_RLE;
  52429. }
  52430. }
  52431. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52432. import { Nullable } from "babylonjs/types";
  52433. import { Scene } from "babylonjs/scene";
  52434. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52435. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52436. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52437. /**
  52438. * This represents a texture coming from an HDR input.
  52439. *
  52440. * The only supported format is currently panorama picture stored in RGBE format.
  52441. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52442. */
  52443. export class HDRCubeTexture extends BaseTexture {
  52444. private static _facesMapping;
  52445. private _generateHarmonics;
  52446. private _noMipmap;
  52447. private _textureMatrix;
  52448. private _size;
  52449. private _onLoad;
  52450. private _onError;
  52451. /**
  52452. * The texture URL.
  52453. */
  52454. url: string;
  52455. /**
  52456. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52457. */
  52458. coordinatesMode: number;
  52459. protected _isBlocking: boolean;
  52460. /**
  52461. * Sets wether or not the texture is blocking during loading.
  52462. */
  52463. /**
  52464. * Gets wether or not the texture is blocking during loading.
  52465. */
  52466. isBlocking: boolean;
  52467. protected _rotationY: number;
  52468. /**
  52469. * Sets texture matrix rotation angle around Y axis in radians.
  52470. */
  52471. /**
  52472. * Gets texture matrix rotation angle around Y axis radians.
  52473. */
  52474. rotationY: number;
  52475. /**
  52476. * Gets or sets the center of the bounding box associated with the cube texture
  52477. * It must define where the camera used to render the texture was set
  52478. */
  52479. boundingBoxPosition: Vector3;
  52480. private _boundingBoxSize;
  52481. /**
  52482. * Gets or sets the size of the bounding box associated with the cube texture
  52483. * When defined, the cubemap will switch to local mode
  52484. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52485. * @example https://www.babylonjs-playground.com/#RNASML
  52486. */
  52487. boundingBoxSize: Vector3;
  52488. /**
  52489. * Instantiates an HDRTexture from the following parameters.
  52490. *
  52491. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52492. * @param scene The scene the texture will be used in
  52493. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52494. * @param noMipmap Forces to not generate the mipmap if true
  52495. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52496. * @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)
  52497. * @param reserved Reserved flag for internal use.
  52498. */
  52499. 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>);
  52500. /**
  52501. * Get the current class name of the texture useful for serialization or dynamic coding.
  52502. * @returns "HDRCubeTexture"
  52503. */
  52504. getClassName(): string;
  52505. /**
  52506. * Occurs when the file is raw .hdr file.
  52507. */
  52508. private loadTexture;
  52509. clone(): HDRCubeTexture;
  52510. delayLoad(): void;
  52511. /**
  52512. * Get the texture reflection matrix used to rotate/transform the reflection.
  52513. * @returns the reflection matrix
  52514. */
  52515. getReflectionTextureMatrix(): Matrix;
  52516. /**
  52517. * Set the texture reflection matrix used to rotate/transform the reflection.
  52518. * @param value Define the reflection matrix to set
  52519. */
  52520. setReflectionTextureMatrix(value: Matrix): void;
  52521. /**
  52522. * Parses a JSON representation of an HDR Texture in order to create the texture
  52523. * @param parsedTexture Define the JSON representation
  52524. * @param scene Define the scene the texture should be created in
  52525. * @param rootUrl Define the root url in case we need to load relative dependencies
  52526. * @returns the newly created texture after parsing
  52527. */
  52528. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52529. serialize(): any;
  52530. }
  52531. }
  52532. declare module "babylonjs/Physics/physicsEngine" {
  52533. import { Nullable } from "babylonjs/types";
  52534. import { Vector3 } from "babylonjs/Maths/math.vector";
  52535. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52536. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52537. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52538. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52539. /**
  52540. * Class used to control physics engine
  52541. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52542. */
  52543. export class PhysicsEngine implements IPhysicsEngine {
  52544. private _physicsPlugin;
  52545. /**
  52546. * Global value used to control the smallest number supported by the simulation
  52547. */
  52548. static Epsilon: number;
  52549. private _impostors;
  52550. private _joints;
  52551. /**
  52552. * Gets the gravity vector used by the simulation
  52553. */
  52554. gravity: Vector3;
  52555. /**
  52556. * Factory used to create the default physics plugin.
  52557. * @returns The default physics plugin
  52558. */
  52559. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52560. /**
  52561. * Creates a new Physics Engine
  52562. * @param gravity defines the gravity vector used by the simulation
  52563. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52564. */
  52565. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52566. /**
  52567. * Sets the gravity vector used by the simulation
  52568. * @param gravity defines the gravity vector to use
  52569. */
  52570. setGravity(gravity: Vector3): void;
  52571. /**
  52572. * Set the time step of the physics engine.
  52573. * Default is 1/60.
  52574. * To slow it down, enter 1/600 for example.
  52575. * To speed it up, 1/30
  52576. * @param newTimeStep defines the new timestep to apply to this world.
  52577. */
  52578. setTimeStep(newTimeStep?: number): void;
  52579. /**
  52580. * Get the time step of the physics engine.
  52581. * @returns the current time step
  52582. */
  52583. getTimeStep(): number;
  52584. /**
  52585. * Release all resources
  52586. */
  52587. dispose(): void;
  52588. /**
  52589. * Gets the name of the current physics plugin
  52590. * @returns the name of the plugin
  52591. */
  52592. getPhysicsPluginName(): string;
  52593. /**
  52594. * Adding a new impostor for the impostor tracking.
  52595. * This will be done by the impostor itself.
  52596. * @param impostor the impostor to add
  52597. */
  52598. addImpostor(impostor: PhysicsImpostor): void;
  52599. /**
  52600. * Remove an impostor from the engine.
  52601. * This impostor and its mesh will not longer be updated by the physics engine.
  52602. * @param impostor the impostor to remove
  52603. */
  52604. removeImpostor(impostor: PhysicsImpostor): void;
  52605. /**
  52606. * Add a joint to the physics engine
  52607. * @param mainImpostor defines the main impostor to which the joint is added.
  52608. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52609. * @param joint defines the joint that will connect both impostors.
  52610. */
  52611. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52612. /**
  52613. * Removes a joint from the simulation
  52614. * @param mainImpostor defines the impostor used with the joint
  52615. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52616. * @param joint defines the joint to remove
  52617. */
  52618. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52619. /**
  52620. * Called by the scene. No need to call it.
  52621. * @param delta defines the timespam between frames
  52622. */
  52623. _step(delta: number): void;
  52624. /**
  52625. * Gets the current plugin used to run the simulation
  52626. * @returns current plugin
  52627. */
  52628. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52629. /**
  52630. * Gets the list of physic impostors
  52631. * @returns an array of PhysicsImpostor
  52632. */
  52633. getImpostors(): Array<PhysicsImpostor>;
  52634. /**
  52635. * Gets the impostor for a physics enabled object
  52636. * @param object defines the object impersonated by the impostor
  52637. * @returns the PhysicsImpostor or null if not found
  52638. */
  52639. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52640. /**
  52641. * Gets the impostor for a physics body object
  52642. * @param body defines physics body used by the impostor
  52643. * @returns the PhysicsImpostor or null if not found
  52644. */
  52645. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52646. /**
  52647. * Does a raycast in the physics world
  52648. * @param from when should the ray start?
  52649. * @param to when should the ray end?
  52650. * @returns PhysicsRaycastResult
  52651. */
  52652. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52653. }
  52654. }
  52655. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52656. import { Nullable } from "babylonjs/types";
  52657. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52659. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52660. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52661. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52662. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52663. /** @hidden */
  52664. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52665. private _useDeltaForWorldStep;
  52666. world: any;
  52667. name: string;
  52668. private _physicsMaterials;
  52669. private _fixedTimeStep;
  52670. private _cannonRaycastResult;
  52671. private _raycastResult;
  52672. private _physicsBodysToRemoveAfterStep;
  52673. BJSCANNON: any;
  52674. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52675. setGravity(gravity: Vector3): void;
  52676. setTimeStep(timeStep: number): void;
  52677. getTimeStep(): number;
  52678. executeStep(delta: number): void;
  52679. private _removeMarkedPhysicsBodiesFromWorld;
  52680. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52681. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52682. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52683. private _processChildMeshes;
  52684. removePhysicsBody(impostor: PhysicsImpostor): void;
  52685. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52686. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52687. private _addMaterial;
  52688. private _checkWithEpsilon;
  52689. private _createShape;
  52690. private _createHeightmap;
  52691. private _minus90X;
  52692. private _plus90X;
  52693. private _tmpPosition;
  52694. private _tmpDeltaPosition;
  52695. private _tmpUnityRotation;
  52696. private _updatePhysicsBodyTransformation;
  52697. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52698. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52699. isSupported(): boolean;
  52700. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52701. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52702. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52703. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52704. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52705. getBodyMass(impostor: PhysicsImpostor): number;
  52706. getBodyFriction(impostor: PhysicsImpostor): number;
  52707. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52708. getBodyRestitution(impostor: PhysicsImpostor): number;
  52709. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52710. sleepBody(impostor: PhysicsImpostor): void;
  52711. wakeUpBody(impostor: PhysicsImpostor): void;
  52712. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52713. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52714. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52715. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52716. getRadius(impostor: PhysicsImpostor): number;
  52717. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52718. dispose(): void;
  52719. private _extendNamespace;
  52720. /**
  52721. * Does a raycast in the physics world
  52722. * @param from when should the ray start?
  52723. * @param to when should the ray end?
  52724. * @returns PhysicsRaycastResult
  52725. */
  52726. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52727. }
  52728. }
  52729. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52730. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52731. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52732. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52734. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52735. import { Nullable } from "babylonjs/types";
  52736. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52737. /** @hidden */
  52738. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52739. world: any;
  52740. name: string;
  52741. BJSOIMO: any;
  52742. private _raycastResult;
  52743. constructor(iterations?: number, oimoInjection?: any);
  52744. setGravity(gravity: Vector3): void;
  52745. setTimeStep(timeStep: number): void;
  52746. getTimeStep(): number;
  52747. private _tmpImpostorsArray;
  52748. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52749. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52750. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52751. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52752. private _tmpPositionVector;
  52753. removePhysicsBody(impostor: PhysicsImpostor): void;
  52754. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52755. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52756. isSupported(): boolean;
  52757. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52758. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52759. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52760. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52761. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52762. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52763. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52764. getBodyMass(impostor: PhysicsImpostor): number;
  52765. getBodyFriction(impostor: PhysicsImpostor): number;
  52766. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52767. getBodyRestitution(impostor: PhysicsImpostor): number;
  52768. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52769. sleepBody(impostor: PhysicsImpostor): void;
  52770. wakeUpBody(impostor: PhysicsImpostor): void;
  52771. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52772. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52773. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52774. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52775. getRadius(impostor: PhysicsImpostor): number;
  52776. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52777. dispose(): void;
  52778. /**
  52779. * Does a raycast in the physics world
  52780. * @param from when should the ray start?
  52781. * @param to when should the ray end?
  52782. * @returns PhysicsRaycastResult
  52783. */
  52784. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52785. }
  52786. }
  52787. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52788. import { Nullable } from "babylonjs/types";
  52789. import { Scene } from "babylonjs/scene";
  52790. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52791. import { Color4 } from "babylonjs/Maths/math.color";
  52792. import { Mesh } from "babylonjs/Meshes/mesh";
  52793. /**
  52794. * Class containing static functions to help procedurally build meshes
  52795. */
  52796. export class RibbonBuilder {
  52797. /**
  52798. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52799. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52800. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52801. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52802. * * 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
  52803. * * 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
  52804. * * 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
  52805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52806. * * 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
  52807. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52808. * * 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
  52809. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52810. * * 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
  52811. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52813. * @param name defines the name of the mesh
  52814. * @param options defines the options used to create the mesh
  52815. * @param scene defines the hosting scene
  52816. * @returns the ribbon mesh
  52817. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52818. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52819. */
  52820. static CreateRibbon(name: string, options: {
  52821. pathArray: Vector3[][];
  52822. closeArray?: boolean;
  52823. closePath?: boolean;
  52824. offset?: number;
  52825. updatable?: boolean;
  52826. sideOrientation?: number;
  52827. frontUVs?: Vector4;
  52828. backUVs?: Vector4;
  52829. instance?: Mesh;
  52830. invertUV?: boolean;
  52831. uvs?: Vector2[];
  52832. colors?: Color4[];
  52833. }, scene?: Nullable<Scene>): Mesh;
  52834. }
  52835. }
  52836. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52837. import { Nullable } from "babylonjs/types";
  52838. import { Scene } from "babylonjs/scene";
  52839. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52840. import { Mesh } from "babylonjs/Meshes/mesh";
  52841. /**
  52842. * Class containing static functions to help procedurally build meshes
  52843. */
  52844. export class ShapeBuilder {
  52845. /**
  52846. * 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.
  52847. * * 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.
  52848. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52849. * * 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.
  52850. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52851. * * 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
  52852. * * 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
  52853. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52855. * * 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
  52856. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52858. * @param name defines the name of the mesh
  52859. * @param options defines the options used to create the mesh
  52860. * @param scene defines the hosting scene
  52861. * @returns the extruded shape mesh
  52862. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52864. */
  52865. static ExtrudeShape(name: string, options: {
  52866. shape: Vector3[];
  52867. path: Vector3[];
  52868. scale?: number;
  52869. rotation?: number;
  52870. cap?: number;
  52871. updatable?: boolean;
  52872. sideOrientation?: number;
  52873. frontUVs?: Vector4;
  52874. backUVs?: Vector4;
  52875. instance?: Mesh;
  52876. invertUV?: boolean;
  52877. }, scene?: Nullable<Scene>): Mesh;
  52878. /**
  52879. * Creates an custom extruded shape mesh.
  52880. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52881. * * 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.
  52882. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52883. * * 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
  52884. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52885. * * 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
  52886. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52887. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52888. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52889. * * 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
  52890. * * 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
  52891. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52893. * * 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
  52894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52896. * @param name defines the name of the mesh
  52897. * @param options defines the options used to create the mesh
  52898. * @param scene defines the hosting scene
  52899. * @returns the custom extruded shape mesh
  52900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52903. */
  52904. static ExtrudeShapeCustom(name: string, options: {
  52905. shape: Vector3[];
  52906. path: Vector3[];
  52907. scaleFunction?: any;
  52908. rotationFunction?: any;
  52909. ribbonCloseArray?: boolean;
  52910. ribbonClosePath?: boolean;
  52911. cap?: number;
  52912. updatable?: boolean;
  52913. sideOrientation?: number;
  52914. frontUVs?: Vector4;
  52915. backUVs?: Vector4;
  52916. instance?: Mesh;
  52917. invertUV?: boolean;
  52918. }, scene?: Nullable<Scene>): Mesh;
  52919. private static _ExtrudeShapeGeneric;
  52920. }
  52921. }
  52922. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52923. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52924. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52925. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52926. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52927. import { Nullable } from "babylonjs/types";
  52928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52929. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52930. /**
  52931. * AmmoJS Physics plugin
  52932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52933. * @see https://github.com/kripken/ammo.js/
  52934. */
  52935. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52936. private _useDeltaForWorldStep;
  52937. /**
  52938. * Reference to the Ammo library
  52939. */
  52940. bjsAMMO: any;
  52941. /**
  52942. * Created ammoJS world which physics bodies are added to
  52943. */
  52944. world: any;
  52945. /**
  52946. * Name of the plugin
  52947. */
  52948. name: string;
  52949. private _timeStep;
  52950. private _fixedTimeStep;
  52951. private _maxSteps;
  52952. private _tmpQuaternion;
  52953. private _tmpAmmoTransform;
  52954. private _tmpAmmoQuaternion;
  52955. private _tmpAmmoConcreteContactResultCallback;
  52956. private _collisionConfiguration;
  52957. private _dispatcher;
  52958. private _overlappingPairCache;
  52959. private _solver;
  52960. private _softBodySolver;
  52961. private _tmpAmmoVectorA;
  52962. private _tmpAmmoVectorB;
  52963. private _tmpAmmoVectorC;
  52964. private _tmpAmmoVectorD;
  52965. private _tmpContactCallbackResult;
  52966. private _tmpAmmoVectorRCA;
  52967. private _tmpAmmoVectorRCB;
  52968. private _raycastResult;
  52969. private static readonly DISABLE_COLLISION_FLAG;
  52970. private static readonly KINEMATIC_FLAG;
  52971. private static readonly DISABLE_DEACTIVATION_FLAG;
  52972. /**
  52973. * Initializes the ammoJS plugin
  52974. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52975. * @param ammoInjection can be used to inject your own ammo reference
  52976. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52977. */
  52978. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52979. /**
  52980. * Sets the gravity of the physics world (m/(s^2))
  52981. * @param gravity Gravity to set
  52982. */
  52983. setGravity(gravity: Vector3): void;
  52984. /**
  52985. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52986. * @param timeStep timestep to use in seconds
  52987. */
  52988. setTimeStep(timeStep: number): void;
  52989. /**
  52990. * 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)
  52991. * @param fixedTimeStep fixedTimeStep to use in seconds
  52992. */
  52993. setFixedTimeStep(fixedTimeStep: number): void;
  52994. /**
  52995. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52996. * @param maxSteps the maximum number of steps by the physics engine per frame
  52997. */
  52998. setMaxSteps(maxSteps: number): void;
  52999. /**
  53000. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53001. * @returns the current timestep in seconds
  53002. */
  53003. getTimeStep(): number;
  53004. private _isImpostorInContact;
  53005. private _isImpostorPairInContact;
  53006. private _stepSimulation;
  53007. /**
  53008. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53009. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53010. * After the step the babylon meshes are set to the position of the physics imposters
  53011. * @param delta amount of time to step forward
  53012. * @param impostors array of imposters to update before/after the step
  53013. */
  53014. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53015. /**
  53016. * Update babylon mesh to match physics world object
  53017. * @param impostor imposter to match
  53018. */
  53019. private _afterSoftStep;
  53020. /**
  53021. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53022. * @param impostor imposter to match
  53023. */
  53024. private _ropeStep;
  53025. /**
  53026. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53027. * @param impostor imposter to match
  53028. */
  53029. private _softbodyOrClothStep;
  53030. private _tmpVector;
  53031. private _tmpMatrix;
  53032. /**
  53033. * Applies an impulse on the imposter
  53034. * @param impostor imposter to apply impulse to
  53035. * @param force amount of force to be applied to the imposter
  53036. * @param contactPoint the location to apply the impulse on the imposter
  53037. */
  53038. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53039. /**
  53040. * Applies a force on the imposter
  53041. * @param impostor imposter to apply force
  53042. * @param force amount of force to be applied to the imposter
  53043. * @param contactPoint the location to apply the force on the imposter
  53044. */
  53045. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53046. /**
  53047. * Creates a physics body using the plugin
  53048. * @param impostor the imposter to create the physics body on
  53049. */
  53050. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53051. /**
  53052. * Removes the physics body from the imposter and disposes of the body's memory
  53053. * @param impostor imposter to remove the physics body from
  53054. */
  53055. removePhysicsBody(impostor: PhysicsImpostor): void;
  53056. /**
  53057. * Generates a joint
  53058. * @param impostorJoint the imposter joint to create the joint with
  53059. */
  53060. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53061. /**
  53062. * Removes a joint
  53063. * @param impostorJoint the imposter joint to remove the joint from
  53064. */
  53065. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53066. private _addMeshVerts;
  53067. /**
  53068. * Initialise the soft body vertices to match its object's (mesh) vertices
  53069. * Softbody vertices (nodes) are in world space and to match this
  53070. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53071. * @param impostor to create the softbody for
  53072. */
  53073. private _softVertexData;
  53074. /**
  53075. * Create an impostor's soft body
  53076. * @param impostor to create the softbody for
  53077. */
  53078. private _createSoftbody;
  53079. /**
  53080. * Create cloth for an impostor
  53081. * @param impostor to create the softbody for
  53082. */
  53083. private _createCloth;
  53084. /**
  53085. * Create rope for an impostor
  53086. * @param impostor to create the softbody for
  53087. */
  53088. private _createRope;
  53089. private _addHullVerts;
  53090. private _createShape;
  53091. /**
  53092. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53093. * @param impostor imposter containing the physics body and babylon object
  53094. */
  53095. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53096. /**
  53097. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53098. * @param impostor imposter containing the physics body and babylon object
  53099. * @param newPosition new position
  53100. * @param newRotation new rotation
  53101. */
  53102. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53103. /**
  53104. * If this plugin is supported
  53105. * @returns true if its supported
  53106. */
  53107. isSupported(): boolean;
  53108. /**
  53109. * Sets the linear velocity of the physics body
  53110. * @param impostor imposter to set the velocity on
  53111. * @param velocity velocity to set
  53112. */
  53113. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53114. /**
  53115. * Sets the angular velocity of the physics body
  53116. * @param impostor imposter to set the velocity on
  53117. * @param velocity velocity to set
  53118. */
  53119. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53120. /**
  53121. * gets the linear velocity
  53122. * @param impostor imposter to get linear velocity from
  53123. * @returns linear velocity
  53124. */
  53125. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53126. /**
  53127. * gets the angular velocity
  53128. * @param impostor imposter to get angular velocity from
  53129. * @returns angular velocity
  53130. */
  53131. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53132. /**
  53133. * Sets the mass of physics body
  53134. * @param impostor imposter to set the mass on
  53135. * @param mass mass to set
  53136. */
  53137. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53138. /**
  53139. * Gets the mass of the physics body
  53140. * @param impostor imposter to get the mass from
  53141. * @returns mass
  53142. */
  53143. getBodyMass(impostor: PhysicsImpostor): number;
  53144. /**
  53145. * Gets friction of the impostor
  53146. * @param impostor impostor to get friction from
  53147. * @returns friction value
  53148. */
  53149. getBodyFriction(impostor: PhysicsImpostor): number;
  53150. /**
  53151. * Sets friction of the impostor
  53152. * @param impostor impostor to set friction on
  53153. * @param friction friction value
  53154. */
  53155. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53156. /**
  53157. * Gets restitution of the impostor
  53158. * @param impostor impostor to get restitution from
  53159. * @returns restitution value
  53160. */
  53161. getBodyRestitution(impostor: PhysicsImpostor): number;
  53162. /**
  53163. * Sets resitution of the impostor
  53164. * @param impostor impostor to set resitution on
  53165. * @param restitution resitution value
  53166. */
  53167. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53168. /**
  53169. * Gets pressure inside the impostor
  53170. * @param impostor impostor to get pressure from
  53171. * @returns pressure value
  53172. */
  53173. getBodyPressure(impostor: PhysicsImpostor): number;
  53174. /**
  53175. * Sets pressure inside a soft body impostor
  53176. * Cloth and rope must remain 0 pressure
  53177. * @param impostor impostor to set pressure on
  53178. * @param pressure pressure value
  53179. */
  53180. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53181. /**
  53182. * Gets stiffness of the impostor
  53183. * @param impostor impostor to get stiffness from
  53184. * @returns pressure value
  53185. */
  53186. getBodyStiffness(impostor: PhysicsImpostor): number;
  53187. /**
  53188. * Sets stiffness of the impostor
  53189. * @param impostor impostor to set stiffness on
  53190. * @param stiffness stiffness value from 0 to 1
  53191. */
  53192. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53193. /**
  53194. * Gets velocityIterations of the impostor
  53195. * @param impostor impostor to get velocity iterations from
  53196. * @returns velocityIterations value
  53197. */
  53198. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53199. /**
  53200. * Sets velocityIterations of the impostor
  53201. * @param impostor impostor to set velocity iterations on
  53202. * @param velocityIterations velocityIterations value
  53203. */
  53204. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53205. /**
  53206. * Gets positionIterations of the impostor
  53207. * @param impostor impostor to get position iterations from
  53208. * @returns positionIterations value
  53209. */
  53210. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53211. /**
  53212. * Sets positionIterations of the impostor
  53213. * @param impostor impostor to set position on
  53214. * @param positionIterations positionIterations value
  53215. */
  53216. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53217. /**
  53218. * Append an anchor to a cloth object
  53219. * @param impostor is the cloth impostor to add anchor to
  53220. * @param otherImpostor is the rigid impostor to anchor to
  53221. * @param width ratio across width from 0 to 1
  53222. * @param height ratio up height from 0 to 1
  53223. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53224. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53225. */
  53226. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53227. /**
  53228. * Append an hook to a rope object
  53229. * @param impostor is the rope impostor to add hook to
  53230. * @param otherImpostor is the rigid impostor to hook to
  53231. * @param length ratio along the rope from 0 to 1
  53232. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53233. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53234. */
  53235. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53236. /**
  53237. * Sleeps the physics body and stops it from being active
  53238. * @param impostor impostor to sleep
  53239. */
  53240. sleepBody(impostor: PhysicsImpostor): void;
  53241. /**
  53242. * Activates the physics body
  53243. * @param impostor impostor to activate
  53244. */
  53245. wakeUpBody(impostor: PhysicsImpostor): void;
  53246. /**
  53247. * Updates the distance parameters of the joint
  53248. * @param joint joint to update
  53249. * @param maxDistance maximum distance of the joint
  53250. * @param minDistance minimum distance of the joint
  53251. */
  53252. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53253. /**
  53254. * Sets a motor on the joint
  53255. * @param joint joint to set motor on
  53256. * @param speed speed of the motor
  53257. * @param maxForce maximum force of the motor
  53258. * @param motorIndex index of the motor
  53259. */
  53260. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53261. /**
  53262. * Sets the motors limit
  53263. * @param joint joint to set limit on
  53264. * @param upperLimit upper limit
  53265. * @param lowerLimit lower limit
  53266. */
  53267. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53268. /**
  53269. * Syncs the position and rotation of a mesh with the impostor
  53270. * @param mesh mesh to sync
  53271. * @param impostor impostor to update the mesh with
  53272. */
  53273. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53274. /**
  53275. * Gets the radius of the impostor
  53276. * @param impostor impostor to get radius from
  53277. * @returns the radius
  53278. */
  53279. getRadius(impostor: PhysicsImpostor): number;
  53280. /**
  53281. * Gets the box size of the impostor
  53282. * @param impostor impostor to get box size from
  53283. * @param result the resulting box size
  53284. */
  53285. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53286. /**
  53287. * Disposes of the impostor
  53288. */
  53289. dispose(): void;
  53290. /**
  53291. * Does a raycast in the physics world
  53292. * @param from when should the ray start?
  53293. * @param to when should the ray end?
  53294. * @returns PhysicsRaycastResult
  53295. */
  53296. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53297. }
  53298. }
  53299. declare module "babylonjs/Probes/reflectionProbe" {
  53300. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53301. import { Vector3 } from "babylonjs/Maths/math.vector";
  53302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53303. import { Nullable } from "babylonjs/types";
  53304. import { Scene } from "babylonjs/scene";
  53305. module "babylonjs/abstractScene" {
  53306. interface AbstractScene {
  53307. /**
  53308. * The list of reflection probes added to the scene
  53309. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53310. */
  53311. reflectionProbes: Array<ReflectionProbe>;
  53312. /**
  53313. * Removes the given reflection probe from this scene.
  53314. * @param toRemove The reflection probe to remove
  53315. * @returns The index of the removed reflection probe
  53316. */
  53317. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53318. /**
  53319. * Adds the given reflection probe to this scene.
  53320. * @param newReflectionProbe The reflection probe to add
  53321. */
  53322. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53323. }
  53324. }
  53325. /**
  53326. * Class used to generate realtime reflection / refraction cube textures
  53327. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53328. */
  53329. export class ReflectionProbe {
  53330. /** defines the name of the probe */
  53331. name: string;
  53332. private _scene;
  53333. private _renderTargetTexture;
  53334. private _projectionMatrix;
  53335. private _viewMatrix;
  53336. private _target;
  53337. private _add;
  53338. private _attachedMesh;
  53339. private _invertYAxis;
  53340. /** Gets or sets probe position (center of the cube map) */
  53341. position: Vector3;
  53342. /**
  53343. * Creates a new reflection probe
  53344. * @param name defines the name of the probe
  53345. * @param size defines the texture resolution (for each face)
  53346. * @param scene defines the hosting scene
  53347. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53348. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53349. */
  53350. constructor(
  53351. /** defines the name of the probe */
  53352. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53353. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53354. samples: number;
  53355. /** Gets or sets the refresh rate to use (on every frame by default) */
  53356. refreshRate: number;
  53357. /**
  53358. * Gets the hosting scene
  53359. * @returns a Scene
  53360. */
  53361. getScene(): Scene;
  53362. /** Gets the internal CubeTexture used to render to */
  53363. readonly cubeTexture: RenderTargetTexture;
  53364. /** Gets the list of meshes to render */
  53365. readonly renderList: Nullable<AbstractMesh[]>;
  53366. /**
  53367. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53368. * @param mesh defines the mesh to attach to
  53369. */
  53370. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53371. /**
  53372. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53373. * @param renderingGroupId The rendering group id corresponding to its index
  53374. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53375. */
  53376. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53377. /**
  53378. * Clean all associated resources
  53379. */
  53380. dispose(): void;
  53381. /**
  53382. * Converts the reflection probe information to a readable string for debug purpose.
  53383. * @param fullDetails Supports for multiple levels of logging within scene loading
  53384. * @returns the human readable reflection probe info
  53385. */
  53386. toString(fullDetails?: boolean): string;
  53387. /**
  53388. * Get the class name of the relfection probe.
  53389. * @returns "ReflectionProbe"
  53390. */
  53391. getClassName(): string;
  53392. /**
  53393. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53394. * @returns The JSON representation of the texture
  53395. */
  53396. serialize(): any;
  53397. /**
  53398. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53399. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53400. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53401. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53402. * @returns The parsed reflection probe if successful
  53403. */
  53404. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53405. }
  53406. }
  53407. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53408. /** @hidden */
  53409. export var _BabylonLoaderRegistered: boolean;
  53410. }
  53411. declare module "babylonjs/Loading/Plugins/index" {
  53412. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53413. }
  53414. declare module "babylonjs/Loading/index" {
  53415. export * from "babylonjs/Loading/loadingScreen";
  53416. export * from "babylonjs/Loading/Plugins/index";
  53417. export * from "babylonjs/Loading/sceneLoader";
  53418. export * from "babylonjs/Loading/sceneLoaderFlags";
  53419. }
  53420. declare module "babylonjs/Materials/Background/index" {
  53421. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53422. }
  53423. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53424. import { Scene } from "babylonjs/scene";
  53425. import { Color3 } from "babylonjs/Maths/math.color";
  53426. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53428. /**
  53429. * The Physically based simple base material of BJS.
  53430. *
  53431. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53432. * It is used as the base class for both the specGloss and metalRough conventions.
  53433. */
  53434. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53435. /**
  53436. * Number of Simultaneous lights allowed on the material.
  53437. */
  53438. maxSimultaneousLights: number;
  53439. /**
  53440. * If sets to true, disables all the lights affecting the material.
  53441. */
  53442. disableLighting: boolean;
  53443. /**
  53444. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53445. */
  53446. environmentTexture: BaseTexture;
  53447. /**
  53448. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53449. */
  53450. invertNormalMapX: boolean;
  53451. /**
  53452. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53453. */
  53454. invertNormalMapY: boolean;
  53455. /**
  53456. * Normal map used in the model.
  53457. */
  53458. normalTexture: BaseTexture;
  53459. /**
  53460. * Emissivie color used to self-illuminate the model.
  53461. */
  53462. emissiveColor: Color3;
  53463. /**
  53464. * Emissivie texture used to self-illuminate the model.
  53465. */
  53466. emissiveTexture: BaseTexture;
  53467. /**
  53468. * Occlusion Channel Strenght.
  53469. */
  53470. occlusionStrength: number;
  53471. /**
  53472. * Occlusion Texture of the material (adding extra occlusion effects).
  53473. */
  53474. occlusionTexture: BaseTexture;
  53475. /**
  53476. * Defines the alpha limits in alpha test mode.
  53477. */
  53478. alphaCutOff: number;
  53479. /**
  53480. * Gets the current double sided mode.
  53481. */
  53482. /**
  53483. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53484. */
  53485. doubleSided: boolean;
  53486. /**
  53487. * Stores the pre-calculated light information of a mesh in a texture.
  53488. */
  53489. lightmapTexture: BaseTexture;
  53490. /**
  53491. * If true, the light map contains occlusion information instead of lighting info.
  53492. */
  53493. useLightmapAsShadowmap: boolean;
  53494. /**
  53495. * Instantiates a new PBRMaterial instance.
  53496. *
  53497. * @param name The material name
  53498. * @param scene The scene the material will be use in.
  53499. */
  53500. constructor(name: string, scene: Scene);
  53501. getClassName(): string;
  53502. }
  53503. }
  53504. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53505. import { Scene } from "babylonjs/scene";
  53506. import { Color3 } from "babylonjs/Maths/math.color";
  53507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53508. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53509. /**
  53510. * The PBR material of BJS following the metal roughness convention.
  53511. *
  53512. * This fits to the PBR convention in the GLTF definition:
  53513. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53514. */
  53515. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53516. /**
  53517. * The base color has two different interpretations depending on the value of metalness.
  53518. * When the material is a metal, the base color is the specific measured reflectance value
  53519. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53520. * of the material.
  53521. */
  53522. baseColor: Color3;
  53523. /**
  53524. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53525. * well as opacity information in the alpha channel.
  53526. */
  53527. baseTexture: BaseTexture;
  53528. /**
  53529. * Specifies the metallic scalar value of the material.
  53530. * Can also be used to scale the metalness values of the metallic texture.
  53531. */
  53532. metallic: number;
  53533. /**
  53534. * Specifies the roughness scalar value of the material.
  53535. * Can also be used to scale the roughness values of the metallic texture.
  53536. */
  53537. roughness: number;
  53538. /**
  53539. * Texture containing both the metallic value in the B channel and the
  53540. * roughness value in the G channel to keep better precision.
  53541. */
  53542. metallicRoughnessTexture: BaseTexture;
  53543. /**
  53544. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53545. *
  53546. * @param name The material name
  53547. * @param scene The scene the material will be use in.
  53548. */
  53549. constructor(name: string, scene: Scene);
  53550. /**
  53551. * Return the currrent class name of the material.
  53552. */
  53553. getClassName(): string;
  53554. /**
  53555. * Makes a duplicate of the current material.
  53556. * @param name - name to use for the new material.
  53557. */
  53558. clone(name: string): PBRMetallicRoughnessMaterial;
  53559. /**
  53560. * Serialize the material to a parsable JSON object.
  53561. */
  53562. serialize(): any;
  53563. /**
  53564. * Parses a JSON object correponding to the serialize function.
  53565. */
  53566. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53567. }
  53568. }
  53569. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53570. import { Scene } from "babylonjs/scene";
  53571. import { Color3 } from "babylonjs/Maths/math.color";
  53572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53573. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53574. /**
  53575. * The PBR material of BJS following the specular glossiness convention.
  53576. *
  53577. * This fits to the PBR convention in the GLTF definition:
  53578. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53579. */
  53580. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53581. /**
  53582. * Specifies the diffuse color of the material.
  53583. */
  53584. diffuseColor: Color3;
  53585. /**
  53586. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53587. * channel.
  53588. */
  53589. diffuseTexture: BaseTexture;
  53590. /**
  53591. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53592. */
  53593. specularColor: Color3;
  53594. /**
  53595. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53596. */
  53597. glossiness: number;
  53598. /**
  53599. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53600. */
  53601. specularGlossinessTexture: BaseTexture;
  53602. /**
  53603. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53604. *
  53605. * @param name The material name
  53606. * @param scene The scene the material will be use in.
  53607. */
  53608. constructor(name: string, scene: Scene);
  53609. /**
  53610. * Return the currrent class name of the material.
  53611. */
  53612. getClassName(): string;
  53613. /**
  53614. * Makes a duplicate of the current material.
  53615. * @param name - name to use for the new material.
  53616. */
  53617. clone(name: string): PBRSpecularGlossinessMaterial;
  53618. /**
  53619. * Serialize the material to a parsable JSON object.
  53620. */
  53621. serialize(): any;
  53622. /**
  53623. * Parses a JSON object correponding to the serialize function.
  53624. */
  53625. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53626. }
  53627. }
  53628. declare module "babylonjs/Materials/PBR/index" {
  53629. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53630. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53631. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53632. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53633. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53634. }
  53635. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53636. import { Nullable } from "babylonjs/types";
  53637. import { Scene } from "babylonjs/scene";
  53638. import { Matrix } from "babylonjs/Maths/math.vector";
  53639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53640. /**
  53641. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53642. * It can help converting any input color in a desired output one. This can then be used to create effects
  53643. * from sepia, black and white to sixties or futuristic rendering...
  53644. *
  53645. * The only supported format is currently 3dl.
  53646. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53647. */
  53648. export class ColorGradingTexture extends BaseTexture {
  53649. /**
  53650. * The current texture matrix. (will always be identity in color grading texture)
  53651. */
  53652. private _textureMatrix;
  53653. /**
  53654. * The texture URL.
  53655. */
  53656. url: string;
  53657. /**
  53658. * Empty line regex stored for GC.
  53659. */
  53660. private static _noneEmptyLineRegex;
  53661. private _engine;
  53662. /**
  53663. * Instantiates a ColorGradingTexture from the following parameters.
  53664. *
  53665. * @param url The location of the color gradind data (currently only supporting 3dl)
  53666. * @param scene The scene the texture will be used in
  53667. */
  53668. constructor(url: string, scene: Scene);
  53669. /**
  53670. * Returns the texture matrix used in most of the material.
  53671. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53672. */
  53673. getTextureMatrix(): Matrix;
  53674. /**
  53675. * Occurs when the file being loaded is a .3dl LUT file.
  53676. */
  53677. private load3dlTexture;
  53678. /**
  53679. * Starts the loading process of the texture.
  53680. */
  53681. private loadTexture;
  53682. /**
  53683. * Clones the color gradind texture.
  53684. */
  53685. clone(): ColorGradingTexture;
  53686. /**
  53687. * Called during delayed load for textures.
  53688. */
  53689. delayLoad(): void;
  53690. /**
  53691. * Parses a color grading texture serialized by Babylon.
  53692. * @param parsedTexture The texture information being parsedTexture
  53693. * @param scene The scene to load the texture in
  53694. * @param rootUrl The root url of the data assets to load
  53695. * @return A color gradind texture
  53696. */
  53697. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53698. /**
  53699. * Serializes the LUT texture to json format.
  53700. */
  53701. serialize(): any;
  53702. }
  53703. }
  53704. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53706. import { Scene } from "babylonjs/scene";
  53707. import { Nullable } from "babylonjs/types";
  53708. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53709. /**
  53710. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53711. */
  53712. export class EquiRectangularCubeTexture extends BaseTexture {
  53713. /** The six faces of the cube. */
  53714. private static _FacesMapping;
  53715. private _noMipmap;
  53716. private _onLoad;
  53717. private _onError;
  53718. /** The size of the cubemap. */
  53719. private _size;
  53720. /** The buffer of the image. */
  53721. private _buffer;
  53722. /** The width of the input image. */
  53723. private _width;
  53724. /** The height of the input image. */
  53725. private _height;
  53726. /** The URL to the image. */
  53727. url: string;
  53728. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53729. coordinatesMode: number;
  53730. /**
  53731. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53732. * @param url The location of the image
  53733. * @param scene The scene the texture will be used in
  53734. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53735. * @param noMipmap Forces to not generate the mipmap if true
  53736. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53737. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53738. * @param onLoad — defines a callback called when texture is loaded
  53739. * @param onError — defines a callback called if there is an error
  53740. */
  53741. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53742. /**
  53743. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53744. */
  53745. private loadImage;
  53746. /**
  53747. * Convert the image buffer into a cubemap and create a CubeTexture.
  53748. */
  53749. private loadTexture;
  53750. /**
  53751. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53752. * @param buffer The ArrayBuffer that should be converted.
  53753. * @returns The buffer as Float32Array.
  53754. */
  53755. private getFloat32ArrayFromArrayBuffer;
  53756. /**
  53757. * Get the current class name of the texture useful for serialization or dynamic coding.
  53758. * @returns "EquiRectangularCubeTexture"
  53759. */
  53760. getClassName(): string;
  53761. /**
  53762. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53763. * @returns A clone of the current EquiRectangularCubeTexture.
  53764. */
  53765. clone(): EquiRectangularCubeTexture;
  53766. }
  53767. }
  53768. declare module "babylonjs/Misc/tga" {
  53769. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53770. /**
  53771. * Based on jsTGALoader - Javascript loader for TGA file
  53772. * By Vincent Thibault
  53773. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53774. */
  53775. export class TGATools {
  53776. private static _TYPE_INDEXED;
  53777. private static _TYPE_RGB;
  53778. private static _TYPE_GREY;
  53779. private static _TYPE_RLE_INDEXED;
  53780. private static _TYPE_RLE_RGB;
  53781. private static _TYPE_RLE_GREY;
  53782. private static _ORIGIN_MASK;
  53783. private static _ORIGIN_SHIFT;
  53784. private static _ORIGIN_BL;
  53785. private static _ORIGIN_BR;
  53786. private static _ORIGIN_UL;
  53787. private static _ORIGIN_UR;
  53788. /**
  53789. * Gets the header of a TGA file
  53790. * @param data defines the TGA data
  53791. * @returns the header
  53792. */
  53793. static GetTGAHeader(data: Uint8Array): any;
  53794. /**
  53795. * Uploads TGA content to a Babylon Texture
  53796. * @hidden
  53797. */
  53798. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53799. /** @hidden */
  53800. 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;
  53801. /** @hidden */
  53802. 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;
  53803. /** @hidden */
  53804. 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;
  53805. /** @hidden */
  53806. 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;
  53807. /** @hidden */
  53808. 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;
  53809. /** @hidden */
  53810. 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;
  53811. }
  53812. }
  53813. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53814. import { Nullable } from "babylonjs/types";
  53815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53816. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53817. /**
  53818. * Implementation of the TGA Texture Loader.
  53819. * @hidden
  53820. */
  53821. export class _TGATextureLoader implements IInternalTextureLoader {
  53822. /**
  53823. * Defines wether the loader supports cascade loading the different faces.
  53824. */
  53825. readonly supportCascades: boolean;
  53826. /**
  53827. * This returns if the loader support the current file information.
  53828. * @param extension defines the file extension of the file being loaded
  53829. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53830. * @param fallback defines the fallback internal texture if any
  53831. * @param isBase64 defines whether the texture is encoded as a base64
  53832. * @param isBuffer defines whether the texture data are stored as a buffer
  53833. * @returns true if the loader can load the specified file
  53834. */
  53835. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53836. /**
  53837. * Transform the url before loading if required.
  53838. * @param rootUrl the url of the texture
  53839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53840. * @returns the transformed texture
  53841. */
  53842. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53843. /**
  53844. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53845. * @param rootUrl the url of the texture
  53846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53847. * @returns the fallback texture
  53848. */
  53849. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53850. /**
  53851. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53852. * @param data contains the texture data
  53853. * @param texture defines the BabylonJS internal texture
  53854. * @param createPolynomials will be true if polynomials have been requested
  53855. * @param onLoad defines the callback to trigger once the texture is ready
  53856. * @param onError defines the callback to trigger in case of error
  53857. */
  53858. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53859. /**
  53860. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53861. * @param data contains the texture data
  53862. * @param texture defines the BabylonJS internal texture
  53863. * @param callback defines the method to call once ready to upload
  53864. */
  53865. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53866. }
  53867. }
  53868. declare module "babylonjs/Misc/basis" {
  53869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53870. /**
  53871. * Info about the .basis files
  53872. */
  53873. class BasisFileInfo {
  53874. /**
  53875. * If the file has alpha
  53876. */
  53877. hasAlpha: boolean;
  53878. /**
  53879. * Info about each image of the basis file
  53880. */
  53881. images: Array<{
  53882. levels: Array<{
  53883. width: number;
  53884. height: number;
  53885. transcodedPixels: ArrayBufferView;
  53886. }>;
  53887. }>;
  53888. }
  53889. /**
  53890. * Result of transcoding a basis file
  53891. */
  53892. class TranscodeResult {
  53893. /**
  53894. * Info about the .basis file
  53895. */
  53896. fileInfo: BasisFileInfo;
  53897. /**
  53898. * Format to use when loading the file
  53899. */
  53900. format: number;
  53901. }
  53902. /**
  53903. * Configuration options for the Basis transcoder
  53904. */
  53905. export class BasisTranscodeConfiguration {
  53906. /**
  53907. * Supported compression formats used to determine the supported output format of the transcoder
  53908. */
  53909. supportedCompressionFormats?: {
  53910. /**
  53911. * etc1 compression format
  53912. */
  53913. etc1?: boolean;
  53914. /**
  53915. * s3tc compression format
  53916. */
  53917. s3tc?: boolean;
  53918. /**
  53919. * pvrtc compression format
  53920. */
  53921. pvrtc?: boolean;
  53922. /**
  53923. * etc2 compression format
  53924. */
  53925. etc2?: boolean;
  53926. };
  53927. /**
  53928. * If mipmap levels should be loaded for transcoded images (Default: true)
  53929. */
  53930. loadMipmapLevels?: boolean;
  53931. /**
  53932. * Index of a single image to load (Default: all images)
  53933. */
  53934. loadSingleImage?: number;
  53935. }
  53936. /**
  53937. * Used to load .Basis files
  53938. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53939. */
  53940. export class BasisTools {
  53941. private static _IgnoreSupportedFormats;
  53942. /**
  53943. * URL to use when loading the basis transcoder
  53944. */
  53945. static JSModuleURL: string;
  53946. /**
  53947. * URL to use when loading the wasm module for the transcoder
  53948. */
  53949. static WasmModuleURL: string;
  53950. /**
  53951. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53952. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53953. * @returns internal format corresponding to the Basis format
  53954. */
  53955. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53956. private static _WorkerPromise;
  53957. private static _Worker;
  53958. private static _actionId;
  53959. private static _CreateWorkerAsync;
  53960. /**
  53961. * Transcodes a loaded image file to compressed pixel data
  53962. * @param imageData image data to transcode
  53963. * @param config configuration options for the transcoding
  53964. * @returns a promise resulting in the transcoded image
  53965. */
  53966. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53967. /**
  53968. * Loads a texture from the transcode result
  53969. * @param texture texture load to
  53970. * @param transcodeResult the result of transcoding the basis file to load from
  53971. */
  53972. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53973. }
  53974. }
  53975. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53976. import { Nullable } from "babylonjs/types";
  53977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53978. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53979. /**
  53980. * Loader for .basis file format
  53981. */
  53982. export class _BasisTextureLoader implements IInternalTextureLoader {
  53983. /**
  53984. * Defines whether the loader supports cascade loading the different faces.
  53985. */
  53986. readonly supportCascades: boolean;
  53987. /**
  53988. * This returns if the loader support the current file information.
  53989. * @param extension defines the file extension of the file being loaded
  53990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53991. * @param fallback defines the fallback internal texture if any
  53992. * @param isBase64 defines whether the texture is encoded as a base64
  53993. * @param isBuffer defines whether the texture data are stored as a buffer
  53994. * @returns true if the loader can load the specified file
  53995. */
  53996. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53997. /**
  53998. * Transform the url before loading if required.
  53999. * @param rootUrl the url of the texture
  54000. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54001. * @returns the transformed texture
  54002. */
  54003. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54004. /**
  54005. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54006. * @param rootUrl the url of the texture
  54007. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54008. * @returns the fallback texture
  54009. */
  54010. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54011. /**
  54012. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54013. * @param data contains the texture data
  54014. * @param texture defines the BabylonJS internal texture
  54015. * @param createPolynomials will be true if polynomials have been requested
  54016. * @param onLoad defines the callback to trigger once the texture is ready
  54017. * @param onError defines the callback to trigger in case of error
  54018. */
  54019. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54020. /**
  54021. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54022. * @param data contains the texture data
  54023. * @param texture defines the BabylonJS internal texture
  54024. * @param callback defines the method to call once ready to upload
  54025. */
  54026. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54027. }
  54028. }
  54029. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54030. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54031. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54032. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54033. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54034. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54035. }
  54036. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54037. import { Scene } from "babylonjs/scene";
  54038. import { Texture } from "babylonjs/Materials/Textures/texture";
  54039. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54040. /**
  54041. * 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.
  54042. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54043. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54044. */
  54045. export class CustomProceduralTexture extends ProceduralTexture {
  54046. private _animate;
  54047. private _time;
  54048. private _config;
  54049. private _texturePath;
  54050. /**
  54051. * Instantiates a new Custom Procedural Texture.
  54052. * 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.
  54053. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54054. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54055. * @param name Define the name of the texture
  54056. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54057. * @param size Define the size of the texture to create
  54058. * @param scene Define the scene the texture belongs to
  54059. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54060. * @param generateMipMaps Define if the texture should creates mip maps or not
  54061. */
  54062. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54063. private _loadJson;
  54064. /**
  54065. * Is the texture ready to be used ? (rendered at least once)
  54066. * @returns true if ready, otherwise, false.
  54067. */
  54068. isReady(): boolean;
  54069. /**
  54070. * Render the texture to its associated render target.
  54071. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54072. */
  54073. render(useCameraPostProcess?: boolean): void;
  54074. /**
  54075. * Update the list of dependant textures samplers in the shader.
  54076. */
  54077. updateTextures(): void;
  54078. /**
  54079. * Update the uniform values of the procedural texture in the shader.
  54080. */
  54081. updateShaderUniforms(): void;
  54082. /**
  54083. * Define if the texture animates or not.
  54084. */
  54085. animate: boolean;
  54086. }
  54087. }
  54088. declare module "babylonjs/Shaders/noise.fragment" {
  54089. /** @hidden */
  54090. export var noisePixelShader: {
  54091. name: string;
  54092. shader: string;
  54093. };
  54094. }
  54095. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54096. import { Nullable } from "babylonjs/types";
  54097. import { Scene } from "babylonjs/scene";
  54098. import { Texture } from "babylonjs/Materials/Textures/texture";
  54099. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54100. import "babylonjs/Shaders/noise.fragment";
  54101. /**
  54102. * Class used to generate noise procedural textures
  54103. */
  54104. export class NoiseProceduralTexture extends ProceduralTexture {
  54105. private _time;
  54106. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54107. brightness: number;
  54108. /** Defines the number of octaves to process */
  54109. octaves: number;
  54110. /** Defines the level of persistence (0.8 by default) */
  54111. persistence: number;
  54112. /** Gets or sets animation speed factor (default is 1) */
  54113. animationSpeedFactor: number;
  54114. /**
  54115. * Creates a new NoiseProceduralTexture
  54116. * @param name defines the name fo the texture
  54117. * @param size defines the size of the texture (default is 256)
  54118. * @param scene defines the hosting scene
  54119. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54120. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54121. */
  54122. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54123. private _updateShaderUniforms;
  54124. protected _getDefines(): string;
  54125. /** Generate the current state of the procedural texture */
  54126. render(useCameraPostProcess?: boolean): void;
  54127. /**
  54128. * Serializes this noise procedural texture
  54129. * @returns a serialized noise procedural texture object
  54130. */
  54131. serialize(): any;
  54132. /**
  54133. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54134. * @param parsedTexture defines parsed texture data
  54135. * @param scene defines the current scene
  54136. * @param rootUrl defines the root URL containing noise procedural texture information
  54137. * @returns a parsed NoiseProceduralTexture
  54138. */
  54139. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54140. }
  54141. }
  54142. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54143. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54144. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54145. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54146. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54147. }
  54148. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54149. import { Nullable } from "babylonjs/types";
  54150. import { Scene } from "babylonjs/scene";
  54151. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54152. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54153. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54154. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54155. /**
  54156. * Raw cube texture where the raw buffers are passed in
  54157. */
  54158. export class RawCubeTexture extends CubeTexture {
  54159. /**
  54160. * Creates a cube texture where the raw buffers are passed in.
  54161. * @param scene defines the scene the texture is attached to
  54162. * @param data defines the array of data to use to create each face
  54163. * @param size defines the size of the textures
  54164. * @param format defines the format of the data
  54165. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54166. * @param generateMipMaps defines if the engine should generate the mip levels
  54167. * @param invertY defines if data must be stored with Y axis inverted
  54168. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54169. * @param compression defines the compression used (null by default)
  54170. */
  54171. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54172. /**
  54173. * Updates the raw cube texture.
  54174. * @param data defines the data to store
  54175. * @param format defines the data format
  54176. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54177. * @param invertY defines if data must be stored with Y axis inverted
  54178. * @param compression defines the compression used (null by default)
  54179. * @param level defines which level of the texture to update
  54180. */
  54181. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54182. /**
  54183. * Updates a raw cube texture with RGBD encoded data.
  54184. * @param data defines the array of data [mipmap][face] to use to create each face
  54185. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54186. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54187. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54188. * @returns a promsie that resolves when the operation is complete
  54189. */
  54190. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54191. /**
  54192. * Clones the raw cube texture.
  54193. * @return a new cube texture
  54194. */
  54195. clone(): CubeTexture;
  54196. /** @hidden */
  54197. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54198. }
  54199. }
  54200. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54201. import { Scene } from "babylonjs/scene";
  54202. import { Texture } from "babylonjs/Materials/Textures/texture";
  54203. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54204. /**
  54205. * Class used to store 3D textures containing user data
  54206. */
  54207. export class RawTexture3D extends Texture {
  54208. /** Gets or sets the texture format to use */
  54209. format: number;
  54210. private _engine;
  54211. /**
  54212. * Create a new RawTexture3D
  54213. * @param data defines the data of the texture
  54214. * @param width defines the width of the texture
  54215. * @param height defines the height of the texture
  54216. * @param depth defines the depth of the texture
  54217. * @param format defines the texture format to use
  54218. * @param scene defines the hosting scene
  54219. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54220. * @param invertY defines if texture must be stored with Y axis inverted
  54221. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54222. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54223. */
  54224. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54225. /** Gets or sets the texture format to use */
  54226. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54227. /**
  54228. * Update the texture with new data
  54229. * @param data defines the data to store in the texture
  54230. */
  54231. update(data: ArrayBufferView): void;
  54232. }
  54233. }
  54234. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54235. import { Scene } from "babylonjs/scene";
  54236. import { Plane } from "babylonjs/Maths/math.plane";
  54237. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54238. /**
  54239. * Creates a refraction texture used by refraction channel of the standard material.
  54240. * It is like a mirror but to see through a material.
  54241. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54242. */
  54243. export class RefractionTexture extends RenderTargetTexture {
  54244. /**
  54245. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54246. * 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.
  54247. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54248. */
  54249. refractionPlane: Plane;
  54250. /**
  54251. * Define how deep under the surface we should see.
  54252. */
  54253. depth: number;
  54254. /**
  54255. * Creates a refraction texture used by refraction channel of the standard material.
  54256. * It is like a mirror but to see through a material.
  54257. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54258. * @param name Define the texture name
  54259. * @param size Define the size of the underlying texture
  54260. * @param scene Define the scene the refraction belongs to
  54261. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54262. */
  54263. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54264. /**
  54265. * Clone the refraction texture.
  54266. * @returns the cloned texture
  54267. */
  54268. clone(): RefractionTexture;
  54269. /**
  54270. * Serialize the texture to a JSON representation you could use in Parse later on
  54271. * @returns the serialized JSON representation
  54272. */
  54273. serialize(): any;
  54274. }
  54275. }
  54276. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54277. import { Nullable } from "babylonjs/types";
  54278. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54279. import { Matrix } from "babylonjs/Maths/math.vector";
  54280. import { Engine } from "babylonjs/Engines/engine";
  54281. import { Scene } from "babylonjs/scene";
  54282. /**
  54283. * Defines the options related to the creation of an HtmlElementTexture
  54284. */
  54285. export interface IHtmlElementTextureOptions {
  54286. /**
  54287. * Defines wether mip maps should be created or not.
  54288. */
  54289. generateMipMaps?: boolean;
  54290. /**
  54291. * Defines the sampling mode of the texture.
  54292. */
  54293. samplingMode?: number;
  54294. /**
  54295. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54296. */
  54297. engine: Nullable<Engine>;
  54298. /**
  54299. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54300. */
  54301. scene: Nullable<Scene>;
  54302. }
  54303. /**
  54304. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54305. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54306. * is automatically managed.
  54307. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54308. * in your application.
  54309. *
  54310. * As the update is not automatic, you need to call them manually.
  54311. */
  54312. export class HtmlElementTexture extends BaseTexture {
  54313. /**
  54314. * The texture URL.
  54315. */
  54316. element: HTMLVideoElement | HTMLCanvasElement;
  54317. private static readonly DefaultOptions;
  54318. private _textureMatrix;
  54319. private _engine;
  54320. private _isVideo;
  54321. private _generateMipMaps;
  54322. private _samplingMode;
  54323. /**
  54324. * Instantiates a HtmlElementTexture from the following parameters.
  54325. *
  54326. * @param name Defines the name of the texture
  54327. * @param element Defines the video or canvas the texture is filled with
  54328. * @param options Defines the other none mandatory texture creation options
  54329. */
  54330. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54331. private _createInternalTexture;
  54332. /**
  54333. * Returns the texture matrix used in most of the material.
  54334. */
  54335. getTextureMatrix(): Matrix;
  54336. /**
  54337. * Updates the content of the texture.
  54338. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54339. */
  54340. update(invertY?: Nullable<boolean>): void;
  54341. }
  54342. }
  54343. declare module "babylonjs/Materials/Textures/index" {
  54344. export * from "babylonjs/Materials/Textures/baseTexture";
  54345. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54346. export * from "babylonjs/Materials/Textures/cubeTexture";
  54347. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54348. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54349. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54350. export * from "babylonjs/Materials/Textures/internalTexture";
  54351. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54352. export * from "babylonjs/Materials/Textures/Loaders/index";
  54353. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54354. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54355. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54356. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54357. export * from "babylonjs/Materials/Textures/rawTexture";
  54358. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54359. export * from "babylonjs/Materials/Textures/refractionTexture";
  54360. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54361. export * from "babylonjs/Materials/Textures/texture";
  54362. export * from "babylonjs/Materials/Textures/videoTexture";
  54363. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54364. }
  54365. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54366. /**
  54367. * Enum used to define the target of a block
  54368. */
  54369. export enum NodeMaterialBlockTargets {
  54370. /** Vertex shader */
  54371. Vertex = 1,
  54372. /** Fragment shader */
  54373. Fragment = 2,
  54374. /** Neutral */
  54375. Neutral = 4,
  54376. /** Vertex and Fragment */
  54377. VertexAndFragment = 3
  54378. }
  54379. }
  54380. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54381. /**
  54382. * Defines the kind of connection point for node based material
  54383. */
  54384. export enum NodeMaterialBlockConnectionPointTypes {
  54385. /** Float */
  54386. Float = 1,
  54387. /** Int */
  54388. Int = 2,
  54389. /** Vector2 */
  54390. Vector2 = 4,
  54391. /** Vector3 */
  54392. Vector3 = 8,
  54393. /** Vector4 */
  54394. Vector4 = 16,
  54395. /** Color3 */
  54396. Color3 = 32,
  54397. /** Color4 */
  54398. Color4 = 64,
  54399. /** Matrix */
  54400. Matrix = 128,
  54401. /** Detect type based on connection */
  54402. AutoDetect = 1024,
  54403. /** Output type that will be defined by input type */
  54404. BasedOnInput = 2048
  54405. }
  54406. }
  54407. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54409. /**
  54410. * Root class for all node material optimizers
  54411. */
  54412. export class NodeMaterialOptimizer {
  54413. /**
  54414. * Function used to optimize a NodeMaterial graph
  54415. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54416. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54417. */
  54418. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54419. }
  54420. }
  54421. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54422. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54423. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54424. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54425. import { Scene } from "babylonjs/scene";
  54426. /**
  54427. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54428. */
  54429. export class TransformBlock extends NodeMaterialBlock {
  54430. /**
  54431. * Defines the value to use to complement W value to transform it to a Vector4
  54432. */
  54433. complementW: number;
  54434. /**
  54435. * Defines the value to use to complement z value to transform it to a Vector4
  54436. */
  54437. complementZ: number;
  54438. /**
  54439. * Creates a new TransformBlock
  54440. * @param name defines the block name
  54441. */
  54442. constructor(name: string);
  54443. /**
  54444. * Gets the current class name
  54445. * @returns the class name
  54446. */
  54447. getClassName(): string;
  54448. /**
  54449. * Gets the vector input
  54450. */
  54451. readonly vector: NodeMaterialConnectionPoint;
  54452. /**
  54453. * Gets the output component
  54454. */
  54455. readonly output: NodeMaterialConnectionPoint;
  54456. /**
  54457. * Gets the matrix transform input
  54458. */
  54459. readonly transform: NodeMaterialConnectionPoint;
  54460. protected _buildBlock(state: NodeMaterialBuildState): this;
  54461. serialize(): any;
  54462. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54463. protected _dumpPropertiesCode(): string;
  54464. }
  54465. }
  54466. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54470. /**
  54471. * Block used to output the vertex position
  54472. */
  54473. export class VertexOutputBlock extends NodeMaterialBlock {
  54474. /**
  54475. * Creates a new VertexOutputBlock
  54476. * @param name defines the block name
  54477. */
  54478. constructor(name: string);
  54479. /**
  54480. * Gets the current class name
  54481. * @returns the class name
  54482. */
  54483. getClassName(): string;
  54484. /**
  54485. * Gets the vector input component
  54486. */
  54487. readonly vector: NodeMaterialConnectionPoint;
  54488. protected _buildBlock(state: NodeMaterialBuildState): this;
  54489. }
  54490. }
  54491. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54495. /**
  54496. * Block used to output the final color
  54497. */
  54498. export class FragmentOutputBlock extends NodeMaterialBlock {
  54499. /**
  54500. * Create a new FragmentOutputBlock
  54501. * @param name defines the block name
  54502. */
  54503. constructor(name: string);
  54504. /**
  54505. * Gets the current class name
  54506. * @returns the class name
  54507. */
  54508. getClassName(): string;
  54509. /**
  54510. * Gets the rgba input component
  54511. */
  54512. readonly rgba: NodeMaterialConnectionPoint;
  54513. /**
  54514. * Gets the rgb input component
  54515. */
  54516. readonly rgb: NodeMaterialConnectionPoint;
  54517. /**
  54518. * Gets the a input component
  54519. */
  54520. readonly a: NodeMaterialConnectionPoint;
  54521. protected _buildBlock(state: NodeMaterialBuildState): this;
  54522. }
  54523. }
  54524. declare module "babylonjs/Materials/Node/nodeMaterialSystemValues" {
  54525. /**
  54526. * Enum used to define system values e.g. values automatically provided by the system
  54527. */
  54528. export enum NodeMaterialSystemValues {
  54529. /** World */
  54530. World = 1,
  54531. /** View */
  54532. View = 2,
  54533. /** Projection */
  54534. Projection = 3,
  54535. /** ViewProjection */
  54536. ViewProjection = 4,
  54537. /** WorldView */
  54538. WorldView = 5,
  54539. /** WorldViewProjection */
  54540. WorldViewProjection = 6,
  54541. /** CameraPosition */
  54542. CameraPosition = 7,
  54543. /** Fog Color */
  54544. FogColor = 8
  54545. }
  54546. }
  54547. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54551. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54553. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54554. import { Effect } from "babylonjs/Materials/effect";
  54555. import { Mesh } from "babylonjs/Meshes/mesh";
  54556. import { Nullable } from "babylonjs/types";
  54557. import { Scene } from "babylonjs/scene";
  54558. /**
  54559. * Block used to read a reflection texture from a sampler
  54560. */
  54561. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54562. private _define3DName;
  54563. private _defineCubicName;
  54564. private _defineExplicitName;
  54565. private _defineProjectionName;
  54566. private _defineLocalCubicName;
  54567. private _defineSphericalName;
  54568. private _definePlanarName;
  54569. private _defineEquirectangularName;
  54570. private _defineMirroredEquirectangularFixedName;
  54571. private _defineEquirectangularFixedName;
  54572. private _defineSkyboxName;
  54573. private _cubeSamplerName;
  54574. private _2DSamplerName;
  54575. private _positionUVWName;
  54576. private _directionWName;
  54577. private _reflectionCoordsName;
  54578. private _reflection2DCoordsName;
  54579. private _reflectionColorName;
  54580. private _reflectionMatrixName;
  54581. /**
  54582. * Gets or sets the texture associated with the node
  54583. */
  54584. texture: Nullable<BaseTexture>;
  54585. /**
  54586. * Create a new TextureBlock
  54587. * @param name defines the block name
  54588. */
  54589. constructor(name: string);
  54590. /**
  54591. * Gets the current class name
  54592. * @returns the class name
  54593. */
  54594. getClassName(): string;
  54595. /**
  54596. * Gets the world position input component
  54597. */
  54598. readonly position: NodeMaterialConnectionPoint;
  54599. /**
  54600. * Gets the world position input component
  54601. */
  54602. readonly worldPosition: NodeMaterialConnectionPoint;
  54603. /**
  54604. * Gets the world normal input component
  54605. */
  54606. readonly worldNormal: NodeMaterialConnectionPoint;
  54607. /**
  54608. * Gets the world input component
  54609. */
  54610. readonly world: NodeMaterialConnectionPoint;
  54611. /**
  54612. * Gets the camera (or eye) position component
  54613. */
  54614. readonly cameraPosition: NodeMaterialConnectionPoint;
  54615. /**
  54616. * Gets the view input component
  54617. */
  54618. readonly view: NodeMaterialConnectionPoint;
  54619. /**
  54620. * Gets the rgb output component
  54621. */
  54622. readonly rgb: NodeMaterialConnectionPoint;
  54623. /**
  54624. * Gets the r output component
  54625. */
  54626. readonly r: NodeMaterialConnectionPoint;
  54627. /**
  54628. * Gets the g output component
  54629. */
  54630. readonly g: NodeMaterialConnectionPoint;
  54631. /**
  54632. * Gets the b output component
  54633. */
  54634. readonly b: NodeMaterialConnectionPoint;
  54635. autoConfigure(material: NodeMaterial): void;
  54636. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54637. isReady(): boolean;
  54638. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54639. private _injectVertexCode;
  54640. private _writeOutput;
  54641. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54642. serialize(): any;
  54643. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54644. }
  54645. }
  54646. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54648. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54649. import { Scene } from "babylonjs/scene";
  54650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54651. import { Matrix } from "babylonjs/Maths/math.vector";
  54652. import { Mesh } from "babylonjs/Meshes/mesh";
  54653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54654. import { Observable } from "babylonjs/Misc/observable";
  54655. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54656. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54657. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54658. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54659. import { Nullable } from "babylonjs/types";
  54660. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54661. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54662. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54663. /**
  54664. * Interface used to configure the node material editor
  54665. */
  54666. export interface INodeMaterialEditorOptions {
  54667. /** Define the URl to load node editor script */
  54668. editorURL?: string;
  54669. }
  54670. /** @hidden */
  54671. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54672. /** BONES */
  54673. NUM_BONE_INFLUENCERS: number;
  54674. BonesPerMesh: number;
  54675. BONETEXTURE: boolean;
  54676. /** MORPH TARGETS */
  54677. MORPHTARGETS: boolean;
  54678. MORPHTARGETS_NORMAL: boolean;
  54679. MORPHTARGETS_TANGENT: boolean;
  54680. MORPHTARGETS_UV: boolean;
  54681. NUM_MORPH_INFLUENCERS: number;
  54682. /** IMAGE PROCESSING */
  54683. IMAGEPROCESSING: boolean;
  54684. VIGNETTE: boolean;
  54685. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54686. VIGNETTEBLENDMODEOPAQUE: boolean;
  54687. TONEMAPPING: boolean;
  54688. TONEMAPPING_ACES: boolean;
  54689. CONTRAST: boolean;
  54690. EXPOSURE: boolean;
  54691. COLORCURVES: boolean;
  54692. COLORGRADING: boolean;
  54693. COLORGRADING3D: boolean;
  54694. SAMPLER3DGREENDEPTH: boolean;
  54695. SAMPLER3DBGRMAP: boolean;
  54696. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54697. /** MISC. */
  54698. BUMPDIRECTUV: number;
  54699. constructor();
  54700. setValue(name: string, value: boolean): void;
  54701. }
  54702. /**
  54703. * Class used to configure NodeMaterial
  54704. */
  54705. export interface INodeMaterialOptions {
  54706. /**
  54707. * Defines if blocks should emit comments
  54708. */
  54709. emitComments: boolean;
  54710. }
  54711. /**
  54712. * Class used to create a node based material built by assembling shader blocks
  54713. */
  54714. export class NodeMaterial extends PushMaterial {
  54715. private static _BuildIdGenerator;
  54716. private _options;
  54717. private _vertexCompilationState;
  54718. private _fragmentCompilationState;
  54719. private _sharedData;
  54720. private _buildId;
  54721. private _buildWasSuccessful;
  54722. private _cachedWorldViewMatrix;
  54723. private _cachedWorldViewProjectionMatrix;
  54724. private _optimizers;
  54725. private _animationFrame;
  54726. /** Define the URl to load node editor script */
  54727. static EditorURL: string;
  54728. private BJSNODEMATERIALEDITOR;
  54729. /** Get the inspector from bundle or global */
  54730. private _getGlobalNodeMaterialEditor;
  54731. /**
  54732. * 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)
  54733. */
  54734. ignoreAlpha: boolean;
  54735. /**
  54736. * Defines the maximum number of lights that can be used in the material
  54737. */
  54738. maxSimultaneousLights: number;
  54739. /**
  54740. * Observable raised when the material is built
  54741. */
  54742. onBuildObservable: Observable<NodeMaterial>;
  54743. /**
  54744. * Gets or sets the root nodes of the material vertex shader
  54745. */
  54746. _vertexOutputNodes: NodeMaterialBlock[];
  54747. /**
  54748. * Gets or sets the root nodes of the material fragment (pixel) shader
  54749. */
  54750. _fragmentOutputNodes: NodeMaterialBlock[];
  54751. /** Gets or sets options to control the node material overall behavior */
  54752. options: INodeMaterialOptions;
  54753. /**
  54754. * Default configuration related to image processing available in the standard Material.
  54755. */
  54756. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54757. /**
  54758. * Gets the image processing configuration used either in this material.
  54759. */
  54760. /**
  54761. * Sets the Default image processing configuration used either in the this material.
  54762. *
  54763. * If sets to null, the scene one is in use.
  54764. */
  54765. imageProcessingConfiguration: ImageProcessingConfiguration;
  54766. /**
  54767. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54768. */
  54769. attachedBlocks: NodeMaterialBlock[];
  54770. /**
  54771. * Create a new node based material
  54772. * @param name defines the material name
  54773. * @param scene defines the hosting scene
  54774. * @param options defines creation option
  54775. */
  54776. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54777. /**
  54778. * Gets the current class name of the material e.g. "NodeMaterial"
  54779. * @returns the class name
  54780. */
  54781. getClassName(): string;
  54782. /**
  54783. * Keep track of the image processing observer to allow dispose and replace.
  54784. */
  54785. private _imageProcessingObserver;
  54786. /**
  54787. * Attaches a new image processing configuration to the Standard Material.
  54788. * @param configuration
  54789. */
  54790. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54791. /**
  54792. * Get a block by its name
  54793. * @param name defines the name of the block to retrieve
  54794. * @returns the required block or null if not found
  54795. */
  54796. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54797. /**
  54798. * Get a block by its name
  54799. * @param predicate defines the predicate used to find the good candidate
  54800. * @returns the required block or null if not found
  54801. */
  54802. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54803. /**
  54804. * Get an input block by its name
  54805. * @param predicate defines the predicate used to find the good candidate
  54806. * @returns the required input block or null if not found
  54807. */
  54808. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54809. /**
  54810. * Gets the list of input blocks attached to this material
  54811. * @returns an array of InputBlocks
  54812. */
  54813. getInputBlocks(): InputBlock[];
  54814. /**
  54815. * Adds a new optimizer to the list of optimizers
  54816. * @param optimizer defines the optimizers to add
  54817. * @returns the current material
  54818. */
  54819. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54820. /**
  54821. * Remove an optimizer from the list of optimizers
  54822. * @param optimizer defines the optimizers to remove
  54823. * @returns the current material
  54824. */
  54825. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54826. /**
  54827. * Add a new block to the list of output nodes
  54828. * @param node defines the node to add
  54829. * @returns the current material
  54830. */
  54831. addOutputNode(node: NodeMaterialBlock): this;
  54832. /**
  54833. * Remove a block from the list of root nodes
  54834. * @param node defines the node to remove
  54835. * @returns the current material
  54836. */
  54837. removeOutputNode(node: NodeMaterialBlock): this;
  54838. private _addVertexOutputNode;
  54839. private _removeVertexOutputNode;
  54840. private _addFragmentOutputNode;
  54841. private _removeFragmentOutputNode;
  54842. /**
  54843. * Specifies if the material will require alpha blending
  54844. * @returns a boolean specifying if alpha blending is needed
  54845. */
  54846. needAlphaBlending(): boolean;
  54847. /**
  54848. * Specifies if this material should be rendered in alpha test mode
  54849. * @returns a boolean specifying if an alpha test is needed.
  54850. */
  54851. needAlphaTesting(): boolean;
  54852. private _initializeBlock;
  54853. private _resetDualBlocks;
  54854. /**
  54855. * Build the material and generates the inner effect
  54856. * @param verbose defines if the build should log activity
  54857. */
  54858. build(verbose?: boolean): void;
  54859. /**
  54860. * Runs an otpimization phase to try to improve the shader code
  54861. */
  54862. optimize(): void;
  54863. private _prepareDefinesForAttributes;
  54864. /**
  54865. * Get if the submesh is ready to be used and all its information available.
  54866. * Child classes can use it to update shaders
  54867. * @param mesh defines the mesh to check
  54868. * @param subMesh defines which submesh to check
  54869. * @param useInstances specifies that instances should be used
  54870. * @returns a boolean indicating that the submesh is ready or not
  54871. */
  54872. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54873. /**
  54874. * Get a string representing the shaders built by the current node graph
  54875. */
  54876. readonly compiledShaders: string;
  54877. /**
  54878. * Binds the world matrix to the material
  54879. * @param world defines the world transformation matrix
  54880. */
  54881. bindOnlyWorldMatrix(world: Matrix): void;
  54882. /**
  54883. * Binds the submesh to this material by preparing the effect and shader to draw
  54884. * @param world defines the world transformation matrix
  54885. * @param mesh defines the mesh containing the submesh
  54886. * @param subMesh defines the submesh to bind the material to
  54887. */
  54888. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54889. /**
  54890. * Gets the active textures from the material
  54891. * @returns an array of textures
  54892. */
  54893. getActiveTextures(): BaseTexture[];
  54894. /**
  54895. * Gets the list of texture blocks
  54896. * @returns an array of texture blocks
  54897. */
  54898. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54899. /**
  54900. * Specifies if the material uses a texture
  54901. * @param texture defines the texture to check against the material
  54902. * @returns a boolean specifying if the material uses the texture
  54903. */
  54904. hasTexture(texture: BaseTexture): boolean;
  54905. /**
  54906. * Disposes the material
  54907. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54908. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54909. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54910. */
  54911. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54912. /** Creates the node editor window. */
  54913. private _createNodeEditor;
  54914. /**
  54915. * Launch the node material editor
  54916. * @param config Define the configuration of the editor
  54917. * @return a promise fulfilled when the node editor is visible
  54918. */
  54919. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54920. /**
  54921. * Clear the current material
  54922. */
  54923. clear(): void;
  54924. /**
  54925. * Clear the current material and set it to a default state
  54926. */
  54927. setToDefault(): void;
  54928. /**
  54929. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54930. * @param url defines the url to load from
  54931. * @returns a promise that will fullfil when the material is fully loaded
  54932. */
  54933. loadAsync(url: string): Promise<unknown>;
  54934. private _gatherBlocks;
  54935. /**
  54936. * Generate a string containing the code declaration required to create an equivalent of this material
  54937. * @returns a string
  54938. */
  54939. generateCode(): string;
  54940. /**
  54941. * Serializes this material in a JSON representation
  54942. * @returns the serialized material object
  54943. */
  54944. serialize(): any;
  54945. private _restoreConnections;
  54946. /**
  54947. * Clear the current graph and load a new one from a serialization object
  54948. * @param source defines the JSON representation of the material
  54949. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54950. */
  54951. loadFromSerialization(source: any, rootUrl?: string): void;
  54952. /**
  54953. * Creates a node material from parsed material data
  54954. * @param source defines the JSON representation of the material
  54955. * @param scene defines the hosting scene
  54956. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54957. * @returns a new node material
  54958. */
  54959. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54960. /**
  54961. * Creates a new node material set to default basic configuration
  54962. * @param name defines the name of the material
  54963. * @param scene defines the hosting scene
  54964. * @returns a new NodeMaterial
  54965. */
  54966. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54967. }
  54968. }
  54969. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54972. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54974. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54976. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54977. import { Effect } from "babylonjs/Materials/effect";
  54978. import { Mesh } from "babylonjs/Meshes/mesh";
  54979. import { Nullable } from "babylonjs/types";
  54980. import { Scene } from "babylonjs/scene";
  54981. /**
  54982. * Block used to read a texture from a sampler
  54983. */
  54984. export class TextureBlock extends NodeMaterialBlock {
  54985. private _defineName;
  54986. private _samplerName;
  54987. private _transformedUVName;
  54988. private _textureTransformName;
  54989. private _textureInfoName;
  54990. private _mainUVName;
  54991. private _mainUVDefineName;
  54992. /**
  54993. * Gets or sets the texture associated with the node
  54994. */
  54995. texture: Nullable<BaseTexture>;
  54996. /**
  54997. * Create a new TextureBlock
  54998. * @param name defines the block name
  54999. */
  55000. constructor(name: string);
  55001. /**
  55002. * Gets the current class name
  55003. * @returns the class name
  55004. */
  55005. getClassName(): string;
  55006. /**
  55007. * Gets the uv input component
  55008. */
  55009. readonly uv: NodeMaterialConnectionPoint;
  55010. /**
  55011. * Gets the rgba output component
  55012. */
  55013. readonly rgba: NodeMaterialConnectionPoint;
  55014. /**
  55015. * Gets the rgb output component
  55016. */
  55017. readonly rgb: NodeMaterialConnectionPoint;
  55018. /**
  55019. * Gets the r output component
  55020. */
  55021. readonly r: NodeMaterialConnectionPoint;
  55022. /**
  55023. * Gets the g output component
  55024. */
  55025. readonly g: NodeMaterialConnectionPoint;
  55026. /**
  55027. * Gets the b output component
  55028. */
  55029. readonly b: NodeMaterialConnectionPoint;
  55030. /**
  55031. * Gets the a output component
  55032. */
  55033. readonly a: NodeMaterialConnectionPoint;
  55034. readonly target: NodeMaterialBlockTargets;
  55035. autoConfigure(material: NodeMaterial): void;
  55036. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55038. isReady(): boolean;
  55039. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55040. private readonly _isMixed;
  55041. private _injectVertexCode;
  55042. private _writeOutput;
  55043. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55044. protected _dumpPropertiesCode(): string;
  55045. serialize(): any;
  55046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55047. }
  55048. }
  55049. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55052. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55053. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55054. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55055. /**
  55056. * Class used to store shared data between 2 NodeMaterialBuildState
  55057. */
  55058. export class NodeMaterialBuildStateSharedData {
  55059. /**
  55060. * Gets the list of emitted varyings
  55061. */
  55062. temps: string[];
  55063. /**
  55064. * Gets the list of emitted varyings
  55065. */
  55066. varyings: string[];
  55067. /**
  55068. * Gets the varying declaration string
  55069. */
  55070. varyingDeclaration: string;
  55071. /**
  55072. * Input blocks
  55073. */
  55074. inputBlocks: InputBlock[];
  55075. /**
  55076. * Input blocks
  55077. */
  55078. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55079. /**
  55080. * Bindable blocks (Blocks that need to set data to the effect)
  55081. */
  55082. bindableBlocks: NodeMaterialBlock[];
  55083. /**
  55084. * List of blocks that can provide a compilation fallback
  55085. */
  55086. blocksWithFallbacks: NodeMaterialBlock[];
  55087. /**
  55088. * List of blocks that can provide a define update
  55089. */
  55090. blocksWithDefines: NodeMaterialBlock[];
  55091. /**
  55092. * List of blocks that can provide a repeatable content
  55093. */
  55094. repeatableContentBlocks: NodeMaterialBlock[];
  55095. /**
  55096. * List of blocks that can provide a dynamic list of uniforms
  55097. */
  55098. dynamicUniformBlocks: NodeMaterialBlock[];
  55099. /**
  55100. * List of blocks that can block the isReady function for the material
  55101. */
  55102. blockingBlocks: NodeMaterialBlock[];
  55103. /**
  55104. * Gets the list of animated inputs
  55105. */
  55106. animatedInputs: InputBlock[];
  55107. /**
  55108. * Build Id used to avoid multiple recompilations
  55109. */
  55110. buildId: number;
  55111. /** List of emitted variables */
  55112. variableNames: {
  55113. [key: string]: number;
  55114. };
  55115. /** List of emitted defines */
  55116. defineNames: {
  55117. [key: string]: number;
  55118. };
  55119. /** Should emit comments? */
  55120. emitComments: boolean;
  55121. /** Emit build activity */
  55122. verbose: boolean;
  55123. /**
  55124. * Gets the compilation hints emitted at compilation time
  55125. */
  55126. hints: {
  55127. needWorldViewMatrix: boolean;
  55128. needWorldViewProjectionMatrix: boolean;
  55129. needAlphaBlending: boolean;
  55130. needAlphaTesting: boolean;
  55131. };
  55132. /**
  55133. * List of compilation checks
  55134. */
  55135. checks: {
  55136. emitVertex: boolean;
  55137. emitFragment: boolean;
  55138. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55139. };
  55140. /** Creates a new shared data */
  55141. constructor();
  55142. /**
  55143. * Emits console errors and exceptions if there is a failing check
  55144. */
  55145. emitErrors(): void;
  55146. }
  55147. }
  55148. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55149. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55150. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55151. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55152. /**
  55153. * Class used to store node based material build state
  55154. */
  55155. export class NodeMaterialBuildState {
  55156. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55157. supportUniformBuffers: boolean;
  55158. /**
  55159. * Gets the list of emitted attributes
  55160. */
  55161. attributes: string[];
  55162. /**
  55163. * Gets the list of emitted uniforms
  55164. */
  55165. uniforms: string[];
  55166. /**
  55167. * Gets the list of emitted uniform buffers
  55168. */
  55169. uniformBuffers: string[];
  55170. /**
  55171. * Gets the list of emitted samplers
  55172. */
  55173. samplers: string[];
  55174. /**
  55175. * Gets the list of emitted functions
  55176. */
  55177. functions: {
  55178. [key: string]: string;
  55179. };
  55180. /**
  55181. * Gets the list of emitted extensions
  55182. */
  55183. extensions: {
  55184. [key: string]: string;
  55185. };
  55186. /**
  55187. * Gets the target of the compilation state
  55188. */
  55189. target: NodeMaterialBlockTargets;
  55190. /**
  55191. * Gets the list of emitted counters
  55192. */
  55193. counters: {
  55194. [key: string]: number;
  55195. };
  55196. /**
  55197. * Shared data between multiple NodeMaterialBuildState instances
  55198. */
  55199. sharedData: NodeMaterialBuildStateSharedData;
  55200. /** @hidden */
  55201. _vertexState: NodeMaterialBuildState;
  55202. /** @hidden */
  55203. _attributeDeclaration: string;
  55204. /** @hidden */
  55205. _uniformDeclaration: string;
  55206. /** @hidden */
  55207. _samplerDeclaration: string;
  55208. /** @hidden */
  55209. _varyingTransfer: string;
  55210. private _repeatableContentAnchorIndex;
  55211. /** @hidden */
  55212. _builtCompilationString: string;
  55213. /**
  55214. * Gets the emitted compilation strings
  55215. */
  55216. compilationString: string;
  55217. /**
  55218. * Finalize the compilation strings
  55219. * @param state defines the current compilation state
  55220. */
  55221. finalize(state: NodeMaterialBuildState): void;
  55222. /** @hidden */
  55223. readonly _repeatableContentAnchor: string;
  55224. /** @hidden */
  55225. _getFreeVariableName(prefix: string): string;
  55226. /** @hidden */
  55227. _getFreeDefineName(prefix: string): string;
  55228. /** @hidden */
  55229. _excludeVariableName(name: string): void;
  55230. /** @hidden */
  55231. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55232. /** @hidden */
  55233. _emitExtension(name: string, extension: string): void;
  55234. /** @hidden */
  55235. _emitFunction(name: string, code: string, comments: string): void;
  55236. /** @hidden */
  55237. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55238. replaceStrings?: {
  55239. search: RegExp;
  55240. replace: string;
  55241. }[];
  55242. repeatKey?: string;
  55243. }): string;
  55244. /** @hidden */
  55245. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55246. repeatKey?: string;
  55247. removeAttributes?: boolean;
  55248. removeUniforms?: boolean;
  55249. removeVaryings?: boolean;
  55250. removeIfDef?: boolean;
  55251. replaceStrings?: {
  55252. search: RegExp;
  55253. replace: string;
  55254. }[];
  55255. }, storeKey?: string): void;
  55256. /** @hidden */
  55257. _registerTempVariable(name: string): boolean;
  55258. /** @hidden */
  55259. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55260. /** @hidden */
  55261. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55262. }
  55263. }
  55264. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55265. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55267. import { Nullable } from "babylonjs/types";
  55268. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55269. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55270. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55272. import { Mesh } from "babylonjs/Meshes/mesh";
  55273. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55274. import { Scene } from "babylonjs/scene";
  55275. /**
  55276. * Defines a block that can be used inside a node based material
  55277. */
  55278. export class NodeMaterialBlock {
  55279. private _buildId;
  55280. private _buildTarget;
  55281. private _target;
  55282. private _isFinalMerger;
  55283. private _isInput;
  55284. /** @hidden */
  55285. _codeVariableName: string;
  55286. /** @hidden */
  55287. _inputs: NodeMaterialConnectionPoint[];
  55288. /** @hidden */
  55289. _outputs: NodeMaterialConnectionPoint[];
  55290. /** @hidden */
  55291. _preparationId: number;
  55292. /**
  55293. * Gets or sets the name of the block
  55294. */
  55295. name: string;
  55296. /**
  55297. * Gets or sets the unique id of the node
  55298. */
  55299. uniqueId: number;
  55300. /**
  55301. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55302. */
  55303. readonly isFinalMerger: boolean;
  55304. /**
  55305. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55306. */
  55307. readonly isInput: boolean;
  55308. /**
  55309. * Gets or sets the build Id
  55310. */
  55311. buildId: number;
  55312. /**
  55313. * Gets or sets the target of the block
  55314. */
  55315. target: NodeMaterialBlockTargets;
  55316. /**
  55317. * Gets the list of input points
  55318. */
  55319. readonly inputs: NodeMaterialConnectionPoint[];
  55320. /** Gets the list of output points */
  55321. readonly outputs: NodeMaterialConnectionPoint[];
  55322. /**
  55323. * Find an input by its name
  55324. * @param name defines the name of the input to look for
  55325. * @returns the input or null if not found
  55326. */
  55327. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55328. /**
  55329. * Find an output by its name
  55330. * @param name defines the name of the outputto look for
  55331. * @returns the output or null if not found
  55332. */
  55333. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55334. /**
  55335. * Creates a new NodeMaterialBlock
  55336. * @param name defines the block name
  55337. * @param target defines the target of that block (Vertex by default)
  55338. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55339. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55340. */
  55341. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55342. /**
  55343. * Initialize the block and prepare the context for build
  55344. * @param state defines the state that will be used for the build
  55345. */
  55346. initialize(state: NodeMaterialBuildState): void;
  55347. /**
  55348. * Bind data to effect. Will only be called for blocks with isBindable === true
  55349. * @param effect defines the effect to bind data to
  55350. * @param nodeMaterial defines the hosting NodeMaterial
  55351. * @param mesh defines the mesh that will be rendered
  55352. */
  55353. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55354. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55355. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55356. protected _writeFloat(value: number): string;
  55357. /**
  55358. * Gets the current class name e.g. "NodeMaterialBlock"
  55359. * @returns the class name
  55360. */
  55361. getClassName(): string;
  55362. /**
  55363. * Register a new input. Must be called inside a block constructor
  55364. * @param name defines the connection point name
  55365. * @param type defines the connection point type
  55366. * @param isOptional defines a boolean indicating that this input can be omitted
  55367. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55368. * @returns the current block
  55369. */
  55370. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55371. /**
  55372. * Register a new output. Must be called inside a block constructor
  55373. * @param name defines the connection point name
  55374. * @param type defines the connection point type
  55375. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55376. * @returns the current block
  55377. */
  55378. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55379. /**
  55380. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55381. * @param forOutput defines an optional connection point to check compatibility with
  55382. * @returns the first available input or null
  55383. */
  55384. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55385. /**
  55386. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55387. * @param forBlock defines an optional block to check compatibility with
  55388. * @returns the first available input or null
  55389. */
  55390. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55391. /**
  55392. * Gets the sibling of the given output
  55393. * @param current defines the current output
  55394. * @returns the next output in the list or null
  55395. */
  55396. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55397. /**
  55398. * Connect current block with another block
  55399. * @param other defines the block to connect with
  55400. * @param options define the various options to help pick the right connections
  55401. * @returns the current block
  55402. */
  55403. connectTo(other: NodeMaterialBlock, options?: {
  55404. input?: string;
  55405. output?: string;
  55406. outputSwizzle?: string;
  55407. }): this | undefined;
  55408. protected _buildBlock(state: NodeMaterialBuildState): void;
  55409. /**
  55410. * Add uniforms, samplers and uniform buffers at compilation time
  55411. * @param state defines the state to update
  55412. * @param nodeMaterial defines the node material requesting the update
  55413. * @param defines defines the material defines to update
  55414. */
  55415. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55416. /**
  55417. * Add potential fallbacks if shader compilation fails
  55418. * @param mesh defines the mesh to be rendered
  55419. * @param fallbacks defines the current prioritized list of fallbacks
  55420. */
  55421. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55422. /**
  55423. * Update defines for shader compilation
  55424. * @param mesh defines the mesh to be rendered
  55425. * @param nodeMaterial defines the node material requesting the update
  55426. * @param defines defines the material defines to update
  55427. * @param useInstances specifies that instances should be used
  55428. */
  55429. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55430. /**
  55431. * Initialize defines for shader compilation
  55432. * @param mesh defines the mesh to be rendered
  55433. * @param nodeMaterial defines the node material requesting the update
  55434. * @param defines defines the material defines to be prepared
  55435. * @param useInstances specifies that instances should be used
  55436. */
  55437. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55438. /**
  55439. * Lets the block try to connect some inputs automatically
  55440. * @param material defines the hosting NodeMaterial
  55441. */
  55442. autoConfigure(material: NodeMaterial): void;
  55443. /**
  55444. * Function called when a block is declared as repeatable content generator
  55445. * @param vertexShaderState defines the current compilation state for the vertex shader
  55446. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55447. * @param mesh defines the mesh to be rendered
  55448. * @param defines defines the material defines to update
  55449. */
  55450. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55451. /**
  55452. * Checks if the block is ready
  55453. * @param mesh defines the mesh to be rendered
  55454. * @param nodeMaterial defines the node material requesting the update
  55455. * @param defines defines the material defines to update
  55456. * @param useInstances specifies that instances should be used
  55457. * @returns true if the block is ready
  55458. */
  55459. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55460. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55461. private _processBuild;
  55462. /**
  55463. * Compile the current node and generate the shader code
  55464. * @param state defines the current compilation state (uniforms, samplers, current string)
  55465. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55466. * @returns true if already built
  55467. */
  55468. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55469. protected _inputRename(name: string): string;
  55470. protected _outputRename(name: string): string;
  55471. protected _dumpPropertiesCode(): string;
  55472. /** @hidden */
  55473. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55474. /**
  55475. * Clone the current block to a new identical block
  55476. * @param scene defines the hosting scene
  55477. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55478. * @returns a copy of the current block
  55479. */
  55480. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55481. /**
  55482. * Serializes this block in a JSON representation
  55483. * @returns the serialized block object
  55484. */
  55485. serialize(): any;
  55486. /** @hidden */
  55487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55488. }
  55489. }
  55490. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55491. /**
  55492. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55493. */
  55494. export enum NodeMaterialBlockConnectionPointMode {
  55495. /** Value is an uniform */
  55496. Uniform = 0,
  55497. /** Value is a mesh attribute */
  55498. Attribute = 1,
  55499. /** Value is a varying between vertex and fragment shaders */
  55500. Varying = 2,
  55501. /** Mode is undefined */
  55502. Undefined = 3
  55503. }
  55504. }
  55505. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55506. /**
  55507. * Enum defining the type of animations supported by InputBlock
  55508. */
  55509. export enum AnimatedInputBlockTypes {
  55510. /** No animation */
  55511. None = 0,
  55512. /** Time based animation. Will only work for floats */
  55513. Time = 1
  55514. }
  55515. }
  55516. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55518. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55519. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  55520. import { Nullable } from "babylonjs/types";
  55521. import { Effect } from "babylonjs/Materials/effect";
  55522. import { Matrix } from "babylonjs/Maths/math.vector";
  55523. import { Scene } from "babylonjs/scene";
  55524. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55526. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55527. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55528. /**
  55529. * Block used to expose an input value
  55530. */
  55531. export class InputBlock extends NodeMaterialBlock {
  55532. private _mode;
  55533. private _associatedVariableName;
  55534. private _storedValue;
  55535. private _valueCallback;
  55536. private _type;
  55537. private _animationType;
  55538. /** @hidden */
  55539. _systemValue: Nullable<NodeMaterialSystemValues>;
  55540. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55541. visibleInInspector: boolean;
  55542. /**
  55543. * Gets or sets the connection point type (default is float)
  55544. */
  55545. readonly type: NodeMaterialBlockConnectionPointTypes;
  55546. /**
  55547. * Creates a new InputBlock
  55548. * @param name defines the block name
  55549. * @param target defines the target of that block (Vertex by default)
  55550. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55551. */
  55552. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55553. /**
  55554. * Gets the output component
  55555. */
  55556. readonly output: NodeMaterialConnectionPoint;
  55557. /**
  55558. * Set the source of this connection point to a vertex attribute
  55559. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55560. * @returns the current connection point
  55561. */
  55562. setAsAttribute(attributeName?: string): InputBlock;
  55563. /**
  55564. * Set the source of this connection point to a system value
  55565. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55566. * @returns the current connection point
  55567. */
  55568. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55569. /**
  55570. * Gets or sets the value of that point.
  55571. * Please note that this value will be ignored if valueCallback is defined
  55572. */
  55573. value: any;
  55574. /**
  55575. * Gets or sets a callback used to get the value of that point.
  55576. * Please note that setting this value will force the connection point to ignore the value property
  55577. */
  55578. valueCallback: () => any;
  55579. /**
  55580. * Gets or sets the associated variable name in the shader
  55581. */
  55582. associatedVariableName: string;
  55583. /** Gets or sets the type of animation applied to the input */
  55584. animationType: AnimatedInputBlockTypes;
  55585. /**
  55586. * Gets a boolean indicating that this connection point not defined yet
  55587. */
  55588. readonly isUndefined: boolean;
  55589. /**
  55590. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55591. * In this case the connection point name must be the name of the uniform to use.
  55592. * Can only be set on inputs
  55593. */
  55594. isUniform: boolean;
  55595. /**
  55596. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55597. * In this case the connection point name must be the name of the attribute to use
  55598. * Can only be set on inputs
  55599. */
  55600. isAttribute: boolean;
  55601. /**
  55602. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55603. * Can only be set on exit points
  55604. */
  55605. isVarying: boolean;
  55606. /**
  55607. * Gets a boolean indicating that the current connection point is a system value
  55608. */
  55609. readonly isSystemValue: boolean;
  55610. /**
  55611. * Gets or sets the current well known value or null if not defined as a system value
  55612. */
  55613. systemValue: Nullable<NodeMaterialSystemValues>;
  55614. /**
  55615. * Gets the current class name
  55616. * @returns the class name
  55617. */
  55618. getClassName(): string;
  55619. /**
  55620. * Animate the input if animationType !== None
  55621. * @param scene defines the rendering scene
  55622. */
  55623. animate(scene: Scene): void;
  55624. private _emitDefine;
  55625. initialize(state: NodeMaterialBuildState): void;
  55626. /**
  55627. * Set the input block to its default value (based on its type)
  55628. */
  55629. setDefaultValue(): void;
  55630. protected _dumpPropertiesCode(): string;
  55631. private _emit;
  55632. /** @hidden */
  55633. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55634. /** @hidden */
  55635. _transmit(effect: Effect, scene: Scene): void;
  55636. protected _buildBlock(state: NodeMaterialBuildState): void;
  55637. serialize(): any;
  55638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55639. }
  55640. }
  55641. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55642. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55643. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55644. import { Nullable } from "babylonjs/types";
  55645. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55647. /**
  55648. * Defines a connection point for a block
  55649. */
  55650. export class NodeMaterialConnectionPoint {
  55651. /** @hidden */
  55652. _ownerBlock: NodeMaterialBlock;
  55653. /** @hidden */
  55654. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55655. private _endpoints;
  55656. private _associatedVariableName;
  55657. /** @hidden */
  55658. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55659. /** @hidden */
  55660. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55661. private _type;
  55662. /** @hidden */
  55663. _enforceAssociatedVariableName: boolean;
  55664. /**
  55665. * Gets or sets the additional types supported byt this connection point
  55666. */
  55667. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55668. /**
  55669. * Gets or sets the associated variable name in the shader
  55670. */
  55671. associatedVariableName: string;
  55672. /**
  55673. * Gets or sets the connection point type (default is float)
  55674. */
  55675. type: NodeMaterialBlockConnectionPointTypes;
  55676. /**
  55677. * Gets or sets the connection point name
  55678. */
  55679. name: string;
  55680. /**
  55681. * Gets or sets a boolean indicating that this connection point can be omitted
  55682. */
  55683. isOptional: boolean;
  55684. /**
  55685. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55686. */
  55687. define: string;
  55688. /** Gets or sets the target of that connection point */
  55689. target: NodeMaterialBlockTargets;
  55690. /**
  55691. * Gets a boolean indicating that the current point is connected
  55692. */
  55693. readonly isConnected: boolean;
  55694. /**
  55695. * Gets a boolean indicating that the current point is connected to an input block
  55696. */
  55697. readonly isConnectedToInputBlock: boolean;
  55698. /**
  55699. * Gets a the connected input block (if any)
  55700. */
  55701. readonly connectInputBlock: Nullable<InputBlock>;
  55702. /** Get the other side of the connection (if any) */
  55703. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55704. /** Get the block that owns this connection point */
  55705. readonly ownerBlock: NodeMaterialBlock;
  55706. /** Get the block connected on the other side of this connection (if any) */
  55707. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55708. /** Get the block connected on the endpoints of this connection (if any) */
  55709. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55710. /** Gets the list of connected endpoints */
  55711. readonly endpoints: NodeMaterialConnectionPoint[];
  55712. /** Gets a boolean indicating if that output point is connected to at least one input */
  55713. readonly hasEndpoints: boolean;
  55714. /**
  55715. * Creates a new connection point
  55716. * @param name defines the connection point name
  55717. * @param ownerBlock defines the block hosting this connection point
  55718. */
  55719. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55720. /**
  55721. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55722. * @returns the class name
  55723. */
  55724. getClassName(): string;
  55725. /**
  55726. * Gets an boolean indicating if the current point can be connected to another point
  55727. * @param connectionPoint defines the other connection point
  55728. * @returns true if the connection is possible
  55729. */
  55730. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55731. /**
  55732. * Connect this point to another connection point
  55733. * @param connectionPoint defines the other connection point
  55734. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55735. * @returns the current connection point
  55736. */
  55737. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55738. /**
  55739. * Disconnect this point from one of his endpoint
  55740. * @param endpoint defines the other connection point
  55741. * @returns the current connection point
  55742. */
  55743. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55744. /**
  55745. * Serializes this point in a JSON representation
  55746. * @returns the serialized point object
  55747. */
  55748. serialize(): any;
  55749. }
  55750. }
  55751. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55753. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55755. import { Mesh } from "babylonjs/Meshes/mesh";
  55756. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55758. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55759. /**
  55760. * Block used to add support for vertex skinning (bones)
  55761. */
  55762. export class BonesBlock extends NodeMaterialBlock {
  55763. /**
  55764. * Creates a new BonesBlock
  55765. * @param name defines the block name
  55766. */
  55767. constructor(name: string);
  55768. /**
  55769. * Initialize the block and prepare the context for build
  55770. * @param state defines the state that will be used for the build
  55771. */
  55772. initialize(state: NodeMaterialBuildState): void;
  55773. /**
  55774. * Gets the current class name
  55775. * @returns the class name
  55776. */
  55777. getClassName(): string;
  55778. /**
  55779. * Gets the matrix indices input component
  55780. */
  55781. readonly matricesIndices: NodeMaterialConnectionPoint;
  55782. /**
  55783. * Gets the matrix weights input component
  55784. */
  55785. readonly matricesWeights: NodeMaterialConnectionPoint;
  55786. /**
  55787. * Gets the extra matrix indices input component
  55788. */
  55789. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55790. /**
  55791. * Gets the extra matrix weights input component
  55792. */
  55793. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55794. /**
  55795. * Gets the world input component
  55796. */
  55797. readonly world: NodeMaterialConnectionPoint;
  55798. /**
  55799. * Gets the output component
  55800. */
  55801. readonly output: NodeMaterialConnectionPoint;
  55802. autoConfigure(material: NodeMaterial): void;
  55803. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55804. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55806. protected _buildBlock(state: NodeMaterialBuildState): this;
  55807. }
  55808. }
  55809. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55814. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55815. /**
  55816. * Block used to add support for instances
  55817. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55818. */
  55819. export class InstancesBlock extends NodeMaterialBlock {
  55820. /**
  55821. * Creates a new InstancesBlock
  55822. * @param name defines the block name
  55823. */
  55824. constructor(name: string);
  55825. /**
  55826. * Gets the current class name
  55827. * @returns the class name
  55828. */
  55829. getClassName(): string;
  55830. /**
  55831. * Gets the first world row input component
  55832. */
  55833. readonly world0: NodeMaterialConnectionPoint;
  55834. /**
  55835. * Gets the second world row input component
  55836. */
  55837. readonly world1: NodeMaterialConnectionPoint;
  55838. /**
  55839. * Gets the third world row input component
  55840. */
  55841. readonly world2: NodeMaterialConnectionPoint;
  55842. /**
  55843. * Gets the forth world row input component
  55844. */
  55845. readonly world3: NodeMaterialConnectionPoint;
  55846. /**
  55847. * Gets the world input component
  55848. */
  55849. readonly world: NodeMaterialConnectionPoint;
  55850. /**
  55851. * Gets the output component
  55852. */
  55853. readonly output: NodeMaterialConnectionPoint;
  55854. autoConfigure(material: NodeMaterial): void;
  55855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55856. protected _buildBlock(state: NodeMaterialBuildState): this;
  55857. }
  55858. }
  55859. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55864. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55865. import { Effect } from "babylonjs/Materials/effect";
  55866. import { Mesh } from "babylonjs/Meshes/mesh";
  55867. /**
  55868. * Block used to add morph targets support to vertex shader
  55869. */
  55870. export class MorphTargetsBlock extends NodeMaterialBlock {
  55871. private _repeatableContentAnchor;
  55872. private _repeatebleContentGenerated;
  55873. /**
  55874. * Create a new MorphTargetsBlock
  55875. * @param name defines the block name
  55876. */
  55877. constructor(name: string);
  55878. /**
  55879. * Gets the current class name
  55880. * @returns the class name
  55881. */
  55882. getClassName(): string;
  55883. /**
  55884. * Gets the position input component
  55885. */
  55886. readonly position: NodeMaterialConnectionPoint;
  55887. /**
  55888. * Gets the normal input component
  55889. */
  55890. readonly normal: NodeMaterialConnectionPoint;
  55891. /**
  55892. * Gets the tangent input component
  55893. */
  55894. readonly tangent: NodeMaterialConnectionPoint;
  55895. /**
  55896. * Gets the tangent input component
  55897. */
  55898. readonly uv: NodeMaterialConnectionPoint;
  55899. /**
  55900. * Gets the position output component
  55901. */
  55902. readonly positionOutput: NodeMaterialConnectionPoint;
  55903. /**
  55904. * Gets the normal output component
  55905. */
  55906. readonly normalOutput: NodeMaterialConnectionPoint;
  55907. /**
  55908. * Gets the tangent output component
  55909. */
  55910. readonly tangentOutput: NodeMaterialConnectionPoint;
  55911. /**
  55912. * Gets the tangent output component
  55913. */
  55914. readonly uvOutput: NodeMaterialConnectionPoint;
  55915. initialize(state: NodeMaterialBuildState): void;
  55916. autoConfigure(material: NodeMaterial): void;
  55917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55918. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55919. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55920. protected _buildBlock(state: NodeMaterialBuildState): this;
  55921. }
  55922. }
  55923. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55927. import { Nullable } from "babylonjs/types";
  55928. import { Scene } from "babylonjs/scene";
  55929. import { Effect } from "babylonjs/Materials/effect";
  55930. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55931. import { Mesh } from "babylonjs/Meshes/mesh";
  55932. import { Light } from "babylonjs/Lights/light";
  55933. /**
  55934. * Block used to get data information from a light
  55935. */
  55936. export class LightInformationBlock extends NodeMaterialBlock {
  55937. private _lightDataDefineName;
  55938. private _lightColorDefineName;
  55939. /**
  55940. * Gets or sets the light associated with this block
  55941. */
  55942. light: Nullable<Light>;
  55943. /**
  55944. * Creates a new LightInformationBlock
  55945. * @param name defines the block name
  55946. */
  55947. constructor(name: string);
  55948. /**
  55949. * Gets the current class name
  55950. * @returns the class name
  55951. */
  55952. getClassName(): string;
  55953. /**
  55954. * Gets the world position input component
  55955. */
  55956. readonly worldPosition: NodeMaterialConnectionPoint;
  55957. /**
  55958. * Gets the direction output component
  55959. */
  55960. readonly direction: NodeMaterialConnectionPoint;
  55961. /**
  55962. * Gets the direction output component
  55963. */
  55964. readonly color: NodeMaterialConnectionPoint;
  55965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55966. protected _buildBlock(state: NodeMaterialBuildState): this;
  55967. serialize(): any;
  55968. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55969. }
  55970. }
  55971. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55972. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55973. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55974. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55975. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55976. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  55977. }
  55978. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55982. import { Scene } from "babylonjs/scene";
  55983. /**
  55984. * Block used to add an alpha test in the fragment shader
  55985. */
  55986. export class AlphaTestBlock extends NodeMaterialBlock {
  55987. /**
  55988. * Gets or sets the alpha value where alpha testing happens
  55989. */
  55990. alphaCutOff: number;
  55991. /**
  55992. * Create a new AlphaTestBlock
  55993. * @param name defines the block name
  55994. */
  55995. constructor(name: string);
  55996. /**
  55997. * Gets the current class name
  55998. * @returns the class name
  55999. */
  56000. getClassName(): string;
  56001. /**
  56002. * Gets the color input component
  56003. */
  56004. readonly color: NodeMaterialConnectionPoint;
  56005. /**
  56006. * Gets the alpha input component
  56007. */
  56008. readonly alpha: NodeMaterialConnectionPoint;
  56009. protected _buildBlock(state: NodeMaterialBuildState): this;
  56010. protected _dumpPropertiesCode(): string;
  56011. serialize(): any;
  56012. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56013. }
  56014. }
  56015. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56020. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56021. import { Effect } from "babylonjs/Materials/effect";
  56022. import { Mesh } from "babylonjs/Meshes/mesh";
  56023. /**
  56024. * Block used to add image processing support to fragment shader
  56025. */
  56026. export class ImageProcessingBlock extends NodeMaterialBlock {
  56027. /**
  56028. * Create a new ImageProcessingBlock
  56029. * @param name defines the block name
  56030. */
  56031. constructor(name: string);
  56032. /**
  56033. * Gets the current class name
  56034. * @returns the class name
  56035. */
  56036. getClassName(): string;
  56037. /**
  56038. * Gets the color input component
  56039. */
  56040. readonly color: NodeMaterialConnectionPoint;
  56041. /**
  56042. * Gets the output component
  56043. */
  56044. readonly output: NodeMaterialConnectionPoint;
  56045. /**
  56046. * Initialize the block and prepare the context for build
  56047. * @param state defines the state that will be used for the build
  56048. */
  56049. initialize(state: NodeMaterialBuildState): void;
  56050. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56053. protected _buildBlock(state: NodeMaterialBuildState): this;
  56054. }
  56055. }
  56056. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56060. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56062. import { Effect } from "babylonjs/Materials/effect";
  56063. import { Mesh } from "babylonjs/Meshes/mesh";
  56064. import { Scene } from "babylonjs/scene";
  56065. /**
  56066. * Block used to pertub normals based on a normal map
  56067. */
  56068. export class PerturbNormalBlock extends NodeMaterialBlock {
  56069. private _tangentSpaceParameterName;
  56070. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56071. invertX: boolean;
  56072. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56073. invertY: boolean;
  56074. /**
  56075. * Create a new PerturbNormalBlock
  56076. * @param name defines the block name
  56077. */
  56078. constructor(name: string);
  56079. /**
  56080. * Gets the current class name
  56081. * @returns the class name
  56082. */
  56083. getClassName(): string;
  56084. /**
  56085. * Gets the world position input component
  56086. */
  56087. readonly worldPosition: NodeMaterialConnectionPoint;
  56088. /**
  56089. * Gets the world normal input component
  56090. */
  56091. readonly worldNormal: NodeMaterialConnectionPoint;
  56092. /**
  56093. * Gets the uv input component
  56094. */
  56095. readonly uv: NodeMaterialConnectionPoint;
  56096. /**
  56097. * Gets the normal map color input component
  56098. */
  56099. readonly normalMapColor: NodeMaterialConnectionPoint;
  56100. /**
  56101. * Gets the strength input component
  56102. */
  56103. readonly strength: NodeMaterialConnectionPoint;
  56104. /**
  56105. * Gets the output component
  56106. */
  56107. readonly output: NodeMaterialConnectionPoint;
  56108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56110. autoConfigure(material: NodeMaterial): void;
  56111. protected _buildBlock(state: NodeMaterialBuildState): this;
  56112. protected _dumpPropertiesCode(): string;
  56113. serialize(): any;
  56114. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56115. }
  56116. }
  56117. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56118. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56119. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  56120. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56121. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56122. }
  56123. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56126. import { Mesh } from "babylonjs/Meshes/mesh";
  56127. import { Effect } from "babylonjs/Materials/effect";
  56128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56130. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56131. /**
  56132. * Block used to add support for scene fog
  56133. */
  56134. export class FogBlock extends NodeMaterialBlock {
  56135. private _fogDistanceName;
  56136. private _fogParameters;
  56137. /**
  56138. * Create a new FogBlock
  56139. * @param name defines the block name
  56140. */
  56141. constructor(name: string);
  56142. /**
  56143. * Gets the current class name
  56144. * @returns the class name
  56145. */
  56146. getClassName(): string;
  56147. /**
  56148. * Gets the world position input component
  56149. */
  56150. readonly worldPosition: NodeMaterialConnectionPoint;
  56151. /**
  56152. * Gets the view input component
  56153. */
  56154. readonly view: NodeMaterialConnectionPoint;
  56155. /**
  56156. * Gets the color input component
  56157. */
  56158. readonly input: NodeMaterialConnectionPoint;
  56159. /**
  56160. * Gets the fog color input component
  56161. */
  56162. readonly fogColor: NodeMaterialConnectionPoint;
  56163. /**
  56164. * Gets the output component
  56165. */
  56166. readonly output: NodeMaterialConnectionPoint;
  56167. autoConfigure(material: NodeMaterial): void;
  56168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56169. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56170. protected _buildBlock(state: NodeMaterialBuildState): this;
  56171. }
  56172. }
  56173. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56178. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56179. import { Effect } from "babylonjs/Materials/effect";
  56180. import { Mesh } from "babylonjs/Meshes/mesh";
  56181. import { Light } from "babylonjs/Lights/light";
  56182. import { Nullable } from "babylonjs/types";
  56183. import { Scene } from "babylonjs/scene";
  56184. /**
  56185. * Block used to add light in the fragment shader
  56186. */
  56187. export class LightBlock extends NodeMaterialBlock {
  56188. private _lightId;
  56189. /**
  56190. * Gets or sets the light associated with this block
  56191. */
  56192. light: Nullable<Light>;
  56193. /**
  56194. * Create a new LightBlock
  56195. * @param name defines the block name
  56196. */
  56197. constructor(name: string);
  56198. /**
  56199. * Gets the current class name
  56200. * @returns the class name
  56201. */
  56202. getClassName(): string;
  56203. /**
  56204. * Gets the world position input component
  56205. */
  56206. readonly worldPosition: NodeMaterialConnectionPoint;
  56207. /**
  56208. * Gets the world normal input component
  56209. */
  56210. readonly worldNormal: NodeMaterialConnectionPoint;
  56211. /**
  56212. * Gets the camera (or eye) position component
  56213. */
  56214. readonly cameraPosition: NodeMaterialConnectionPoint;
  56215. /**
  56216. * Gets the diffuse output component
  56217. */
  56218. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56219. /**
  56220. * Gets the specular output component
  56221. */
  56222. readonly specularOutput: NodeMaterialConnectionPoint;
  56223. autoConfigure(material: NodeMaterial): void;
  56224. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56225. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56226. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56227. private _injectVertexCode;
  56228. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56229. serialize(): any;
  56230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56231. }
  56232. }
  56233. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56234. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56235. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56236. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56237. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56238. }
  56239. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56240. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56241. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56242. }
  56243. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56247. /**
  56248. * Block used to multiply 2 values
  56249. */
  56250. export class MultiplyBlock extends NodeMaterialBlock {
  56251. /**
  56252. * Creates a new MultiplyBlock
  56253. * @param name defines the block name
  56254. */
  56255. constructor(name: string);
  56256. /**
  56257. * Gets the current class name
  56258. * @returns the class name
  56259. */
  56260. getClassName(): string;
  56261. /**
  56262. * Gets the left operand input component
  56263. */
  56264. readonly left: NodeMaterialConnectionPoint;
  56265. /**
  56266. * Gets the right operand input component
  56267. */
  56268. readonly right: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the output component
  56271. */
  56272. readonly output: NodeMaterialConnectionPoint;
  56273. protected _buildBlock(state: NodeMaterialBuildState): this;
  56274. }
  56275. }
  56276. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56280. /**
  56281. * Block used to add 2 vectors
  56282. */
  56283. export class AddBlock extends NodeMaterialBlock {
  56284. /**
  56285. * Creates a new AddBlock
  56286. * @param name defines the block name
  56287. */
  56288. constructor(name: string);
  56289. /**
  56290. * Gets the current class name
  56291. * @returns the class name
  56292. */
  56293. getClassName(): string;
  56294. /**
  56295. * Gets the left operand input component
  56296. */
  56297. readonly left: NodeMaterialConnectionPoint;
  56298. /**
  56299. * Gets the right operand input component
  56300. */
  56301. readonly right: NodeMaterialConnectionPoint;
  56302. /**
  56303. * Gets the output component
  56304. */
  56305. readonly output: NodeMaterialConnectionPoint;
  56306. protected _buildBlock(state: NodeMaterialBuildState): this;
  56307. }
  56308. }
  56309. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56310. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56311. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56312. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56313. /**
  56314. * Block used to scale a vector by a float
  56315. */
  56316. export class ScaleBlock extends NodeMaterialBlock {
  56317. /**
  56318. * Creates a new ScaleBlock
  56319. * @param name defines the block name
  56320. */
  56321. constructor(name: string);
  56322. /**
  56323. * Gets the current class name
  56324. * @returns the class name
  56325. */
  56326. getClassName(): string;
  56327. /**
  56328. * Gets the input component
  56329. */
  56330. readonly input: NodeMaterialConnectionPoint;
  56331. /**
  56332. * Gets the factor input component
  56333. */
  56334. readonly factor: NodeMaterialConnectionPoint;
  56335. /**
  56336. * Gets the output component
  56337. */
  56338. readonly output: NodeMaterialConnectionPoint;
  56339. protected _buildBlock(state: NodeMaterialBuildState): this;
  56340. }
  56341. }
  56342. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56346. import { Scene } from "babylonjs/scene";
  56347. /**
  56348. * Block used to clamp a float
  56349. */
  56350. export class ClampBlock extends NodeMaterialBlock {
  56351. /** Gets or sets the minimum range */
  56352. minimum: number;
  56353. /** Gets or sets the maximum range */
  56354. maximum: number;
  56355. /**
  56356. * Creates a new ClampBlock
  56357. * @param name defines the block name
  56358. */
  56359. constructor(name: string);
  56360. /**
  56361. * Gets the current class name
  56362. * @returns the class name
  56363. */
  56364. getClassName(): string;
  56365. /**
  56366. * Gets the value input component
  56367. */
  56368. readonly value: NodeMaterialConnectionPoint;
  56369. /**
  56370. * Gets the output component
  56371. */
  56372. readonly output: NodeMaterialConnectionPoint;
  56373. protected _buildBlock(state: NodeMaterialBuildState): this;
  56374. protected _dumpPropertiesCode(): string;
  56375. serialize(): any;
  56376. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56377. }
  56378. }
  56379. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56383. /**
  56384. * Block used to apply a cross product between 2 vectors
  56385. */
  56386. export class CrossBlock extends NodeMaterialBlock {
  56387. /**
  56388. * Creates a new CrossBlock
  56389. * @param name defines the block name
  56390. */
  56391. constructor(name: string);
  56392. /**
  56393. * Gets the current class name
  56394. * @returns the class name
  56395. */
  56396. getClassName(): string;
  56397. /**
  56398. * Gets the left operand input component
  56399. */
  56400. readonly left: NodeMaterialConnectionPoint;
  56401. /**
  56402. * Gets the right operand input component
  56403. */
  56404. readonly right: NodeMaterialConnectionPoint;
  56405. /**
  56406. * Gets the output component
  56407. */
  56408. readonly output: NodeMaterialConnectionPoint;
  56409. protected _buildBlock(state: NodeMaterialBuildState): this;
  56410. }
  56411. }
  56412. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56416. /**
  56417. * Block used to apply a dot product between 2 vectors
  56418. */
  56419. export class DotBlock extends NodeMaterialBlock {
  56420. /**
  56421. * Creates a new DotBlock
  56422. * @param name defines the block name
  56423. */
  56424. constructor(name: string);
  56425. /**
  56426. * Gets the current class name
  56427. * @returns the class name
  56428. */
  56429. getClassName(): string;
  56430. /**
  56431. * Gets the left operand input component
  56432. */
  56433. readonly left: NodeMaterialConnectionPoint;
  56434. /**
  56435. * Gets the right operand input component
  56436. */
  56437. readonly right: NodeMaterialConnectionPoint;
  56438. /**
  56439. * Gets the output component
  56440. */
  56441. readonly output: NodeMaterialConnectionPoint;
  56442. protected _buildBlock(state: NodeMaterialBuildState): this;
  56443. }
  56444. }
  56445. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56449. import { Vector2 } from "babylonjs/Maths/math.vector";
  56450. import { Scene } from "babylonjs/scene";
  56451. /**
  56452. * Block used to remap a float from a range to a new one
  56453. */
  56454. export class RemapBlock extends NodeMaterialBlock {
  56455. /**
  56456. * Gets or sets the source range
  56457. */
  56458. sourceRange: Vector2;
  56459. /**
  56460. * Gets or sets the target range
  56461. */
  56462. targetRange: Vector2;
  56463. /**
  56464. * Creates a new RemapBlock
  56465. * @param name defines the block name
  56466. */
  56467. constructor(name: string);
  56468. /**
  56469. * Gets the current class name
  56470. * @returns the class name
  56471. */
  56472. getClassName(): string;
  56473. /**
  56474. * Gets the input component
  56475. */
  56476. readonly input: NodeMaterialConnectionPoint;
  56477. /**
  56478. * Gets the source min input component
  56479. */
  56480. readonly sourceMin: NodeMaterialConnectionPoint;
  56481. /**
  56482. * Gets the source max input component
  56483. */
  56484. readonly sourceMax: NodeMaterialConnectionPoint;
  56485. /**
  56486. * Gets the target min input component
  56487. */
  56488. readonly targetMin: NodeMaterialConnectionPoint;
  56489. /**
  56490. * Gets the target max input component
  56491. */
  56492. readonly targetMax: NodeMaterialConnectionPoint;
  56493. /**
  56494. * Gets the output component
  56495. */
  56496. readonly output: NodeMaterialConnectionPoint;
  56497. protected _buildBlock(state: NodeMaterialBuildState): this;
  56498. protected _dumpPropertiesCode(): string;
  56499. serialize(): any;
  56500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56501. }
  56502. }
  56503. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56507. /**
  56508. * Block used to normalize a vector
  56509. */
  56510. export class NormalizeBlock extends NodeMaterialBlock {
  56511. /**
  56512. * Creates a new NormalizeBlock
  56513. * @param name defines the block name
  56514. */
  56515. constructor(name: string);
  56516. /**
  56517. * Gets the current class name
  56518. * @returns the class name
  56519. */
  56520. getClassName(): string;
  56521. /**
  56522. * Gets the input component
  56523. */
  56524. readonly input: NodeMaterialConnectionPoint;
  56525. /**
  56526. * Gets the output component
  56527. */
  56528. readonly output: NodeMaterialConnectionPoint;
  56529. protected _buildBlock(state: NodeMaterialBuildState): this;
  56530. }
  56531. }
  56532. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56536. import { Scene } from "babylonjs/scene";
  56537. /**
  56538. * Operations supported by the Trigonometry block
  56539. */
  56540. export enum TrigonometryBlockOperations {
  56541. /** Cos */
  56542. Cos = 0,
  56543. /** Sin */
  56544. Sin = 1,
  56545. /** Abs */
  56546. Abs = 2,
  56547. /** Exp */
  56548. Exp = 3,
  56549. /** Exp2 */
  56550. Exp2 = 4,
  56551. /** Round */
  56552. Round = 5,
  56553. /** Floor */
  56554. Floor = 6,
  56555. /** Ceiling */
  56556. Ceiling = 7
  56557. }
  56558. /**
  56559. * Block used to apply trigonometry operation to floats
  56560. */
  56561. export class TrigonometryBlock extends NodeMaterialBlock {
  56562. /**
  56563. * Gets or sets the operation applied by the block
  56564. */
  56565. operation: TrigonometryBlockOperations;
  56566. /**
  56567. * Creates a new TrigonometryBlock
  56568. * @param name defines the block name
  56569. */
  56570. constructor(name: string);
  56571. /**
  56572. * Gets the current class name
  56573. * @returns the class name
  56574. */
  56575. getClassName(): string;
  56576. /**
  56577. * Gets the input component
  56578. */
  56579. readonly input: NodeMaterialConnectionPoint;
  56580. /**
  56581. * Gets the output component
  56582. */
  56583. readonly output: NodeMaterialConnectionPoint;
  56584. protected _buildBlock(state: NodeMaterialBuildState): this;
  56585. serialize(): any;
  56586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56587. }
  56588. }
  56589. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56593. /**
  56594. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56595. */
  56596. export class ColorMergerBlock extends NodeMaterialBlock {
  56597. /**
  56598. * Create a new ColorMergerBlock
  56599. * @param name defines the block name
  56600. */
  56601. constructor(name: string);
  56602. /**
  56603. * Gets the current class name
  56604. * @returns the class name
  56605. */
  56606. getClassName(): string;
  56607. /**
  56608. * Gets the r component (input)
  56609. */
  56610. readonly r: NodeMaterialConnectionPoint;
  56611. /**
  56612. * Gets the g component (input)
  56613. */
  56614. readonly g: NodeMaterialConnectionPoint;
  56615. /**
  56616. * Gets the b component (input)
  56617. */
  56618. readonly b: NodeMaterialConnectionPoint;
  56619. /**
  56620. * Gets the a component (input)
  56621. */
  56622. readonly a: NodeMaterialConnectionPoint;
  56623. /**
  56624. * Gets the rgba component (output)
  56625. */
  56626. readonly rgba: NodeMaterialConnectionPoint;
  56627. /**
  56628. * Gets the rgb component (output)
  56629. */
  56630. readonly rgb: NodeMaterialConnectionPoint;
  56631. protected _buildBlock(state: NodeMaterialBuildState): this;
  56632. }
  56633. }
  56634. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56638. /**
  56639. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56640. */
  56641. export class VectorMergerBlock extends NodeMaterialBlock {
  56642. /**
  56643. * Create a new VectorMergerBlock
  56644. * @param name defines the block name
  56645. */
  56646. constructor(name: string);
  56647. /**
  56648. * Gets the current class name
  56649. * @returns the class name
  56650. */
  56651. getClassName(): string;
  56652. /**
  56653. * Gets the x component (input)
  56654. */
  56655. readonly x: NodeMaterialConnectionPoint;
  56656. /**
  56657. * Gets the y component (input)
  56658. */
  56659. readonly y: NodeMaterialConnectionPoint;
  56660. /**
  56661. * Gets the z component (input)
  56662. */
  56663. readonly z: NodeMaterialConnectionPoint;
  56664. /**
  56665. * Gets the w component (input)
  56666. */
  56667. readonly w: NodeMaterialConnectionPoint;
  56668. /**
  56669. * Gets the xyzw component (output)
  56670. */
  56671. readonly xyzw: NodeMaterialConnectionPoint;
  56672. /**
  56673. * Gets the xyz component (output)
  56674. */
  56675. readonly xyz: NodeMaterialConnectionPoint;
  56676. /**
  56677. * Gets the xy component (output)
  56678. */
  56679. readonly xy: NodeMaterialConnectionPoint;
  56680. protected _buildBlock(state: NodeMaterialBuildState): this;
  56681. }
  56682. }
  56683. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56686. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56687. /**
  56688. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56689. */
  56690. export class ColorSplitterBlock extends NodeMaterialBlock {
  56691. /**
  56692. * Create a new ColorSplitterBlock
  56693. * @param name defines the block name
  56694. */
  56695. constructor(name: string);
  56696. /**
  56697. * Gets the current class name
  56698. * @returns the class name
  56699. */
  56700. getClassName(): string;
  56701. /**
  56702. * Gets the rgba component (input)
  56703. */
  56704. readonly rgba: NodeMaterialConnectionPoint;
  56705. /**
  56706. * Gets the rgb component (input)
  56707. */
  56708. readonly rgbIn: NodeMaterialConnectionPoint;
  56709. /**
  56710. * Gets the rgb component (output)
  56711. */
  56712. readonly rgbOut: NodeMaterialConnectionPoint;
  56713. /**
  56714. * Gets the r component (output)
  56715. */
  56716. readonly r: NodeMaterialConnectionPoint;
  56717. /**
  56718. * Gets the g component (output)
  56719. */
  56720. readonly g: NodeMaterialConnectionPoint;
  56721. /**
  56722. * Gets the b component (output)
  56723. */
  56724. readonly b: NodeMaterialConnectionPoint;
  56725. /**
  56726. * Gets the a component (output)
  56727. */
  56728. readonly a: NodeMaterialConnectionPoint;
  56729. protected _inputRename(name: string): string;
  56730. protected _outputRename(name: string): string;
  56731. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56732. }
  56733. }
  56734. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56738. /**
  56739. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56740. */
  56741. export class VectorSplitterBlock extends NodeMaterialBlock {
  56742. /**
  56743. * Create a new VectorSplitterBlock
  56744. * @param name defines the block name
  56745. */
  56746. constructor(name: string);
  56747. /**
  56748. * Gets the current class name
  56749. * @returns the class name
  56750. */
  56751. getClassName(): string;
  56752. /**
  56753. * Gets the xyzw component (input)
  56754. */
  56755. readonly xyzw: NodeMaterialConnectionPoint;
  56756. /**
  56757. * Gets the xyz component (input)
  56758. */
  56759. readonly xyzIn: NodeMaterialConnectionPoint;
  56760. /**
  56761. * Gets the xy component (input)
  56762. */
  56763. readonly xyIn: NodeMaterialConnectionPoint;
  56764. /**
  56765. * Gets the xyz component (output)
  56766. */
  56767. readonly xyzOut: NodeMaterialConnectionPoint;
  56768. /**
  56769. * Gets the xy component (output)
  56770. */
  56771. readonly xyOut: NodeMaterialConnectionPoint;
  56772. /**
  56773. * Gets the x component (output)
  56774. */
  56775. readonly x: NodeMaterialConnectionPoint;
  56776. /**
  56777. * Gets the y component (output)
  56778. */
  56779. readonly y: NodeMaterialConnectionPoint;
  56780. /**
  56781. * Gets the z component (output)
  56782. */
  56783. readonly z: NodeMaterialConnectionPoint;
  56784. /**
  56785. * Gets the w component (output)
  56786. */
  56787. readonly w: NodeMaterialConnectionPoint;
  56788. protected _inputRename(name: string): string;
  56789. protected _outputRename(name: string): string;
  56790. protected _buildBlock(state: NodeMaterialBuildState): this;
  56791. }
  56792. }
  56793. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56794. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56795. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56796. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56797. /**
  56798. * Block used to lerp 2 values
  56799. */
  56800. export class LerpBlock extends NodeMaterialBlock {
  56801. /**
  56802. * Creates a new LerpBlock
  56803. * @param name defines the block name
  56804. */
  56805. constructor(name: string);
  56806. /**
  56807. * Gets the current class name
  56808. * @returns the class name
  56809. */
  56810. getClassName(): string;
  56811. /**
  56812. * Gets the left operand input component
  56813. */
  56814. readonly left: NodeMaterialConnectionPoint;
  56815. /**
  56816. * Gets the right operand input component
  56817. */
  56818. readonly right: NodeMaterialConnectionPoint;
  56819. /**
  56820. * Gets the gradient operand input component
  56821. */
  56822. readonly gradient: NodeMaterialConnectionPoint;
  56823. /**
  56824. * Gets the output component
  56825. */
  56826. readonly output: NodeMaterialConnectionPoint;
  56827. protected _buildBlock(state: NodeMaterialBuildState): this;
  56828. }
  56829. }
  56830. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56834. /**
  56835. * Block used to divide 2 vectors
  56836. */
  56837. export class DivideBlock extends NodeMaterialBlock {
  56838. /**
  56839. * Creates a new DivideBlock
  56840. * @param name defines the block name
  56841. */
  56842. constructor(name: string);
  56843. /**
  56844. * Gets the current class name
  56845. * @returns the class name
  56846. */
  56847. getClassName(): string;
  56848. /**
  56849. * Gets the left operand input component
  56850. */
  56851. readonly left: NodeMaterialConnectionPoint;
  56852. /**
  56853. * Gets the right operand input component
  56854. */
  56855. readonly right: NodeMaterialConnectionPoint;
  56856. /**
  56857. * Gets the output component
  56858. */
  56859. readonly output: NodeMaterialConnectionPoint;
  56860. protected _buildBlock(state: NodeMaterialBuildState): this;
  56861. }
  56862. }
  56863. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56867. /**
  56868. * Block used to subtract 2 vectors
  56869. */
  56870. export class SubtractBlock extends NodeMaterialBlock {
  56871. /**
  56872. * Creates a new SubtractBlock
  56873. * @param name defines the block name
  56874. */
  56875. constructor(name: string);
  56876. /**
  56877. * Gets the current class name
  56878. * @returns the class name
  56879. */
  56880. getClassName(): string;
  56881. /**
  56882. * Gets the left operand input component
  56883. */
  56884. readonly left: NodeMaterialConnectionPoint;
  56885. /**
  56886. * Gets the right operand input component
  56887. */
  56888. readonly right: NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the output component
  56891. */
  56892. readonly output: NodeMaterialConnectionPoint;
  56893. protected _buildBlock(state: NodeMaterialBuildState): this;
  56894. }
  56895. }
  56896. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56900. /**
  56901. * Block used to step a value
  56902. */
  56903. export class StepBlock extends NodeMaterialBlock {
  56904. /**
  56905. * Creates a new AddBlock
  56906. * @param name defines the block name
  56907. */
  56908. constructor(name: string);
  56909. /**
  56910. * Gets the current class name
  56911. * @returns the class name
  56912. */
  56913. getClassName(): string;
  56914. /**
  56915. * Gets the value operand input component
  56916. */
  56917. readonly value: NodeMaterialConnectionPoint;
  56918. /**
  56919. * Gets the edge operand input component
  56920. */
  56921. readonly edge: NodeMaterialConnectionPoint;
  56922. /**
  56923. * Gets the output component
  56924. */
  56925. readonly output: NodeMaterialConnectionPoint;
  56926. protected _buildBlock(state: NodeMaterialBuildState): this;
  56927. }
  56928. }
  56929. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  56930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56933. /**
  56934. * Block used to get the opposite (1 - x) of a value
  56935. */
  56936. export class OneMinusBlock extends NodeMaterialBlock {
  56937. /**
  56938. * Creates a new OneMinusBlock
  56939. * @param name defines the block name
  56940. */
  56941. constructor(name: string);
  56942. /**
  56943. * Gets the current class name
  56944. * @returns the class name
  56945. */
  56946. getClassName(): string;
  56947. /**
  56948. * Gets the input component
  56949. */
  56950. readonly input: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the output component
  56953. */
  56954. readonly output: NodeMaterialConnectionPoint;
  56955. protected _buildBlock(state: NodeMaterialBuildState): this;
  56956. }
  56957. }
  56958. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  56959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56962. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56963. /**
  56964. * Block used to get the view direction
  56965. */
  56966. export class ViewDirectionBlock extends NodeMaterialBlock {
  56967. /**
  56968. * Creates a new ViewDirectionBlock
  56969. * @param name defines the block name
  56970. */
  56971. constructor(name: string);
  56972. /**
  56973. * Gets the current class name
  56974. * @returns the class name
  56975. */
  56976. getClassName(): string;
  56977. /**
  56978. * Gets the world position component
  56979. */
  56980. readonly worldPosition: NodeMaterialConnectionPoint;
  56981. /**
  56982. * Gets the camera position component
  56983. */
  56984. readonly cameraPosition: NodeMaterialConnectionPoint;
  56985. /**
  56986. * Gets the output component
  56987. */
  56988. readonly output: NodeMaterialConnectionPoint;
  56989. autoConfigure(material: NodeMaterial): void;
  56990. protected _buildBlock(state: NodeMaterialBuildState): this;
  56991. }
  56992. }
  56993. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  56994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56997. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  56998. /**
  56999. * Block used to compute fresnel value
  57000. */
  57001. export class FresnelBlock extends NodeMaterialBlock {
  57002. /**
  57003. * Create a new FresnelBlock
  57004. * @param name defines the block name
  57005. */
  57006. constructor(name: string);
  57007. /**
  57008. * Gets the current class name
  57009. * @returns the class name
  57010. */
  57011. getClassName(): string;
  57012. /**
  57013. * Gets the world normal input component
  57014. */
  57015. readonly worldNormal: NodeMaterialConnectionPoint;
  57016. /**
  57017. * Gets the view direction input component
  57018. */
  57019. readonly viewDirection: NodeMaterialConnectionPoint;
  57020. /**
  57021. * Gets the bias input component
  57022. */
  57023. readonly bias: NodeMaterialConnectionPoint;
  57024. /**
  57025. * Gets the camera (or eye) position component
  57026. */
  57027. readonly power: NodeMaterialConnectionPoint;
  57028. /**
  57029. * Gets the fresnel output component
  57030. */
  57031. readonly fresnel: NodeMaterialConnectionPoint;
  57032. autoConfigure(material: NodeMaterial): void;
  57033. protected _buildBlock(state: NodeMaterialBuildState): this;
  57034. }
  57035. }
  57036. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57037. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57038. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57039. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57040. /**
  57041. * Block used to get the max of 2 values
  57042. */
  57043. export class MaxBlock extends NodeMaterialBlock {
  57044. /**
  57045. * Creates a new MaxBlock
  57046. * @param name defines the block name
  57047. */
  57048. constructor(name: string);
  57049. /**
  57050. * Gets the current class name
  57051. * @returns the class name
  57052. */
  57053. getClassName(): string;
  57054. /**
  57055. * Gets the left operand input component
  57056. */
  57057. readonly left: NodeMaterialConnectionPoint;
  57058. /**
  57059. * Gets the right operand input component
  57060. */
  57061. readonly right: NodeMaterialConnectionPoint;
  57062. /**
  57063. * Gets the output component
  57064. */
  57065. readonly output: NodeMaterialConnectionPoint;
  57066. protected _buildBlock(state: NodeMaterialBuildState): this;
  57067. }
  57068. }
  57069. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57073. /**
  57074. * Block used to get the min of 2 values
  57075. */
  57076. export class MinBlock extends NodeMaterialBlock {
  57077. /**
  57078. * Creates a new MinBlock
  57079. * @param name defines the block name
  57080. */
  57081. constructor(name: string);
  57082. /**
  57083. * Gets the current class name
  57084. * @returns the class name
  57085. */
  57086. getClassName(): string;
  57087. /**
  57088. * Gets the left operand input component
  57089. */
  57090. readonly left: NodeMaterialConnectionPoint;
  57091. /**
  57092. * Gets the right operand input component
  57093. */
  57094. readonly right: NodeMaterialConnectionPoint;
  57095. /**
  57096. * Gets the output component
  57097. */
  57098. readonly output: NodeMaterialConnectionPoint;
  57099. protected _buildBlock(state: NodeMaterialBuildState): this;
  57100. }
  57101. }
  57102. declare module "babylonjs/Materials/Node/Blocks/index" {
  57103. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57104. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57105. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57106. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57107. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57108. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57109. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57110. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57111. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57112. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57113. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57114. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57115. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57116. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57117. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57118. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57119. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57120. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57121. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57122. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57123. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57124. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57125. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57126. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57127. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57128. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57129. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57130. }
  57131. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57132. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57133. }
  57134. declare module "babylonjs/Materials/Node/index" {
  57135. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  57136. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  57137. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57138. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57139. export * from "babylonjs/Materials/Node/nodeMaterial";
  57140. export * from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  57141. export * from "babylonjs/Materials/Node/Blocks/index";
  57142. export * from "babylonjs/Materials/Node/Optimizers/index";
  57143. }
  57144. declare module "babylonjs/Materials/effectRenderer" {
  57145. import { Nullable } from "babylonjs/types";
  57146. import { Texture } from "babylonjs/Materials/Textures/texture";
  57147. import { Engine } from "babylonjs/Engines/engine";
  57148. import { Viewport } from "babylonjs/Maths/math.viewport";
  57149. import { Observable } from "babylonjs/Misc/observable";
  57150. import { Effect } from "babylonjs/Materials/effect";
  57151. import "babylonjs/Shaders/postprocess.vertex";
  57152. /**
  57153. * Effect Render Options
  57154. */
  57155. export interface IEffectRendererOptions {
  57156. /**
  57157. * Defines the vertices positions.
  57158. */
  57159. positions?: number[];
  57160. /**
  57161. * Defines the indices.
  57162. */
  57163. indices?: number[];
  57164. }
  57165. /**
  57166. * Helper class to render one or more effects
  57167. */
  57168. export class EffectRenderer {
  57169. private engine;
  57170. private static _DefaultOptions;
  57171. private _vertexBuffers;
  57172. private _indexBuffer;
  57173. private _ringBufferIndex;
  57174. private _ringScreenBuffer;
  57175. private _fullscreenViewport;
  57176. private _getNextFrameBuffer;
  57177. /**
  57178. * Creates an effect renderer
  57179. * @param engine the engine to use for rendering
  57180. * @param options defines the options of the effect renderer
  57181. */
  57182. constructor(engine: Engine, options?: IEffectRendererOptions);
  57183. /**
  57184. * Sets the current viewport in normalized coordinates 0-1
  57185. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57186. */
  57187. setViewport(viewport?: Viewport): void;
  57188. /**
  57189. * Binds the embedded attributes buffer to the effect.
  57190. * @param effect Defines the effect to bind the attributes for
  57191. */
  57192. bindBuffers(effect: Effect): void;
  57193. /**
  57194. * Sets the current effect wrapper to use during draw.
  57195. * The effect needs to be ready before calling this api.
  57196. * This also sets the default full screen position attribute.
  57197. * @param effectWrapper Defines the effect to draw with
  57198. */
  57199. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57200. /**
  57201. * Draws a full screen quad.
  57202. */
  57203. draw(): void;
  57204. /**
  57205. * renders one or more effects to a specified texture
  57206. * @param effectWrappers list of effects to renderer
  57207. * @param outputTexture texture to draw to, if null it will render to the screen
  57208. */
  57209. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57210. /**
  57211. * Disposes of the effect renderer
  57212. */
  57213. dispose(): void;
  57214. }
  57215. /**
  57216. * Options to create an EffectWrapper
  57217. */
  57218. interface EffectWrapperCreationOptions {
  57219. /**
  57220. * Engine to use to create the effect
  57221. */
  57222. engine: Engine;
  57223. /**
  57224. * Fragment shader for the effect
  57225. */
  57226. fragmentShader: string;
  57227. /**
  57228. * Vertex shader for the effect
  57229. */
  57230. vertexShader?: string;
  57231. /**
  57232. * Attributes to use in the shader
  57233. */
  57234. attributeNames?: Array<string>;
  57235. /**
  57236. * Uniforms to use in the shader
  57237. */
  57238. uniformNames?: Array<string>;
  57239. /**
  57240. * Texture sampler names to use in the shader
  57241. */
  57242. samplerNames?: Array<string>;
  57243. /**
  57244. * The friendly name of the effect displayed in Spector.
  57245. */
  57246. name?: string;
  57247. }
  57248. /**
  57249. * Wraps an effect to be used for rendering
  57250. */
  57251. export class EffectWrapper {
  57252. /**
  57253. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57254. */
  57255. onApplyObservable: Observable<{}>;
  57256. /**
  57257. * The underlying effect
  57258. */
  57259. effect: Effect;
  57260. /**
  57261. * Creates an effect to be renderer
  57262. * @param creationOptions options to create the effect
  57263. */
  57264. constructor(creationOptions: EffectWrapperCreationOptions);
  57265. /**
  57266. * Disposes of the effect wrapper
  57267. */
  57268. dispose(): void;
  57269. }
  57270. }
  57271. declare module "babylonjs/Materials/index" {
  57272. export * from "babylonjs/Materials/Background/index";
  57273. export * from "babylonjs/Materials/colorCurves";
  57274. export * from "babylonjs/Materials/effect";
  57275. export * from "babylonjs/Materials/fresnelParameters";
  57276. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57277. export * from "babylonjs/Materials/material";
  57278. export * from "babylonjs/Materials/materialDefines";
  57279. export * from "babylonjs/Materials/materialHelper";
  57280. export * from "babylonjs/Materials/multiMaterial";
  57281. export * from "babylonjs/Materials/PBR/index";
  57282. export * from "babylonjs/Materials/pushMaterial";
  57283. export * from "babylonjs/Materials/shaderMaterial";
  57284. export * from "babylonjs/Materials/standardMaterial";
  57285. export * from "babylonjs/Materials/Textures/index";
  57286. export * from "babylonjs/Materials/uniformBuffer";
  57287. export * from "babylonjs/Materials/materialFlags";
  57288. export * from "babylonjs/Materials/Node/index";
  57289. export * from "babylonjs/Materials/effectRenderer";
  57290. }
  57291. declare module "babylonjs/Maths/index" {
  57292. export * from "babylonjs/Maths/math.scalar";
  57293. export * from "babylonjs/Maths/math";
  57294. export * from "babylonjs/Maths/sphericalPolynomial";
  57295. }
  57296. declare module "babylonjs/Misc/workerPool" {
  57297. import { IDisposable } from "babylonjs/scene";
  57298. /**
  57299. * Helper class to push actions to a pool of workers.
  57300. */
  57301. export class WorkerPool implements IDisposable {
  57302. private _workerInfos;
  57303. private _pendingActions;
  57304. /**
  57305. * Constructor
  57306. * @param workers Array of workers to use for actions
  57307. */
  57308. constructor(workers: Array<Worker>);
  57309. /**
  57310. * Terminates all workers and clears any pending actions.
  57311. */
  57312. dispose(): void;
  57313. /**
  57314. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57315. * pended until a worker has completed its action.
  57316. * @param action The action to perform. Call onComplete when the action is complete.
  57317. */
  57318. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57319. private _execute;
  57320. }
  57321. }
  57322. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57323. import { IDisposable } from "babylonjs/scene";
  57324. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57325. /**
  57326. * Configuration for Draco compression
  57327. */
  57328. export interface IDracoCompressionConfiguration {
  57329. /**
  57330. * Configuration for the decoder.
  57331. */
  57332. decoder: {
  57333. /**
  57334. * The url to the WebAssembly module.
  57335. */
  57336. wasmUrl?: string;
  57337. /**
  57338. * The url to the WebAssembly binary.
  57339. */
  57340. wasmBinaryUrl?: string;
  57341. /**
  57342. * The url to the fallback JavaScript module.
  57343. */
  57344. fallbackUrl?: string;
  57345. };
  57346. }
  57347. /**
  57348. * Draco compression (https://google.github.io/draco/)
  57349. *
  57350. * This class wraps the Draco module.
  57351. *
  57352. * **Encoder**
  57353. *
  57354. * The encoder is not currently implemented.
  57355. *
  57356. * **Decoder**
  57357. *
  57358. * 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.
  57359. *
  57360. * To update the configuration, use the following code:
  57361. * ```javascript
  57362. * DracoCompression.Configuration = {
  57363. * decoder: {
  57364. * wasmUrl: "<url to the WebAssembly library>",
  57365. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57366. * fallbackUrl: "<url to the fallback JavaScript library>",
  57367. * }
  57368. * };
  57369. * ```
  57370. *
  57371. * 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.
  57372. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57373. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57374. *
  57375. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57376. * ```javascript
  57377. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57378. * ```
  57379. *
  57380. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57381. */
  57382. export class DracoCompression implements IDisposable {
  57383. private _workerPoolPromise?;
  57384. private _decoderModulePromise?;
  57385. /**
  57386. * The configuration. Defaults to the following urls:
  57387. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57388. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57389. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57390. */
  57391. static Configuration: IDracoCompressionConfiguration;
  57392. /**
  57393. * Returns true if the decoder configuration is available.
  57394. */
  57395. static readonly DecoderAvailable: boolean;
  57396. /**
  57397. * Default number of workers to create when creating the draco compression object.
  57398. */
  57399. static DefaultNumWorkers: number;
  57400. private static GetDefaultNumWorkers;
  57401. private static _Default;
  57402. /**
  57403. * Default instance for the draco compression object.
  57404. */
  57405. static readonly Default: DracoCompression;
  57406. /**
  57407. * Constructor
  57408. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57409. */
  57410. constructor(numWorkers?: number);
  57411. /**
  57412. * Stop all async operations and release resources.
  57413. */
  57414. dispose(): void;
  57415. /**
  57416. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57417. * @returns a promise that resolves when ready
  57418. */
  57419. whenReadyAsync(): Promise<void>;
  57420. /**
  57421. * Decode Draco compressed mesh data to vertex data.
  57422. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57423. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57424. * @returns A promise that resolves with the decoded vertex data
  57425. */
  57426. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57427. [kind: string]: number;
  57428. }): Promise<VertexData>;
  57429. }
  57430. }
  57431. declare module "babylonjs/Meshes/Compression/index" {
  57432. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57433. }
  57434. declare module "babylonjs/Meshes/csg" {
  57435. import { Nullable } from "babylonjs/types";
  57436. import { Scene } from "babylonjs/scene";
  57437. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57438. import { Mesh } from "babylonjs/Meshes/mesh";
  57439. import { Material } from "babylonjs/Materials/material";
  57440. /**
  57441. * Class for building Constructive Solid Geometry
  57442. */
  57443. export class CSG {
  57444. private polygons;
  57445. /**
  57446. * The world matrix
  57447. */
  57448. matrix: Matrix;
  57449. /**
  57450. * Stores the position
  57451. */
  57452. position: Vector3;
  57453. /**
  57454. * Stores the rotation
  57455. */
  57456. rotation: Vector3;
  57457. /**
  57458. * Stores the rotation quaternion
  57459. */
  57460. rotationQuaternion: Nullable<Quaternion>;
  57461. /**
  57462. * Stores the scaling vector
  57463. */
  57464. scaling: Vector3;
  57465. /**
  57466. * Convert the Mesh to CSG
  57467. * @param mesh The Mesh to convert to CSG
  57468. * @returns A new CSG from the Mesh
  57469. */
  57470. static FromMesh(mesh: Mesh): CSG;
  57471. /**
  57472. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57473. * @param polygons Polygons used to construct a CSG solid
  57474. */
  57475. private static FromPolygons;
  57476. /**
  57477. * Clones, or makes a deep copy, of the CSG
  57478. * @returns A new CSG
  57479. */
  57480. clone(): CSG;
  57481. /**
  57482. * Unions this CSG with another CSG
  57483. * @param csg The CSG to union against this CSG
  57484. * @returns The unioned CSG
  57485. */
  57486. union(csg: CSG): CSG;
  57487. /**
  57488. * Unions this CSG with another CSG in place
  57489. * @param csg The CSG to union against this CSG
  57490. */
  57491. unionInPlace(csg: CSG): void;
  57492. /**
  57493. * Subtracts this CSG with another CSG
  57494. * @param csg The CSG to subtract against this CSG
  57495. * @returns A new CSG
  57496. */
  57497. subtract(csg: CSG): CSG;
  57498. /**
  57499. * Subtracts this CSG with another CSG in place
  57500. * @param csg The CSG to subtact against this CSG
  57501. */
  57502. subtractInPlace(csg: CSG): void;
  57503. /**
  57504. * Intersect this CSG with another CSG
  57505. * @param csg The CSG to intersect against this CSG
  57506. * @returns A new CSG
  57507. */
  57508. intersect(csg: CSG): CSG;
  57509. /**
  57510. * Intersects this CSG with another CSG in place
  57511. * @param csg The CSG to intersect against this CSG
  57512. */
  57513. intersectInPlace(csg: CSG): void;
  57514. /**
  57515. * Return a new CSG solid with solid and empty space switched. This solid is
  57516. * not modified.
  57517. * @returns A new CSG solid with solid and empty space switched
  57518. */
  57519. inverse(): CSG;
  57520. /**
  57521. * Inverses the CSG in place
  57522. */
  57523. inverseInPlace(): void;
  57524. /**
  57525. * This is used to keep meshes transformations so they can be restored
  57526. * when we build back a Babylon Mesh
  57527. * NB : All CSG operations are performed in world coordinates
  57528. * @param csg The CSG to copy the transform attributes from
  57529. * @returns This CSG
  57530. */
  57531. copyTransformAttributes(csg: CSG): CSG;
  57532. /**
  57533. * Build Raw mesh from CSG
  57534. * Coordinates here are in world space
  57535. * @param name The name of the mesh geometry
  57536. * @param scene The Scene
  57537. * @param keepSubMeshes Specifies if the submeshes should be kept
  57538. * @returns A new Mesh
  57539. */
  57540. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57541. /**
  57542. * Build Mesh from CSG taking material and transforms into account
  57543. * @param name The name of the Mesh
  57544. * @param material The material of the Mesh
  57545. * @param scene The Scene
  57546. * @param keepSubMeshes Specifies if submeshes should be kept
  57547. * @returns The new Mesh
  57548. */
  57549. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57550. }
  57551. }
  57552. declare module "babylonjs/Meshes/trailMesh" {
  57553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57554. import { Mesh } from "babylonjs/Meshes/mesh";
  57555. import { Scene } from "babylonjs/scene";
  57556. /**
  57557. * Class used to create a trail following a mesh
  57558. */
  57559. export class TrailMesh extends Mesh {
  57560. private _generator;
  57561. private _autoStart;
  57562. private _running;
  57563. private _diameter;
  57564. private _length;
  57565. private _sectionPolygonPointsCount;
  57566. private _sectionVectors;
  57567. private _sectionNormalVectors;
  57568. private _beforeRenderObserver;
  57569. /**
  57570. * @constructor
  57571. * @param name The value used by scene.getMeshByName() to do a lookup.
  57572. * @param generator The mesh to generate a trail.
  57573. * @param scene The scene to add this mesh to.
  57574. * @param diameter Diameter of trailing mesh. Default is 1.
  57575. * @param length Length of trailing mesh. Default is 60.
  57576. * @param autoStart Automatically start trailing mesh. Default true.
  57577. */
  57578. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57579. /**
  57580. * "TrailMesh"
  57581. * @returns "TrailMesh"
  57582. */
  57583. getClassName(): string;
  57584. private _createMesh;
  57585. /**
  57586. * Start trailing mesh.
  57587. */
  57588. start(): void;
  57589. /**
  57590. * Stop trailing mesh.
  57591. */
  57592. stop(): void;
  57593. /**
  57594. * Update trailing mesh geometry.
  57595. */
  57596. update(): void;
  57597. /**
  57598. * Returns a new TrailMesh object.
  57599. * @param name is a string, the name given to the new mesh
  57600. * @param newGenerator use new generator object for cloned trail mesh
  57601. * @returns a new mesh
  57602. */
  57603. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57604. /**
  57605. * Serializes this trail mesh
  57606. * @param serializationObject object to write serialization to
  57607. */
  57608. serialize(serializationObject: any): void;
  57609. /**
  57610. * Parses a serialized trail mesh
  57611. * @param parsedMesh the serialized mesh
  57612. * @param scene the scene to create the trail mesh in
  57613. * @returns the created trail mesh
  57614. */
  57615. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57616. }
  57617. }
  57618. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57619. import { Nullable } from "babylonjs/types";
  57620. import { Scene } from "babylonjs/scene";
  57621. import { Vector4 } from "babylonjs/Maths/math.vector";
  57622. import { Color4 } from "babylonjs/Maths/math.color";
  57623. import { Mesh } from "babylonjs/Meshes/mesh";
  57624. /**
  57625. * Class containing static functions to help procedurally build meshes
  57626. */
  57627. export class TiledBoxBuilder {
  57628. /**
  57629. * Creates a box mesh
  57630. * 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)
  57631. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57633. * * 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
  57634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57635. * @param name defines the name of the mesh
  57636. * @param options defines the options used to create the mesh
  57637. * @param scene defines the hosting scene
  57638. * @returns the box mesh
  57639. */
  57640. static CreateTiledBox(name: string, options: {
  57641. pattern?: number;
  57642. width?: number;
  57643. height?: number;
  57644. depth?: number;
  57645. tileSize?: number;
  57646. tileWidth?: number;
  57647. tileHeight?: number;
  57648. alignHorizontal?: number;
  57649. alignVertical?: number;
  57650. faceUV?: Vector4[];
  57651. faceColors?: Color4[];
  57652. sideOrientation?: number;
  57653. updatable?: boolean;
  57654. }, scene?: Nullable<Scene>): Mesh;
  57655. }
  57656. }
  57657. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57658. import { Vector4 } from "babylonjs/Maths/math.vector";
  57659. import { Mesh } from "babylonjs/Meshes/mesh";
  57660. /**
  57661. * Class containing static functions to help procedurally build meshes
  57662. */
  57663. export class TorusKnotBuilder {
  57664. /**
  57665. * Creates a torus knot mesh
  57666. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57667. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57668. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57669. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57671. * * 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
  57672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57673. * @param name defines the name of the mesh
  57674. * @param options defines the options used to create the mesh
  57675. * @param scene defines the hosting scene
  57676. * @returns the torus knot mesh
  57677. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57678. */
  57679. static CreateTorusKnot(name: string, options: {
  57680. radius?: number;
  57681. tube?: number;
  57682. radialSegments?: number;
  57683. tubularSegments?: number;
  57684. p?: number;
  57685. q?: number;
  57686. updatable?: boolean;
  57687. sideOrientation?: number;
  57688. frontUVs?: Vector4;
  57689. backUVs?: Vector4;
  57690. }, scene: any): Mesh;
  57691. }
  57692. }
  57693. declare module "babylonjs/Meshes/polygonMesh" {
  57694. import { Scene } from "babylonjs/scene";
  57695. import { Vector2 } from "babylonjs/Maths/math.vector";
  57696. import { Mesh } from "babylonjs/Meshes/mesh";
  57697. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57698. import { Path2 } from "babylonjs/Maths/math.path";
  57699. /**
  57700. * Polygon
  57701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57702. */
  57703. export class Polygon {
  57704. /**
  57705. * Creates a rectangle
  57706. * @param xmin bottom X coord
  57707. * @param ymin bottom Y coord
  57708. * @param xmax top X coord
  57709. * @param ymax top Y coord
  57710. * @returns points that make the resulting rectation
  57711. */
  57712. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57713. /**
  57714. * Creates a circle
  57715. * @param radius radius of circle
  57716. * @param cx scale in x
  57717. * @param cy scale in y
  57718. * @param numberOfSides number of sides that make up the circle
  57719. * @returns points that make the resulting circle
  57720. */
  57721. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57722. /**
  57723. * Creates a polygon from input string
  57724. * @param input Input polygon data
  57725. * @returns the parsed points
  57726. */
  57727. static Parse(input: string): Vector2[];
  57728. /**
  57729. * Starts building a polygon from x and y coordinates
  57730. * @param x x coordinate
  57731. * @param y y coordinate
  57732. * @returns the started path2
  57733. */
  57734. static StartingAt(x: number, y: number): Path2;
  57735. }
  57736. /**
  57737. * Builds a polygon
  57738. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57739. */
  57740. export class PolygonMeshBuilder {
  57741. private _points;
  57742. private _outlinepoints;
  57743. private _holes;
  57744. private _name;
  57745. private _scene;
  57746. private _epoints;
  57747. private _eholes;
  57748. private _addToepoint;
  57749. /**
  57750. * Babylon reference to the earcut plugin.
  57751. */
  57752. bjsEarcut: any;
  57753. /**
  57754. * Creates a PolygonMeshBuilder
  57755. * @param name name of the builder
  57756. * @param contours Path of the polygon
  57757. * @param scene scene to add to when creating the mesh
  57758. * @param earcutInjection can be used to inject your own earcut reference
  57759. */
  57760. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57761. /**
  57762. * Adds a whole within the polygon
  57763. * @param hole Array of points defining the hole
  57764. * @returns this
  57765. */
  57766. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57767. /**
  57768. * Creates the polygon
  57769. * @param updatable If the mesh should be updatable
  57770. * @param depth The depth of the mesh created
  57771. * @returns the created mesh
  57772. */
  57773. build(updatable?: boolean, depth?: number): Mesh;
  57774. /**
  57775. * Creates the polygon
  57776. * @param depth The depth of the mesh created
  57777. * @returns the created VertexData
  57778. */
  57779. buildVertexData(depth?: number): VertexData;
  57780. /**
  57781. * Adds a side to the polygon
  57782. * @param positions points that make the polygon
  57783. * @param normals normals of the polygon
  57784. * @param uvs uvs of the polygon
  57785. * @param indices indices of the polygon
  57786. * @param bounds bounds of the polygon
  57787. * @param points points of the polygon
  57788. * @param depth depth of the polygon
  57789. * @param flip flip of the polygon
  57790. */
  57791. private addSide;
  57792. }
  57793. }
  57794. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57795. import { Scene } from "babylonjs/scene";
  57796. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57797. import { Color4 } from "babylonjs/Maths/math.color";
  57798. import { Mesh } from "babylonjs/Meshes/mesh";
  57799. import { Nullable } from "babylonjs/types";
  57800. /**
  57801. * Class containing static functions to help procedurally build meshes
  57802. */
  57803. export class PolygonBuilder {
  57804. /**
  57805. * Creates a polygon mesh
  57806. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57807. * * 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
  57808. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57810. * * 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)
  57811. * * Remember you can only change the shape positions, not their number when updating a polygon
  57812. * @param name defines the name of the mesh
  57813. * @param options defines the options used to create the mesh
  57814. * @param scene defines the hosting scene
  57815. * @param earcutInjection can be used to inject your own earcut reference
  57816. * @returns the polygon mesh
  57817. */
  57818. static CreatePolygon(name: string, options: {
  57819. shape: Vector3[];
  57820. holes?: Vector3[][];
  57821. depth?: number;
  57822. faceUV?: Vector4[];
  57823. faceColors?: Color4[];
  57824. updatable?: boolean;
  57825. sideOrientation?: number;
  57826. frontUVs?: Vector4;
  57827. backUVs?: Vector4;
  57828. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57829. /**
  57830. * Creates an extruded polygon mesh, with depth in the Y direction.
  57831. * * 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)
  57832. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57833. * @param name defines the name of the mesh
  57834. * @param options defines the options used to create the mesh
  57835. * @param scene defines the hosting scene
  57836. * @param earcutInjection can be used to inject your own earcut reference
  57837. * @returns the polygon mesh
  57838. */
  57839. static ExtrudePolygon(name: string, options: {
  57840. shape: Vector3[];
  57841. holes?: Vector3[][];
  57842. depth?: number;
  57843. faceUV?: Vector4[];
  57844. faceColors?: Color4[];
  57845. updatable?: boolean;
  57846. sideOrientation?: number;
  57847. frontUVs?: Vector4;
  57848. backUVs?: Vector4;
  57849. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57850. }
  57851. }
  57852. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  57853. import { Scene } from "babylonjs/scene";
  57854. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57855. import { Mesh } from "babylonjs/Meshes/mesh";
  57856. import { Nullable } from "babylonjs/types";
  57857. /**
  57858. * Class containing static functions to help procedurally build meshes
  57859. */
  57860. export class LatheBuilder {
  57861. /**
  57862. * Creates lathe mesh.
  57863. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57864. * * 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
  57865. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57866. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57867. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57868. * * 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
  57869. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57870. * * 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
  57871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57872. * * 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
  57873. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57875. * @param name defines the name of the mesh
  57876. * @param options defines the options used to create the mesh
  57877. * @param scene defines the hosting scene
  57878. * @returns the lathe mesh
  57879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57880. */
  57881. static CreateLathe(name: string, options: {
  57882. shape: Vector3[];
  57883. radius?: number;
  57884. tessellation?: number;
  57885. clip?: number;
  57886. arc?: number;
  57887. closed?: boolean;
  57888. updatable?: boolean;
  57889. sideOrientation?: number;
  57890. frontUVs?: Vector4;
  57891. backUVs?: Vector4;
  57892. cap?: number;
  57893. invertUV?: boolean;
  57894. }, scene?: Nullable<Scene>): Mesh;
  57895. }
  57896. }
  57897. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  57898. import { Nullable } from "babylonjs/types";
  57899. import { Scene } from "babylonjs/scene";
  57900. import { Vector4 } from "babylonjs/Maths/math.vector";
  57901. import { Mesh } from "babylonjs/Meshes/mesh";
  57902. /**
  57903. * Class containing static functions to help procedurally build meshes
  57904. */
  57905. export class TiledPlaneBuilder {
  57906. /**
  57907. * Creates a tiled plane mesh
  57908. * * The parameter `pattern` will, depending on value, do nothing or
  57909. * * * flip (reflect about central vertical) alternate tiles across and up
  57910. * * * flip every tile on alternate rows
  57911. * * * rotate (180 degs) alternate tiles across and up
  57912. * * * rotate every tile on alternate rows
  57913. * * * flip and rotate alternate tiles across and up
  57914. * * * flip and rotate every tile on alternate rows
  57915. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  57916. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  57917. * * 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
  57918. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57919. * * 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)
  57920. * * 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)
  57921. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57922. * @param name defines the name of the mesh
  57923. * @param options defines the options used to create the mesh
  57924. * @param scene defines the hosting scene
  57925. * @returns the box mesh
  57926. */
  57927. static CreateTiledPlane(name: string, options: {
  57928. pattern?: number;
  57929. tileSize?: number;
  57930. tileWidth?: number;
  57931. tileHeight?: number;
  57932. size?: number;
  57933. width?: number;
  57934. height?: number;
  57935. alignHorizontal?: number;
  57936. alignVertical?: number;
  57937. sideOrientation?: number;
  57938. frontUVs?: Vector4;
  57939. backUVs?: Vector4;
  57940. updatable?: boolean;
  57941. }, scene?: Nullable<Scene>): Mesh;
  57942. }
  57943. }
  57944. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  57945. import { Nullable } from "babylonjs/types";
  57946. import { Scene } from "babylonjs/scene";
  57947. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57948. import { Mesh } from "babylonjs/Meshes/mesh";
  57949. /**
  57950. * Class containing static functions to help procedurally build meshes
  57951. */
  57952. export class TubeBuilder {
  57953. /**
  57954. * Creates a tube mesh.
  57955. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57956. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57957. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57958. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57959. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57960. * * 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)
  57961. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57962. * * 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
  57963. * * 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
  57964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57965. * * 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
  57966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57968. * @param name defines the name of the mesh
  57969. * @param options defines the options used to create the mesh
  57970. * @param scene defines the hosting scene
  57971. * @returns the tube mesh
  57972. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57973. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57974. */
  57975. static CreateTube(name: string, options: {
  57976. path: Vector3[];
  57977. radius?: number;
  57978. tessellation?: number;
  57979. radiusFunction?: {
  57980. (i: number, distance: number): number;
  57981. };
  57982. cap?: number;
  57983. arc?: number;
  57984. updatable?: boolean;
  57985. sideOrientation?: number;
  57986. frontUVs?: Vector4;
  57987. backUVs?: Vector4;
  57988. instance?: Mesh;
  57989. invertUV?: boolean;
  57990. }, scene?: Nullable<Scene>): Mesh;
  57991. }
  57992. }
  57993. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  57994. import { Scene } from "babylonjs/scene";
  57995. import { Vector4 } from "babylonjs/Maths/math.vector";
  57996. import { Mesh } from "babylonjs/Meshes/mesh";
  57997. import { Nullable } from "babylonjs/types";
  57998. /**
  57999. * Class containing static functions to help procedurally build meshes
  58000. */
  58001. export class IcoSphereBuilder {
  58002. /**
  58003. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58004. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58005. * * 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`)
  58006. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58007. * * 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
  58008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58009. * * 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
  58010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58011. * @param name defines the name of the mesh
  58012. * @param options defines the options used to create the mesh
  58013. * @param scene defines the hosting scene
  58014. * @returns the icosahedron mesh
  58015. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58016. */
  58017. static CreateIcoSphere(name: string, options: {
  58018. radius?: number;
  58019. radiusX?: number;
  58020. radiusY?: number;
  58021. radiusZ?: number;
  58022. flat?: boolean;
  58023. subdivisions?: number;
  58024. sideOrientation?: number;
  58025. frontUVs?: Vector4;
  58026. backUVs?: Vector4;
  58027. updatable?: boolean;
  58028. }, scene?: Nullable<Scene>): Mesh;
  58029. }
  58030. }
  58031. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58032. import { Vector3 } from "babylonjs/Maths/math.vector";
  58033. import { Mesh } from "babylonjs/Meshes/mesh";
  58034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58035. /**
  58036. * Class containing static functions to help procedurally build meshes
  58037. */
  58038. export class DecalBuilder {
  58039. /**
  58040. * Creates a decal mesh.
  58041. * 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
  58042. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58043. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58044. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58045. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58046. * @param name defines the name of the mesh
  58047. * @param sourceMesh defines the mesh where the decal must be applied
  58048. * @param options defines the options used to create the mesh
  58049. * @param scene defines the hosting scene
  58050. * @returns the decal mesh
  58051. * @see https://doc.babylonjs.com/how_to/decals
  58052. */
  58053. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58054. position?: Vector3;
  58055. normal?: Vector3;
  58056. size?: Vector3;
  58057. angle?: number;
  58058. }): Mesh;
  58059. }
  58060. }
  58061. declare module "babylonjs/Meshes/meshBuilder" {
  58062. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58063. import { Nullable } from "babylonjs/types";
  58064. import { Scene } from "babylonjs/scene";
  58065. import { Mesh } from "babylonjs/Meshes/mesh";
  58066. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58067. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58069. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58070. import { Plane } from "babylonjs/Maths/math.plane";
  58071. /**
  58072. * Class containing static functions to help procedurally build meshes
  58073. */
  58074. export class MeshBuilder {
  58075. /**
  58076. * Creates a box mesh
  58077. * * The parameter `size` sets the size (float) of each box side (default 1)
  58078. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58079. * * 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)
  58080. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58082. * * 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
  58083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58084. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58085. * @param name defines the name of the mesh
  58086. * @param options defines the options used to create the mesh
  58087. * @param scene defines the hosting scene
  58088. * @returns the box mesh
  58089. */
  58090. static CreateBox(name: string, options: {
  58091. size?: number;
  58092. width?: number;
  58093. height?: number;
  58094. depth?: number;
  58095. faceUV?: Vector4[];
  58096. faceColors?: Color4[];
  58097. sideOrientation?: number;
  58098. frontUVs?: Vector4;
  58099. backUVs?: Vector4;
  58100. updatable?: boolean;
  58101. }, scene?: Nullable<Scene>): Mesh;
  58102. /**
  58103. * Creates a tiled box mesh
  58104. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58106. * @param name defines the name of the mesh
  58107. * @param options defines the options used to create the mesh
  58108. * @param scene defines the hosting scene
  58109. * @returns the tiled box mesh
  58110. */
  58111. static CreateTiledBox(name: string, options: {
  58112. pattern?: number;
  58113. size?: number;
  58114. width?: number;
  58115. height?: number;
  58116. depth: number;
  58117. tileSize?: number;
  58118. tileWidth?: number;
  58119. tileHeight?: number;
  58120. faceUV?: Vector4[];
  58121. faceColors?: Color4[];
  58122. alignHorizontal?: number;
  58123. alignVertical?: number;
  58124. sideOrientation?: number;
  58125. updatable?: boolean;
  58126. }, scene?: Nullable<Scene>): Mesh;
  58127. /**
  58128. * Creates a sphere mesh
  58129. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58130. * * 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`)
  58131. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58132. * * 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
  58133. * * 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)
  58134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58135. * * 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
  58136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58137. * @param name defines the name of the mesh
  58138. * @param options defines the options used to create the mesh
  58139. * @param scene defines the hosting scene
  58140. * @returns the sphere mesh
  58141. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58142. */
  58143. static CreateSphere(name: string, options: {
  58144. segments?: number;
  58145. diameter?: number;
  58146. diameterX?: number;
  58147. diameterY?: number;
  58148. diameterZ?: number;
  58149. arc?: number;
  58150. slice?: number;
  58151. sideOrientation?: number;
  58152. frontUVs?: Vector4;
  58153. backUVs?: Vector4;
  58154. updatable?: boolean;
  58155. }, scene?: Nullable<Scene>): Mesh;
  58156. /**
  58157. * Creates a plane polygonal mesh. By default, this is a disc
  58158. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58159. * * 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
  58160. * * 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
  58161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58162. * * 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
  58163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58164. * @param name defines the name of the mesh
  58165. * @param options defines the options used to create the mesh
  58166. * @param scene defines the hosting scene
  58167. * @returns the plane polygonal mesh
  58168. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58169. */
  58170. static CreateDisc(name: string, options: {
  58171. radius?: number;
  58172. tessellation?: number;
  58173. arc?: number;
  58174. updatable?: boolean;
  58175. sideOrientation?: number;
  58176. frontUVs?: Vector4;
  58177. backUVs?: Vector4;
  58178. }, scene?: Nullable<Scene>): Mesh;
  58179. /**
  58180. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58181. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58182. * * 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`)
  58183. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58184. * * 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
  58185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58186. * * 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
  58187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58188. * @param name defines the name of the mesh
  58189. * @param options defines the options used to create the mesh
  58190. * @param scene defines the hosting scene
  58191. * @returns the icosahedron mesh
  58192. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58193. */
  58194. static CreateIcoSphere(name: string, options: {
  58195. radius?: number;
  58196. radiusX?: number;
  58197. radiusY?: number;
  58198. radiusZ?: number;
  58199. flat?: boolean;
  58200. subdivisions?: number;
  58201. sideOrientation?: number;
  58202. frontUVs?: Vector4;
  58203. backUVs?: Vector4;
  58204. updatable?: boolean;
  58205. }, scene?: Nullable<Scene>): Mesh;
  58206. /**
  58207. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58208. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58209. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58210. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58211. * * 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
  58212. * * 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
  58213. * * 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
  58214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58215. * * 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
  58216. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58217. * * 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
  58218. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58219. * * 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
  58220. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58222. * @param name defines the name of the mesh
  58223. * @param options defines the options used to create the mesh
  58224. * @param scene defines the hosting scene
  58225. * @returns the ribbon mesh
  58226. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58227. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58228. */
  58229. static CreateRibbon(name: string, options: {
  58230. pathArray: Vector3[][];
  58231. closeArray?: boolean;
  58232. closePath?: boolean;
  58233. offset?: number;
  58234. updatable?: boolean;
  58235. sideOrientation?: number;
  58236. frontUVs?: Vector4;
  58237. backUVs?: Vector4;
  58238. instance?: Mesh;
  58239. invertUV?: boolean;
  58240. uvs?: Vector2[];
  58241. colors?: Color4[];
  58242. }, scene?: Nullable<Scene>): Mesh;
  58243. /**
  58244. * Creates a cylinder or a cone mesh
  58245. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58246. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58247. * * 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.
  58248. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58249. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58250. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58251. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58252. * * 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).
  58253. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58254. * * 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).
  58255. * * 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
  58256. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58257. * * 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
  58258. * * 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.
  58259. * * If `enclose` is false, a ring surface is one element.
  58260. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58261. * * 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
  58262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58263. * * 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
  58264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58265. * @param name defines the name of the mesh
  58266. * @param options defines the options used to create the mesh
  58267. * @param scene defines the hosting scene
  58268. * @returns the cylinder mesh
  58269. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58270. */
  58271. static CreateCylinder(name: string, options: {
  58272. height?: number;
  58273. diameterTop?: number;
  58274. diameterBottom?: number;
  58275. diameter?: number;
  58276. tessellation?: number;
  58277. subdivisions?: number;
  58278. arc?: number;
  58279. faceColors?: Color4[];
  58280. faceUV?: Vector4[];
  58281. updatable?: boolean;
  58282. hasRings?: boolean;
  58283. enclose?: boolean;
  58284. cap?: number;
  58285. sideOrientation?: number;
  58286. frontUVs?: Vector4;
  58287. backUVs?: Vector4;
  58288. }, scene?: Nullable<Scene>): Mesh;
  58289. /**
  58290. * Creates a torus mesh
  58291. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58292. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58293. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58295. * * 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
  58296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58297. * @param name defines the name of the mesh
  58298. * @param options defines the options used to create the mesh
  58299. * @param scene defines the hosting scene
  58300. * @returns the torus mesh
  58301. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58302. */
  58303. static CreateTorus(name: string, options: {
  58304. diameter?: number;
  58305. thickness?: number;
  58306. tessellation?: number;
  58307. updatable?: boolean;
  58308. sideOrientation?: number;
  58309. frontUVs?: Vector4;
  58310. backUVs?: Vector4;
  58311. }, scene?: Nullable<Scene>): Mesh;
  58312. /**
  58313. * Creates a torus knot mesh
  58314. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58315. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58316. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58317. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58319. * * 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
  58320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58321. * @param name defines the name of the mesh
  58322. * @param options defines the options used to create the mesh
  58323. * @param scene defines the hosting scene
  58324. * @returns the torus knot mesh
  58325. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58326. */
  58327. static CreateTorusKnot(name: string, options: {
  58328. radius?: number;
  58329. tube?: number;
  58330. radialSegments?: number;
  58331. tubularSegments?: number;
  58332. p?: number;
  58333. q?: number;
  58334. updatable?: boolean;
  58335. sideOrientation?: number;
  58336. frontUVs?: Vector4;
  58337. backUVs?: Vector4;
  58338. }, scene?: Nullable<Scene>): Mesh;
  58339. /**
  58340. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58341. * * 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
  58342. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58343. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58344. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58345. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58346. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58347. * * 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
  58348. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58350. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58351. * @param name defines the name of the new line system
  58352. * @param options defines the options used to create the line system
  58353. * @param scene defines the hosting scene
  58354. * @returns a new line system mesh
  58355. */
  58356. static CreateLineSystem(name: string, options: {
  58357. lines: Vector3[][];
  58358. updatable?: boolean;
  58359. instance?: Nullable<LinesMesh>;
  58360. colors?: Nullable<Color4[][]>;
  58361. useVertexAlpha?: boolean;
  58362. }, scene: Nullable<Scene>): LinesMesh;
  58363. /**
  58364. * Creates a line mesh
  58365. * 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
  58366. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58367. * * The parameter `points` is an array successive Vector3
  58368. * * 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
  58369. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58370. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58371. * * When updating an instance, remember that only point positions can change, not the number of points
  58372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58374. * @param name defines the name of the new line system
  58375. * @param options defines the options used to create the line system
  58376. * @param scene defines the hosting scene
  58377. * @returns a new line mesh
  58378. */
  58379. static CreateLines(name: string, options: {
  58380. points: Vector3[];
  58381. updatable?: boolean;
  58382. instance?: Nullable<LinesMesh>;
  58383. colors?: Color4[];
  58384. useVertexAlpha?: boolean;
  58385. }, scene?: Nullable<Scene>): LinesMesh;
  58386. /**
  58387. * Creates a dashed line mesh
  58388. * * 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
  58389. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58390. * * The parameter `points` is an array successive Vector3
  58391. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58392. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58393. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58394. * * 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
  58395. * * When updating an instance, remember that only point positions can change, not the number of points
  58396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58397. * @param name defines the name of the mesh
  58398. * @param options defines the options used to create the mesh
  58399. * @param scene defines the hosting scene
  58400. * @returns the dashed line mesh
  58401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58402. */
  58403. static CreateDashedLines(name: string, options: {
  58404. points: Vector3[];
  58405. dashSize?: number;
  58406. gapSize?: number;
  58407. dashNb?: number;
  58408. updatable?: boolean;
  58409. instance?: LinesMesh;
  58410. }, scene?: Nullable<Scene>): LinesMesh;
  58411. /**
  58412. * 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.
  58413. * * 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.
  58414. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58415. * * 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.
  58416. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58417. * * 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
  58418. * * 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
  58419. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58421. * * 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
  58422. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58424. * @param name defines the name of the mesh
  58425. * @param options defines the options used to create the mesh
  58426. * @param scene defines the hosting scene
  58427. * @returns the extruded shape mesh
  58428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58430. */
  58431. static ExtrudeShape(name: string, options: {
  58432. shape: Vector3[];
  58433. path: Vector3[];
  58434. scale?: number;
  58435. rotation?: number;
  58436. cap?: number;
  58437. updatable?: boolean;
  58438. sideOrientation?: number;
  58439. frontUVs?: Vector4;
  58440. backUVs?: Vector4;
  58441. instance?: Mesh;
  58442. invertUV?: boolean;
  58443. }, scene?: Nullable<Scene>): Mesh;
  58444. /**
  58445. * Creates an custom extruded shape mesh.
  58446. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58447. * * 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.
  58448. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58449. * * 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
  58450. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58451. * * 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
  58452. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58453. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58454. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58455. * * 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
  58456. * * 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
  58457. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58459. * * 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
  58460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58462. * @param name defines the name of the mesh
  58463. * @param options defines the options used to create the mesh
  58464. * @param scene defines the hosting scene
  58465. * @returns the custom extruded shape mesh
  58466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58469. */
  58470. static ExtrudeShapeCustom(name: string, options: {
  58471. shape: Vector3[];
  58472. path: Vector3[];
  58473. scaleFunction?: any;
  58474. rotationFunction?: any;
  58475. ribbonCloseArray?: boolean;
  58476. ribbonClosePath?: boolean;
  58477. cap?: number;
  58478. updatable?: boolean;
  58479. sideOrientation?: number;
  58480. frontUVs?: Vector4;
  58481. backUVs?: Vector4;
  58482. instance?: Mesh;
  58483. invertUV?: boolean;
  58484. }, scene?: Nullable<Scene>): Mesh;
  58485. /**
  58486. * Creates lathe mesh.
  58487. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58488. * * 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
  58489. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58490. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58491. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58492. * * 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
  58493. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58494. * * 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
  58495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58496. * * 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
  58497. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58499. * @param name defines the name of the mesh
  58500. * @param options defines the options used to create the mesh
  58501. * @param scene defines the hosting scene
  58502. * @returns the lathe mesh
  58503. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58504. */
  58505. static CreateLathe(name: string, options: {
  58506. shape: Vector3[];
  58507. radius?: number;
  58508. tessellation?: number;
  58509. clip?: number;
  58510. arc?: number;
  58511. closed?: boolean;
  58512. updatable?: boolean;
  58513. sideOrientation?: number;
  58514. frontUVs?: Vector4;
  58515. backUVs?: Vector4;
  58516. cap?: number;
  58517. invertUV?: boolean;
  58518. }, scene?: Nullable<Scene>): Mesh;
  58519. /**
  58520. * Creates a tiled plane mesh
  58521. * * You can set a limited pattern arrangement with the tiles
  58522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58523. * * 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
  58524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58525. * @param name defines the name of the mesh
  58526. * @param options defines the options used to create the mesh
  58527. * @param scene defines the hosting scene
  58528. * @returns the plane mesh
  58529. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58530. */
  58531. static CreateTiledPlane(name: string, options: {
  58532. pattern?: number;
  58533. tileSize?: number;
  58534. tileWidth?: number;
  58535. tileHeight?: number;
  58536. size?: number;
  58537. width?: number;
  58538. height?: number;
  58539. alignHorizontal?: number;
  58540. alignVertical?: number;
  58541. sideOrientation?: number;
  58542. frontUVs?: Vector4;
  58543. backUVs?: Vector4;
  58544. updatable?: boolean;
  58545. }, scene?: Nullable<Scene>): Mesh;
  58546. /**
  58547. * Creates a plane mesh
  58548. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58549. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58550. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58552. * * 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
  58553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58554. * @param name defines the name of the mesh
  58555. * @param options defines the options used to create the mesh
  58556. * @param scene defines the hosting scene
  58557. * @returns the plane mesh
  58558. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58559. */
  58560. static CreatePlane(name: string, options: {
  58561. size?: number;
  58562. width?: number;
  58563. height?: number;
  58564. sideOrientation?: number;
  58565. frontUVs?: Vector4;
  58566. backUVs?: Vector4;
  58567. updatable?: boolean;
  58568. sourcePlane?: Plane;
  58569. }, scene?: Nullable<Scene>): Mesh;
  58570. /**
  58571. * Creates a ground mesh
  58572. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58573. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58575. * @param name defines the name of the mesh
  58576. * @param options defines the options used to create the mesh
  58577. * @param scene defines the hosting scene
  58578. * @returns the ground mesh
  58579. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58580. */
  58581. static CreateGround(name: string, options: {
  58582. width?: number;
  58583. height?: number;
  58584. subdivisions?: number;
  58585. subdivisionsX?: number;
  58586. subdivisionsY?: number;
  58587. updatable?: boolean;
  58588. }, scene?: Nullable<Scene>): Mesh;
  58589. /**
  58590. * Creates a tiled ground mesh
  58591. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58592. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58593. * * 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
  58594. * * 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
  58595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58596. * @param name defines the name of the mesh
  58597. * @param options defines the options used to create the mesh
  58598. * @param scene defines the hosting scene
  58599. * @returns the tiled ground mesh
  58600. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58601. */
  58602. static CreateTiledGround(name: string, options: {
  58603. xmin: number;
  58604. zmin: number;
  58605. xmax: number;
  58606. zmax: number;
  58607. subdivisions?: {
  58608. w: number;
  58609. h: number;
  58610. };
  58611. precision?: {
  58612. w: number;
  58613. h: number;
  58614. };
  58615. updatable?: boolean;
  58616. }, scene?: Nullable<Scene>): Mesh;
  58617. /**
  58618. * Creates a ground mesh from a height map
  58619. * * The parameter `url` sets the URL of the height map image resource.
  58620. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58621. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58622. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58623. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58624. * * 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.
  58625. * * 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).
  58626. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58628. * @param name defines the name of the mesh
  58629. * @param url defines the url to the height map
  58630. * @param options defines the options used to create the mesh
  58631. * @param scene defines the hosting scene
  58632. * @returns the ground mesh
  58633. * @see https://doc.babylonjs.com/babylon101/height_map
  58634. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58635. */
  58636. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58637. width?: number;
  58638. height?: number;
  58639. subdivisions?: number;
  58640. minHeight?: number;
  58641. maxHeight?: number;
  58642. colorFilter?: Color3;
  58643. alphaFilter?: number;
  58644. updatable?: boolean;
  58645. onReady?: (mesh: GroundMesh) => void;
  58646. }, scene?: Nullable<Scene>): GroundMesh;
  58647. /**
  58648. * Creates a polygon mesh
  58649. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58650. * * 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
  58651. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58653. * * 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)
  58654. * * Remember you can only change the shape positions, not their number when updating a polygon
  58655. * @param name defines the name of the mesh
  58656. * @param options defines the options used to create the mesh
  58657. * @param scene defines the hosting scene
  58658. * @param earcutInjection can be used to inject your own earcut reference
  58659. * @returns the polygon mesh
  58660. */
  58661. static CreatePolygon(name: string, options: {
  58662. shape: Vector3[];
  58663. holes?: Vector3[][];
  58664. depth?: number;
  58665. faceUV?: Vector4[];
  58666. faceColors?: Color4[];
  58667. updatable?: boolean;
  58668. sideOrientation?: number;
  58669. frontUVs?: Vector4;
  58670. backUVs?: Vector4;
  58671. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58672. /**
  58673. * Creates an extruded polygon mesh, with depth in the Y direction.
  58674. * * 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)
  58675. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58676. * @param name defines the name of the mesh
  58677. * @param options defines the options used to create the mesh
  58678. * @param scene defines the hosting scene
  58679. * @param earcutInjection can be used to inject your own earcut reference
  58680. * @returns the polygon mesh
  58681. */
  58682. static ExtrudePolygon(name: string, options: {
  58683. shape: Vector3[];
  58684. holes?: Vector3[][];
  58685. depth?: number;
  58686. faceUV?: Vector4[];
  58687. faceColors?: Color4[];
  58688. updatable?: boolean;
  58689. sideOrientation?: number;
  58690. frontUVs?: Vector4;
  58691. backUVs?: Vector4;
  58692. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58693. /**
  58694. * Creates a tube mesh.
  58695. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58696. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58697. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58698. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58699. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58700. * * 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)
  58701. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58702. * * 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
  58703. * * 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
  58704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58705. * * 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
  58706. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58708. * @param name defines the name of the mesh
  58709. * @param options defines the options used to create the mesh
  58710. * @param scene defines the hosting scene
  58711. * @returns the tube mesh
  58712. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58713. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58714. */
  58715. static CreateTube(name: string, options: {
  58716. path: Vector3[];
  58717. radius?: number;
  58718. tessellation?: number;
  58719. radiusFunction?: {
  58720. (i: number, distance: number): number;
  58721. };
  58722. cap?: number;
  58723. arc?: number;
  58724. updatable?: boolean;
  58725. sideOrientation?: number;
  58726. frontUVs?: Vector4;
  58727. backUVs?: Vector4;
  58728. instance?: Mesh;
  58729. invertUV?: boolean;
  58730. }, scene?: Nullable<Scene>): Mesh;
  58731. /**
  58732. * Creates a polyhedron mesh
  58733. * * 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
  58734. * * The parameter `size` (positive float, default 1) sets the polygon size
  58735. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58736. * * 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`
  58737. * * 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
  58738. * * 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)`)
  58739. * * 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
  58740. * * 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
  58741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58742. * * 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
  58743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58744. * @param name defines the name of the mesh
  58745. * @param options defines the options used to create the mesh
  58746. * @param scene defines the hosting scene
  58747. * @returns the polyhedron mesh
  58748. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58749. */
  58750. static CreatePolyhedron(name: string, options: {
  58751. type?: number;
  58752. size?: number;
  58753. sizeX?: number;
  58754. sizeY?: number;
  58755. sizeZ?: number;
  58756. custom?: any;
  58757. faceUV?: Vector4[];
  58758. faceColors?: Color4[];
  58759. flat?: boolean;
  58760. updatable?: boolean;
  58761. sideOrientation?: number;
  58762. frontUVs?: Vector4;
  58763. backUVs?: Vector4;
  58764. }, scene?: Nullable<Scene>): Mesh;
  58765. /**
  58766. * Creates a decal mesh.
  58767. * 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
  58768. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58769. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58770. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58771. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58772. * @param name defines the name of the mesh
  58773. * @param sourceMesh defines the mesh where the decal must be applied
  58774. * @param options defines the options used to create the mesh
  58775. * @param scene defines the hosting scene
  58776. * @returns the decal mesh
  58777. * @see https://doc.babylonjs.com/how_to/decals
  58778. */
  58779. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58780. position?: Vector3;
  58781. normal?: Vector3;
  58782. size?: Vector3;
  58783. angle?: number;
  58784. }): Mesh;
  58785. }
  58786. }
  58787. declare module "babylonjs/Meshes/meshSimplification" {
  58788. import { Mesh } from "babylonjs/Meshes/mesh";
  58789. /**
  58790. * A simplifier interface for future simplification implementations
  58791. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58792. */
  58793. export interface ISimplifier {
  58794. /**
  58795. * Simplification of a given mesh according to the given settings.
  58796. * Since this requires computation, it is assumed that the function runs async.
  58797. * @param settings The settings of the simplification, including quality and distance
  58798. * @param successCallback A callback that will be called after the mesh was simplified.
  58799. * @param errorCallback in case of an error, this callback will be called. optional.
  58800. */
  58801. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58802. }
  58803. /**
  58804. * Expected simplification settings.
  58805. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58806. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58807. */
  58808. export interface ISimplificationSettings {
  58809. /**
  58810. * Gets or sets the expected quality
  58811. */
  58812. quality: number;
  58813. /**
  58814. * Gets or sets the distance when this optimized version should be used
  58815. */
  58816. distance: number;
  58817. /**
  58818. * Gets an already optimized mesh
  58819. */
  58820. optimizeMesh?: boolean;
  58821. }
  58822. /**
  58823. * Class used to specify simplification options
  58824. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58825. */
  58826. export class SimplificationSettings implements ISimplificationSettings {
  58827. /** expected quality */
  58828. quality: number;
  58829. /** distance when this optimized version should be used */
  58830. distance: number;
  58831. /** already optimized mesh */
  58832. optimizeMesh?: boolean | undefined;
  58833. /**
  58834. * Creates a SimplificationSettings
  58835. * @param quality expected quality
  58836. * @param distance distance when this optimized version should be used
  58837. * @param optimizeMesh already optimized mesh
  58838. */
  58839. constructor(
  58840. /** expected quality */
  58841. quality: number,
  58842. /** distance when this optimized version should be used */
  58843. distance: number,
  58844. /** already optimized mesh */
  58845. optimizeMesh?: boolean | undefined);
  58846. }
  58847. /**
  58848. * Interface used to define a simplification task
  58849. */
  58850. export interface ISimplificationTask {
  58851. /**
  58852. * Array of settings
  58853. */
  58854. settings: Array<ISimplificationSettings>;
  58855. /**
  58856. * Simplification type
  58857. */
  58858. simplificationType: SimplificationType;
  58859. /**
  58860. * Mesh to simplify
  58861. */
  58862. mesh: Mesh;
  58863. /**
  58864. * Callback called on success
  58865. */
  58866. successCallback?: () => void;
  58867. /**
  58868. * Defines if parallel processing can be used
  58869. */
  58870. parallelProcessing: boolean;
  58871. }
  58872. /**
  58873. * Queue used to order the simplification tasks
  58874. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58875. */
  58876. export class SimplificationQueue {
  58877. private _simplificationArray;
  58878. /**
  58879. * Gets a boolean indicating that the process is still running
  58880. */
  58881. running: boolean;
  58882. /**
  58883. * Creates a new queue
  58884. */
  58885. constructor();
  58886. /**
  58887. * Adds a new simplification task
  58888. * @param task defines a task to add
  58889. */
  58890. addTask(task: ISimplificationTask): void;
  58891. /**
  58892. * Execute next task
  58893. */
  58894. executeNext(): void;
  58895. /**
  58896. * Execute a simplification task
  58897. * @param task defines the task to run
  58898. */
  58899. runSimplification(task: ISimplificationTask): void;
  58900. private getSimplifier;
  58901. }
  58902. /**
  58903. * The implemented types of simplification
  58904. * At the moment only Quadratic Error Decimation is implemented
  58905. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58906. */
  58907. export enum SimplificationType {
  58908. /** Quadratic error decimation */
  58909. QUADRATIC = 0
  58910. }
  58911. }
  58912. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  58913. import { Scene } from "babylonjs/scene";
  58914. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  58915. import { ISceneComponent } from "babylonjs/sceneComponent";
  58916. module "babylonjs/scene" {
  58917. interface Scene {
  58918. /** @hidden (Backing field) */
  58919. _simplificationQueue: SimplificationQueue;
  58920. /**
  58921. * Gets or sets the simplification queue attached to the scene
  58922. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58923. */
  58924. simplificationQueue: SimplificationQueue;
  58925. }
  58926. }
  58927. module "babylonjs/Meshes/mesh" {
  58928. interface Mesh {
  58929. /**
  58930. * Simplify the mesh according to the given array of settings.
  58931. * Function will return immediately and will simplify async
  58932. * @param settings a collection of simplification settings
  58933. * @param parallelProcessing should all levels calculate parallel or one after the other
  58934. * @param simplificationType the type of simplification to run
  58935. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  58936. * @returns the current mesh
  58937. */
  58938. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  58939. }
  58940. }
  58941. /**
  58942. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  58943. * created in a scene
  58944. */
  58945. export class SimplicationQueueSceneComponent implements ISceneComponent {
  58946. /**
  58947. * The component name helpfull to identify the component in the list of scene components.
  58948. */
  58949. readonly name: string;
  58950. /**
  58951. * The scene the component belongs to.
  58952. */
  58953. scene: Scene;
  58954. /**
  58955. * Creates a new instance of the component for the given scene
  58956. * @param scene Defines the scene to register the component in
  58957. */
  58958. constructor(scene: Scene);
  58959. /**
  58960. * Registers the component in a given scene
  58961. */
  58962. register(): void;
  58963. /**
  58964. * Rebuilds the elements related to this component in case of
  58965. * context lost for instance.
  58966. */
  58967. rebuild(): void;
  58968. /**
  58969. * Disposes the component and the associated ressources
  58970. */
  58971. dispose(): void;
  58972. private _beforeCameraUpdate;
  58973. }
  58974. }
  58975. declare module "babylonjs/Meshes/Builders/index" {
  58976. export * from "babylonjs/Meshes/Builders/boxBuilder";
  58977. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  58978. export * from "babylonjs/Meshes/Builders/discBuilder";
  58979. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  58980. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  58981. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  58982. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  58983. export * from "babylonjs/Meshes/Builders/torusBuilder";
  58984. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  58985. export * from "babylonjs/Meshes/Builders/linesBuilder";
  58986. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  58987. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  58988. export * from "babylonjs/Meshes/Builders/latheBuilder";
  58989. export * from "babylonjs/Meshes/Builders/planeBuilder";
  58990. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  58991. export * from "babylonjs/Meshes/Builders/groundBuilder";
  58992. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  58993. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  58994. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  58995. export * from "babylonjs/Meshes/Builders/decalBuilder";
  58996. }
  58997. declare module "babylonjs/Meshes/index" {
  58998. export * from "babylonjs/Meshes/abstractMesh";
  58999. export * from "babylonjs/Meshes/buffer";
  59000. export * from "babylonjs/Meshes/Compression/index";
  59001. export * from "babylonjs/Meshes/csg";
  59002. export * from "babylonjs/Meshes/geometry";
  59003. export * from "babylonjs/Meshes/groundMesh";
  59004. export * from "babylonjs/Meshes/trailMesh";
  59005. export * from "babylonjs/Meshes/instancedMesh";
  59006. export * from "babylonjs/Meshes/linesMesh";
  59007. export * from "babylonjs/Meshes/mesh";
  59008. export * from "babylonjs/Meshes/mesh.vertexData";
  59009. export * from "babylonjs/Meshes/meshBuilder";
  59010. export * from "babylonjs/Meshes/meshSimplification";
  59011. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59012. export * from "babylonjs/Meshes/polygonMesh";
  59013. export * from "babylonjs/Meshes/subMesh";
  59014. export * from "babylonjs/Meshes/meshLODLevel";
  59015. export * from "babylonjs/Meshes/transformNode";
  59016. export * from "babylonjs/Meshes/Builders/index";
  59017. export * from "babylonjs/Meshes/dataBuffer";
  59018. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59019. }
  59020. declare module "babylonjs/Morph/index" {
  59021. export * from "babylonjs/Morph/morphTarget";
  59022. export * from "babylonjs/Morph/morphTargetManager";
  59023. }
  59024. declare module "babylonjs/Navigation/INavigationEngine" {
  59025. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59026. import { Vector3 } from "babylonjs/Maths/math";
  59027. import { Mesh } from "babylonjs/Meshes/mesh";
  59028. import { Scene } from "babylonjs/scene";
  59029. /**
  59030. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59031. */
  59032. export interface INavigationEnginePlugin {
  59033. /**
  59034. * plugin name
  59035. */
  59036. name: string;
  59037. /**
  59038. * Creates a navigation mesh
  59039. * @param meshes array of all the geometry used to compute the navigatio mesh
  59040. * @param parameters bunch of parameters used to filter geometry
  59041. */
  59042. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59043. /**
  59044. * Create a navigation mesh debug mesh
  59045. * @param scene is where the mesh will be added
  59046. * @returns debug display mesh
  59047. */
  59048. createDebugNavMesh(scene: Scene): Mesh;
  59049. /**
  59050. * Get a navigation mesh constrained position, closest to the parameter position
  59051. * @param position world position
  59052. * @returns the closest point to position constrained by the navigation mesh
  59053. */
  59054. getClosestPoint(position: Vector3): Vector3;
  59055. /**
  59056. * Get a navigation mesh constrained position, within a particular radius
  59057. * @param position world position
  59058. * @param maxRadius the maximum distance to the constrained world position
  59059. * @returns the closest point to position constrained by the navigation mesh
  59060. */
  59061. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59062. /**
  59063. * Compute the final position from a segment made of destination-position
  59064. * @param position world position
  59065. * @param destination world position
  59066. * @returns the resulting point along the navmesh
  59067. */
  59068. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59069. /**
  59070. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59071. * @param start world position
  59072. * @param end world position
  59073. * @returns array containing world position composing the path
  59074. */
  59075. computePath(start: Vector3, end: Vector3): Vector3[];
  59076. /**
  59077. * If this plugin is supported
  59078. * @returns true if plugin is supported
  59079. */
  59080. isSupported(): boolean;
  59081. /**
  59082. * Create a new Crowd so you can add agents
  59083. * @param maxAgents the maximum agent count in the crowd
  59084. * @param maxAgentRadius the maximum radius an agent can have
  59085. * @param scene to attach the crowd to
  59086. * @returns the crowd you can add agents to
  59087. */
  59088. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59089. /**
  59090. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59091. * The queries will try to find a solution within those bounds
  59092. * default is (1,1,1)
  59093. * @param extent x,y,z value that define the extent around the queries point of reference
  59094. */
  59095. setDefaultQueryExtent(extent: Vector3): void;
  59096. /**
  59097. * Get the Bounding box extent specified by setDefaultQueryExtent
  59098. * @returns the box extent values
  59099. */
  59100. getDefaultQueryExtent(): Vector3;
  59101. /**
  59102. * Release all resources
  59103. */
  59104. dispose(): void;
  59105. }
  59106. /**
  59107. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59108. */
  59109. export interface ICrowd {
  59110. /**
  59111. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59112. * You can attach anything to that node. The node position is updated in the scene update tick.
  59113. * @param pos world position that will be constrained by the navigation mesh
  59114. * @param parameters agent parameters
  59115. * @param transform hooked to the agent that will be update by the scene
  59116. * @returns agent index
  59117. */
  59118. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59119. /**
  59120. * Returns the agent position in world space
  59121. * @param index agent index returned by addAgent
  59122. * @returns world space position
  59123. */
  59124. getAgentPosition(index: number): Vector3;
  59125. /**
  59126. * Gets the agent velocity in world space
  59127. * @param index agent index returned by addAgent
  59128. * @returns world space velocity
  59129. */
  59130. getAgentVelocity(index: number): Vector3;
  59131. /**
  59132. * remove a particular agent previously created
  59133. * @param index agent index returned by addAgent
  59134. */
  59135. removeAgent(index: number): void;
  59136. /**
  59137. * get the list of all agents attached to this crowd
  59138. * @returns list of agent indices
  59139. */
  59140. getAgents(): number[];
  59141. /**
  59142. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59143. * @param deltaTime in seconds
  59144. */
  59145. update(deltaTime: number): void;
  59146. /**
  59147. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59148. * @param index agent index returned by addAgent
  59149. * @param destination targeted world position
  59150. */
  59151. agentGoto(index: number, destination: Vector3): void;
  59152. /**
  59153. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59154. * The queries will try to find a solution within those bounds
  59155. * default is (1,1,1)
  59156. * @param extent x,y,z value that define the extent around the queries point of reference
  59157. */
  59158. setDefaultQueryExtent(extent: Vector3): void;
  59159. /**
  59160. * Get the Bounding box extent specified by setDefaultQueryExtent
  59161. * @returns the box extent values
  59162. */
  59163. getDefaultQueryExtent(): Vector3;
  59164. /**
  59165. * Release all resources
  59166. */
  59167. dispose(): void;
  59168. }
  59169. /**
  59170. * Configures an agent
  59171. */
  59172. export interface IAgentParameters {
  59173. /**
  59174. * Agent radius. [Limit: >= 0]
  59175. */
  59176. radius: number;
  59177. /**
  59178. * Agent height. [Limit: > 0]
  59179. */
  59180. height: number;
  59181. /**
  59182. * Maximum allowed acceleration. [Limit: >= 0]
  59183. */
  59184. maxAcceleration: number;
  59185. /**
  59186. * Maximum allowed speed. [Limit: >= 0]
  59187. */
  59188. maxSpeed: number;
  59189. /**
  59190. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59191. */
  59192. collisionQueryRange: number;
  59193. /**
  59194. * The path visibility optimization range. [Limit: > 0]
  59195. */
  59196. pathOptimizationRange: number;
  59197. /**
  59198. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59199. */
  59200. separationWeight: number;
  59201. }
  59202. /**
  59203. * Configures the navigation mesh creation
  59204. */
  59205. export interface INavMeshParameters {
  59206. /**
  59207. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59208. */
  59209. cs: number;
  59210. /**
  59211. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59212. */
  59213. ch: number;
  59214. /**
  59215. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59216. */
  59217. walkableSlopeAngle: number;
  59218. /**
  59219. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59220. * be considered walkable. [Limit: >= 3] [Units: vx]
  59221. */
  59222. walkableHeight: number;
  59223. /**
  59224. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59225. */
  59226. walkableClimb: number;
  59227. /**
  59228. * The distance to erode/shrink the walkable area of the heightfield away from
  59229. * obstructions. [Limit: >=0] [Units: vx]
  59230. */
  59231. walkableRadius: number;
  59232. /**
  59233. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59234. */
  59235. maxEdgeLen: number;
  59236. /**
  59237. * The maximum distance a simplfied contour's border edges should deviate
  59238. * the original raw contour. [Limit: >=0] [Units: vx]
  59239. */
  59240. maxSimplificationError: number;
  59241. /**
  59242. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59243. */
  59244. minRegionArea: number;
  59245. /**
  59246. * Any regions with a span count smaller than this value will, if possible,
  59247. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59248. */
  59249. mergeRegionArea: number;
  59250. /**
  59251. * The maximum number of vertices allowed for polygons generated during the
  59252. * contour to polygon conversion process. [Limit: >= 3]
  59253. */
  59254. maxVertsPerPoly: number;
  59255. /**
  59256. * Sets the sampling distance to use when generating the detail mesh.
  59257. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59258. */
  59259. detailSampleDist: number;
  59260. /**
  59261. * The maximum distance the detail mesh surface should deviate from heightfield
  59262. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59263. */
  59264. detailSampleMaxError: number;
  59265. }
  59266. }
  59267. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59268. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59269. import { Mesh } from "babylonjs/Meshes/mesh";
  59270. import { Scene } from "babylonjs/scene";
  59271. import { Vector3 } from "babylonjs/Maths/math";
  59272. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59273. /**
  59274. * RecastJS navigation plugin
  59275. */
  59276. export class RecastJSPlugin implements INavigationEnginePlugin {
  59277. /**
  59278. * Reference to the Recast library
  59279. */
  59280. bjsRECAST: any;
  59281. /**
  59282. * plugin name
  59283. */
  59284. name: string;
  59285. /**
  59286. * the first navmesh created. We might extend this to support multiple navmeshes
  59287. */
  59288. navMesh: any;
  59289. /**
  59290. * Initializes the recastJS plugin
  59291. * @param recastInjection can be used to inject your own recast reference
  59292. */
  59293. constructor(recastInjection?: any);
  59294. /**
  59295. * Creates a navigation mesh
  59296. * @param meshes array of all the geometry used to compute the navigatio mesh
  59297. * @param parameters bunch of parameters used to filter geometry
  59298. */
  59299. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59300. /**
  59301. * Create a navigation mesh debug mesh
  59302. * @param scene is where the mesh will be added
  59303. * @returns debug display mesh
  59304. */
  59305. createDebugNavMesh(scene: Scene): Mesh;
  59306. /**
  59307. * Get a navigation mesh constrained position, closest to the parameter position
  59308. * @param position world position
  59309. * @returns the closest point to position constrained by the navigation mesh
  59310. */
  59311. getClosestPoint(position: Vector3): Vector3;
  59312. /**
  59313. * Get a navigation mesh constrained position, within a particular radius
  59314. * @param position world position
  59315. * @param maxRadius the maximum distance to the constrained world position
  59316. * @returns the closest point to position constrained by the navigation mesh
  59317. */
  59318. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59319. /**
  59320. * Compute the final position from a segment made of destination-position
  59321. * @param position world position
  59322. * @param destination world position
  59323. * @returns the resulting point along the navmesh
  59324. */
  59325. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59326. /**
  59327. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59328. * @param start world position
  59329. * @param end world position
  59330. * @returns array containing world position composing the path
  59331. */
  59332. computePath(start: Vector3, end: Vector3): Vector3[];
  59333. /**
  59334. * Create a new Crowd so you can add agents
  59335. * @param maxAgents the maximum agent count in the crowd
  59336. * @param maxAgentRadius the maximum radius an agent can have
  59337. * @param scene to attach the crowd to
  59338. * @returns the crowd you can add agents to
  59339. */
  59340. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59341. /**
  59342. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59343. * The queries will try to find a solution within those bounds
  59344. * default is (1,1,1)
  59345. * @param extent x,y,z value that define the extent around the queries point of reference
  59346. */
  59347. setDefaultQueryExtent(extent: Vector3): void;
  59348. /**
  59349. * Get the Bounding box extent specified by setDefaultQueryExtent
  59350. * @returns the box extent values
  59351. */
  59352. getDefaultQueryExtent(): Vector3;
  59353. /**
  59354. * Disposes
  59355. */
  59356. dispose(): void;
  59357. /**
  59358. * If this plugin is supported
  59359. * @returns true if plugin is supported
  59360. */
  59361. isSupported(): boolean;
  59362. }
  59363. /**
  59364. * Recast detour crowd implementation
  59365. */
  59366. export class RecastJSCrowd implements ICrowd {
  59367. /**
  59368. * Recast/detour plugin
  59369. */
  59370. bjsRECASTPlugin: RecastJSPlugin;
  59371. /**
  59372. * Link to the detour crowd
  59373. */
  59374. recastCrowd: any;
  59375. /**
  59376. * One transform per agent
  59377. */
  59378. transforms: TransformNode[];
  59379. /**
  59380. * All agents created
  59381. */
  59382. agents: number[];
  59383. /**
  59384. * Link to the scene is kept to unregister the crowd from the scene
  59385. */
  59386. private _scene;
  59387. /**
  59388. * Observer for crowd updates
  59389. */
  59390. private _onBeforeAnimationsObserver;
  59391. /**
  59392. * Constructor
  59393. * @param plugin recastJS plugin
  59394. * @param maxAgents the maximum agent count in the crowd
  59395. * @param maxAgentRadius the maximum radius an agent can have
  59396. * @param scene to attach the crowd to
  59397. * @returns the crowd you can add agents to
  59398. */
  59399. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59400. /**
  59401. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59402. * You can attach anything to that node. The node position is updated in the scene update tick.
  59403. * @param pos world position that will be constrained by the navigation mesh
  59404. * @param parameters agent parameters
  59405. * @param transform hooked to the agent that will be update by the scene
  59406. * @returns agent index
  59407. */
  59408. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59409. /**
  59410. * Returns the agent position in world space
  59411. * @param index agent index returned by addAgent
  59412. * @returns world space position
  59413. */
  59414. getAgentPosition(index: number): Vector3;
  59415. /**
  59416. * Returns the agent velocity in world space
  59417. * @param index agent index returned by addAgent
  59418. * @returns world space velocity
  59419. */
  59420. getAgentVelocity(index: number): Vector3;
  59421. /**
  59422. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59423. * @param index agent index returned by addAgent
  59424. * @param destination targeted world position
  59425. */
  59426. agentGoto(index: number, destination: Vector3): void;
  59427. /**
  59428. * remove a particular agent previously created
  59429. * @param index agent index returned by addAgent
  59430. */
  59431. removeAgent(index: number): void;
  59432. /**
  59433. * get the list of all agents attached to this crowd
  59434. * @returns list of agent indices
  59435. */
  59436. getAgents(): number[];
  59437. /**
  59438. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59439. * @param deltaTime in seconds
  59440. */
  59441. update(deltaTime: number): void;
  59442. /**
  59443. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59444. * The queries will try to find a solution within those bounds
  59445. * default is (1,1,1)
  59446. * @param extent x,y,z value that define the extent around the queries point of reference
  59447. */
  59448. setDefaultQueryExtent(extent: Vector3): void;
  59449. /**
  59450. * Get the Bounding box extent specified by setDefaultQueryExtent
  59451. * @returns the box extent values
  59452. */
  59453. getDefaultQueryExtent(): Vector3;
  59454. /**
  59455. * Release all resources
  59456. */
  59457. dispose(): void;
  59458. }
  59459. }
  59460. declare module "babylonjs/Navigation/Plugins/index" {
  59461. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59462. }
  59463. declare module "babylonjs/Navigation/index" {
  59464. export * from "babylonjs/Navigation/INavigationEngine";
  59465. export * from "babylonjs/Navigation/Plugins/index";
  59466. }
  59467. declare module "babylonjs/Offline/database" {
  59468. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59469. /**
  59470. * Class used to enable access to IndexedDB
  59471. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59472. */
  59473. export class Database implements IOfflineProvider {
  59474. private _callbackManifestChecked;
  59475. private _currentSceneUrl;
  59476. private _db;
  59477. private _enableSceneOffline;
  59478. private _enableTexturesOffline;
  59479. private _manifestVersionFound;
  59480. private _mustUpdateRessources;
  59481. private _hasReachedQuota;
  59482. private _isSupported;
  59483. private _idbFactory;
  59484. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59485. private static IsUASupportingBlobStorage;
  59486. /**
  59487. * Gets a boolean indicating if Database storate is enabled (off by default)
  59488. */
  59489. static IDBStorageEnabled: boolean;
  59490. /**
  59491. * Gets a boolean indicating if scene must be saved in the database
  59492. */
  59493. readonly enableSceneOffline: boolean;
  59494. /**
  59495. * Gets a boolean indicating if textures must be saved in the database
  59496. */
  59497. readonly enableTexturesOffline: boolean;
  59498. /**
  59499. * Creates a new Database
  59500. * @param urlToScene defines the url to load the scene
  59501. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59502. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59503. */
  59504. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59505. private static _ParseURL;
  59506. private static _ReturnFullUrlLocation;
  59507. private _checkManifestFile;
  59508. /**
  59509. * Open the database and make it available
  59510. * @param successCallback defines the callback to call on success
  59511. * @param errorCallback defines the callback to call on error
  59512. */
  59513. open(successCallback: () => void, errorCallback: () => void): void;
  59514. /**
  59515. * Loads an image from the database
  59516. * @param url defines the url to load from
  59517. * @param image defines the target DOM image
  59518. */
  59519. loadImage(url: string, image: HTMLImageElement): void;
  59520. private _loadImageFromDBAsync;
  59521. private _saveImageIntoDBAsync;
  59522. private _checkVersionFromDB;
  59523. private _loadVersionFromDBAsync;
  59524. private _saveVersionIntoDBAsync;
  59525. /**
  59526. * Loads a file from database
  59527. * @param url defines the URL to load from
  59528. * @param sceneLoaded defines a callback to call on success
  59529. * @param progressCallBack defines a callback to call when progress changed
  59530. * @param errorCallback defines a callback to call on error
  59531. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59532. */
  59533. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59534. private _loadFileAsync;
  59535. private _saveFileAsync;
  59536. /**
  59537. * Validates if xhr data is correct
  59538. * @param xhr defines the request to validate
  59539. * @param dataType defines the expected data type
  59540. * @returns true if data is correct
  59541. */
  59542. private static _ValidateXHRData;
  59543. }
  59544. }
  59545. declare module "babylonjs/Offline/index" {
  59546. export * from "babylonjs/Offline/database";
  59547. export * from "babylonjs/Offline/IOfflineProvider";
  59548. }
  59549. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59550. /** @hidden */
  59551. export var gpuUpdateParticlesPixelShader: {
  59552. name: string;
  59553. shader: string;
  59554. };
  59555. }
  59556. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59557. /** @hidden */
  59558. export var gpuUpdateParticlesVertexShader: {
  59559. name: string;
  59560. shader: string;
  59561. };
  59562. }
  59563. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59564. /** @hidden */
  59565. export var clipPlaneFragmentDeclaration2: {
  59566. name: string;
  59567. shader: string;
  59568. };
  59569. }
  59570. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59571. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59572. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59573. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59574. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59575. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59576. /** @hidden */
  59577. export var gpuRenderParticlesPixelShader: {
  59578. name: string;
  59579. shader: string;
  59580. };
  59581. }
  59582. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59583. /** @hidden */
  59584. export var clipPlaneVertexDeclaration2: {
  59585. name: string;
  59586. shader: string;
  59587. };
  59588. }
  59589. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59590. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59591. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59592. /** @hidden */
  59593. export var gpuRenderParticlesVertexShader: {
  59594. name: string;
  59595. shader: string;
  59596. };
  59597. }
  59598. declare module "babylonjs/Particles/gpuParticleSystem" {
  59599. import { Nullable } from "babylonjs/types";
  59600. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59601. import { Observable } from "babylonjs/Misc/observable";
  59602. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59603. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59604. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59605. import { Scene, IDisposable } from "babylonjs/scene";
  59606. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59607. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59608. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59609. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59610. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59611. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59612. /**
  59613. * This represents a GPU particle system in Babylon
  59614. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59615. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59616. */
  59617. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59618. /**
  59619. * The layer mask we are rendering the particles through.
  59620. */
  59621. layerMask: number;
  59622. private _capacity;
  59623. private _activeCount;
  59624. private _currentActiveCount;
  59625. private _accumulatedCount;
  59626. private _renderEffect;
  59627. private _updateEffect;
  59628. private _buffer0;
  59629. private _buffer1;
  59630. private _spriteBuffer;
  59631. private _updateVAO;
  59632. private _renderVAO;
  59633. private _targetIndex;
  59634. private _sourceBuffer;
  59635. private _targetBuffer;
  59636. private _engine;
  59637. private _currentRenderId;
  59638. private _started;
  59639. private _stopped;
  59640. private _timeDelta;
  59641. private _randomTexture;
  59642. private _randomTexture2;
  59643. private _attributesStrideSize;
  59644. private _updateEffectOptions;
  59645. private _randomTextureSize;
  59646. private _actualFrame;
  59647. private readonly _rawTextureWidth;
  59648. /**
  59649. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59650. */
  59651. static readonly IsSupported: boolean;
  59652. /**
  59653. * An event triggered when the system is disposed.
  59654. */
  59655. onDisposeObservable: Observable<GPUParticleSystem>;
  59656. /**
  59657. * Gets the maximum number of particles active at the same time.
  59658. * @returns The max number of active particles.
  59659. */
  59660. getCapacity(): number;
  59661. /**
  59662. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59663. * to override the particles.
  59664. */
  59665. forceDepthWrite: boolean;
  59666. /**
  59667. * Gets or set the number of active particles
  59668. */
  59669. activeParticleCount: number;
  59670. private _preWarmDone;
  59671. /**
  59672. * Is this system ready to be used/rendered
  59673. * @return true if the system is ready
  59674. */
  59675. isReady(): boolean;
  59676. /**
  59677. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59678. * @returns True if it has been started, otherwise false.
  59679. */
  59680. isStarted(): boolean;
  59681. /**
  59682. * Starts the particle system and begins to emit
  59683. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59684. */
  59685. start(delay?: number): void;
  59686. /**
  59687. * Stops the particle system.
  59688. */
  59689. stop(): void;
  59690. /**
  59691. * Remove all active particles
  59692. */
  59693. reset(): void;
  59694. /**
  59695. * Returns the string "GPUParticleSystem"
  59696. * @returns a string containing the class name
  59697. */
  59698. getClassName(): string;
  59699. private _colorGradientsTexture;
  59700. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59701. /**
  59702. * Adds a new color gradient
  59703. * @param gradient defines the gradient to use (between 0 and 1)
  59704. * @param color1 defines the color to affect to the specified gradient
  59705. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59706. * @returns the current particle system
  59707. */
  59708. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59709. /**
  59710. * Remove a specific color gradient
  59711. * @param gradient defines the gradient to remove
  59712. * @returns the current particle system
  59713. */
  59714. removeColorGradient(gradient: number): GPUParticleSystem;
  59715. private _angularSpeedGradientsTexture;
  59716. private _sizeGradientsTexture;
  59717. private _velocityGradientsTexture;
  59718. private _limitVelocityGradientsTexture;
  59719. private _dragGradientsTexture;
  59720. private _addFactorGradient;
  59721. /**
  59722. * Adds a new size gradient
  59723. * @param gradient defines the gradient to use (between 0 and 1)
  59724. * @param factor defines the size factor to affect to the specified gradient
  59725. * @returns the current particle system
  59726. */
  59727. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59728. /**
  59729. * Remove a specific size gradient
  59730. * @param gradient defines the gradient to remove
  59731. * @returns the current particle system
  59732. */
  59733. removeSizeGradient(gradient: number): GPUParticleSystem;
  59734. /**
  59735. * Adds a new angular speed gradient
  59736. * @param gradient defines the gradient to use (between 0 and 1)
  59737. * @param factor defines the angular speed to affect to the specified gradient
  59738. * @returns the current particle system
  59739. */
  59740. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59741. /**
  59742. * Remove a specific angular speed gradient
  59743. * @param gradient defines the gradient to remove
  59744. * @returns the current particle system
  59745. */
  59746. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59747. /**
  59748. * Adds a new velocity gradient
  59749. * @param gradient defines the gradient to use (between 0 and 1)
  59750. * @param factor defines the velocity to affect to the specified gradient
  59751. * @returns the current particle system
  59752. */
  59753. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59754. /**
  59755. * Remove a specific velocity gradient
  59756. * @param gradient defines the gradient to remove
  59757. * @returns the current particle system
  59758. */
  59759. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59760. /**
  59761. * Adds a new limit velocity gradient
  59762. * @param gradient defines the gradient to use (between 0 and 1)
  59763. * @param factor defines the limit velocity value to affect to the specified gradient
  59764. * @returns the current particle system
  59765. */
  59766. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59767. /**
  59768. * Remove a specific limit velocity gradient
  59769. * @param gradient defines the gradient to remove
  59770. * @returns the current particle system
  59771. */
  59772. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59773. /**
  59774. * Adds a new drag gradient
  59775. * @param gradient defines the gradient to use (between 0 and 1)
  59776. * @param factor defines the drag value to affect to the specified gradient
  59777. * @returns the current particle system
  59778. */
  59779. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59780. /**
  59781. * Remove a specific drag gradient
  59782. * @param gradient defines the gradient to remove
  59783. * @returns the current particle system
  59784. */
  59785. removeDragGradient(gradient: number): GPUParticleSystem;
  59786. /**
  59787. * Not supported by GPUParticleSystem
  59788. * @param gradient defines the gradient to use (between 0 and 1)
  59789. * @param factor defines the emit rate value to affect to the specified gradient
  59790. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59791. * @returns the current particle system
  59792. */
  59793. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59794. /**
  59795. * Not supported by GPUParticleSystem
  59796. * @param gradient defines the gradient to remove
  59797. * @returns the current particle system
  59798. */
  59799. removeEmitRateGradient(gradient: number): IParticleSystem;
  59800. /**
  59801. * Not supported by GPUParticleSystem
  59802. * @param gradient defines the gradient to use (between 0 and 1)
  59803. * @param factor defines the start size value to affect to the specified gradient
  59804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59805. * @returns the current particle system
  59806. */
  59807. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59808. /**
  59809. * Not supported by GPUParticleSystem
  59810. * @param gradient defines the gradient to remove
  59811. * @returns the current particle system
  59812. */
  59813. removeStartSizeGradient(gradient: number): IParticleSystem;
  59814. /**
  59815. * Not supported by GPUParticleSystem
  59816. * @param gradient defines the gradient to use (between 0 and 1)
  59817. * @param min defines the color remap minimal range
  59818. * @param max defines the color remap maximal range
  59819. * @returns the current particle system
  59820. */
  59821. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59822. /**
  59823. * Not supported by GPUParticleSystem
  59824. * @param gradient defines the gradient to remove
  59825. * @returns the current particle system
  59826. */
  59827. removeColorRemapGradient(): IParticleSystem;
  59828. /**
  59829. * Not supported by GPUParticleSystem
  59830. * @param gradient defines the gradient to use (between 0 and 1)
  59831. * @param min defines the alpha remap minimal range
  59832. * @param max defines the alpha remap maximal range
  59833. * @returns the current particle system
  59834. */
  59835. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  59836. /**
  59837. * Not supported by GPUParticleSystem
  59838. * @param gradient defines the gradient to remove
  59839. * @returns the current particle system
  59840. */
  59841. removeAlphaRemapGradient(): IParticleSystem;
  59842. /**
  59843. * Not supported by GPUParticleSystem
  59844. * @param gradient defines the gradient to use (between 0 and 1)
  59845. * @param color defines the color to affect to the specified gradient
  59846. * @returns the current particle system
  59847. */
  59848. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  59849. /**
  59850. * Not supported by GPUParticleSystem
  59851. * @param gradient defines the gradient to remove
  59852. * @returns the current particle system
  59853. */
  59854. removeRampGradient(): IParticleSystem;
  59855. /**
  59856. * Not supported by GPUParticleSystem
  59857. * @returns the list of ramp gradients
  59858. */
  59859. getRampGradients(): Nullable<Array<Color3Gradient>>;
  59860. /**
  59861. * Not supported by GPUParticleSystem
  59862. * Gets or sets a boolean indicating that ramp gradients must be used
  59863. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  59864. */
  59865. useRampGradients: boolean;
  59866. /**
  59867. * Not supported by GPUParticleSystem
  59868. * @param gradient defines the gradient to use (between 0 and 1)
  59869. * @param factor defines the life time factor to affect to the specified gradient
  59870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59871. * @returns the current particle system
  59872. */
  59873. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59874. /**
  59875. * Not supported by GPUParticleSystem
  59876. * @param gradient defines the gradient to remove
  59877. * @returns the current particle system
  59878. */
  59879. removeLifeTimeGradient(gradient: number): IParticleSystem;
  59880. /**
  59881. * Instantiates a GPU particle system.
  59882. * 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.
  59883. * @param name The name of the particle system
  59884. * @param options The options used to create the system
  59885. * @param scene The scene the particle system belongs to
  59886. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  59887. */
  59888. constructor(name: string, options: Partial<{
  59889. capacity: number;
  59890. randomTextureSize: number;
  59891. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  59892. protected _reset(): void;
  59893. private _createUpdateVAO;
  59894. private _createRenderVAO;
  59895. private _initialize;
  59896. /** @hidden */
  59897. _recreateUpdateEffect(): void;
  59898. /** @hidden */
  59899. _recreateRenderEffect(): void;
  59900. /**
  59901. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  59902. * @param preWarm defines if we are in the pre-warmimg phase
  59903. */
  59904. animate(preWarm?: boolean): void;
  59905. private _createFactorGradientTexture;
  59906. private _createSizeGradientTexture;
  59907. private _createAngularSpeedGradientTexture;
  59908. private _createVelocityGradientTexture;
  59909. private _createLimitVelocityGradientTexture;
  59910. private _createDragGradientTexture;
  59911. private _createColorGradientTexture;
  59912. /**
  59913. * Renders the particle system in its current state
  59914. * @param preWarm defines if the system should only update the particles but not render them
  59915. * @returns the current number of particles
  59916. */
  59917. render(preWarm?: boolean): number;
  59918. /**
  59919. * Rebuilds the particle system
  59920. */
  59921. rebuild(): void;
  59922. private _releaseBuffers;
  59923. private _releaseVAOs;
  59924. /**
  59925. * Disposes the particle system and free the associated resources
  59926. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  59927. */
  59928. dispose(disposeTexture?: boolean): void;
  59929. /**
  59930. * Clones the particle system.
  59931. * @param name The name of the cloned object
  59932. * @param newEmitter The new emitter to use
  59933. * @returns the cloned particle system
  59934. */
  59935. clone(name: string, newEmitter: any): GPUParticleSystem;
  59936. /**
  59937. * Serializes the particle system to a JSON object.
  59938. * @returns the JSON object
  59939. */
  59940. serialize(): any;
  59941. /**
  59942. * Parses a JSON object to create a GPU particle system.
  59943. * @param parsedParticleSystem The JSON object to parse
  59944. * @param scene The scene to create the particle system in
  59945. * @param rootUrl The root url to use to load external dependencies like texture
  59946. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  59947. * @returns the parsed GPU particle system
  59948. */
  59949. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  59950. }
  59951. }
  59952. declare module "babylonjs/Particles/particleSystemSet" {
  59953. import { Nullable } from "babylonjs/types";
  59954. import { Color3 } from "babylonjs/Maths/math.color";
  59955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59957. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59958. import { Scene, IDisposable } from "babylonjs/scene";
  59959. /**
  59960. * Represents a set of particle systems working together to create a specific effect
  59961. */
  59962. export class ParticleSystemSet implements IDisposable {
  59963. private _emitterCreationOptions;
  59964. private _emitterNode;
  59965. /**
  59966. * Gets the particle system list
  59967. */
  59968. systems: IParticleSystem[];
  59969. /**
  59970. * Gets the emitter node used with this set
  59971. */
  59972. readonly emitterNode: Nullable<TransformNode>;
  59973. /**
  59974. * Creates a new emitter mesh as a sphere
  59975. * @param options defines the options used to create the sphere
  59976. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  59977. * @param scene defines the hosting scene
  59978. */
  59979. setEmitterAsSphere(options: {
  59980. diameter: number;
  59981. segments: number;
  59982. color: Color3;
  59983. }, renderingGroupId: number, scene: Scene): void;
  59984. /**
  59985. * Starts all particle systems of the set
  59986. * @param emitter defines an optional mesh to use as emitter for the particle systems
  59987. */
  59988. start(emitter?: AbstractMesh): void;
  59989. /**
  59990. * Release all associated resources
  59991. */
  59992. dispose(): void;
  59993. /**
  59994. * Serialize the set into a JSON compatible object
  59995. * @returns a JSON compatible representation of the set
  59996. */
  59997. serialize(): any;
  59998. /**
  59999. * Parse a new ParticleSystemSet from a serialized source
  60000. * @param data defines a JSON compatible representation of the set
  60001. * @param scene defines the hosting scene
  60002. * @param gpu defines if we want GPU particles or CPU particles
  60003. * @returns a new ParticleSystemSet
  60004. */
  60005. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60006. }
  60007. }
  60008. declare module "babylonjs/Particles/particleHelper" {
  60009. import { Nullable } from "babylonjs/types";
  60010. import { Scene } from "babylonjs/scene";
  60011. import { Vector3 } from "babylonjs/Maths/math.vector";
  60012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60013. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60014. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60015. /**
  60016. * This class is made for on one-liner static method to help creating particle system set.
  60017. */
  60018. export class ParticleHelper {
  60019. /**
  60020. * Gets or sets base Assets URL
  60021. */
  60022. static BaseAssetsUrl: string;
  60023. /**
  60024. * Create a default particle system that you can tweak
  60025. * @param emitter defines the emitter to use
  60026. * @param capacity defines the system capacity (default is 500 particles)
  60027. * @param scene defines the hosting scene
  60028. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60029. * @returns the new Particle system
  60030. */
  60031. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60032. /**
  60033. * This is the main static method (one-liner) of this helper to create different particle systems
  60034. * @param type This string represents the type to the particle system to create
  60035. * @param scene The scene where the particle system should live
  60036. * @param gpu If the system will use gpu
  60037. * @returns the ParticleSystemSet created
  60038. */
  60039. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60040. /**
  60041. * Static function used to export a particle system to a ParticleSystemSet variable.
  60042. * Please note that the emitter shape is not exported
  60043. * @param systems defines the particle systems to export
  60044. * @returns the created particle system set
  60045. */
  60046. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60047. }
  60048. }
  60049. declare module "babylonjs/Particles/particleSystemComponent" {
  60050. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60051. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60052. import "babylonjs/Shaders/particles.vertex";
  60053. module "babylonjs/Engines/engine" {
  60054. interface Engine {
  60055. /**
  60056. * Create an effect to use with particle systems.
  60057. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60058. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60059. * @param uniformsNames defines a list of attribute names
  60060. * @param samplers defines an array of string used to represent textures
  60061. * @param defines defines the string containing the defines to use to compile the shaders
  60062. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60063. * @param onCompiled defines a function to call when the effect creation is successful
  60064. * @param onError defines a function to call when the effect creation has failed
  60065. * @returns the new Effect
  60066. */
  60067. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60068. }
  60069. }
  60070. module "babylonjs/Meshes/mesh" {
  60071. interface Mesh {
  60072. /**
  60073. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60074. * @returns an array of IParticleSystem
  60075. */
  60076. getEmittedParticleSystems(): IParticleSystem[];
  60077. /**
  60078. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60079. * @returns an array of IParticleSystem
  60080. */
  60081. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60082. }
  60083. }
  60084. /**
  60085. * @hidden
  60086. */
  60087. export var _IDoNeedToBeInTheBuild: number;
  60088. }
  60089. declare module "babylonjs/Particles/index" {
  60090. export * from "babylonjs/Particles/baseParticleSystem";
  60091. export * from "babylonjs/Particles/EmitterTypes/index";
  60092. export * from "babylonjs/Particles/gpuParticleSystem";
  60093. export * from "babylonjs/Particles/IParticleSystem";
  60094. export * from "babylonjs/Particles/particle";
  60095. export * from "babylonjs/Particles/particleHelper";
  60096. export * from "babylonjs/Particles/particleSystem";
  60097. export * from "babylonjs/Particles/particleSystemComponent";
  60098. export * from "babylonjs/Particles/particleSystemSet";
  60099. export * from "babylonjs/Particles/solidParticle";
  60100. export * from "babylonjs/Particles/solidParticleSystem";
  60101. export * from "babylonjs/Particles/subEmitter";
  60102. }
  60103. declare module "babylonjs/Physics/physicsEngineComponent" {
  60104. import { Nullable } from "babylonjs/types";
  60105. import { Observable, Observer } from "babylonjs/Misc/observable";
  60106. import { Vector3 } from "babylonjs/Maths/math.vector";
  60107. import { Mesh } from "babylonjs/Meshes/mesh";
  60108. import { ISceneComponent } from "babylonjs/sceneComponent";
  60109. import { Scene } from "babylonjs/scene";
  60110. import { Node } from "babylonjs/node";
  60111. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60112. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60113. module "babylonjs/scene" {
  60114. interface Scene {
  60115. /** @hidden (Backing field) */
  60116. _physicsEngine: Nullable<IPhysicsEngine>;
  60117. /**
  60118. * Gets the current physics engine
  60119. * @returns a IPhysicsEngine or null if none attached
  60120. */
  60121. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60122. /**
  60123. * Enables physics to the current scene
  60124. * @param gravity defines the scene's gravity for the physics engine
  60125. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60126. * @return a boolean indicating if the physics engine was initialized
  60127. */
  60128. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60129. /**
  60130. * Disables and disposes the physics engine associated with the scene
  60131. */
  60132. disablePhysicsEngine(): void;
  60133. /**
  60134. * Gets a boolean indicating if there is an active physics engine
  60135. * @returns a boolean indicating if there is an active physics engine
  60136. */
  60137. isPhysicsEnabled(): boolean;
  60138. /**
  60139. * Deletes a physics compound impostor
  60140. * @param compound defines the compound to delete
  60141. */
  60142. deleteCompoundImpostor(compound: any): void;
  60143. /**
  60144. * An event triggered when physic simulation is about to be run
  60145. */
  60146. onBeforePhysicsObservable: Observable<Scene>;
  60147. /**
  60148. * An event triggered when physic simulation has been done
  60149. */
  60150. onAfterPhysicsObservable: Observable<Scene>;
  60151. }
  60152. }
  60153. module "babylonjs/Meshes/abstractMesh" {
  60154. interface AbstractMesh {
  60155. /** @hidden */
  60156. _physicsImpostor: Nullable<PhysicsImpostor>;
  60157. /**
  60158. * Gets or sets impostor used for physic simulation
  60159. * @see http://doc.babylonjs.com/features/physics_engine
  60160. */
  60161. physicsImpostor: Nullable<PhysicsImpostor>;
  60162. /**
  60163. * Gets the current physics impostor
  60164. * @see http://doc.babylonjs.com/features/physics_engine
  60165. * @returns a physics impostor or null
  60166. */
  60167. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60168. /** Apply a physic impulse to the mesh
  60169. * @param force defines the force to apply
  60170. * @param contactPoint defines where to apply the force
  60171. * @returns the current mesh
  60172. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60173. */
  60174. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60175. /**
  60176. * Creates a physic joint between two meshes
  60177. * @param otherMesh defines the other mesh to use
  60178. * @param pivot1 defines the pivot to use on this mesh
  60179. * @param pivot2 defines the pivot to use on the other mesh
  60180. * @param options defines additional options (can be plugin dependent)
  60181. * @returns the current mesh
  60182. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60183. */
  60184. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60185. /** @hidden */
  60186. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60187. }
  60188. }
  60189. /**
  60190. * Defines the physics engine scene component responsible to manage a physics engine
  60191. */
  60192. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60193. /**
  60194. * The component name helpful to identify the component in the list of scene components.
  60195. */
  60196. readonly name: string;
  60197. /**
  60198. * The scene the component belongs to.
  60199. */
  60200. scene: Scene;
  60201. /**
  60202. * Creates a new instance of the component for the given scene
  60203. * @param scene Defines the scene to register the component in
  60204. */
  60205. constructor(scene: Scene);
  60206. /**
  60207. * Registers the component in a given scene
  60208. */
  60209. register(): void;
  60210. /**
  60211. * Rebuilds the elements related to this component in case of
  60212. * context lost for instance.
  60213. */
  60214. rebuild(): void;
  60215. /**
  60216. * Disposes the component and the associated ressources
  60217. */
  60218. dispose(): void;
  60219. }
  60220. }
  60221. declare module "babylonjs/Physics/physicsHelper" {
  60222. import { Nullable } from "babylonjs/types";
  60223. import { Vector3 } from "babylonjs/Maths/math.vector";
  60224. import { Mesh } from "babylonjs/Meshes/mesh";
  60225. import { Scene } from "babylonjs/scene";
  60226. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60227. /**
  60228. * A helper for physics simulations
  60229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60230. */
  60231. export class PhysicsHelper {
  60232. private _scene;
  60233. private _physicsEngine;
  60234. /**
  60235. * Initializes the Physics helper
  60236. * @param scene Babylon.js scene
  60237. */
  60238. constructor(scene: Scene);
  60239. /**
  60240. * Applies a radial explosion impulse
  60241. * @param origin the origin of the explosion
  60242. * @param radiusOrEventOptions the radius or the options of radial explosion
  60243. * @param strength the explosion strength
  60244. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60245. * @returns A physics radial explosion event, or null
  60246. */
  60247. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60248. /**
  60249. * Applies a radial explosion force
  60250. * @param origin the origin of the explosion
  60251. * @param radiusOrEventOptions the radius or the options of radial explosion
  60252. * @param strength the explosion strength
  60253. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60254. * @returns A physics radial explosion event, or null
  60255. */
  60256. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60257. /**
  60258. * Creates a gravitational field
  60259. * @param origin the origin of the explosion
  60260. * @param radiusOrEventOptions the radius or the options of radial explosion
  60261. * @param strength the explosion strength
  60262. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60263. * @returns A physics gravitational field event, or null
  60264. */
  60265. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60266. /**
  60267. * Creates a physics updraft event
  60268. * @param origin the origin of the updraft
  60269. * @param radiusOrEventOptions the radius or the options of the updraft
  60270. * @param strength the strength of the updraft
  60271. * @param height the height of the updraft
  60272. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60273. * @returns A physics updraft event, or null
  60274. */
  60275. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60276. /**
  60277. * Creates a physics vortex event
  60278. * @param origin the of the vortex
  60279. * @param radiusOrEventOptions the radius or the options of the vortex
  60280. * @param strength the strength of the vortex
  60281. * @param height the height of the vortex
  60282. * @returns a Physics vortex event, or null
  60283. * A physics vortex event or null
  60284. */
  60285. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60286. }
  60287. /**
  60288. * Represents a physics radial explosion event
  60289. */
  60290. class PhysicsRadialExplosionEvent {
  60291. private _scene;
  60292. private _options;
  60293. private _sphere;
  60294. private _dataFetched;
  60295. /**
  60296. * Initializes a radial explosioin event
  60297. * @param _scene BabylonJS scene
  60298. * @param _options The options for the vortex event
  60299. */
  60300. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60301. /**
  60302. * Returns the data related to the radial explosion event (sphere).
  60303. * @returns The radial explosion event data
  60304. */
  60305. getData(): PhysicsRadialExplosionEventData;
  60306. /**
  60307. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60308. * @param impostor A physics imposter
  60309. * @param origin the origin of the explosion
  60310. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60311. */
  60312. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60313. /**
  60314. * Triggers affecterd impostors callbacks
  60315. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60316. */
  60317. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60318. /**
  60319. * Disposes the sphere.
  60320. * @param force Specifies if the sphere should be disposed by force
  60321. */
  60322. dispose(force?: boolean): void;
  60323. /*** Helpers ***/
  60324. private _prepareSphere;
  60325. private _intersectsWithSphere;
  60326. }
  60327. /**
  60328. * Represents a gravitational field event
  60329. */
  60330. class PhysicsGravitationalFieldEvent {
  60331. private _physicsHelper;
  60332. private _scene;
  60333. private _origin;
  60334. private _options;
  60335. private _tickCallback;
  60336. private _sphere;
  60337. private _dataFetched;
  60338. /**
  60339. * Initializes the physics gravitational field event
  60340. * @param _physicsHelper A physics helper
  60341. * @param _scene BabylonJS scene
  60342. * @param _origin The origin position of the gravitational field event
  60343. * @param _options The options for the vortex event
  60344. */
  60345. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60346. /**
  60347. * Returns the data related to the gravitational field event (sphere).
  60348. * @returns A gravitational field event
  60349. */
  60350. getData(): PhysicsGravitationalFieldEventData;
  60351. /**
  60352. * Enables the gravitational field.
  60353. */
  60354. enable(): void;
  60355. /**
  60356. * Disables the gravitational field.
  60357. */
  60358. disable(): void;
  60359. /**
  60360. * Disposes the sphere.
  60361. * @param force The force to dispose from the gravitational field event
  60362. */
  60363. dispose(force?: boolean): void;
  60364. private _tick;
  60365. }
  60366. /**
  60367. * Represents a physics updraft event
  60368. */
  60369. class PhysicsUpdraftEvent {
  60370. private _scene;
  60371. private _origin;
  60372. private _options;
  60373. private _physicsEngine;
  60374. private _originTop;
  60375. private _originDirection;
  60376. private _tickCallback;
  60377. private _cylinder;
  60378. private _cylinderPosition;
  60379. private _dataFetched;
  60380. /**
  60381. * Initializes the physics updraft event
  60382. * @param _scene BabylonJS scene
  60383. * @param _origin The origin position of the updraft
  60384. * @param _options The options for the updraft event
  60385. */
  60386. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60387. /**
  60388. * Returns the data related to the updraft event (cylinder).
  60389. * @returns A physics updraft event
  60390. */
  60391. getData(): PhysicsUpdraftEventData;
  60392. /**
  60393. * Enables the updraft.
  60394. */
  60395. enable(): void;
  60396. /**
  60397. * Disables the updraft.
  60398. */
  60399. disable(): void;
  60400. /**
  60401. * Disposes the cylinder.
  60402. * @param force Specifies if the updraft should be disposed by force
  60403. */
  60404. dispose(force?: boolean): void;
  60405. private getImpostorHitData;
  60406. private _tick;
  60407. /*** Helpers ***/
  60408. private _prepareCylinder;
  60409. private _intersectsWithCylinder;
  60410. }
  60411. /**
  60412. * Represents a physics vortex event
  60413. */
  60414. class PhysicsVortexEvent {
  60415. private _scene;
  60416. private _origin;
  60417. private _options;
  60418. private _physicsEngine;
  60419. private _originTop;
  60420. private _tickCallback;
  60421. private _cylinder;
  60422. private _cylinderPosition;
  60423. private _dataFetched;
  60424. /**
  60425. * Initializes the physics vortex event
  60426. * @param _scene The BabylonJS scene
  60427. * @param _origin The origin position of the vortex
  60428. * @param _options The options for the vortex event
  60429. */
  60430. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60431. /**
  60432. * Returns the data related to the vortex event (cylinder).
  60433. * @returns The physics vortex event data
  60434. */
  60435. getData(): PhysicsVortexEventData;
  60436. /**
  60437. * Enables the vortex.
  60438. */
  60439. enable(): void;
  60440. /**
  60441. * Disables the cortex.
  60442. */
  60443. disable(): void;
  60444. /**
  60445. * Disposes the sphere.
  60446. * @param force
  60447. */
  60448. dispose(force?: boolean): void;
  60449. private getImpostorHitData;
  60450. private _tick;
  60451. /*** Helpers ***/
  60452. private _prepareCylinder;
  60453. private _intersectsWithCylinder;
  60454. }
  60455. /**
  60456. * Options fot the radial explosion event
  60457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60458. */
  60459. export class PhysicsRadialExplosionEventOptions {
  60460. /**
  60461. * The radius of the sphere for the radial explosion.
  60462. */
  60463. radius: number;
  60464. /**
  60465. * The strenth of the explosion.
  60466. */
  60467. strength: number;
  60468. /**
  60469. * The strenght of the force in correspondence to the distance of the affected object
  60470. */
  60471. falloff: PhysicsRadialImpulseFalloff;
  60472. /**
  60473. * Sphere options for the radial explosion.
  60474. */
  60475. sphere: {
  60476. segments: number;
  60477. diameter: number;
  60478. };
  60479. /**
  60480. * Sphere options for the radial explosion.
  60481. */
  60482. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60483. }
  60484. /**
  60485. * Options fot the updraft event
  60486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60487. */
  60488. export class PhysicsUpdraftEventOptions {
  60489. /**
  60490. * The radius of the cylinder for the vortex
  60491. */
  60492. radius: number;
  60493. /**
  60494. * The strenth of the updraft.
  60495. */
  60496. strength: number;
  60497. /**
  60498. * The height of the cylinder for the updraft.
  60499. */
  60500. height: number;
  60501. /**
  60502. * The mode for the the updraft.
  60503. */
  60504. updraftMode: PhysicsUpdraftMode;
  60505. }
  60506. /**
  60507. * Options fot the vortex event
  60508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60509. */
  60510. export class PhysicsVortexEventOptions {
  60511. /**
  60512. * The radius of the cylinder for the vortex
  60513. */
  60514. radius: number;
  60515. /**
  60516. * The strenth of the vortex.
  60517. */
  60518. strength: number;
  60519. /**
  60520. * The height of the cylinder for the vortex.
  60521. */
  60522. height: number;
  60523. /**
  60524. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60525. */
  60526. centripetalForceThreshold: number;
  60527. /**
  60528. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60529. */
  60530. centripetalForceMultiplier: number;
  60531. /**
  60532. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60533. */
  60534. centrifugalForceMultiplier: number;
  60535. /**
  60536. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60537. */
  60538. updraftForceMultiplier: number;
  60539. }
  60540. /**
  60541. * The strenght of the force in correspondence to the distance of the affected object
  60542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60543. */
  60544. export enum PhysicsRadialImpulseFalloff {
  60545. /** Defines that impulse is constant in strength across it's whole radius */
  60546. Constant = 0,
  60547. /** Defines that impulse gets weaker if it's further from the origin */
  60548. Linear = 1
  60549. }
  60550. /**
  60551. * The strength of the force in correspondence to the distance of the affected object
  60552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60553. */
  60554. export enum PhysicsUpdraftMode {
  60555. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60556. Center = 0,
  60557. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60558. Perpendicular = 1
  60559. }
  60560. /**
  60561. * Interface for a physics hit data
  60562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60563. */
  60564. export interface PhysicsHitData {
  60565. /**
  60566. * The force applied at the contact point
  60567. */
  60568. force: Vector3;
  60569. /**
  60570. * The contact point
  60571. */
  60572. contactPoint: Vector3;
  60573. /**
  60574. * The distance from the origin to the contact point
  60575. */
  60576. distanceFromOrigin: number;
  60577. }
  60578. /**
  60579. * Interface for radial explosion event data
  60580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60581. */
  60582. export interface PhysicsRadialExplosionEventData {
  60583. /**
  60584. * A sphere used for the radial explosion event
  60585. */
  60586. sphere: Mesh;
  60587. }
  60588. /**
  60589. * Interface for gravitational field event data
  60590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60591. */
  60592. export interface PhysicsGravitationalFieldEventData {
  60593. /**
  60594. * A sphere mesh used for the gravitational field event
  60595. */
  60596. sphere: Mesh;
  60597. }
  60598. /**
  60599. * Interface for updraft event data
  60600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60601. */
  60602. export interface PhysicsUpdraftEventData {
  60603. /**
  60604. * A cylinder used for the updraft event
  60605. */
  60606. cylinder: Mesh;
  60607. }
  60608. /**
  60609. * Interface for vortex event data
  60610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60611. */
  60612. export interface PhysicsVortexEventData {
  60613. /**
  60614. * A cylinder used for the vortex event
  60615. */
  60616. cylinder: Mesh;
  60617. }
  60618. /**
  60619. * Interface for an affected physics impostor
  60620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60621. */
  60622. export interface PhysicsAffectedImpostorWithData {
  60623. /**
  60624. * The impostor affected by the effect
  60625. */
  60626. impostor: PhysicsImpostor;
  60627. /**
  60628. * The data about the hit/horce from the explosion
  60629. */
  60630. hitData: PhysicsHitData;
  60631. }
  60632. }
  60633. declare module "babylonjs/Physics/Plugins/index" {
  60634. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60635. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60636. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60637. }
  60638. declare module "babylonjs/Physics/index" {
  60639. export * from "babylonjs/Physics/IPhysicsEngine";
  60640. export * from "babylonjs/Physics/physicsEngine";
  60641. export * from "babylonjs/Physics/physicsEngineComponent";
  60642. export * from "babylonjs/Physics/physicsHelper";
  60643. export * from "babylonjs/Physics/physicsImpostor";
  60644. export * from "babylonjs/Physics/physicsJoint";
  60645. export * from "babylonjs/Physics/Plugins/index";
  60646. }
  60647. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60648. /** @hidden */
  60649. export var blackAndWhitePixelShader: {
  60650. name: string;
  60651. shader: string;
  60652. };
  60653. }
  60654. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60655. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60656. import { Camera } from "babylonjs/Cameras/camera";
  60657. import { Engine } from "babylonjs/Engines/engine";
  60658. import "babylonjs/Shaders/blackAndWhite.fragment";
  60659. /**
  60660. * Post process used to render in black and white
  60661. */
  60662. export class BlackAndWhitePostProcess extends PostProcess {
  60663. /**
  60664. * Linear about to convert he result to black and white (default: 1)
  60665. */
  60666. degree: number;
  60667. /**
  60668. * Creates a black and white post process
  60669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60670. * @param name The name of the effect.
  60671. * @param options The required width/height ratio to downsize to before computing the render pass.
  60672. * @param camera The camera to apply the render pass to.
  60673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60674. * @param engine The engine which the post process will be applied. (default: current engine)
  60675. * @param reusable If the post process can be reused on the same frame. (default: false)
  60676. */
  60677. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60678. }
  60679. }
  60680. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60681. import { Nullable } from "babylonjs/types";
  60682. import { Camera } from "babylonjs/Cameras/camera";
  60683. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60684. import { Engine } from "babylonjs/Engines/engine";
  60685. /**
  60686. * This represents a set of one or more post processes in Babylon.
  60687. * A post process can be used to apply a shader to a texture after it is rendered.
  60688. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60689. */
  60690. export class PostProcessRenderEffect {
  60691. private _postProcesses;
  60692. private _getPostProcesses;
  60693. private _singleInstance;
  60694. private _cameras;
  60695. private _indicesForCamera;
  60696. /**
  60697. * Name of the effect
  60698. * @hidden
  60699. */
  60700. _name: string;
  60701. /**
  60702. * Instantiates a post process render effect.
  60703. * A post process can be used to apply a shader to a texture after it is rendered.
  60704. * @param engine The engine the effect is tied to
  60705. * @param name The name of the effect
  60706. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60707. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60708. */
  60709. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60710. /**
  60711. * Checks if all the post processes in the effect are supported.
  60712. */
  60713. readonly isSupported: boolean;
  60714. /**
  60715. * Updates the current state of the effect
  60716. * @hidden
  60717. */
  60718. _update(): void;
  60719. /**
  60720. * Attaches the effect on cameras
  60721. * @param cameras The camera to attach to.
  60722. * @hidden
  60723. */
  60724. _attachCameras(cameras: Camera): void;
  60725. /**
  60726. * Attaches the effect on cameras
  60727. * @param cameras The camera to attach to.
  60728. * @hidden
  60729. */
  60730. _attachCameras(cameras: Camera[]): void;
  60731. /**
  60732. * Detaches the effect on cameras
  60733. * @param cameras The camera to detatch from.
  60734. * @hidden
  60735. */
  60736. _detachCameras(cameras: Camera): void;
  60737. /**
  60738. * Detatches the effect on cameras
  60739. * @param cameras The camera to detatch from.
  60740. * @hidden
  60741. */
  60742. _detachCameras(cameras: Camera[]): void;
  60743. /**
  60744. * Enables the effect on given cameras
  60745. * @param cameras The camera to enable.
  60746. * @hidden
  60747. */
  60748. _enable(cameras: Camera): void;
  60749. /**
  60750. * Enables the effect on given cameras
  60751. * @param cameras The camera to enable.
  60752. * @hidden
  60753. */
  60754. _enable(cameras: Nullable<Camera[]>): void;
  60755. /**
  60756. * Disables the effect on the given cameras
  60757. * @param cameras The camera to disable.
  60758. * @hidden
  60759. */
  60760. _disable(cameras: Camera): void;
  60761. /**
  60762. * Disables the effect on the given cameras
  60763. * @param cameras The camera to disable.
  60764. * @hidden
  60765. */
  60766. _disable(cameras: Nullable<Camera[]>): void;
  60767. /**
  60768. * Gets a list of the post processes contained in the effect.
  60769. * @param camera The camera to get the post processes on.
  60770. * @returns The list of the post processes in the effect.
  60771. */
  60772. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60773. }
  60774. }
  60775. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60776. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60777. /** @hidden */
  60778. export var extractHighlightsPixelShader: {
  60779. name: string;
  60780. shader: string;
  60781. };
  60782. }
  60783. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60784. import { Nullable } from "babylonjs/types";
  60785. import { Camera } from "babylonjs/Cameras/camera";
  60786. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60787. import { Engine } from "babylonjs/Engines/engine";
  60788. import "babylonjs/Shaders/extractHighlights.fragment";
  60789. /**
  60790. * 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.
  60791. */
  60792. export class ExtractHighlightsPostProcess extends PostProcess {
  60793. /**
  60794. * The luminance threshold, pixels below this value will be set to black.
  60795. */
  60796. threshold: number;
  60797. /** @hidden */
  60798. _exposure: number;
  60799. /**
  60800. * Post process which has the input texture to be used when performing highlight extraction
  60801. * @hidden
  60802. */
  60803. _inputPostProcess: Nullable<PostProcess>;
  60804. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60805. }
  60806. }
  60807. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60808. /** @hidden */
  60809. export var bloomMergePixelShader: {
  60810. name: string;
  60811. shader: string;
  60812. };
  60813. }
  60814. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  60815. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60816. import { Nullable } from "babylonjs/types";
  60817. import { Engine } from "babylonjs/Engines/engine";
  60818. import { Camera } from "babylonjs/Cameras/camera";
  60819. import "babylonjs/Shaders/bloomMerge.fragment";
  60820. /**
  60821. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  60822. */
  60823. export class BloomMergePostProcess extends PostProcess {
  60824. /** Weight of the bloom to be added to the original input. */
  60825. weight: number;
  60826. /**
  60827. * Creates a new instance of @see BloomMergePostProcess
  60828. * @param name The name of the effect.
  60829. * @param originalFromInput Post process which's input will be used for the merge.
  60830. * @param blurred Blurred highlights post process which's output will be used.
  60831. * @param weight Weight of the bloom to be added to the original input.
  60832. * @param options The required width/height ratio to downsize to before computing the render pass.
  60833. * @param camera The camera to apply the render pass to.
  60834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60835. * @param engine The engine which the post process will be applied. (default: current engine)
  60836. * @param reusable If the post process can be reused on the same frame. (default: false)
  60837. * @param textureType Type of textures used when performing the post process. (default: 0)
  60838. * @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)
  60839. */
  60840. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  60841. /** Weight of the bloom to be added to the original input. */
  60842. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60843. }
  60844. }
  60845. declare module "babylonjs/PostProcesses/bloomEffect" {
  60846. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60847. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60848. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60849. import { Camera } from "babylonjs/Cameras/camera";
  60850. import { Scene } from "babylonjs/scene";
  60851. /**
  60852. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  60853. */
  60854. export class BloomEffect extends PostProcessRenderEffect {
  60855. private bloomScale;
  60856. /**
  60857. * @hidden Internal
  60858. */
  60859. _effects: Array<PostProcess>;
  60860. /**
  60861. * @hidden Internal
  60862. */
  60863. _downscale: ExtractHighlightsPostProcess;
  60864. private _blurX;
  60865. private _blurY;
  60866. private _merge;
  60867. /**
  60868. * The luminance threshold to find bright areas of the image to bloom.
  60869. */
  60870. threshold: number;
  60871. /**
  60872. * The strength of the bloom.
  60873. */
  60874. weight: number;
  60875. /**
  60876. * Specifies the size of the bloom blur kernel, relative to the final output size
  60877. */
  60878. kernel: number;
  60879. /**
  60880. * Creates a new instance of @see BloomEffect
  60881. * @param scene The scene the effect belongs to.
  60882. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  60883. * @param bloomKernel The size of the kernel to be used when applying the blur.
  60884. * @param bloomWeight The the strength of bloom.
  60885. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  60886. * @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)
  60887. */
  60888. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  60889. /**
  60890. * Disposes each of the internal effects for a given camera.
  60891. * @param camera The camera to dispose the effect on.
  60892. */
  60893. disposeEffects(camera: Camera): void;
  60894. /**
  60895. * @hidden Internal
  60896. */
  60897. _updateEffects(): void;
  60898. /**
  60899. * Internal
  60900. * @returns if all the contained post processes are ready.
  60901. * @hidden
  60902. */
  60903. _isReady(): boolean;
  60904. }
  60905. }
  60906. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  60907. /** @hidden */
  60908. export var chromaticAberrationPixelShader: {
  60909. name: string;
  60910. shader: string;
  60911. };
  60912. }
  60913. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  60914. import { Vector2 } from "babylonjs/Maths/math.vector";
  60915. import { Nullable } from "babylonjs/types";
  60916. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60917. import { Camera } from "babylonjs/Cameras/camera";
  60918. import { Engine } from "babylonjs/Engines/engine";
  60919. import "babylonjs/Shaders/chromaticAberration.fragment";
  60920. /**
  60921. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  60922. */
  60923. export class ChromaticAberrationPostProcess extends PostProcess {
  60924. /**
  60925. * The amount of seperation of rgb channels (default: 30)
  60926. */
  60927. aberrationAmount: number;
  60928. /**
  60929. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  60930. */
  60931. radialIntensity: number;
  60932. /**
  60933. * 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))
  60934. */
  60935. direction: Vector2;
  60936. /**
  60937. * 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))
  60938. */
  60939. centerPosition: Vector2;
  60940. /**
  60941. * Creates a new instance ChromaticAberrationPostProcess
  60942. * @param name The name of the effect.
  60943. * @param screenWidth The width of the screen to apply the effect on.
  60944. * @param screenHeight The height of the screen to apply the effect on.
  60945. * @param options The required width/height ratio to downsize to before computing the render pass.
  60946. * @param camera The camera to apply the render pass to.
  60947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60948. * @param engine The engine which the post process will be applied. (default: current engine)
  60949. * @param reusable If the post process can be reused on the same frame. (default: false)
  60950. * @param textureType Type of textures used when performing the post process. (default: 0)
  60951. * @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)
  60952. */
  60953. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60954. }
  60955. }
  60956. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  60957. /** @hidden */
  60958. export var circleOfConfusionPixelShader: {
  60959. name: string;
  60960. shader: string;
  60961. };
  60962. }
  60963. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  60964. import { Nullable } from "babylonjs/types";
  60965. import { Engine } from "babylonjs/Engines/engine";
  60966. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60967. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60968. import { Camera } from "babylonjs/Cameras/camera";
  60969. import "babylonjs/Shaders/circleOfConfusion.fragment";
  60970. /**
  60971. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  60972. */
  60973. export class CircleOfConfusionPostProcess extends PostProcess {
  60974. /**
  60975. * 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.
  60976. */
  60977. lensSize: number;
  60978. /**
  60979. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  60980. */
  60981. fStop: number;
  60982. /**
  60983. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  60984. */
  60985. focusDistance: number;
  60986. /**
  60987. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  60988. */
  60989. focalLength: number;
  60990. private _depthTexture;
  60991. /**
  60992. * Creates a new instance CircleOfConfusionPostProcess
  60993. * @param name The name of the effect.
  60994. * @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.
  60995. * @param options The required width/height ratio to downsize to before computing the render pass.
  60996. * @param camera The camera to apply the render pass to.
  60997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60998. * @param engine The engine which the post process will be applied. (default: current engine)
  60999. * @param reusable If the post process can be reused on the same frame. (default: false)
  61000. * @param textureType Type of textures used when performing the post process. (default: 0)
  61001. * @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)
  61002. */
  61003. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61004. /**
  61005. * 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.
  61006. */
  61007. depthTexture: RenderTargetTexture;
  61008. }
  61009. }
  61010. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61011. /** @hidden */
  61012. export var colorCorrectionPixelShader: {
  61013. name: string;
  61014. shader: string;
  61015. };
  61016. }
  61017. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61018. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61019. import { Engine } from "babylonjs/Engines/engine";
  61020. import { Camera } from "babylonjs/Cameras/camera";
  61021. import "babylonjs/Shaders/colorCorrection.fragment";
  61022. /**
  61023. *
  61024. * This post-process allows the modification of rendered colors by using
  61025. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61026. *
  61027. * The object needs to be provided an url to a texture containing the color
  61028. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61029. * Use an image editing software to tweak the LUT to match your needs.
  61030. *
  61031. * For an example of a color LUT, see here:
  61032. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61033. * For explanations on color grading, see here:
  61034. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61035. *
  61036. */
  61037. export class ColorCorrectionPostProcess extends PostProcess {
  61038. private _colorTableTexture;
  61039. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61040. }
  61041. }
  61042. declare module "babylonjs/Shaders/convolution.fragment" {
  61043. /** @hidden */
  61044. export var convolutionPixelShader: {
  61045. name: string;
  61046. shader: string;
  61047. };
  61048. }
  61049. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61051. import { Nullable } from "babylonjs/types";
  61052. import { Camera } from "babylonjs/Cameras/camera";
  61053. import { Engine } from "babylonjs/Engines/engine";
  61054. import "babylonjs/Shaders/convolution.fragment";
  61055. /**
  61056. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61057. * input texture to perform effects such as edge detection or sharpening
  61058. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61059. */
  61060. export class ConvolutionPostProcess extends PostProcess {
  61061. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61062. kernel: number[];
  61063. /**
  61064. * Creates a new instance ConvolutionPostProcess
  61065. * @param name The name of the effect.
  61066. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61067. * @param options The required width/height ratio to downsize to before computing the render pass.
  61068. * @param camera The camera to apply the render pass to.
  61069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61070. * @param engine The engine which the post process will be applied. (default: current engine)
  61071. * @param reusable If the post process can be reused on the same frame. (default: false)
  61072. * @param textureType Type of textures used when performing the post process. (default: 0)
  61073. */
  61074. constructor(name: string,
  61075. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61076. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61077. /**
  61078. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61079. */
  61080. static EdgeDetect0Kernel: number[];
  61081. /**
  61082. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61083. */
  61084. static EdgeDetect1Kernel: number[];
  61085. /**
  61086. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61087. */
  61088. static EdgeDetect2Kernel: number[];
  61089. /**
  61090. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61091. */
  61092. static SharpenKernel: number[];
  61093. /**
  61094. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61095. */
  61096. static EmbossKernel: number[];
  61097. /**
  61098. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61099. */
  61100. static GaussianKernel: number[];
  61101. }
  61102. }
  61103. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61104. import { Nullable } from "babylonjs/types";
  61105. import { Vector2 } from "babylonjs/Maths/math.vector";
  61106. import { Camera } from "babylonjs/Cameras/camera";
  61107. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61108. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61109. import { Engine } from "babylonjs/Engines/engine";
  61110. import { Scene } from "babylonjs/scene";
  61111. /**
  61112. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61113. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61114. * based on samples that have a large difference in distance than the center pixel.
  61115. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61116. */
  61117. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61118. direction: Vector2;
  61119. /**
  61120. * Creates a new instance CircleOfConfusionPostProcess
  61121. * @param name The name of the effect.
  61122. * @param scene The scene the effect belongs to.
  61123. * @param direction The direction the blur should be applied.
  61124. * @param kernel The size of the kernel used to blur.
  61125. * @param options The required width/height ratio to downsize to before computing the render pass.
  61126. * @param camera The camera to apply the render pass to.
  61127. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61128. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61130. * @param engine The engine which the post process will be applied. (default: current engine)
  61131. * @param reusable If the post process can be reused on the same frame. (default: false)
  61132. * @param textureType Type of textures used when performing the post process. (default: 0)
  61133. * @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)
  61134. */
  61135. 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);
  61136. }
  61137. }
  61138. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61139. /** @hidden */
  61140. export var depthOfFieldMergePixelShader: {
  61141. name: string;
  61142. shader: string;
  61143. };
  61144. }
  61145. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61146. import { Nullable } from "babylonjs/types";
  61147. import { Camera } from "babylonjs/Cameras/camera";
  61148. import { Effect } from "babylonjs/Materials/effect";
  61149. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61150. import { Engine } from "babylonjs/Engines/engine";
  61151. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61152. /**
  61153. * Options to be set when merging outputs from the default pipeline.
  61154. */
  61155. export class DepthOfFieldMergePostProcessOptions {
  61156. /**
  61157. * The original image to merge on top of
  61158. */
  61159. originalFromInput: PostProcess;
  61160. /**
  61161. * Parameters to perform the merge of the depth of field effect
  61162. */
  61163. depthOfField?: {
  61164. circleOfConfusion: PostProcess;
  61165. blurSteps: Array<PostProcess>;
  61166. };
  61167. /**
  61168. * Parameters to perform the merge of bloom effect
  61169. */
  61170. bloom?: {
  61171. blurred: PostProcess;
  61172. weight: number;
  61173. };
  61174. }
  61175. /**
  61176. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61177. */
  61178. export class DepthOfFieldMergePostProcess extends PostProcess {
  61179. private blurSteps;
  61180. /**
  61181. * Creates a new instance of DepthOfFieldMergePostProcess
  61182. * @param name The name of the effect.
  61183. * @param originalFromInput Post process which's input will be used for the merge.
  61184. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61185. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61186. * @param options The required width/height ratio to downsize to before computing the render pass.
  61187. * @param camera The camera to apply the render pass to.
  61188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61189. * @param engine The engine which the post process will be applied. (default: current engine)
  61190. * @param reusable If the post process can be reused on the same frame. (default: false)
  61191. * @param textureType Type of textures used when performing the post process. (default: 0)
  61192. * @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)
  61193. */
  61194. 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);
  61195. /**
  61196. * Updates the effect with the current post process compile time values and recompiles the shader.
  61197. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61198. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61199. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61200. * @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
  61201. * @param onCompiled Called when the shader has been compiled.
  61202. * @param onError Called if there is an error when compiling a shader.
  61203. */
  61204. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61205. }
  61206. }
  61207. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61208. import { Nullable } from "babylonjs/types";
  61209. import { Camera } from "babylonjs/Cameras/camera";
  61210. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61211. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61212. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61213. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61214. import { Scene } from "babylonjs/scene";
  61215. /**
  61216. * Specifies the level of max blur that should be applied when using the depth of field effect
  61217. */
  61218. export enum DepthOfFieldEffectBlurLevel {
  61219. /**
  61220. * Subtle blur
  61221. */
  61222. Low = 0,
  61223. /**
  61224. * Medium blur
  61225. */
  61226. Medium = 1,
  61227. /**
  61228. * Large blur
  61229. */
  61230. High = 2
  61231. }
  61232. /**
  61233. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61234. */
  61235. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61236. private _circleOfConfusion;
  61237. /**
  61238. * @hidden Internal, blurs from high to low
  61239. */
  61240. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61241. private _depthOfFieldBlurY;
  61242. private _dofMerge;
  61243. /**
  61244. * @hidden Internal post processes in depth of field effect
  61245. */
  61246. _effects: Array<PostProcess>;
  61247. /**
  61248. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61249. */
  61250. focalLength: number;
  61251. /**
  61252. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61253. */
  61254. fStop: number;
  61255. /**
  61256. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61257. */
  61258. focusDistance: number;
  61259. /**
  61260. * 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.
  61261. */
  61262. lensSize: number;
  61263. /**
  61264. * Creates a new instance DepthOfFieldEffect
  61265. * @param scene The scene the effect belongs to.
  61266. * @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.
  61267. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61268. * @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)
  61269. */
  61270. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61271. /**
  61272. * Get the current class name of the current effet
  61273. * @returns "DepthOfFieldEffect"
  61274. */
  61275. getClassName(): string;
  61276. /**
  61277. * 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.
  61278. */
  61279. depthTexture: RenderTargetTexture;
  61280. /**
  61281. * Disposes each of the internal effects for a given camera.
  61282. * @param camera The camera to dispose the effect on.
  61283. */
  61284. disposeEffects(camera: Camera): void;
  61285. /**
  61286. * @hidden Internal
  61287. */
  61288. _updateEffects(): void;
  61289. /**
  61290. * Internal
  61291. * @returns if all the contained post processes are ready.
  61292. * @hidden
  61293. */
  61294. _isReady(): boolean;
  61295. }
  61296. }
  61297. declare module "babylonjs/Shaders/displayPass.fragment" {
  61298. /** @hidden */
  61299. export var displayPassPixelShader: {
  61300. name: string;
  61301. shader: string;
  61302. };
  61303. }
  61304. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61305. import { Nullable } from "babylonjs/types";
  61306. import { Camera } from "babylonjs/Cameras/camera";
  61307. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61308. import { Engine } from "babylonjs/Engines/engine";
  61309. import "babylonjs/Shaders/displayPass.fragment";
  61310. /**
  61311. * DisplayPassPostProcess which produces an output the same as it's input
  61312. */
  61313. export class DisplayPassPostProcess extends PostProcess {
  61314. /**
  61315. * Creates the DisplayPassPostProcess
  61316. * @param name The name of the effect.
  61317. * @param options The required width/height ratio to downsize to before computing the render pass.
  61318. * @param camera The camera to apply the render pass to.
  61319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61320. * @param engine The engine which the post process will be applied. (default: current engine)
  61321. * @param reusable If the post process can be reused on the same frame. (default: false)
  61322. */
  61323. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61324. }
  61325. }
  61326. declare module "babylonjs/Shaders/filter.fragment" {
  61327. /** @hidden */
  61328. export var filterPixelShader: {
  61329. name: string;
  61330. shader: string;
  61331. };
  61332. }
  61333. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61334. import { Nullable } from "babylonjs/types";
  61335. import { Matrix } from "babylonjs/Maths/math.vector";
  61336. import { Camera } from "babylonjs/Cameras/camera";
  61337. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61338. import { Engine } from "babylonjs/Engines/engine";
  61339. import "babylonjs/Shaders/filter.fragment";
  61340. /**
  61341. * Applies a kernel filter to the image
  61342. */
  61343. export class FilterPostProcess extends PostProcess {
  61344. /** The matrix to be applied to the image */
  61345. kernelMatrix: Matrix;
  61346. /**
  61347. *
  61348. * @param name The name of the effect.
  61349. * @param kernelMatrix The matrix to be applied to the image
  61350. * @param options The required width/height ratio to downsize to before computing the render pass.
  61351. * @param camera The camera to apply the render pass to.
  61352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61353. * @param engine The engine which the post process will be applied. (default: current engine)
  61354. * @param reusable If the post process can be reused on the same frame. (default: false)
  61355. */
  61356. constructor(name: string,
  61357. /** The matrix to be applied to the image */
  61358. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61359. }
  61360. }
  61361. declare module "babylonjs/Shaders/fxaa.fragment" {
  61362. /** @hidden */
  61363. export var fxaaPixelShader: {
  61364. name: string;
  61365. shader: string;
  61366. };
  61367. }
  61368. declare module "babylonjs/Shaders/fxaa.vertex" {
  61369. /** @hidden */
  61370. export var fxaaVertexShader: {
  61371. name: string;
  61372. shader: string;
  61373. };
  61374. }
  61375. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61376. import { Nullable } from "babylonjs/types";
  61377. import { Camera } from "babylonjs/Cameras/camera";
  61378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61379. import { Engine } from "babylonjs/Engines/engine";
  61380. import "babylonjs/Shaders/fxaa.fragment";
  61381. import "babylonjs/Shaders/fxaa.vertex";
  61382. /**
  61383. * Fxaa post process
  61384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61385. */
  61386. export class FxaaPostProcess extends PostProcess {
  61387. /** @hidden */
  61388. texelWidth: number;
  61389. /** @hidden */
  61390. texelHeight: number;
  61391. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61392. private _getDefines;
  61393. }
  61394. }
  61395. declare module "babylonjs/Shaders/grain.fragment" {
  61396. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61397. /** @hidden */
  61398. export var grainPixelShader: {
  61399. name: string;
  61400. shader: string;
  61401. };
  61402. }
  61403. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61404. import { Nullable } from "babylonjs/types";
  61405. import { Camera } from "babylonjs/Cameras/camera";
  61406. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61407. import { Engine } from "babylonjs/Engines/engine";
  61408. import "babylonjs/Shaders/grain.fragment";
  61409. /**
  61410. * The GrainPostProcess adds noise to the image at mid luminance levels
  61411. */
  61412. export class GrainPostProcess extends PostProcess {
  61413. /**
  61414. * The intensity of the grain added (default: 30)
  61415. */
  61416. intensity: number;
  61417. /**
  61418. * If the grain should be randomized on every frame
  61419. */
  61420. animated: boolean;
  61421. /**
  61422. * Creates a new instance of @see GrainPostProcess
  61423. * @param name The name of the effect.
  61424. * @param options The required width/height ratio to downsize to before computing the render pass.
  61425. * @param camera The camera to apply the render pass to.
  61426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61427. * @param engine The engine which the post process will be applied. (default: current engine)
  61428. * @param reusable If the post process can be reused on the same frame. (default: false)
  61429. * @param textureType Type of textures used when performing the post process. (default: 0)
  61430. * @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)
  61431. */
  61432. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61433. }
  61434. }
  61435. declare module "babylonjs/Shaders/highlights.fragment" {
  61436. /** @hidden */
  61437. export var highlightsPixelShader: {
  61438. name: string;
  61439. shader: string;
  61440. };
  61441. }
  61442. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61443. import { Nullable } from "babylonjs/types";
  61444. import { Camera } from "babylonjs/Cameras/camera";
  61445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61446. import { Engine } from "babylonjs/Engines/engine";
  61447. import "babylonjs/Shaders/highlights.fragment";
  61448. /**
  61449. * Extracts highlights from the image
  61450. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61451. */
  61452. export class HighlightsPostProcess extends PostProcess {
  61453. /**
  61454. * Extracts highlights from the image
  61455. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61456. * @param name The name of the effect.
  61457. * @param options The required width/height ratio to downsize to before computing the render pass.
  61458. * @param camera The camera to apply the render pass to.
  61459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61460. * @param engine The engine which the post process will be applied. (default: current engine)
  61461. * @param reusable If the post process can be reused on the same frame. (default: false)
  61462. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61463. */
  61464. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61465. }
  61466. }
  61467. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61468. /** @hidden */
  61469. export var mrtFragmentDeclaration: {
  61470. name: string;
  61471. shader: string;
  61472. };
  61473. }
  61474. declare module "babylonjs/Shaders/geometry.fragment" {
  61475. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61476. /** @hidden */
  61477. export var geometryPixelShader: {
  61478. name: string;
  61479. shader: string;
  61480. };
  61481. }
  61482. declare module "babylonjs/Shaders/geometry.vertex" {
  61483. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61484. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61486. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61488. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61489. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61490. /** @hidden */
  61491. export var geometryVertexShader: {
  61492. name: string;
  61493. shader: string;
  61494. };
  61495. }
  61496. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61497. import { Matrix } from "babylonjs/Maths/math.vector";
  61498. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61499. import { Mesh } from "babylonjs/Meshes/mesh";
  61500. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61501. import { Effect } from "babylonjs/Materials/effect";
  61502. import { Scene } from "babylonjs/scene";
  61503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61504. import "babylonjs/Shaders/geometry.fragment";
  61505. import "babylonjs/Shaders/geometry.vertex";
  61506. /** @hidden */
  61507. interface ISavedTransformationMatrix {
  61508. world: Matrix;
  61509. viewProjection: Matrix;
  61510. }
  61511. /**
  61512. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61513. */
  61514. export class GeometryBufferRenderer {
  61515. /**
  61516. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61517. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61518. */
  61519. static readonly POSITION_TEXTURE_TYPE: number;
  61520. /**
  61521. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61522. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61523. */
  61524. static readonly VELOCITY_TEXTURE_TYPE: number;
  61525. /**
  61526. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61527. * in order to compute objects velocities when enableVelocity is set to "true"
  61528. * @hidden
  61529. */
  61530. _previousTransformationMatrices: {
  61531. [index: number]: ISavedTransformationMatrix;
  61532. };
  61533. /**
  61534. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61535. * in order to compute objects velocities when enableVelocity is set to "true"
  61536. * @hidden
  61537. */
  61538. _previousBonesTransformationMatrices: {
  61539. [index: number]: Float32Array;
  61540. };
  61541. /**
  61542. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61543. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61544. */
  61545. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61546. private _scene;
  61547. private _multiRenderTarget;
  61548. private _ratio;
  61549. private _enablePosition;
  61550. private _enableVelocity;
  61551. private _positionIndex;
  61552. private _velocityIndex;
  61553. protected _effect: Effect;
  61554. protected _cachedDefines: string;
  61555. /**
  61556. * Set the render list (meshes to be rendered) used in the G buffer.
  61557. */
  61558. renderList: Mesh[];
  61559. /**
  61560. * Gets wether or not G buffer are supported by the running hardware.
  61561. * This requires draw buffer supports
  61562. */
  61563. readonly isSupported: boolean;
  61564. /**
  61565. * Returns the index of the given texture type in the G-Buffer textures array
  61566. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61567. * @returns the index of the given texture type in the G-Buffer textures array
  61568. */
  61569. getTextureIndex(textureType: number): number;
  61570. /**
  61571. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61572. */
  61573. /**
  61574. * Sets whether or not objects positions are enabled for the G buffer.
  61575. */
  61576. enablePosition: boolean;
  61577. /**
  61578. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61579. */
  61580. /**
  61581. * Sets wether or not objects velocities are enabled for the G buffer.
  61582. */
  61583. enableVelocity: boolean;
  61584. /**
  61585. * Gets the scene associated with the buffer.
  61586. */
  61587. readonly scene: Scene;
  61588. /**
  61589. * Gets the ratio used by the buffer during its creation.
  61590. * How big is the buffer related to the main canvas.
  61591. */
  61592. readonly ratio: number;
  61593. /** @hidden */
  61594. static _SceneComponentInitialization: (scene: Scene) => void;
  61595. /**
  61596. * Creates a new G Buffer for the scene
  61597. * @param scene The scene the buffer belongs to
  61598. * @param ratio How big is the buffer related to the main canvas.
  61599. */
  61600. constructor(scene: Scene, ratio?: number);
  61601. /**
  61602. * Checks wether everything is ready to render a submesh to the G buffer.
  61603. * @param subMesh the submesh to check readiness for
  61604. * @param useInstances is the mesh drawn using instance or not
  61605. * @returns true if ready otherwise false
  61606. */
  61607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61608. /**
  61609. * Gets the current underlying G Buffer.
  61610. * @returns the buffer
  61611. */
  61612. getGBuffer(): MultiRenderTarget;
  61613. /**
  61614. * Gets the number of samples used to render the buffer (anti aliasing).
  61615. */
  61616. /**
  61617. * Sets the number of samples used to render the buffer (anti aliasing).
  61618. */
  61619. samples: number;
  61620. /**
  61621. * Disposes the renderer and frees up associated resources.
  61622. */
  61623. dispose(): void;
  61624. protected _createRenderTargets(): void;
  61625. private _copyBonesTransformationMatrices;
  61626. }
  61627. }
  61628. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61629. import { Nullable } from "babylonjs/types";
  61630. import { Scene } from "babylonjs/scene";
  61631. import { ISceneComponent } from "babylonjs/sceneComponent";
  61632. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61633. module "babylonjs/scene" {
  61634. interface Scene {
  61635. /** @hidden (Backing field) */
  61636. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61637. /**
  61638. * Gets or Sets the current geometry buffer associated to the scene.
  61639. */
  61640. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61641. /**
  61642. * Enables a GeometryBufferRender and associates it with the scene
  61643. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61644. * @returns the GeometryBufferRenderer
  61645. */
  61646. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61647. /**
  61648. * Disables the GeometryBufferRender associated with the scene
  61649. */
  61650. disableGeometryBufferRenderer(): void;
  61651. }
  61652. }
  61653. /**
  61654. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61655. * in several rendering techniques.
  61656. */
  61657. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61658. /**
  61659. * The component name helpful to identify the component in the list of scene components.
  61660. */
  61661. readonly name: string;
  61662. /**
  61663. * The scene the component belongs to.
  61664. */
  61665. scene: Scene;
  61666. /**
  61667. * Creates a new instance of the component for the given scene
  61668. * @param scene Defines the scene to register the component in
  61669. */
  61670. constructor(scene: Scene);
  61671. /**
  61672. * Registers the component in a given scene
  61673. */
  61674. register(): void;
  61675. /**
  61676. * Rebuilds the elements related to this component in case of
  61677. * context lost for instance.
  61678. */
  61679. rebuild(): void;
  61680. /**
  61681. * Disposes the component and the associated ressources
  61682. */
  61683. dispose(): void;
  61684. private _gatherRenderTargets;
  61685. }
  61686. }
  61687. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61688. /** @hidden */
  61689. export var motionBlurPixelShader: {
  61690. name: string;
  61691. shader: string;
  61692. };
  61693. }
  61694. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61695. import { Nullable } from "babylonjs/types";
  61696. import { Camera } from "babylonjs/Cameras/camera";
  61697. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61698. import { Scene } from "babylonjs/scene";
  61699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61700. import "babylonjs/Animations/animatable";
  61701. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61702. import "babylonjs/Shaders/motionBlur.fragment";
  61703. import { Engine } from "babylonjs/Engines/engine";
  61704. /**
  61705. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61706. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61707. * As an example, all you have to do is to create the post-process:
  61708. * var mb = new BABYLON.MotionBlurPostProcess(
  61709. * 'mb', // The name of the effect.
  61710. * scene, // The scene containing the objects to blur according to their velocity.
  61711. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61712. * camera // The camera to apply the render pass to.
  61713. * );
  61714. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61715. */
  61716. export class MotionBlurPostProcess extends PostProcess {
  61717. /**
  61718. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61719. */
  61720. motionStrength: number;
  61721. /**
  61722. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61723. */
  61724. /**
  61725. * Sets the number of iterations to be used for motion blur quality
  61726. */
  61727. motionBlurSamples: number;
  61728. private _motionBlurSamples;
  61729. private _geometryBufferRenderer;
  61730. /**
  61731. * Creates a new instance MotionBlurPostProcess
  61732. * @param name The name of the effect.
  61733. * @param scene The scene containing the objects to blur according to their velocity.
  61734. * @param options The required width/height ratio to downsize to before computing the render pass.
  61735. * @param camera The camera to apply the render pass to.
  61736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61737. * @param engine The engine which the post process will be applied. (default: current engine)
  61738. * @param reusable If the post process can be reused on the same frame. (default: false)
  61739. * @param textureType Type of textures used when performing the post process. (default: 0)
  61740. * @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)
  61741. */
  61742. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61743. /**
  61744. * Excludes the given skinned mesh from computing bones velocities.
  61745. * 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.
  61746. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61747. */
  61748. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61749. /**
  61750. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61751. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61752. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61753. */
  61754. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61755. /**
  61756. * Disposes the post process.
  61757. * @param camera The camera to dispose the post process on.
  61758. */
  61759. dispose(camera?: Camera): void;
  61760. }
  61761. }
  61762. declare module "babylonjs/Shaders/refraction.fragment" {
  61763. /** @hidden */
  61764. export var refractionPixelShader: {
  61765. name: string;
  61766. shader: string;
  61767. };
  61768. }
  61769. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61770. import { Color3 } from "babylonjs/Maths/math.color";
  61771. import { Camera } from "babylonjs/Cameras/camera";
  61772. import { Texture } from "babylonjs/Materials/Textures/texture";
  61773. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61774. import { Engine } from "babylonjs/Engines/engine";
  61775. import "babylonjs/Shaders/refraction.fragment";
  61776. /**
  61777. * Post process which applies a refractin texture
  61778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61779. */
  61780. export class RefractionPostProcess extends PostProcess {
  61781. /** the base color of the refraction (used to taint the rendering) */
  61782. color: Color3;
  61783. /** simulated refraction depth */
  61784. depth: number;
  61785. /** the coefficient of the base color (0 to remove base color tainting) */
  61786. colorLevel: number;
  61787. private _refTexture;
  61788. private _ownRefractionTexture;
  61789. /**
  61790. * Gets or sets the refraction texture
  61791. * Please note that you are responsible for disposing the texture if you set it manually
  61792. */
  61793. refractionTexture: Texture;
  61794. /**
  61795. * Initializes the RefractionPostProcess
  61796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61797. * @param name The name of the effect.
  61798. * @param refractionTextureUrl Url of the refraction texture to use
  61799. * @param color the base color of the refraction (used to taint the rendering)
  61800. * @param depth simulated refraction depth
  61801. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61802. * @param camera The camera to apply the render pass to.
  61803. * @param options The required width/height ratio to downsize to before computing the render pass.
  61804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61805. * @param engine The engine which the post process will be applied. (default: current engine)
  61806. * @param reusable If the post process can be reused on the same frame. (default: false)
  61807. */
  61808. constructor(name: string, refractionTextureUrl: string,
  61809. /** the base color of the refraction (used to taint the rendering) */
  61810. color: Color3,
  61811. /** simulated refraction depth */
  61812. depth: number,
  61813. /** the coefficient of the base color (0 to remove base color tainting) */
  61814. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61815. /**
  61816. * Disposes of the post process
  61817. * @param camera Camera to dispose post process on
  61818. */
  61819. dispose(camera: Camera): void;
  61820. }
  61821. }
  61822. declare module "babylonjs/Shaders/sharpen.fragment" {
  61823. /** @hidden */
  61824. export var sharpenPixelShader: {
  61825. name: string;
  61826. shader: string;
  61827. };
  61828. }
  61829. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  61830. import { Nullable } from "babylonjs/types";
  61831. import { Camera } from "babylonjs/Cameras/camera";
  61832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61833. import "babylonjs/Shaders/sharpen.fragment";
  61834. import { Engine } from "babylonjs/Engines/engine";
  61835. /**
  61836. * The SharpenPostProcess applies a sharpen kernel to every pixel
  61837. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61838. */
  61839. export class SharpenPostProcess extends PostProcess {
  61840. /**
  61841. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  61842. */
  61843. colorAmount: number;
  61844. /**
  61845. * How much sharpness should be applied (default: 0.3)
  61846. */
  61847. edgeAmount: number;
  61848. /**
  61849. * Creates a new instance ConvolutionPostProcess
  61850. * @param name The name of the effect.
  61851. * @param options The required width/height ratio to downsize to before computing the render pass.
  61852. * @param camera The camera to apply the render pass to.
  61853. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61854. * @param engine The engine which the post process will be applied. (default: current engine)
  61855. * @param reusable If the post process can be reused on the same frame. (default: false)
  61856. * @param textureType Type of textures used when performing the post process. (default: 0)
  61857. * @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)
  61858. */
  61859. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61860. }
  61861. }
  61862. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  61863. import { Nullable } from "babylonjs/types";
  61864. import { Camera } from "babylonjs/Cameras/camera";
  61865. import { Engine } from "babylonjs/Engines/engine";
  61866. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61867. import { IInspectable } from "babylonjs/Misc/iInspectable";
  61868. /**
  61869. * PostProcessRenderPipeline
  61870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61871. */
  61872. export class PostProcessRenderPipeline {
  61873. private engine;
  61874. private _renderEffects;
  61875. private _renderEffectsForIsolatedPass;
  61876. /**
  61877. * List of inspectable custom properties (used by the Inspector)
  61878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61879. */
  61880. inspectableCustomProperties: IInspectable[];
  61881. /**
  61882. * @hidden
  61883. */
  61884. protected _cameras: Camera[];
  61885. /** @hidden */
  61886. _name: string;
  61887. /**
  61888. * Gets pipeline name
  61889. */
  61890. readonly name: string;
  61891. /**
  61892. * Initializes a PostProcessRenderPipeline
  61893. * @param engine engine to add the pipeline to
  61894. * @param name name of the pipeline
  61895. */
  61896. constructor(engine: Engine, name: string);
  61897. /**
  61898. * Gets the class name
  61899. * @returns "PostProcessRenderPipeline"
  61900. */
  61901. getClassName(): string;
  61902. /**
  61903. * If all the render effects in the pipeline are supported
  61904. */
  61905. readonly isSupported: boolean;
  61906. /**
  61907. * Adds an effect to the pipeline
  61908. * @param renderEffect the effect to add
  61909. */
  61910. addEffect(renderEffect: PostProcessRenderEffect): void;
  61911. /** @hidden */
  61912. _rebuild(): void;
  61913. /** @hidden */
  61914. _enableEffect(renderEffectName: string, cameras: Camera): void;
  61915. /** @hidden */
  61916. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  61917. /** @hidden */
  61918. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61919. /** @hidden */
  61920. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  61921. /** @hidden */
  61922. _attachCameras(cameras: Camera, unique: boolean): void;
  61923. /** @hidden */
  61924. _attachCameras(cameras: Camera[], unique: boolean): void;
  61925. /** @hidden */
  61926. _detachCameras(cameras: Camera): void;
  61927. /** @hidden */
  61928. _detachCameras(cameras: Nullable<Camera[]>): void;
  61929. /** @hidden */
  61930. _update(): void;
  61931. /** @hidden */
  61932. _reset(): void;
  61933. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  61934. /**
  61935. * Disposes of the pipeline
  61936. */
  61937. dispose(): void;
  61938. }
  61939. }
  61940. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  61941. import { Camera } from "babylonjs/Cameras/camera";
  61942. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61943. /**
  61944. * PostProcessRenderPipelineManager class
  61945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61946. */
  61947. export class PostProcessRenderPipelineManager {
  61948. private _renderPipelines;
  61949. /**
  61950. * Initializes a PostProcessRenderPipelineManager
  61951. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61952. */
  61953. constructor();
  61954. /**
  61955. * Gets the list of supported render pipelines
  61956. */
  61957. readonly supportedPipelines: PostProcessRenderPipeline[];
  61958. /**
  61959. * Adds a pipeline to the manager
  61960. * @param renderPipeline The pipeline to add
  61961. */
  61962. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  61963. /**
  61964. * Attaches a camera to the pipeline
  61965. * @param renderPipelineName The name of the pipeline to attach to
  61966. * @param cameras the camera to attach
  61967. * @param unique if the camera can be attached multiple times to the pipeline
  61968. */
  61969. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  61970. /**
  61971. * Detaches a camera from the pipeline
  61972. * @param renderPipelineName The name of the pipeline to detach from
  61973. * @param cameras the camera to detach
  61974. */
  61975. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  61976. /**
  61977. * Enables an effect by name on a pipeline
  61978. * @param renderPipelineName the name of the pipeline to enable the effect in
  61979. * @param renderEffectName the name of the effect to enable
  61980. * @param cameras the cameras that the effect should be enabled on
  61981. */
  61982. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61983. /**
  61984. * Disables an effect by name on a pipeline
  61985. * @param renderPipelineName the name of the pipeline to disable the effect in
  61986. * @param renderEffectName the name of the effect to disable
  61987. * @param cameras the cameras that the effect should be disabled on
  61988. */
  61989. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  61990. /**
  61991. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  61992. */
  61993. update(): void;
  61994. /** @hidden */
  61995. _rebuild(): void;
  61996. /**
  61997. * Disposes of the manager and pipelines
  61998. */
  61999. dispose(): void;
  62000. }
  62001. }
  62002. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62003. import { ISceneComponent } from "babylonjs/sceneComponent";
  62004. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62005. import { Scene } from "babylonjs/scene";
  62006. module "babylonjs/scene" {
  62007. interface Scene {
  62008. /** @hidden (Backing field) */
  62009. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62010. /**
  62011. * Gets the postprocess render pipeline manager
  62012. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62013. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62014. */
  62015. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62016. }
  62017. }
  62018. /**
  62019. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62020. */
  62021. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62022. /**
  62023. * The component name helpfull to identify the component in the list of scene components.
  62024. */
  62025. readonly name: string;
  62026. /**
  62027. * The scene the component belongs to.
  62028. */
  62029. scene: Scene;
  62030. /**
  62031. * Creates a new instance of the component for the given scene
  62032. * @param scene Defines the scene to register the component in
  62033. */
  62034. constructor(scene: Scene);
  62035. /**
  62036. * Registers the component in a given scene
  62037. */
  62038. register(): void;
  62039. /**
  62040. * Rebuilds the elements related to this component in case of
  62041. * context lost for instance.
  62042. */
  62043. rebuild(): void;
  62044. /**
  62045. * Disposes the component and the associated ressources
  62046. */
  62047. dispose(): void;
  62048. private _gatherRenderTargets;
  62049. }
  62050. }
  62051. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62052. import { Nullable } from "babylonjs/types";
  62053. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62054. import { Camera } from "babylonjs/Cameras/camera";
  62055. import { IDisposable } from "babylonjs/scene";
  62056. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62057. import { Scene } from "babylonjs/scene";
  62058. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62059. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62060. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62061. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62062. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62063. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62064. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62065. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62066. import { Animation } from "babylonjs/Animations/animation";
  62067. /**
  62068. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62069. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62070. */
  62071. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62072. private _scene;
  62073. private _camerasToBeAttached;
  62074. /**
  62075. * ID of the sharpen post process,
  62076. */
  62077. private readonly SharpenPostProcessId;
  62078. /**
  62079. * @ignore
  62080. * ID of the image processing post process;
  62081. */
  62082. readonly ImageProcessingPostProcessId: string;
  62083. /**
  62084. * @ignore
  62085. * ID of the Fast Approximate Anti-Aliasing post process;
  62086. */
  62087. readonly FxaaPostProcessId: string;
  62088. /**
  62089. * ID of the chromatic aberration post process,
  62090. */
  62091. private readonly ChromaticAberrationPostProcessId;
  62092. /**
  62093. * ID of the grain post process
  62094. */
  62095. private readonly GrainPostProcessId;
  62096. /**
  62097. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62098. */
  62099. sharpen: SharpenPostProcess;
  62100. private _sharpenEffect;
  62101. private bloom;
  62102. /**
  62103. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62104. */
  62105. depthOfField: DepthOfFieldEffect;
  62106. /**
  62107. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62108. */
  62109. fxaa: FxaaPostProcess;
  62110. /**
  62111. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62112. */
  62113. imageProcessing: ImageProcessingPostProcess;
  62114. /**
  62115. * Chromatic aberration post process which will shift rgb colors in the image
  62116. */
  62117. chromaticAberration: ChromaticAberrationPostProcess;
  62118. private _chromaticAberrationEffect;
  62119. /**
  62120. * Grain post process which add noise to the image
  62121. */
  62122. grain: GrainPostProcess;
  62123. private _grainEffect;
  62124. /**
  62125. * Glow post process which adds a glow to emissive areas of the image
  62126. */
  62127. private _glowLayer;
  62128. /**
  62129. * Animations which can be used to tweak settings over a period of time
  62130. */
  62131. animations: Animation[];
  62132. private _imageProcessingConfigurationObserver;
  62133. private _sharpenEnabled;
  62134. private _bloomEnabled;
  62135. private _depthOfFieldEnabled;
  62136. private _depthOfFieldBlurLevel;
  62137. private _fxaaEnabled;
  62138. private _imageProcessingEnabled;
  62139. private _defaultPipelineTextureType;
  62140. private _bloomScale;
  62141. private _chromaticAberrationEnabled;
  62142. private _grainEnabled;
  62143. private _buildAllowed;
  62144. /**
  62145. * Gets active scene
  62146. */
  62147. readonly scene: Scene;
  62148. /**
  62149. * Enable or disable the sharpen process from the pipeline
  62150. */
  62151. sharpenEnabled: boolean;
  62152. private _resizeObserver;
  62153. private _hardwareScaleLevel;
  62154. private _bloomKernel;
  62155. /**
  62156. * Specifies the size of the bloom blur kernel, relative to the final output size
  62157. */
  62158. bloomKernel: number;
  62159. /**
  62160. * Specifies the weight of the bloom in the final rendering
  62161. */
  62162. private _bloomWeight;
  62163. /**
  62164. * Specifies the luma threshold for the area that will be blurred by the bloom
  62165. */
  62166. private _bloomThreshold;
  62167. private _hdr;
  62168. /**
  62169. * The strength of the bloom.
  62170. */
  62171. bloomWeight: number;
  62172. /**
  62173. * The strength of the bloom.
  62174. */
  62175. bloomThreshold: number;
  62176. /**
  62177. * The scale of the bloom, lower value will provide better performance.
  62178. */
  62179. bloomScale: number;
  62180. /**
  62181. * Enable or disable the bloom from the pipeline
  62182. */
  62183. bloomEnabled: boolean;
  62184. private _rebuildBloom;
  62185. /**
  62186. * If the depth of field is enabled.
  62187. */
  62188. depthOfFieldEnabled: boolean;
  62189. /**
  62190. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62191. */
  62192. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62193. /**
  62194. * If the anti aliasing is enabled.
  62195. */
  62196. fxaaEnabled: boolean;
  62197. private _samples;
  62198. /**
  62199. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62200. */
  62201. samples: number;
  62202. /**
  62203. * If image processing is enabled.
  62204. */
  62205. imageProcessingEnabled: boolean;
  62206. /**
  62207. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62208. */
  62209. glowLayerEnabled: boolean;
  62210. /**
  62211. * Gets the glow layer (or null if not defined)
  62212. */
  62213. readonly glowLayer: Nullable<GlowLayer>;
  62214. /**
  62215. * Enable or disable the chromaticAberration process from the pipeline
  62216. */
  62217. chromaticAberrationEnabled: boolean;
  62218. /**
  62219. * Enable or disable the grain process from the pipeline
  62220. */
  62221. grainEnabled: boolean;
  62222. /**
  62223. * @constructor
  62224. * @param name - The rendering pipeline name (default: "")
  62225. * @param hdr - If high dynamic range textures should be used (default: true)
  62226. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62227. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62228. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62229. */
  62230. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62231. /**
  62232. * Get the class name
  62233. * @returns "DefaultRenderingPipeline"
  62234. */
  62235. getClassName(): string;
  62236. /**
  62237. * Force the compilation of the entire pipeline.
  62238. */
  62239. prepare(): void;
  62240. private _hasCleared;
  62241. private _prevPostProcess;
  62242. private _prevPrevPostProcess;
  62243. private _setAutoClearAndTextureSharing;
  62244. private _depthOfFieldSceneObserver;
  62245. private _buildPipeline;
  62246. private _disposePostProcesses;
  62247. /**
  62248. * Adds a camera to the pipeline
  62249. * @param camera the camera to be added
  62250. */
  62251. addCamera(camera: Camera): void;
  62252. /**
  62253. * Removes a camera from the pipeline
  62254. * @param camera the camera to remove
  62255. */
  62256. removeCamera(camera: Camera): void;
  62257. /**
  62258. * Dispose of the pipeline and stop all post processes
  62259. */
  62260. dispose(): void;
  62261. /**
  62262. * Serialize the rendering pipeline (Used when exporting)
  62263. * @returns the serialized object
  62264. */
  62265. serialize(): any;
  62266. /**
  62267. * Parse the serialized pipeline
  62268. * @param source Source pipeline.
  62269. * @param scene The scene to load the pipeline to.
  62270. * @param rootUrl The URL of the serialized pipeline.
  62271. * @returns An instantiated pipeline from the serialized object.
  62272. */
  62273. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62274. }
  62275. }
  62276. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62277. /** @hidden */
  62278. export var lensHighlightsPixelShader: {
  62279. name: string;
  62280. shader: string;
  62281. };
  62282. }
  62283. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62284. /** @hidden */
  62285. export var depthOfFieldPixelShader: {
  62286. name: string;
  62287. shader: string;
  62288. };
  62289. }
  62290. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62291. import { Camera } from "babylonjs/Cameras/camera";
  62292. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62293. import { Scene } from "babylonjs/scene";
  62294. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62295. import "babylonjs/Shaders/chromaticAberration.fragment";
  62296. import "babylonjs/Shaders/lensHighlights.fragment";
  62297. import "babylonjs/Shaders/depthOfField.fragment";
  62298. /**
  62299. * BABYLON.JS Chromatic Aberration GLSL Shader
  62300. * Author: Olivier Guyot
  62301. * Separates very slightly R, G and B colors on the edges of the screen
  62302. * Inspired by Francois Tarlier & Martins Upitis
  62303. */
  62304. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62305. /**
  62306. * @ignore
  62307. * The chromatic aberration PostProcess id in the pipeline
  62308. */
  62309. LensChromaticAberrationEffect: string;
  62310. /**
  62311. * @ignore
  62312. * The highlights enhancing PostProcess id in the pipeline
  62313. */
  62314. HighlightsEnhancingEffect: string;
  62315. /**
  62316. * @ignore
  62317. * The depth-of-field PostProcess id in the pipeline
  62318. */
  62319. LensDepthOfFieldEffect: string;
  62320. private _scene;
  62321. private _depthTexture;
  62322. private _grainTexture;
  62323. private _chromaticAberrationPostProcess;
  62324. private _highlightsPostProcess;
  62325. private _depthOfFieldPostProcess;
  62326. private _edgeBlur;
  62327. private _grainAmount;
  62328. private _chromaticAberration;
  62329. private _distortion;
  62330. private _highlightsGain;
  62331. private _highlightsThreshold;
  62332. private _dofDistance;
  62333. private _dofAperture;
  62334. private _dofDarken;
  62335. private _dofPentagon;
  62336. private _blurNoise;
  62337. /**
  62338. * @constructor
  62339. *
  62340. * Effect parameters are as follow:
  62341. * {
  62342. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62343. * edge_blur: number; // from 0 to x (1 for realism)
  62344. * distortion: number; // from 0 to x (1 for realism)
  62345. * grain_amount: number; // from 0 to 1
  62346. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62347. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62348. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62349. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62350. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62351. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62352. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62353. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62354. * }
  62355. * Note: if an effect parameter is unset, effect is disabled
  62356. *
  62357. * @param name The rendering pipeline name
  62358. * @param parameters - An object containing all parameters (see above)
  62359. * @param scene The scene linked to this pipeline
  62360. * @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)
  62361. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62362. */
  62363. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62364. /**
  62365. * Get the class name
  62366. * @returns "LensRenderingPipeline"
  62367. */
  62368. getClassName(): string;
  62369. /**
  62370. * Gets associated scene
  62371. */
  62372. readonly scene: Scene;
  62373. /**
  62374. * Gets or sets the edge blur
  62375. */
  62376. edgeBlur: number;
  62377. /**
  62378. * Gets or sets the grain amount
  62379. */
  62380. grainAmount: number;
  62381. /**
  62382. * Gets or sets the chromatic aberration amount
  62383. */
  62384. chromaticAberration: number;
  62385. /**
  62386. * Gets or sets the depth of field aperture
  62387. */
  62388. dofAperture: number;
  62389. /**
  62390. * Gets or sets the edge distortion
  62391. */
  62392. edgeDistortion: number;
  62393. /**
  62394. * Gets or sets the depth of field distortion
  62395. */
  62396. dofDistortion: number;
  62397. /**
  62398. * Gets or sets the darken out of focus amount
  62399. */
  62400. darkenOutOfFocus: number;
  62401. /**
  62402. * Gets or sets a boolean indicating if blur noise is enabled
  62403. */
  62404. blurNoise: boolean;
  62405. /**
  62406. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62407. */
  62408. pentagonBokeh: boolean;
  62409. /**
  62410. * Gets or sets the highlight grain amount
  62411. */
  62412. highlightsGain: number;
  62413. /**
  62414. * Gets or sets the highlight threshold
  62415. */
  62416. highlightsThreshold: number;
  62417. /**
  62418. * Sets the amount of blur at the edges
  62419. * @param amount blur amount
  62420. */
  62421. setEdgeBlur(amount: number): void;
  62422. /**
  62423. * Sets edge blur to 0
  62424. */
  62425. disableEdgeBlur(): void;
  62426. /**
  62427. * Sets the amout of grain
  62428. * @param amount Amount of grain
  62429. */
  62430. setGrainAmount(amount: number): void;
  62431. /**
  62432. * Set grain amount to 0
  62433. */
  62434. disableGrain(): void;
  62435. /**
  62436. * Sets the chromatic aberration amount
  62437. * @param amount amount of chromatic aberration
  62438. */
  62439. setChromaticAberration(amount: number): void;
  62440. /**
  62441. * Sets chromatic aberration amount to 0
  62442. */
  62443. disableChromaticAberration(): void;
  62444. /**
  62445. * Sets the EdgeDistortion amount
  62446. * @param amount amount of EdgeDistortion
  62447. */
  62448. setEdgeDistortion(amount: number): void;
  62449. /**
  62450. * Sets edge distortion to 0
  62451. */
  62452. disableEdgeDistortion(): void;
  62453. /**
  62454. * Sets the FocusDistance amount
  62455. * @param amount amount of FocusDistance
  62456. */
  62457. setFocusDistance(amount: number): void;
  62458. /**
  62459. * Disables depth of field
  62460. */
  62461. disableDepthOfField(): void;
  62462. /**
  62463. * Sets the Aperture amount
  62464. * @param amount amount of Aperture
  62465. */
  62466. setAperture(amount: number): void;
  62467. /**
  62468. * Sets the DarkenOutOfFocus amount
  62469. * @param amount amount of DarkenOutOfFocus
  62470. */
  62471. setDarkenOutOfFocus(amount: number): void;
  62472. private _pentagonBokehIsEnabled;
  62473. /**
  62474. * Creates a pentagon bokeh effect
  62475. */
  62476. enablePentagonBokeh(): void;
  62477. /**
  62478. * Disables the pentagon bokeh effect
  62479. */
  62480. disablePentagonBokeh(): void;
  62481. /**
  62482. * Enables noise blur
  62483. */
  62484. enableNoiseBlur(): void;
  62485. /**
  62486. * Disables noise blur
  62487. */
  62488. disableNoiseBlur(): void;
  62489. /**
  62490. * Sets the HighlightsGain amount
  62491. * @param amount amount of HighlightsGain
  62492. */
  62493. setHighlightsGain(amount: number): void;
  62494. /**
  62495. * Sets the HighlightsThreshold amount
  62496. * @param amount amount of HighlightsThreshold
  62497. */
  62498. setHighlightsThreshold(amount: number): void;
  62499. /**
  62500. * Disables highlights
  62501. */
  62502. disableHighlights(): void;
  62503. /**
  62504. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62505. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62506. */
  62507. dispose(disableDepthRender?: boolean): void;
  62508. private _createChromaticAberrationPostProcess;
  62509. private _createHighlightsPostProcess;
  62510. private _createDepthOfFieldPostProcess;
  62511. private _createGrainTexture;
  62512. }
  62513. }
  62514. declare module "babylonjs/Shaders/ssao2.fragment" {
  62515. /** @hidden */
  62516. export var ssao2PixelShader: {
  62517. name: string;
  62518. shader: string;
  62519. };
  62520. }
  62521. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62522. /** @hidden */
  62523. export var ssaoCombinePixelShader: {
  62524. name: string;
  62525. shader: string;
  62526. };
  62527. }
  62528. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62529. import { Camera } from "babylonjs/Cameras/camera";
  62530. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62531. import { Scene } from "babylonjs/scene";
  62532. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62533. import "babylonjs/Shaders/ssao2.fragment";
  62534. import "babylonjs/Shaders/ssaoCombine.fragment";
  62535. /**
  62536. * Render pipeline to produce ssao effect
  62537. */
  62538. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62539. /**
  62540. * @ignore
  62541. * The PassPostProcess id in the pipeline that contains the original scene color
  62542. */
  62543. SSAOOriginalSceneColorEffect: string;
  62544. /**
  62545. * @ignore
  62546. * The SSAO PostProcess id in the pipeline
  62547. */
  62548. SSAORenderEffect: string;
  62549. /**
  62550. * @ignore
  62551. * The horizontal blur PostProcess id in the pipeline
  62552. */
  62553. SSAOBlurHRenderEffect: string;
  62554. /**
  62555. * @ignore
  62556. * The vertical blur PostProcess id in the pipeline
  62557. */
  62558. SSAOBlurVRenderEffect: string;
  62559. /**
  62560. * @ignore
  62561. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62562. */
  62563. SSAOCombineRenderEffect: string;
  62564. /**
  62565. * The output strength of the SSAO post-process. Default value is 1.0.
  62566. */
  62567. totalStrength: number;
  62568. /**
  62569. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62570. */
  62571. maxZ: number;
  62572. /**
  62573. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62574. */
  62575. minZAspect: number;
  62576. private _samples;
  62577. /**
  62578. * Number of samples used for the SSAO calculations. Default value is 8
  62579. */
  62580. samples: number;
  62581. private _textureSamples;
  62582. /**
  62583. * Number of samples to use for antialiasing
  62584. */
  62585. textureSamples: number;
  62586. /**
  62587. * Ratio object used for SSAO ratio and blur ratio
  62588. */
  62589. private _ratio;
  62590. /**
  62591. * Dynamically generated sphere sampler.
  62592. */
  62593. private _sampleSphere;
  62594. /**
  62595. * Blur filter offsets
  62596. */
  62597. private _samplerOffsets;
  62598. private _expensiveBlur;
  62599. /**
  62600. * If bilateral blur should be used
  62601. */
  62602. expensiveBlur: boolean;
  62603. /**
  62604. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62605. */
  62606. radius: number;
  62607. /**
  62608. * The base color of the SSAO post-process
  62609. * The final result is "base + ssao" between [0, 1]
  62610. */
  62611. base: number;
  62612. /**
  62613. * Support test.
  62614. */
  62615. static readonly IsSupported: boolean;
  62616. private _scene;
  62617. private _depthTexture;
  62618. private _normalTexture;
  62619. private _randomTexture;
  62620. private _originalColorPostProcess;
  62621. private _ssaoPostProcess;
  62622. private _blurHPostProcess;
  62623. private _blurVPostProcess;
  62624. private _ssaoCombinePostProcess;
  62625. private _firstUpdate;
  62626. /**
  62627. * Gets active scene
  62628. */
  62629. readonly scene: Scene;
  62630. /**
  62631. * @constructor
  62632. * @param name The rendering pipeline name
  62633. * @param scene The scene linked to this pipeline
  62634. * @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 }
  62635. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62636. */
  62637. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62638. /**
  62639. * Get the class name
  62640. * @returns "SSAO2RenderingPipeline"
  62641. */
  62642. getClassName(): string;
  62643. /**
  62644. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62645. */
  62646. dispose(disableGeometryBufferRenderer?: boolean): void;
  62647. private _createBlurPostProcess;
  62648. /** @hidden */
  62649. _rebuild(): void;
  62650. private _bits;
  62651. private _radicalInverse_VdC;
  62652. private _hammersley;
  62653. private _hemisphereSample_uniform;
  62654. private _generateHemisphere;
  62655. private _createSSAOPostProcess;
  62656. private _createSSAOCombinePostProcess;
  62657. private _createRandomTexture;
  62658. /**
  62659. * Serialize the rendering pipeline (Used when exporting)
  62660. * @returns the serialized object
  62661. */
  62662. serialize(): any;
  62663. /**
  62664. * Parse the serialized pipeline
  62665. * @param source Source pipeline.
  62666. * @param scene The scene to load the pipeline to.
  62667. * @param rootUrl The URL of the serialized pipeline.
  62668. * @returns An instantiated pipeline from the serialized object.
  62669. */
  62670. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62671. }
  62672. }
  62673. declare module "babylonjs/Shaders/ssao.fragment" {
  62674. /** @hidden */
  62675. export var ssaoPixelShader: {
  62676. name: string;
  62677. shader: string;
  62678. };
  62679. }
  62680. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62681. import { Camera } from "babylonjs/Cameras/camera";
  62682. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62683. import { Scene } from "babylonjs/scene";
  62684. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62685. import "babylonjs/Shaders/ssao.fragment";
  62686. import "babylonjs/Shaders/ssaoCombine.fragment";
  62687. /**
  62688. * Render pipeline to produce ssao effect
  62689. */
  62690. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62691. /**
  62692. * @ignore
  62693. * The PassPostProcess id in the pipeline that contains the original scene color
  62694. */
  62695. SSAOOriginalSceneColorEffect: string;
  62696. /**
  62697. * @ignore
  62698. * The SSAO PostProcess id in the pipeline
  62699. */
  62700. SSAORenderEffect: string;
  62701. /**
  62702. * @ignore
  62703. * The horizontal blur PostProcess id in the pipeline
  62704. */
  62705. SSAOBlurHRenderEffect: string;
  62706. /**
  62707. * @ignore
  62708. * The vertical blur PostProcess id in the pipeline
  62709. */
  62710. SSAOBlurVRenderEffect: string;
  62711. /**
  62712. * @ignore
  62713. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62714. */
  62715. SSAOCombineRenderEffect: string;
  62716. /**
  62717. * The output strength of the SSAO post-process. Default value is 1.0.
  62718. */
  62719. totalStrength: number;
  62720. /**
  62721. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62722. */
  62723. radius: number;
  62724. /**
  62725. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62726. * Must not be equal to fallOff and superior to fallOff.
  62727. * Default value is 0.0075
  62728. */
  62729. area: number;
  62730. /**
  62731. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62732. * Must not be equal to area and inferior to area.
  62733. * Default value is 0.000001
  62734. */
  62735. fallOff: number;
  62736. /**
  62737. * The base color of the SSAO post-process
  62738. * The final result is "base + ssao" between [0, 1]
  62739. */
  62740. base: number;
  62741. private _scene;
  62742. private _depthTexture;
  62743. private _randomTexture;
  62744. private _originalColorPostProcess;
  62745. private _ssaoPostProcess;
  62746. private _blurHPostProcess;
  62747. private _blurVPostProcess;
  62748. private _ssaoCombinePostProcess;
  62749. private _firstUpdate;
  62750. /**
  62751. * Gets active scene
  62752. */
  62753. readonly scene: Scene;
  62754. /**
  62755. * @constructor
  62756. * @param name - The rendering pipeline name
  62757. * @param scene - The scene linked to this pipeline
  62758. * @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 }
  62759. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62760. */
  62761. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62762. /**
  62763. * Get the class name
  62764. * @returns "SSAORenderingPipeline"
  62765. */
  62766. getClassName(): string;
  62767. /**
  62768. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62769. */
  62770. dispose(disableDepthRender?: boolean): void;
  62771. private _createBlurPostProcess;
  62772. /** @hidden */
  62773. _rebuild(): void;
  62774. private _createSSAOPostProcess;
  62775. private _createSSAOCombinePostProcess;
  62776. private _createRandomTexture;
  62777. }
  62778. }
  62779. declare module "babylonjs/Shaders/standard.fragment" {
  62780. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62781. /** @hidden */
  62782. export var standardPixelShader: {
  62783. name: string;
  62784. shader: string;
  62785. };
  62786. }
  62787. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62788. import { Nullable } from "babylonjs/types";
  62789. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62790. import { Camera } from "babylonjs/Cameras/camera";
  62791. import { Texture } from "babylonjs/Materials/Textures/texture";
  62792. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62793. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62794. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62795. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62796. import { IDisposable } from "babylonjs/scene";
  62797. import { SpotLight } from "babylonjs/Lights/spotLight";
  62798. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62799. import { Scene } from "babylonjs/scene";
  62800. import { Animation } from "babylonjs/Animations/animation";
  62801. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62802. import "babylonjs/Shaders/standard.fragment";
  62803. /**
  62804. * Standard rendering pipeline
  62805. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62806. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62807. */
  62808. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62809. /**
  62810. * Public members
  62811. */
  62812. /**
  62813. * Post-process which contains the original scene color before the pipeline applies all the effects
  62814. */
  62815. originalPostProcess: Nullable<PostProcess>;
  62816. /**
  62817. * Post-process used to down scale an image x4
  62818. */
  62819. downSampleX4PostProcess: Nullable<PostProcess>;
  62820. /**
  62821. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  62822. */
  62823. brightPassPostProcess: Nullable<PostProcess>;
  62824. /**
  62825. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  62826. */
  62827. blurHPostProcesses: PostProcess[];
  62828. /**
  62829. * Post-process array storing all the vertical blur post-processes used by the pipeline
  62830. */
  62831. blurVPostProcesses: PostProcess[];
  62832. /**
  62833. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  62834. */
  62835. textureAdderPostProcess: Nullable<PostProcess>;
  62836. /**
  62837. * Post-process used to create volumetric lighting effect
  62838. */
  62839. volumetricLightPostProcess: Nullable<PostProcess>;
  62840. /**
  62841. * Post-process used to smooth the previous volumetric light post-process on the X axis
  62842. */
  62843. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  62844. /**
  62845. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  62846. */
  62847. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  62848. /**
  62849. * Post-process used to merge the volumetric light effect and the real scene color
  62850. */
  62851. volumetricLightMergePostProces: Nullable<PostProcess>;
  62852. /**
  62853. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  62854. */
  62855. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  62856. /**
  62857. * Base post-process used to calculate the average luminance of the final image for HDR
  62858. */
  62859. luminancePostProcess: Nullable<PostProcess>;
  62860. /**
  62861. * Post-processes used to create down sample post-processes in order to get
  62862. * the average luminance of the final image for HDR
  62863. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  62864. */
  62865. luminanceDownSamplePostProcesses: PostProcess[];
  62866. /**
  62867. * Post-process used to create a HDR effect (light adaptation)
  62868. */
  62869. hdrPostProcess: Nullable<PostProcess>;
  62870. /**
  62871. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  62872. */
  62873. textureAdderFinalPostProcess: Nullable<PostProcess>;
  62874. /**
  62875. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  62876. */
  62877. lensFlareFinalPostProcess: Nullable<PostProcess>;
  62878. /**
  62879. * Post-process used to merge the final HDR post-process and the real scene color
  62880. */
  62881. hdrFinalPostProcess: Nullable<PostProcess>;
  62882. /**
  62883. * Post-process used to create a lens flare effect
  62884. */
  62885. lensFlarePostProcess: Nullable<PostProcess>;
  62886. /**
  62887. * Post-process that merges the result of the lens flare post-process and the real scene color
  62888. */
  62889. lensFlareComposePostProcess: Nullable<PostProcess>;
  62890. /**
  62891. * Post-process used to create a motion blur effect
  62892. */
  62893. motionBlurPostProcess: Nullable<PostProcess>;
  62894. /**
  62895. * Post-process used to create a depth of field effect
  62896. */
  62897. depthOfFieldPostProcess: Nullable<PostProcess>;
  62898. /**
  62899. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62900. */
  62901. fxaaPostProcess: Nullable<FxaaPostProcess>;
  62902. /**
  62903. * Represents the brightness threshold in order to configure the illuminated surfaces
  62904. */
  62905. brightThreshold: number;
  62906. /**
  62907. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  62908. */
  62909. blurWidth: number;
  62910. /**
  62911. * Sets if the blur for highlighted surfaces must be only horizontal
  62912. */
  62913. horizontalBlur: boolean;
  62914. /**
  62915. * Gets the overall exposure used by the pipeline
  62916. */
  62917. /**
  62918. * Sets the overall exposure used by the pipeline
  62919. */
  62920. exposure: number;
  62921. /**
  62922. * Texture used typically to simulate "dirty" on camera lens
  62923. */
  62924. lensTexture: Nullable<Texture>;
  62925. /**
  62926. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  62927. */
  62928. volumetricLightCoefficient: number;
  62929. /**
  62930. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  62931. */
  62932. volumetricLightPower: number;
  62933. /**
  62934. * Used the set the blur intensity to smooth the volumetric lights
  62935. */
  62936. volumetricLightBlurScale: number;
  62937. /**
  62938. * Light (spot or directional) used to generate the volumetric lights rays
  62939. * The source light must have a shadow generate so the pipeline can get its
  62940. * depth map
  62941. */
  62942. sourceLight: Nullable<SpotLight | DirectionalLight>;
  62943. /**
  62944. * For eye adaptation, represents the minimum luminance the eye can see
  62945. */
  62946. hdrMinimumLuminance: number;
  62947. /**
  62948. * For eye adaptation, represents the decrease luminance speed
  62949. */
  62950. hdrDecreaseRate: number;
  62951. /**
  62952. * For eye adaptation, represents the increase luminance speed
  62953. */
  62954. hdrIncreaseRate: number;
  62955. /**
  62956. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62957. */
  62958. /**
  62959. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  62960. */
  62961. hdrAutoExposure: boolean;
  62962. /**
  62963. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  62964. */
  62965. lensColorTexture: Nullable<Texture>;
  62966. /**
  62967. * The overall strengh for the lens flare effect
  62968. */
  62969. lensFlareStrength: number;
  62970. /**
  62971. * Dispersion coefficient for lens flare ghosts
  62972. */
  62973. lensFlareGhostDispersal: number;
  62974. /**
  62975. * Main lens flare halo width
  62976. */
  62977. lensFlareHaloWidth: number;
  62978. /**
  62979. * Based on the lens distortion effect, defines how much the lens flare result
  62980. * is distorted
  62981. */
  62982. lensFlareDistortionStrength: number;
  62983. /**
  62984. * Configures the blur intensity used for for lens flare (halo)
  62985. */
  62986. lensFlareBlurWidth: number;
  62987. /**
  62988. * Lens star texture must be used to simulate rays on the flares and is available
  62989. * in the documentation
  62990. */
  62991. lensStarTexture: Nullable<Texture>;
  62992. /**
  62993. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  62994. * flare effect by taking account of the dirt texture
  62995. */
  62996. lensFlareDirtTexture: Nullable<Texture>;
  62997. /**
  62998. * Represents the focal length for the depth of field effect
  62999. */
  63000. depthOfFieldDistance: number;
  63001. /**
  63002. * Represents the blur intensity for the blurred part of the depth of field effect
  63003. */
  63004. depthOfFieldBlurWidth: number;
  63005. /**
  63006. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63007. */
  63008. /**
  63009. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63010. */
  63011. motionStrength: number;
  63012. /**
  63013. * Gets wether or not the motion blur post-process is object based or screen based.
  63014. */
  63015. /**
  63016. * Sets wether or not the motion blur post-process should be object based or screen based
  63017. */
  63018. objectBasedMotionBlur: boolean;
  63019. /**
  63020. * List of animations for the pipeline (IAnimatable implementation)
  63021. */
  63022. animations: Animation[];
  63023. /**
  63024. * Private members
  63025. */
  63026. private _scene;
  63027. private _currentDepthOfFieldSource;
  63028. private _basePostProcess;
  63029. private _fixedExposure;
  63030. private _currentExposure;
  63031. private _hdrAutoExposure;
  63032. private _hdrCurrentLuminance;
  63033. private _motionStrength;
  63034. private _isObjectBasedMotionBlur;
  63035. private _floatTextureType;
  63036. private _camerasToBeAttached;
  63037. private _ratio;
  63038. private _bloomEnabled;
  63039. private _depthOfFieldEnabled;
  63040. private _vlsEnabled;
  63041. private _lensFlareEnabled;
  63042. private _hdrEnabled;
  63043. private _motionBlurEnabled;
  63044. private _fxaaEnabled;
  63045. private _motionBlurSamples;
  63046. private _volumetricLightStepsCount;
  63047. private _samples;
  63048. /**
  63049. * @ignore
  63050. * Specifies if the bloom pipeline is enabled
  63051. */
  63052. BloomEnabled: boolean;
  63053. /**
  63054. * @ignore
  63055. * Specifies if the depth of field pipeline is enabed
  63056. */
  63057. DepthOfFieldEnabled: boolean;
  63058. /**
  63059. * @ignore
  63060. * Specifies if the lens flare pipeline is enabed
  63061. */
  63062. LensFlareEnabled: boolean;
  63063. /**
  63064. * @ignore
  63065. * Specifies if the HDR pipeline is enabled
  63066. */
  63067. HDREnabled: boolean;
  63068. /**
  63069. * @ignore
  63070. * Specifies if the volumetric lights scattering effect is enabled
  63071. */
  63072. VLSEnabled: boolean;
  63073. /**
  63074. * @ignore
  63075. * Specifies if the motion blur effect is enabled
  63076. */
  63077. MotionBlurEnabled: boolean;
  63078. /**
  63079. * Specifies if anti-aliasing is enabled
  63080. */
  63081. fxaaEnabled: boolean;
  63082. /**
  63083. * Specifies the number of steps used to calculate the volumetric lights
  63084. * Typically in interval [50, 200]
  63085. */
  63086. volumetricLightStepsCount: number;
  63087. /**
  63088. * Specifies the number of samples used for the motion blur effect
  63089. * Typically in interval [16, 64]
  63090. */
  63091. motionBlurSamples: number;
  63092. /**
  63093. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63094. */
  63095. samples: number;
  63096. /**
  63097. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63098. * @constructor
  63099. * @param name The rendering pipeline name
  63100. * @param scene The scene linked to this pipeline
  63101. * @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)
  63102. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63103. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63104. */
  63105. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63106. private _buildPipeline;
  63107. private _createDownSampleX4PostProcess;
  63108. private _createBrightPassPostProcess;
  63109. private _createBlurPostProcesses;
  63110. private _createTextureAdderPostProcess;
  63111. private _createVolumetricLightPostProcess;
  63112. private _createLuminancePostProcesses;
  63113. private _createHdrPostProcess;
  63114. private _createLensFlarePostProcess;
  63115. private _createDepthOfFieldPostProcess;
  63116. private _createMotionBlurPostProcess;
  63117. private _getDepthTexture;
  63118. private _disposePostProcesses;
  63119. /**
  63120. * Dispose of the pipeline and stop all post processes
  63121. */
  63122. dispose(): void;
  63123. /**
  63124. * Serialize the rendering pipeline (Used when exporting)
  63125. * @returns the serialized object
  63126. */
  63127. serialize(): any;
  63128. /**
  63129. * Parse the serialized pipeline
  63130. * @param source Source pipeline.
  63131. * @param scene The scene to load the pipeline to.
  63132. * @param rootUrl The URL of the serialized pipeline.
  63133. * @returns An instantiated pipeline from the serialized object.
  63134. */
  63135. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63136. /**
  63137. * Luminance steps
  63138. */
  63139. static LuminanceSteps: number;
  63140. }
  63141. }
  63142. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63143. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63144. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63145. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63146. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63147. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63148. }
  63149. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63150. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63151. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63152. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63153. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63154. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63155. }
  63156. declare module "babylonjs/Shaders/tonemap.fragment" {
  63157. /** @hidden */
  63158. export var tonemapPixelShader: {
  63159. name: string;
  63160. shader: string;
  63161. };
  63162. }
  63163. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63164. import { Camera } from "babylonjs/Cameras/camera";
  63165. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63166. import "babylonjs/Shaders/tonemap.fragment";
  63167. import { Engine } from "babylonjs/Engines/engine";
  63168. /** Defines operator used for tonemapping */
  63169. export enum TonemappingOperator {
  63170. /** Hable */
  63171. Hable = 0,
  63172. /** Reinhard */
  63173. Reinhard = 1,
  63174. /** HejiDawson */
  63175. HejiDawson = 2,
  63176. /** Photographic */
  63177. Photographic = 3
  63178. }
  63179. /**
  63180. * Defines a post process to apply tone mapping
  63181. */
  63182. export class TonemapPostProcess extends PostProcess {
  63183. private _operator;
  63184. /** Defines the required exposure adjustement */
  63185. exposureAdjustment: number;
  63186. /**
  63187. * Creates a new TonemapPostProcess
  63188. * @param name defines the name of the postprocess
  63189. * @param _operator defines the operator to use
  63190. * @param exposureAdjustment defines the required exposure adjustement
  63191. * @param camera defines the camera to use (can be null)
  63192. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63193. * @param engine defines the hosting engine (can be ignore if camera is set)
  63194. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63195. */
  63196. constructor(name: string, _operator: TonemappingOperator,
  63197. /** Defines the required exposure adjustement */
  63198. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63199. }
  63200. }
  63201. declare module "babylonjs/Shaders/depth.vertex" {
  63202. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63203. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63205. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63206. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63207. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63208. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63209. /** @hidden */
  63210. export var depthVertexShader: {
  63211. name: string;
  63212. shader: string;
  63213. };
  63214. }
  63215. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63216. /** @hidden */
  63217. export var volumetricLightScatteringPixelShader: {
  63218. name: string;
  63219. shader: string;
  63220. };
  63221. }
  63222. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63223. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63224. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63226. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63227. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63228. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63229. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63230. /** @hidden */
  63231. export var volumetricLightScatteringPassVertexShader: {
  63232. name: string;
  63233. shader: string;
  63234. };
  63235. }
  63236. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63237. /** @hidden */
  63238. export var volumetricLightScatteringPassPixelShader: {
  63239. name: string;
  63240. shader: string;
  63241. };
  63242. }
  63243. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63244. import { Vector3 } from "babylonjs/Maths/math.vector";
  63245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63246. import { Mesh } from "babylonjs/Meshes/mesh";
  63247. import { Camera } from "babylonjs/Cameras/camera";
  63248. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63250. import { Scene } from "babylonjs/scene";
  63251. import "babylonjs/Meshes/Builders/planeBuilder";
  63252. import "babylonjs/Shaders/depth.vertex";
  63253. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63254. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63255. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63256. import { Engine } from "babylonjs/Engines/engine";
  63257. /**
  63258. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63259. */
  63260. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63261. private _volumetricLightScatteringPass;
  63262. private _volumetricLightScatteringRTT;
  63263. private _viewPort;
  63264. private _screenCoordinates;
  63265. private _cachedDefines;
  63266. /**
  63267. * If not undefined, the mesh position is computed from the attached node position
  63268. */
  63269. attachedNode: {
  63270. position: Vector3;
  63271. };
  63272. /**
  63273. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63274. */
  63275. customMeshPosition: Vector3;
  63276. /**
  63277. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63278. */
  63279. useCustomMeshPosition: boolean;
  63280. /**
  63281. * If the post-process should inverse the light scattering direction
  63282. */
  63283. invert: boolean;
  63284. /**
  63285. * The internal mesh used by the post-process
  63286. */
  63287. mesh: Mesh;
  63288. /**
  63289. * @hidden
  63290. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63291. */
  63292. useDiffuseColor: boolean;
  63293. /**
  63294. * Array containing the excluded meshes not rendered in the internal pass
  63295. */
  63296. excludedMeshes: AbstractMesh[];
  63297. /**
  63298. * Controls the overall intensity of the post-process
  63299. */
  63300. exposure: number;
  63301. /**
  63302. * Dissipates each sample's contribution in range [0, 1]
  63303. */
  63304. decay: number;
  63305. /**
  63306. * Controls the overall intensity of each sample
  63307. */
  63308. weight: number;
  63309. /**
  63310. * Controls the density of each sample
  63311. */
  63312. density: number;
  63313. /**
  63314. * @constructor
  63315. * @param name The post-process name
  63316. * @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)
  63317. * @param camera The camera that the post-process will be attached to
  63318. * @param mesh The mesh used to create the light scattering
  63319. * @param samples The post-process quality, default 100
  63320. * @param samplingModeThe post-process filtering mode
  63321. * @param engine The babylon engine
  63322. * @param reusable If the post-process is reusable
  63323. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63324. */
  63325. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63326. /**
  63327. * Returns the string "VolumetricLightScatteringPostProcess"
  63328. * @returns "VolumetricLightScatteringPostProcess"
  63329. */
  63330. getClassName(): string;
  63331. private _isReady;
  63332. /**
  63333. * Sets the new light position for light scattering effect
  63334. * @param position The new custom light position
  63335. */
  63336. setCustomMeshPosition(position: Vector3): void;
  63337. /**
  63338. * Returns the light position for light scattering effect
  63339. * @return Vector3 The custom light position
  63340. */
  63341. getCustomMeshPosition(): Vector3;
  63342. /**
  63343. * Disposes the internal assets and detaches the post-process from the camera
  63344. */
  63345. dispose(camera: Camera): void;
  63346. /**
  63347. * Returns the render target texture used by the post-process
  63348. * @return the render target texture used by the post-process
  63349. */
  63350. getPass(): RenderTargetTexture;
  63351. private _meshExcluded;
  63352. private _createPass;
  63353. private _updateMeshScreenCoordinates;
  63354. /**
  63355. * Creates a default mesh for the Volumeric Light Scattering post-process
  63356. * @param name The mesh name
  63357. * @param scene The scene where to create the mesh
  63358. * @return the default mesh
  63359. */
  63360. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63361. }
  63362. }
  63363. declare module "babylonjs/PostProcesses/index" {
  63364. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63365. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63366. export * from "babylonjs/PostProcesses/bloomEffect";
  63367. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63368. export * from "babylonjs/PostProcesses/blurPostProcess";
  63369. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63370. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63371. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63372. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63373. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63374. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63375. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63376. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63377. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63378. export * from "babylonjs/PostProcesses/filterPostProcess";
  63379. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63380. export * from "babylonjs/PostProcesses/grainPostProcess";
  63381. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63382. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63383. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63384. export * from "babylonjs/PostProcesses/passPostProcess";
  63385. export * from "babylonjs/PostProcesses/postProcess";
  63386. export * from "babylonjs/PostProcesses/postProcessManager";
  63387. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63388. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63389. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63390. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63391. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63392. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63393. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63394. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63395. }
  63396. declare module "babylonjs/Probes/index" {
  63397. export * from "babylonjs/Probes/reflectionProbe";
  63398. }
  63399. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63400. import { Scene } from "babylonjs/scene";
  63401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63402. import { SmartArray } from "babylonjs/Misc/smartArray";
  63403. import { ISceneComponent } from "babylonjs/sceneComponent";
  63404. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63405. import "babylonjs/Meshes/Builders/boxBuilder";
  63406. import "babylonjs/Shaders/color.fragment";
  63407. import "babylonjs/Shaders/color.vertex";
  63408. import { Color3 } from "babylonjs/Maths/math.color";
  63409. module "babylonjs/scene" {
  63410. interface Scene {
  63411. /** @hidden (Backing field) */
  63412. _boundingBoxRenderer: BoundingBoxRenderer;
  63413. /** @hidden (Backing field) */
  63414. _forceShowBoundingBoxes: boolean;
  63415. /**
  63416. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63417. */
  63418. forceShowBoundingBoxes: boolean;
  63419. /**
  63420. * Gets the bounding box renderer associated with the scene
  63421. * @returns a BoundingBoxRenderer
  63422. */
  63423. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63424. }
  63425. }
  63426. module "babylonjs/Meshes/abstractMesh" {
  63427. interface AbstractMesh {
  63428. /** @hidden (Backing field) */
  63429. _showBoundingBox: boolean;
  63430. /**
  63431. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63432. */
  63433. showBoundingBox: boolean;
  63434. }
  63435. }
  63436. /**
  63437. * Component responsible of rendering the bounding box of the meshes in a scene.
  63438. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63439. */
  63440. export class BoundingBoxRenderer implements ISceneComponent {
  63441. /**
  63442. * The component name helpfull to identify the component in the list of scene components.
  63443. */
  63444. readonly name: string;
  63445. /**
  63446. * The scene the component belongs to.
  63447. */
  63448. scene: Scene;
  63449. /**
  63450. * Color of the bounding box lines placed in front of an object
  63451. */
  63452. frontColor: Color3;
  63453. /**
  63454. * Color of the bounding box lines placed behind an object
  63455. */
  63456. backColor: Color3;
  63457. /**
  63458. * Defines if the renderer should show the back lines or not
  63459. */
  63460. showBackLines: boolean;
  63461. /**
  63462. * @hidden
  63463. */
  63464. renderList: SmartArray<BoundingBox>;
  63465. private _colorShader;
  63466. private _vertexBuffers;
  63467. private _indexBuffer;
  63468. private _fillIndexBuffer;
  63469. private _fillIndexData;
  63470. /**
  63471. * Instantiates a new bounding box renderer in a scene.
  63472. * @param scene the scene the renderer renders in
  63473. */
  63474. constructor(scene: Scene);
  63475. /**
  63476. * Registers the component in a given scene
  63477. */
  63478. register(): void;
  63479. private _evaluateSubMesh;
  63480. private _activeMesh;
  63481. private _prepareRessources;
  63482. private _createIndexBuffer;
  63483. /**
  63484. * Rebuilds the elements related to this component in case of
  63485. * context lost for instance.
  63486. */
  63487. rebuild(): void;
  63488. /**
  63489. * @hidden
  63490. */
  63491. reset(): void;
  63492. /**
  63493. * Render the bounding boxes of a specific rendering group
  63494. * @param renderingGroupId defines the rendering group to render
  63495. */
  63496. render(renderingGroupId: number): void;
  63497. /**
  63498. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63499. * @param mesh Define the mesh to render the occlusion bounding box for
  63500. */
  63501. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63502. /**
  63503. * Dispose and release the resources attached to this renderer.
  63504. */
  63505. dispose(): void;
  63506. }
  63507. }
  63508. declare module "babylonjs/Shaders/depth.fragment" {
  63509. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63510. /** @hidden */
  63511. export var depthPixelShader: {
  63512. name: string;
  63513. shader: string;
  63514. };
  63515. }
  63516. declare module "babylonjs/Rendering/depthRenderer" {
  63517. import { Nullable } from "babylonjs/types";
  63518. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63519. import { Scene } from "babylonjs/scene";
  63520. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63521. import { Camera } from "babylonjs/Cameras/camera";
  63522. import "babylonjs/Shaders/depth.fragment";
  63523. import "babylonjs/Shaders/depth.vertex";
  63524. /**
  63525. * This represents a depth renderer in Babylon.
  63526. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63527. */
  63528. export class DepthRenderer {
  63529. private _scene;
  63530. private _depthMap;
  63531. private _effect;
  63532. private readonly _storeNonLinearDepth;
  63533. private readonly _clearColor;
  63534. /** Get if the depth renderer is using packed depth or not */
  63535. readonly isPacked: boolean;
  63536. private _cachedDefines;
  63537. private _camera;
  63538. /**
  63539. * Specifiess that the depth renderer will only be used within
  63540. * the camera it is created for.
  63541. * This can help forcing its rendering during the camera processing.
  63542. */
  63543. useOnlyInActiveCamera: boolean;
  63544. /** @hidden */
  63545. static _SceneComponentInitialization: (scene: Scene) => void;
  63546. /**
  63547. * Instantiates a depth renderer
  63548. * @param scene The scene the renderer belongs to
  63549. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63550. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63551. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63552. */
  63553. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63554. /**
  63555. * Creates the depth rendering effect and checks if the effect is ready.
  63556. * @param subMesh The submesh to be used to render the depth map of
  63557. * @param useInstances If multiple world instances should be used
  63558. * @returns if the depth renderer is ready to render the depth map
  63559. */
  63560. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63561. /**
  63562. * Gets the texture which the depth map will be written to.
  63563. * @returns The depth map texture
  63564. */
  63565. getDepthMap(): RenderTargetTexture;
  63566. /**
  63567. * Disposes of the depth renderer.
  63568. */
  63569. dispose(): void;
  63570. }
  63571. }
  63572. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63573. import { Nullable } from "babylonjs/types";
  63574. import { Scene } from "babylonjs/scene";
  63575. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63576. import { Camera } from "babylonjs/Cameras/camera";
  63577. import { ISceneComponent } from "babylonjs/sceneComponent";
  63578. module "babylonjs/scene" {
  63579. interface Scene {
  63580. /** @hidden (Backing field) */
  63581. _depthRenderer: {
  63582. [id: string]: DepthRenderer;
  63583. };
  63584. /**
  63585. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63586. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63587. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63588. * @returns the created depth renderer
  63589. */
  63590. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63591. /**
  63592. * Disables a depth renderer for a given camera
  63593. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63594. */
  63595. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63596. }
  63597. }
  63598. /**
  63599. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63600. * in several rendering techniques.
  63601. */
  63602. export class DepthRendererSceneComponent implements ISceneComponent {
  63603. /**
  63604. * The component name helpfull to identify the component in the list of scene components.
  63605. */
  63606. readonly name: string;
  63607. /**
  63608. * The scene the component belongs to.
  63609. */
  63610. scene: Scene;
  63611. /**
  63612. * Creates a new instance of the component for the given scene
  63613. * @param scene Defines the scene to register the component in
  63614. */
  63615. constructor(scene: Scene);
  63616. /**
  63617. * Registers the component in a given scene
  63618. */
  63619. register(): void;
  63620. /**
  63621. * Rebuilds the elements related to this component in case of
  63622. * context lost for instance.
  63623. */
  63624. rebuild(): void;
  63625. /**
  63626. * Disposes the component and the associated ressources
  63627. */
  63628. dispose(): void;
  63629. private _gatherRenderTargets;
  63630. private _gatherActiveCameraRenderTargets;
  63631. }
  63632. }
  63633. declare module "babylonjs/Shaders/outline.fragment" {
  63634. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63635. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63636. /** @hidden */
  63637. export var outlinePixelShader: {
  63638. name: string;
  63639. shader: string;
  63640. };
  63641. }
  63642. declare module "babylonjs/Shaders/outline.vertex" {
  63643. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63645. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63646. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63647. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63648. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63649. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63650. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63651. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63652. /** @hidden */
  63653. export var outlineVertexShader: {
  63654. name: string;
  63655. shader: string;
  63656. };
  63657. }
  63658. declare module "babylonjs/Rendering/outlineRenderer" {
  63659. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63660. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63661. import { Scene } from "babylonjs/scene";
  63662. import { ISceneComponent } from "babylonjs/sceneComponent";
  63663. import "babylonjs/Shaders/outline.fragment";
  63664. import "babylonjs/Shaders/outline.vertex";
  63665. module "babylonjs/scene" {
  63666. interface Scene {
  63667. /** @hidden */
  63668. _outlineRenderer: OutlineRenderer;
  63669. /**
  63670. * Gets the outline renderer associated with the scene
  63671. * @returns a OutlineRenderer
  63672. */
  63673. getOutlineRenderer(): OutlineRenderer;
  63674. }
  63675. }
  63676. module "babylonjs/Meshes/abstractMesh" {
  63677. interface AbstractMesh {
  63678. /** @hidden (Backing field) */
  63679. _renderOutline: boolean;
  63680. /**
  63681. * Gets or sets a boolean indicating if the outline must be rendered as well
  63682. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63683. */
  63684. renderOutline: boolean;
  63685. /** @hidden (Backing field) */
  63686. _renderOverlay: boolean;
  63687. /**
  63688. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63689. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63690. */
  63691. renderOverlay: boolean;
  63692. }
  63693. }
  63694. /**
  63695. * This class is responsible to draw bothe outline/overlay of meshes.
  63696. * It should not be used directly but through the available method on mesh.
  63697. */
  63698. export class OutlineRenderer implements ISceneComponent {
  63699. /**
  63700. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63701. */
  63702. private static _StencilReference;
  63703. /**
  63704. * The name of the component. Each component must have a unique name.
  63705. */
  63706. name: string;
  63707. /**
  63708. * The scene the component belongs to.
  63709. */
  63710. scene: Scene;
  63711. /**
  63712. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63713. */
  63714. zOffset: number;
  63715. private _engine;
  63716. private _effect;
  63717. private _cachedDefines;
  63718. private _savedDepthWrite;
  63719. /**
  63720. * Instantiates a new outline renderer. (There could be only one per scene).
  63721. * @param scene Defines the scene it belongs to
  63722. */
  63723. constructor(scene: Scene);
  63724. /**
  63725. * Register the component to one instance of a scene.
  63726. */
  63727. register(): void;
  63728. /**
  63729. * Rebuilds the elements related to this component in case of
  63730. * context lost for instance.
  63731. */
  63732. rebuild(): void;
  63733. /**
  63734. * Disposes the component and the associated ressources.
  63735. */
  63736. dispose(): void;
  63737. /**
  63738. * Renders the outline in the canvas.
  63739. * @param subMesh Defines the sumesh to render
  63740. * @param batch Defines the batch of meshes in case of instances
  63741. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63742. */
  63743. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63744. /**
  63745. * Returns whether or not the outline renderer is ready for a given submesh.
  63746. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63747. * @param subMesh Defines the submesh to check readyness for
  63748. * @param useInstances Defines wheter wee are trying to render instances or not
  63749. * @returns true if ready otherwise false
  63750. */
  63751. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63752. private _beforeRenderingMesh;
  63753. private _afterRenderingMesh;
  63754. }
  63755. }
  63756. declare module "babylonjs/Rendering/index" {
  63757. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63758. export * from "babylonjs/Rendering/depthRenderer";
  63759. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63760. export * from "babylonjs/Rendering/edgesRenderer";
  63761. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63762. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63763. export * from "babylonjs/Rendering/outlineRenderer";
  63764. export * from "babylonjs/Rendering/renderingGroup";
  63765. export * from "babylonjs/Rendering/renderingManager";
  63766. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63767. }
  63768. declare module "babylonjs/Sprites/spritePackedManager" {
  63769. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63770. import { Scene } from "babylonjs/scene";
  63771. /**
  63772. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63773. * @see http://doc.babylonjs.com/babylon101/sprites
  63774. */
  63775. export class SpritePackedManager extends SpriteManager {
  63776. /** defines the packed manager's name */
  63777. name: string;
  63778. /**
  63779. * Creates a new sprite manager from a packed sprite sheet
  63780. * @param name defines the manager's name
  63781. * @param imgUrl defines the sprite sheet url
  63782. * @param capacity defines the maximum allowed number of sprites
  63783. * @param scene defines the hosting scene
  63784. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63785. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63786. * @param samplingMode defines the smapling mode to use with spritesheet
  63787. * @param fromPacked set to true; do not alter
  63788. */
  63789. constructor(
  63790. /** defines the packed manager's name */
  63791. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63792. }
  63793. }
  63794. declare module "babylonjs/Sprites/index" {
  63795. export * from "babylonjs/Sprites/sprite";
  63796. export * from "babylonjs/Sprites/spriteManager";
  63797. export * from "babylonjs/Sprites/spritePackedManager";
  63798. export * from "babylonjs/Sprites/spriteSceneComponent";
  63799. }
  63800. declare module "babylonjs/Misc/assetsManager" {
  63801. import { Scene } from "babylonjs/scene";
  63802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63803. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63804. import { Skeleton } from "babylonjs/Bones/skeleton";
  63805. import { Observable } from "babylonjs/Misc/observable";
  63806. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63807. import { Texture } from "babylonjs/Materials/Textures/texture";
  63808. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63809. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63810. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63811. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63812. /**
  63813. * Defines the list of states available for a task inside a AssetsManager
  63814. */
  63815. export enum AssetTaskState {
  63816. /**
  63817. * Initialization
  63818. */
  63819. INIT = 0,
  63820. /**
  63821. * Running
  63822. */
  63823. RUNNING = 1,
  63824. /**
  63825. * Done
  63826. */
  63827. DONE = 2,
  63828. /**
  63829. * Error
  63830. */
  63831. ERROR = 3
  63832. }
  63833. /**
  63834. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  63835. */
  63836. export abstract class AbstractAssetTask {
  63837. /**
  63838. * Task name
  63839. */ name: string;
  63840. /**
  63841. * Callback called when the task is successful
  63842. */
  63843. onSuccess: (task: any) => void;
  63844. /**
  63845. * Callback called when the task is not successful
  63846. */
  63847. onError: (task: any, message?: string, exception?: any) => void;
  63848. /**
  63849. * Creates a new AssetsManager
  63850. * @param name defines the name of the task
  63851. */
  63852. constructor(
  63853. /**
  63854. * Task name
  63855. */ name: string);
  63856. private _isCompleted;
  63857. private _taskState;
  63858. private _errorObject;
  63859. /**
  63860. * Get if the task is completed
  63861. */
  63862. readonly isCompleted: boolean;
  63863. /**
  63864. * Gets the current state of the task
  63865. */
  63866. readonly taskState: AssetTaskState;
  63867. /**
  63868. * Gets the current error object (if task is in error)
  63869. */
  63870. readonly errorObject: {
  63871. message?: string;
  63872. exception?: any;
  63873. };
  63874. /**
  63875. * Internal only
  63876. * @hidden
  63877. */
  63878. _setErrorObject(message?: string, exception?: any): void;
  63879. /**
  63880. * Execute the current task
  63881. * @param scene defines the scene where you want your assets to be loaded
  63882. * @param onSuccess is a callback called when the task is successfully executed
  63883. * @param onError is a callback called if an error occurs
  63884. */
  63885. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63886. /**
  63887. * Execute the current task
  63888. * @param scene defines the scene where you want your assets to be loaded
  63889. * @param onSuccess is a callback called when the task is successfully executed
  63890. * @param onError is a callback called if an error occurs
  63891. */
  63892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63893. /**
  63894. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  63895. * This can be used with failed tasks that have the reason for failure fixed.
  63896. */
  63897. reset(): void;
  63898. private onErrorCallback;
  63899. private onDoneCallback;
  63900. }
  63901. /**
  63902. * Define the interface used by progress events raised during assets loading
  63903. */
  63904. export interface IAssetsProgressEvent {
  63905. /**
  63906. * Defines the number of remaining tasks to process
  63907. */
  63908. remainingCount: number;
  63909. /**
  63910. * Defines the total number of tasks
  63911. */
  63912. totalCount: number;
  63913. /**
  63914. * Defines the task that was just processed
  63915. */
  63916. task: AbstractAssetTask;
  63917. }
  63918. /**
  63919. * Class used to share progress information about assets loading
  63920. */
  63921. export class AssetsProgressEvent implements IAssetsProgressEvent {
  63922. /**
  63923. * Defines the number of remaining tasks to process
  63924. */
  63925. remainingCount: number;
  63926. /**
  63927. * Defines the total number of tasks
  63928. */
  63929. totalCount: number;
  63930. /**
  63931. * Defines the task that was just processed
  63932. */
  63933. task: AbstractAssetTask;
  63934. /**
  63935. * Creates a AssetsProgressEvent
  63936. * @param remainingCount defines the number of remaining tasks to process
  63937. * @param totalCount defines the total number of tasks
  63938. * @param task defines the task that was just processed
  63939. */
  63940. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  63941. }
  63942. /**
  63943. * Define a task used by AssetsManager to load meshes
  63944. */
  63945. export class MeshAssetTask extends AbstractAssetTask {
  63946. /**
  63947. * Defines the name of the task
  63948. */
  63949. name: string;
  63950. /**
  63951. * Defines the list of mesh's names you want to load
  63952. */
  63953. meshesNames: any;
  63954. /**
  63955. * Defines the root url to use as a base to load your meshes and associated resources
  63956. */
  63957. rootUrl: string;
  63958. /**
  63959. * Defines the filename of the scene to load from
  63960. */
  63961. sceneFilename: string;
  63962. /**
  63963. * Gets the list of loaded meshes
  63964. */
  63965. loadedMeshes: Array<AbstractMesh>;
  63966. /**
  63967. * Gets the list of loaded particle systems
  63968. */
  63969. loadedParticleSystems: Array<IParticleSystem>;
  63970. /**
  63971. * Gets the list of loaded skeletons
  63972. */
  63973. loadedSkeletons: Array<Skeleton>;
  63974. /**
  63975. * Gets the list of loaded animation groups
  63976. */
  63977. loadedAnimationGroups: Array<AnimationGroup>;
  63978. /**
  63979. * Callback called when the task is successful
  63980. */
  63981. onSuccess: (task: MeshAssetTask) => void;
  63982. /**
  63983. * Callback called when the task is successful
  63984. */
  63985. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  63986. /**
  63987. * Creates a new MeshAssetTask
  63988. * @param name defines the name of the task
  63989. * @param meshesNames defines the list of mesh's names you want to load
  63990. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  63991. * @param sceneFilename defines the filename of the scene to load from
  63992. */
  63993. constructor(
  63994. /**
  63995. * Defines the name of the task
  63996. */
  63997. name: string,
  63998. /**
  63999. * Defines the list of mesh's names you want to load
  64000. */
  64001. meshesNames: any,
  64002. /**
  64003. * Defines the root url to use as a base to load your meshes and associated resources
  64004. */
  64005. rootUrl: string,
  64006. /**
  64007. * Defines the filename of the scene to load from
  64008. */
  64009. sceneFilename: string);
  64010. /**
  64011. * Execute the current task
  64012. * @param scene defines the scene where you want your assets to be loaded
  64013. * @param onSuccess is a callback called when the task is successfully executed
  64014. * @param onError is a callback called if an error occurs
  64015. */
  64016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64017. }
  64018. /**
  64019. * Define a task used by AssetsManager to load text content
  64020. */
  64021. export class TextFileAssetTask extends AbstractAssetTask {
  64022. /**
  64023. * Defines the name of the task
  64024. */
  64025. name: string;
  64026. /**
  64027. * Defines the location of the file to load
  64028. */
  64029. url: string;
  64030. /**
  64031. * Gets the loaded text string
  64032. */
  64033. text: string;
  64034. /**
  64035. * Callback called when the task is successful
  64036. */
  64037. onSuccess: (task: TextFileAssetTask) => void;
  64038. /**
  64039. * Callback called when the task is successful
  64040. */
  64041. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64042. /**
  64043. * Creates a new TextFileAssetTask object
  64044. * @param name defines the name of the task
  64045. * @param url defines the location of the file to load
  64046. */
  64047. constructor(
  64048. /**
  64049. * Defines the name of the task
  64050. */
  64051. name: string,
  64052. /**
  64053. * Defines the location of the file to load
  64054. */
  64055. url: string);
  64056. /**
  64057. * Execute the current task
  64058. * @param scene defines the scene where you want your assets to be loaded
  64059. * @param onSuccess is a callback called when the task is successfully executed
  64060. * @param onError is a callback called if an error occurs
  64061. */
  64062. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64063. }
  64064. /**
  64065. * Define a task used by AssetsManager to load binary data
  64066. */
  64067. export class BinaryFileAssetTask extends AbstractAssetTask {
  64068. /**
  64069. * Defines the name of the task
  64070. */
  64071. name: string;
  64072. /**
  64073. * Defines the location of the file to load
  64074. */
  64075. url: string;
  64076. /**
  64077. * Gets the lodaded data (as an array buffer)
  64078. */
  64079. data: ArrayBuffer;
  64080. /**
  64081. * Callback called when the task is successful
  64082. */
  64083. onSuccess: (task: BinaryFileAssetTask) => void;
  64084. /**
  64085. * Callback called when the task is successful
  64086. */
  64087. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64088. /**
  64089. * Creates a new BinaryFileAssetTask object
  64090. * @param name defines the name of the new task
  64091. * @param url defines the location of the file to load
  64092. */
  64093. constructor(
  64094. /**
  64095. * Defines the name of the task
  64096. */
  64097. name: string,
  64098. /**
  64099. * Defines the location of the file to load
  64100. */
  64101. url: string);
  64102. /**
  64103. * Execute the current task
  64104. * @param scene defines the scene where you want your assets to be loaded
  64105. * @param onSuccess is a callback called when the task is successfully executed
  64106. * @param onError is a callback called if an error occurs
  64107. */
  64108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64109. }
  64110. /**
  64111. * Define a task used by AssetsManager to load images
  64112. */
  64113. export class ImageAssetTask extends AbstractAssetTask {
  64114. /**
  64115. * Defines the name of the task
  64116. */
  64117. name: string;
  64118. /**
  64119. * Defines the location of the image to load
  64120. */
  64121. url: string;
  64122. /**
  64123. * Gets the loaded images
  64124. */
  64125. image: HTMLImageElement;
  64126. /**
  64127. * Callback called when the task is successful
  64128. */
  64129. onSuccess: (task: ImageAssetTask) => void;
  64130. /**
  64131. * Callback called when the task is successful
  64132. */
  64133. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64134. /**
  64135. * Creates a new ImageAssetTask
  64136. * @param name defines the name of the task
  64137. * @param url defines the location of the image to load
  64138. */
  64139. constructor(
  64140. /**
  64141. * Defines the name of the task
  64142. */
  64143. name: string,
  64144. /**
  64145. * Defines the location of the image to load
  64146. */
  64147. url: string);
  64148. /**
  64149. * Execute the current task
  64150. * @param scene defines the scene where you want your assets to be loaded
  64151. * @param onSuccess is a callback called when the task is successfully executed
  64152. * @param onError is a callback called if an error occurs
  64153. */
  64154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64155. }
  64156. /**
  64157. * Defines the interface used by texture loading tasks
  64158. */
  64159. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64160. /**
  64161. * Gets the loaded texture
  64162. */
  64163. texture: TEX;
  64164. }
  64165. /**
  64166. * Define a task used by AssetsManager to load 2D textures
  64167. */
  64168. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64169. /**
  64170. * Defines the name of the task
  64171. */
  64172. name: string;
  64173. /**
  64174. * Defines the location of the file to load
  64175. */
  64176. url: string;
  64177. /**
  64178. * Defines if mipmap should not be generated (default is false)
  64179. */
  64180. noMipmap?: boolean | undefined;
  64181. /**
  64182. * Defines if texture must be inverted on Y axis (default is false)
  64183. */
  64184. invertY?: boolean | undefined;
  64185. /**
  64186. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64187. */
  64188. samplingMode: number;
  64189. /**
  64190. * Gets the loaded texture
  64191. */
  64192. texture: Texture;
  64193. /**
  64194. * Callback called when the task is successful
  64195. */
  64196. onSuccess: (task: TextureAssetTask) => void;
  64197. /**
  64198. * Callback called when the task is successful
  64199. */
  64200. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64201. /**
  64202. * Creates a new TextureAssetTask object
  64203. * @param name defines the name of the task
  64204. * @param url defines the location of the file to load
  64205. * @param noMipmap defines if mipmap should not be generated (default is false)
  64206. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64207. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64208. */
  64209. constructor(
  64210. /**
  64211. * Defines the name of the task
  64212. */
  64213. name: string,
  64214. /**
  64215. * Defines the location of the file to load
  64216. */
  64217. url: string,
  64218. /**
  64219. * Defines if mipmap should not be generated (default is false)
  64220. */
  64221. noMipmap?: boolean | undefined,
  64222. /**
  64223. * Defines if texture must be inverted on Y axis (default is false)
  64224. */
  64225. invertY?: boolean | undefined,
  64226. /**
  64227. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64228. */
  64229. samplingMode?: number);
  64230. /**
  64231. * Execute the current task
  64232. * @param scene defines the scene where you want your assets to be loaded
  64233. * @param onSuccess is a callback called when the task is successfully executed
  64234. * @param onError is a callback called if an error occurs
  64235. */
  64236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64237. }
  64238. /**
  64239. * Define a task used by AssetsManager to load cube textures
  64240. */
  64241. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64242. /**
  64243. * Defines the name of the task
  64244. */
  64245. name: string;
  64246. /**
  64247. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64248. */
  64249. url: string;
  64250. /**
  64251. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64252. */
  64253. extensions?: string[] | undefined;
  64254. /**
  64255. * Defines if mipmaps should not be generated (default is false)
  64256. */
  64257. noMipmap?: boolean | undefined;
  64258. /**
  64259. * Defines the explicit list of files (undefined by default)
  64260. */
  64261. files?: string[] | undefined;
  64262. /**
  64263. * Gets the loaded texture
  64264. */
  64265. texture: CubeTexture;
  64266. /**
  64267. * Callback called when the task is successful
  64268. */
  64269. onSuccess: (task: CubeTextureAssetTask) => void;
  64270. /**
  64271. * Callback called when the task is successful
  64272. */
  64273. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64274. /**
  64275. * Creates a new CubeTextureAssetTask
  64276. * @param name defines the name of the task
  64277. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64278. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64279. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64280. * @param files defines the explicit list of files (undefined by default)
  64281. */
  64282. constructor(
  64283. /**
  64284. * Defines the name of the task
  64285. */
  64286. name: string,
  64287. /**
  64288. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64289. */
  64290. url: string,
  64291. /**
  64292. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64293. */
  64294. extensions?: string[] | undefined,
  64295. /**
  64296. * Defines if mipmaps should not be generated (default is false)
  64297. */
  64298. noMipmap?: boolean | undefined,
  64299. /**
  64300. * Defines the explicit list of files (undefined by default)
  64301. */
  64302. files?: string[] | undefined);
  64303. /**
  64304. * Execute the current task
  64305. * @param scene defines the scene where you want your assets to be loaded
  64306. * @param onSuccess is a callback called when the task is successfully executed
  64307. * @param onError is a callback called if an error occurs
  64308. */
  64309. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64310. }
  64311. /**
  64312. * Define a task used by AssetsManager to load HDR cube textures
  64313. */
  64314. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64315. /**
  64316. * Defines the name of the task
  64317. */
  64318. name: string;
  64319. /**
  64320. * Defines the location of the file to load
  64321. */
  64322. url: string;
  64323. /**
  64324. * Defines the desired size (the more it increases the longer the generation will be)
  64325. */
  64326. size: number;
  64327. /**
  64328. * Defines if mipmaps should not be generated (default is false)
  64329. */
  64330. noMipmap: boolean;
  64331. /**
  64332. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64333. */
  64334. generateHarmonics: boolean;
  64335. /**
  64336. * 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)
  64337. */
  64338. gammaSpace: boolean;
  64339. /**
  64340. * Internal Use Only
  64341. */
  64342. reserved: boolean;
  64343. /**
  64344. * Gets the loaded texture
  64345. */
  64346. texture: HDRCubeTexture;
  64347. /**
  64348. * Callback called when the task is successful
  64349. */
  64350. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64351. /**
  64352. * Callback called when the task is successful
  64353. */
  64354. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64355. /**
  64356. * Creates a new HDRCubeTextureAssetTask object
  64357. * @param name defines the name of the task
  64358. * @param url defines the location of the file to load
  64359. * @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.
  64360. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64361. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64362. * @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)
  64363. * @param reserved Internal use only
  64364. */
  64365. constructor(
  64366. /**
  64367. * Defines the name of the task
  64368. */
  64369. name: string,
  64370. /**
  64371. * Defines the location of the file to load
  64372. */
  64373. url: string,
  64374. /**
  64375. * Defines the desired size (the more it increases the longer the generation will be)
  64376. */
  64377. size: number,
  64378. /**
  64379. * Defines if mipmaps should not be generated (default is false)
  64380. */
  64381. noMipmap?: boolean,
  64382. /**
  64383. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64384. */
  64385. generateHarmonics?: boolean,
  64386. /**
  64387. * 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)
  64388. */
  64389. gammaSpace?: boolean,
  64390. /**
  64391. * Internal Use Only
  64392. */
  64393. reserved?: boolean);
  64394. /**
  64395. * Execute the current task
  64396. * @param scene defines the scene where you want your assets to be loaded
  64397. * @param onSuccess is a callback called when the task is successfully executed
  64398. * @param onError is a callback called if an error occurs
  64399. */
  64400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64401. }
  64402. /**
  64403. * Define a task used by AssetsManager to load Equirectangular cube textures
  64404. */
  64405. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64406. /**
  64407. * Defines the name of the task
  64408. */
  64409. name: string;
  64410. /**
  64411. * Defines the location of the file to load
  64412. */
  64413. url: string;
  64414. /**
  64415. * Defines the desired size (the more it increases the longer the generation will be)
  64416. */
  64417. size: number;
  64418. /**
  64419. * Defines if mipmaps should not be generated (default is false)
  64420. */
  64421. noMipmap: boolean;
  64422. /**
  64423. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64424. * but the standard material would require them in Gamma space) (default is true)
  64425. */
  64426. gammaSpace: boolean;
  64427. /**
  64428. * Gets the loaded texture
  64429. */
  64430. texture: EquiRectangularCubeTexture;
  64431. /**
  64432. * Callback called when the task is successful
  64433. */
  64434. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64435. /**
  64436. * Callback called when the task is successful
  64437. */
  64438. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64439. /**
  64440. * Creates a new EquiRectangularCubeTextureAssetTask object
  64441. * @param name defines the name of the task
  64442. * @param url defines the location of the file to load
  64443. * @param size defines the desired size (the more it increases the longer the generation will be)
  64444. * If the size is omitted this implies you are using a preprocessed cubemap.
  64445. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64446. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64447. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64448. * (default is true)
  64449. */
  64450. constructor(
  64451. /**
  64452. * Defines the name of the task
  64453. */
  64454. name: string,
  64455. /**
  64456. * Defines the location of the file to load
  64457. */
  64458. url: string,
  64459. /**
  64460. * Defines the desired size (the more it increases the longer the generation will be)
  64461. */
  64462. size: number,
  64463. /**
  64464. * Defines if mipmaps should not be generated (default is false)
  64465. */
  64466. noMipmap?: boolean,
  64467. /**
  64468. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64469. * but the standard material would require them in Gamma space) (default is true)
  64470. */
  64471. gammaSpace?: boolean);
  64472. /**
  64473. * Execute the current task
  64474. * @param scene defines the scene where you want your assets to be loaded
  64475. * @param onSuccess is a callback called when the task is successfully executed
  64476. * @param onError is a callback called if an error occurs
  64477. */
  64478. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64479. }
  64480. /**
  64481. * This class can be used to easily import assets into a scene
  64482. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64483. */
  64484. export class AssetsManager {
  64485. private _scene;
  64486. private _isLoading;
  64487. protected _tasks: AbstractAssetTask[];
  64488. protected _waitingTasksCount: number;
  64489. protected _totalTasksCount: number;
  64490. /**
  64491. * Callback called when all tasks are processed
  64492. */
  64493. onFinish: (tasks: AbstractAssetTask[]) => void;
  64494. /**
  64495. * Callback called when a task is successful
  64496. */
  64497. onTaskSuccess: (task: AbstractAssetTask) => void;
  64498. /**
  64499. * Callback called when a task had an error
  64500. */
  64501. onTaskError: (task: AbstractAssetTask) => void;
  64502. /**
  64503. * Callback called when a task is done (whatever the result is)
  64504. */
  64505. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64506. /**
  64507. * Observable called when all tasks are processed
  64508. */
  64509. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64510. /**
  64511. * Observable called when a task had an error
  64512. */
  64513. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64514. /**
  64515. * Observable called when all tasks were executed
  64516. */
  64517. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64518. /**
  64519. * Observable called when a task is done (whatever the result is)
  64520. */
  64521. onProgressObservable: Observable<IAssetsProgressEvent>;
  64522. /**
  64523. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64524. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64525. */
  64526. useDefaultLoadingScreen: boolean;
  64527. /**
  64528. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64529. * when all assets have been downloaded.
  64530. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64531. */
  64532. autoHideLoadingUI: boolean;
  64533. /**
  64534. * Creates a new AssetsManager
  64535. * @param scene defines the scene to work on
  64536. */
  64537. constructor(scene: Scene);
  64538. /**
  64539. * Add a MeshAssetTask to the list of active tasks
  64540. * @param taskName defines the name of the new task
  64541. * @param meshesNames defines the name of meshes to load
  64542. * @param rootUrl defines the root url to use to locate files
  64543. * @param sceneFilename defines the filename of the scene file
  64544. * @returns a new MeshAssetTask object
  64545. */
  64546. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64547. /**
  64548. * Add a TextFileAssetTask to the list of active tasks
  64549. * @param taskName defines the name of the new task
  64550. * @param url defines the url of the file to load
  64551. * @returns a new TextFileAssetTask object
  64552. */
  64553. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64554. /**
  64555. * Add a BinaryFileAssetTask to the list of active tasks
  64556. * @param taskName defines the name of the new task
  64557. * @param url defines the url of the file to load
  64558. * @returns a new BinaryFileAssetTask object
  64559. */
  64560. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64561. /**
  64562. * Add a ImageAssetTask to the list of active tasks
  64563. * @param taskName defines the name of the new task
  64564. * @param url defines the url of the file to load
  64565. * @returns a new ImageAssetTask object
  64566. */
  64567. addImageTask(taskName: string, url: string): ImageAssetTask;
  64568. /**
  64569. * Add a TextureAssetTask to the list of active tasks
  64570. * @param taskName defines the name of the new task
  64571. * @param url defines the url of the file to load
  64572. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64573. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64574. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64575. * @returns a new TextureAssetTask object
  64576. */
  64577. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64578. /**
  64579. * Add a CubeTextureAssetTask to the list of active tasks
  64580. * @param taskName defines the name of the new task
  64581. * @param url defines the url of the file to load
  64582. * @param extensions defines the extension to use to load the cube map (can be null)
  64583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64584. * @param files defines the list of files to load (can be null)
  64585. * @returns a new CubeTextureAssetTask object
  64586. */
  64587. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64588. /**
  64589. *
  64590. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64591. * @param taskName defines the name of the new task
  64592. * @param url defines the url of the file to load
  64593. * @param size defines the size you want for the cubemap (can be null)
  64594. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64595. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64596. * @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)
  64597. * @param reserved Internal use only
  64598. * @returns a new HDRCubeTextureAssetTask object
  64599. */
  64600. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64601. /**
  64602. *
  64603. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64604. * @param taskName defines the name of the new task
  64605. * @param url defines the url of the file to load
  64606. * @param size defines the size you want for the cubemap (can be null)
  64607. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64608. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64609. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64610. * @returns a new EquiRectangularCubeTextureAssetTask object
  64611. */
  64612. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64613. /**
  64614. * Remove a task from the assets manager.
  64615. * @param task the task to remove
  64616. */
  64617. removeTask(task: AbstractAssetTask): void;
  64618. private _decreaseWaitingTasksCount;
  64619. private _runTask;
  64620. /**
  64621. * Reset the AssetsManager and remove all tasks
  64622. * @return the current instance of the AssetsManager
  64623. */
  64624. reset(): AssetsManager;
  64625. /**
  64626. * Start the loading process
  64627. * @return the current instance of the AssetsManager
  64628. */
  64629. load(): AssetsManager;
  64630. /**
  64631. * Start the loading process as an async operation
  64632. * @return a promise returning the list of failed tasks
  64633. */
  64634. loadAsync(): Promise<void>;
  64635. }
  64636. }
  64637. declare module "babylonjs/Misc/deferred" {
  64638. /**
  64639. * Wrapper class for promise with external resolve and reject.
  64640. */
  64641. export class Deferred<T> {
  64642. /**
  64643. * The promise associated with this deferred object.
  64644. */
  64645. readonly promise: Promise<T>;
  64646. private _resolve;
  64647. private _reject;
  64648. /**
  64649. * The resolve method of the promise associated with this deferred object.
  64650. */
  64651. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64652. /**
  64653. * The reject method of the promise associated with this deferred object.
  64654. */
  64655. readonly reject: (reason?: any) => void;
  64656. /**
  64657. * Constructor for this deferred object.
  64658. */
  64659. constructor();
  64660. }
  64661. }
  64662. declare module "babylonjs/Misc/meshExploder" {
  64663. import { Mesh } from "babylonjs/Meshes/mesh";
  64664. /**
  64665. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64666. */
  64667. export class MeshExploder {
  64668. private _centerMesh;
  64669. private _meshes;
  64670. private _meshesOrigins;
  64671. private _toCenterVectors;
  64672. private _scaledDirection;
  64673. private _newPosition;
  64674. private _centerPosition;
  64675. /**
  64676. * Explodes meshes from a center mesh.
  64677. * @param meshes The meshes to explode.
  64678. * @param centerMesh The mesh to be center of explosion.
  64679. */
  64680. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64681. private _setCenterMesh;
  64682. /**
  64683. * Get class name
  64684. * @returns "MeshExploder"
  64685. */
  64686. getClassName(): string;
  64687. /**
  64688. * "Exploded meshes"
  64689. * @returns Array of meshes with the centerMesh at index 0.
  64690. */
  64691. getMeshes(): Array<Mesh>;
  64692. /**
  64693. * Explodes meshes giving a specific direction
  64694. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64695. */
  64696. explode(direction?: number): void;
  64697. }
  64698. }
  64699. declare module "babylonjs/Misc/filesInput" {
  64700. import { Engine } from "babylonjs/Engines/engine";
  64701. import { Scene } from "babylonjs/scene";
  64702. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64703. /**
  64704. * Class used to help managing file picking and drag'n'drop
  64705. */
  64706. export class FilesInput {
  64707. /**
  64708. * List of files ready to be loaded
  64709. */
  64710. static readonly FilesToLoad: {
  64711. [key: string]: File;
  64712. };
  64713. /**
  64714. * Callback called when a file is processed
  64715. */
  64716. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64717. private _engine;
  64718. private _currentScene;
  64719. private _sceneLoadedCallback;
  64720. private _progressCallback;
  64721. private _additionalRenderLoopLogicCallback;
  64722. private _textureLoadingCallback;
  64723. private _startingProcessingFilesCallback;
  64724. private _onReloadCallback;
  64725. private _errorCallback;
  64726. private _elementToMonitor;
  64727. private _sceneFileToLoad;
  64728. private _filesToLoad;
  64729. /**
  64730. * Creates a new FilesInput
  64731. * @param engine defines the rendering engine
  64732. * @param scene defines the hosting scene
  64733. * @param sceneLoadedCallback callback called when scene is loaded
  64734. * @param progressCallback callback called to track progress
  64735. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64736. * @param textureLoadingCallback callback called when a texture is loading
  64737. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64738. * @param onReloadCallback callback called when a reload is requested
  64739. * @param errorCallback callback call if an error occurs
  64740. */
  64741. 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);
  64742. private _dragEnterHandler;
  64743. private _dragOverHandler;
  64744. private _dropHandler;
  64745. /**
  64746. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64747. * @param elementToMonitor defines the DOM element to track
  64748. */
  64749. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64750. /**
  64751. * Release all associated resources
  64752. */
  64753. dispose(): void;
  64754. private renderFunction;
  64755. private drag;
  64756. private drop;
  64757. private _traverseFolder;
  64758. private _processFiles;
  64759. /**
  64760. * Load files from a drop event
  64761. * @param event defines the drop event to use as source
  64762. */
  64763. loadFiles(event: any): void;
  64764. private _processReload;
  64765. /**
  64766. * Reload the current scene from the loaded files
  64767. */
  64768. reload(): void;
  64769. }
  64770. }
  64771. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64772. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64773. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64774. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64775. }
  64776. declare module "babylonjs/Misc/sceneOptimizer" {
  64777. import { Scene, IDisposable } from "babylonjs/scene";
  64778. import { Observable } from "babylonjs/Misc/observable";
  64779. /**
  64780. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64781. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64782. */
  64783. export class SceneOptimization {
  64784. /**
  64785. * Defines the priority of this optimization (0 by default which means first in the list)
  64786. */
  64787. priority: number;
  64788. /**
  64789. * Gets a string describing the action executed by the current optimization
  64790. * @returns description string
  64791. */
  64792. getDescription(): string;
  64793. /**
  64794. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64795. * @param scene defines the current scene where to apply this optimization
  64796. * @param optimizer defines the current optimizer
  64797. * @returns true if everything that can be done was applied
  64798. */
  64799. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64800. /**
  64801. * Creates the SceneOptimization object
  64802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64803. * @param desc defines the description associated with the optimization
  64804. */
  64805. constructor(
  64806. /**
  64807. * Defines the priority of this optimization (0 by default which means first in the list)
  64808. */
  64809. priority?: number);
  64810. }
  64811. /**
  64812. * Defines an optimization used to reduce the size of render target textures
  64813. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64814. */
  64815. export class TextureOptimization extends SceneOptimization {
  64816. /**
  64817. * Defines the priority of this optimization (0 by default which means first in the list)
  64818. */
  64819. priority: number;
  64820. /**
  64821. * 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
  64822. */
  64823. maximumSize: number;
  64824. /**
  64825. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64826. */
  64827. step: number;
  64828. /**
  64829. * Gets a string describing the action executed by the current optimization
  64830. * @returns description string
  64831. */
  64832. getDescription(): string;
  64833. /**
  64834. * Creates the TextureOptimization object
  64835. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64836. * @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
  64837. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64838. */
  64839. constructor(
  64840. /**
  64841. * Defines the priority of this optimization (0 by default which means first in the list)
  64842. */
  64843. priority?: number,
  64844. /**
  64845. * 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
  64846. */
  64847. maximumSize?: number,
  64848. /**
  64849. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  64850. */
  64851. step?: number);
  64852. /**
  64853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64854. * @param scene defines the current scene where to apply this optimization
  64855. * @param optimizer defines the current optimizer
  64856. * @returns true if everything that can be done was applied
  64857. */
  64858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64859. }
  64860. /**
  64861. * Defines an optimization used to increase or decrease the rendering resolution
  64862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64863. */
  64864. export class HardwareScalingOptimization extends SceneOptimization {
  64865. /**
  64866. * Defines the priority of this optimization (0 by default which means first in the list)
  64867. */
  64868. priority: number;
  64869. /**
  64870. * Defines the maximum scale to use (2 by default)
  64871. */
  64872. maximumScale: number;
  64873. /**
  64874. * Defines the step to use between two passes (0.5 by default)
  64875. */
  64876. step: number;
  64877. private _currentScale;
  64878. private _directionOffset;
  64879. /**
  64880. * Gets a string describing the action executed by the current optimization
  64881. * @return description string
  64882. */
  64883. getDescription(): string;
  64884. /**
  64885. * Creates the HardwareScalingOptimization object
  64886. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64887. * @param maximumScale defines the maximum scale to use (2 by default)
  64888. * @param step defines the step to use between two passes (0.5 by default)
  64889. */
  64890. constructor(
  64891. /**
  64892. * Defines the priority of this optimization (0 by default which means first in the list)
  64893. */
  64894. priority?: number,
  64895. /**
  64896. * Defines the maximum scale to use (2 by default)
  64897. */
  64898. maximumScale?: number,
  64899. /**
  64900. * Defines the step to use between two passes (0.5 by default)
  64901. */
  64902. step?: number);
  64903. /**
  64904. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64905. * @param scene defines the current scene where to apply this optimization
  64906. * @param optimizer defines the current optimizer
  64907. * @returns true if everything that can be done was applied
  64908. */
  64909. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64910. }
  64911. /**
  64912. * Defines an optimization used to remove shadows
  64913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64914. */
  64915. export class ShadowsOptimization extends SceneOptimization {
  64916. /**
  64917. * Gets a string describing the action executed by the current optimization
  64918. * @return description string
  64919. */
  64920. getDescription(): string;
  64921. /**
  64922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64923. * @param scene defines the current scene where to apply this optimization
  64924. * @param optimizer defines the current optimizer
  64925. * @returns true if everything that can be done was applied
  64926. */
  64927. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64928. }
  64929. /**
  64930. * Defines an optimization used to turn post-processes off
  64931. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64932. */
  64933. export class PostProcessesOptimization extends SceneOptimization {
  64934. /**
  64935. * Gets a string describing the action executed by the current optimization
  64936. * @return description string
  64937. */
  64938. getDescription(): string;
  64939. /**
  64940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64941. * @param scene defines the current scene where to apply this optimization
  64942. * @param optimizer defines the current optimizer
  64943. * @returns true if everything that can be done was applied
  64944. */
  64945. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64946. }
  64947. /**
  64948. * Defines an optimization used to turn lens flares off
  64949. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64950. */
  64951. export class LensFlaresOptimization extends SceneOptimization {
  64952. /**
  64953. * Gets a string describing the action executed by the current optimization
  64954. * @return description string
  64955. */
  64956. getDescription(): string;
  64957. /**
  64958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64959. * @param scene defines the current scene where to apply this optimization
  64960. * @param optimizer defines the current optimizer
  64961. * @returns true if everything that can be done was applied
  64962. */
  64963. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64964. }
  64965. /**
  64966. * Defines an optimization based on user defined callback.
  64967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64968. */
  64969. export class CustomOptimization extends SceneOptimization {
  64970. /**
  64971. * Callback called to apply the custom optimization.
  64972. */
  64973. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  64974. /**
  64975. * Callback called to get custom description
  64976. */
  64977. onGetDescription: () => string;
  64978. /**
  64979. * Gets a string describing the action executed by the current optimization
  64980. * @returns description string
  64981. */
  64982. getDescription(): string;
  64983. /**
  64984. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64985. * @param scene defines the current scene where to apply this optimization
  64986. * @param optimizer defines the current optimizer
  64987. * @returns true if everything that can be done was applied
  64988. */
  64989. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64990. }
  64991. /**
  64992. * Defines an optimization used to turn particles off
  64993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64994. */
  64995. export class ParticlesOptimization extends SceneOptimization {
  64996. /**
  64997. * Gets a string describing the action executed by the current optimization
  64998. * @return description string
  64999. */
  65000. getDescription(): string;
  65001. /**
  65002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65003. * @param scene defines the current scene where to apply this optimization
  65004. * @param optimizer defines the current optimizer
  65005. * @returns true if everything that can be done was applied
  65006. */
  65007. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65008. }
  65009. /**
  65010. * Defines an optimization used to turn render targets off
  65011. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65012. */
  65013. export class RenderTargetsOptimization extends SceneOptimization {
  65014. /**
  65015. * Gets a string describing the action executed by the current optimization
  65016. * @return description string
  65017. */
  65018. getDescription(): string;
  65019. /**
  65020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65021. * @param scene defines the current scene where to apply this optimization
  65022. * @param optimizer defines the current optimizer
  65023. * @returns true if everything that can be done was applied
  65024. */
  65025. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65026. }
  65027. /**
  65028. * Defines an optimization used to merge meshes with compatible materials
  65029. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65030. */
  65031. export class MergeMeshesOptimization extends SceneOptimization {
  65032. private static _UpdateSelectionTree;
  65033. /**
  65034. * Gets or sets a boolean which defines if optimization octree has to be updated
  65035. */
  65036. /**
  65037. * Gets or sets a boolean which defines if optimization octree has to be updated
  65038. */
  65039. static UpdateSelectionTree: boolean;
  65040. /**
  65041. * Gets a string describing the action executed by the current optimization
  65042. * @return description string
  65043. */
  65044. getDescription(): string;
  65045. private _canBeMerged;
  65046. /**
  65047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65048. * @param scene defines the current scene where to apply this optimization
  65049. * @param optimizer defines the current optimizer
  65050. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65051. * @returns true if everything that can be done was applied
  65052. */
  65053. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65054. }
  65055. /**
  65056. * Defines a list of options used by SceneOptimizer
  65057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65058. */
  65059. export class SceneOptimizerOptions {
  65060. /**
  65061. * Defines the target frame rate to reach (60 by default)
  65062. */
  65063. targetFrameRate: number;
  65064. /**
  65065. * Defines the interval between two checkes (2000ms by default)
  65066. */
  65067. trackerDuration: number;
  65068. /**
  65069. * Gets the list of optimizations to apply
  65070. */
  65071. optimizations: SceneOptimization[];
  65072. /**
  65073. * Creates a new list of options used by SceneOptimizer
  65074. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65075. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65076. */
  65077. constructor(
  65078. /**
  65079. * Defines the target frame rate to reach (60 by default)
  65080. */
  65081. targetFrameRate?: number,
  65082. /**
  65083. * Defines the interval between two checkes (2000ms by default)
  65084. */
  65085. trackerDuration?: number);
  65086. /**
  65087. * Add a new optimization
  65088. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65089. * @returns the current SceneOptimizerOptions
  65090. */
  65091. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65092. /**
  65093. * Add a new custom optimization
  65094. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65095. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65096. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65097. * @returns the current SceneOptimizerOptions
  65098. */
  65099. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65100. /**
  65101. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65102. * @param targetFrameRate defines the target frame rate (60 by default)
  65103. * @returns a SceneOptimizerOptions object
  65104. */
  65105. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65106. /**
  65107. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65108. * @param targetFrameRate defines the target frame rate (60 by default)
  65109. * @returns a SceneOptimizerOptions object
  65110. */
  65111. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65112. /**
  65113. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65114. * @param targetFrameRate defines the target frame rate (60 by default)
  65115. * @returns a SceneOptimizerOptions object
  65116. */
  65117. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65118. }
  65119. /**
  65120. * Class used to run optimizations in order to reach a target frame rate
  65121. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65122. */
  65123. export class SceneOptimizer implements IDisposable {
  65124. private _isRunning;
  65125. private _options;
  65126. private _scene;
  65127. private _currentPriorityLevel;
  65128. private _targetFrameRate;
  65129. private _trackerDuration;
  65130. private _currentFrameRate;
  65131. private _sceneDisposeObserver;
  65132. private _improvementMode;
  65133. /**
  65134. * Defines an observable called when the optimizer reaches the target frame rate
  65135. */
  65136. onSuccessObservable: Observable<SceneOptimizer>;
  65137. /**
  65138. * Defines an observable called when the optimizer enables an optimization
  65139. */
  65140. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65141. /**
  65142. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65143. */
  65144. onFailureObservable: Observable<SceneOptimizer>;
  65145. /**
  65146. * Gets a boolean indicating if the optimizer is in improvement mode
  65147. */
  65148. readonly isInImprovementMode: boolean;
  65149. /**
  65150. * Gets the current priority level (0 at start)
  65151. */
  65152. readonly currentPriorityLevel: number;
  65153. /**
  65154. * Gets the current frame rate checked by the SceneOptimizer
  65155. */
  65156. readonly currentFrameRate: number;
  65157. /**
  65158. * Gets or sets the current target frame rate (60 by default)
  65159. */
  65160. /**
  65161. * Gets or sets the current target frame rate (60 by default)
  65162. */
  65163. targetFrameRate: number;
  65164. /**
  65165. * Gets or sets the current interval between two checks (every 2000ms by default)
  65166. */
  65167. /**
  65168. * Gets or sets the current interval between two checks (every 2000ms by default)
  65169. */
  65170. trackerDuration: number;
  65171. /**
  65172. * Gets the list of active optimizations
  65173. */
  65174. readonly optimizations: SceneOptimization[];
  65175. /**
  65176. * Creates a new SceneOptimizer
  65177. * @param scene defines the scene to work on
  65178. * @param options defines the options to use with the SceneOptimizer
  65179. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65180. * @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)
  65181. */
  65182. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65183. /**
  65184. * Stops the current optimizer
  65185. */
  65186. stop(): void;
  65187. /**
  65188. * Reset the optimizer to initial step (current priority level = 0)
  65189. */
  65190. reset(): void;
  65191. /**
  65192. * Start the optimizer. By default it will try to reach a specific framerate
  65193. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65194. */
  65195. start(): void;
  65196. private _checkCurrentState;
  65197. /**
  65198. * Release all resources
  65199. */
  65200. dispose(): void;
  65201. /**
  65202. * Helper function to create a SceneOptimizer with one single line of code
  65203. * @param scene defines the scene to work on
  65204. * @param options defines the options to use with the SceneOptimizer
  65205. * @param onSuccess defines a callback to call on success
  65206. * @param onFailure defines a callback to call on failure
  65207. * @returns the new SceneOptimizer object
  65208. */
  65209. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65210. }
  65211. }
  65212. declare module "babylonjs/Misc/sceneSerializer" {
  65213. import { Scene } from "babylonjs/scene";
  65214. /**
  65215. * Class used to serialize a scene into a string
  65216. */
  65217. export class SceneSerializer {
  65218. /**
  65219. * Clear cache used by a previous serialization
  65220. */
  65221. static ClearCache(): void;
  65222. /**
  65223. * Serialize a scene into a JSON compatible object
  65224. * @param scene defines the scene to serialize
  65225. * @returns a JSON compatible object
  65226. */
  65227. static Serialize(scene: Scene): any;
  65228. /**
  65229. * Serialize a mesh into a JSON compatible object
  65230. * @param toSerialize defines the mesh to serialize
  65231. * @param withParents defines if parents must be serialized as well
  65232. * @param withChildren defines if children must be serialized as well
  65233. * @returns a JSON compatible object
  65234. */
  65235. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65236. }
  65237. }
  65238. declare module "babylonjs/Misc/textureTools" {
  65239. import { Texture } from "babylonjs/Materials/Textures/texture";
  65240. /**
  65241. * Class used to host texture specific utilities
  65242. */
  65243. export class TextureTools {
  65244. /**
  65245. * Uses the GPU to create a copy texture rescaled at a given size
  65246. * @param texture Texture to copy from
  65247. * @param width defines the desired width
  65248. * @param height defines the desired height
  65249. * @param useBilinearMode defines if bilinear mode has to be used
  65250. * @return the generated texture
  65251. */
  65252. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65253. }
  65254. }
  65255. declare module "babylonjs/Misc/videoRecorder" {
  65256. import { Nullable } from "babylonjs/types";
  65257. import { Engine } from "babylonjs/Engines/engine";
  65258. /**
  65259. * This represents the different options available for the video capture.
  65260. */
  65261. export interface VideoRecorderOptions {
  65262. /** Defines the mime type of the video. */
  65263. mimeType: string;
  65264. /** Defines the FPS the video should be recorded at. */
  65265. fps: number;
  65266. /** Defines the chunk size for the recording data. */
  65267. recordChunckSize: number;
  65268. /** The audio tracks to attach to the recording. */
  65269. audioTracks?: MediaStreamTrack[];
  65270. }
  65271. /**
  65272. * This can help with recording videos from BabylonJS.
  65273. * This is based on the available WebRTC functionalities of the browser.
  65274. *
  65275. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65276. */
  65277. export class VideoRecorder {
  65278. private static readonly _defaultOptions;
  65279. /**
  65280. * Returns whether or not the VideoRecorder is available in your browser.
  65281. * @param engine Defines the Babylon Engine.
  65282. * @returns true if supported otherwise false.
  65283. */
  65284. static IsSupported(engine: Engine): boolean;
  65285. private readonly _options;
  65286. private _canvas;
  65287. private _mediaRecorder;
  65288. private _recordedChunks;
  65289. private _fileName;
  65290. private _resolve;
  65291. private _reject;
  65292. /**
  65293. * True when a recording is already in progress.
  65294. */
  65295. readonly isRecording: boolean;
  65296. /**
  65297. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65298. * @param engine Defines the BabylonJS Engine you wish to record.
  65299. * @param options Defines options that can be used to customize the capture.
  65300. */
  65301. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65302. /**
  65303. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65304. */
  65305. stopRecording(): void;
  65306. /**
  65307. * Starts recording the canvas for a max duration specified in parameters.
  65308. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65309. * If null no automatic download will start and you can rely on the promise to get the data back.
  65310. * @param maxDuration Defines the maximum recording time in seconds.
  65311. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65312. * @return A promise callback at the end of the recording with the video data in Blob.
  65313. */
  65314. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65315. /**
  65316. * Releases internal resources used during the recording.
  65317. */
  65318. dispose(): void;
  65319. private _handleDataAvailable;
  65320. private _handleError;
  65321. private _handleStop;
  65322. }
  65323. }
  65324. declare module "babylonjs/Misc/screenshotTools" {
  65325. import { Camera } from "babylonjs/Cameras/camera";
  65326. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65327. import { Engine } from "babylonjs/Engines/engine";
  65328. /**
  65329. * Class containing a set of static utilities functions for screenshots
  65330. */
  65331. export class ScreenshotTools {
  65332. /**
  65333. * Captures a screenshot of the current rendering
  65334. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65335. * @param engine defines the rendering engine
  65336. * @param camera defines the source camera
  65337. * @param size This parameter can be set to a single number or to an object with the
  65338. * following (optional) properties: precision, width, height. If a single number is passed,
  65339. * it will be used for both width and height. If an object is passed, the screenshot size
  65340. * will be derived from the parameters. The precision property is a multiplier allowing
  65341. * rendering at a higher or lower resolution
  65342. * @param successCallback defines the callback receives a single parameter which contains the
  65343. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65344. * src parameter of an <img> to display it
  65345. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65346. * Check your browser for supported MIME types
  65347. */
  65348. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65349. /**
  65350. * Captures a screenshot of the current rendering
  65351. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65352. * @param engine defines the rendering engine
  65353. * @param camera defines the source camera
  65354. * @param size This parameter can be set to a single number or to an object with the
  65355. * following (optional) properties: precision, width, height. If a single number is passed,
  65356. * it will be used for both width and height. If an object is passed, the screenshot size
  65357. * will be derived from the parameters. The precision property is a multiplier allowing
  65358. * rendering at a higher or lower resolution
  65359. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65360. * Check your browser for supported MIME types
  65361. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65362. * to the src parameter of an <img> to display it
  65363. */
  65364. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65365. /**
  65366. * Generates an image screenshot from the specified camera.
  65367. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65368. * @param engine The engine to use for rendering
  65369. * @param camera The camera to use for rendering
  65370. * @param size This parameter can be set to a single number or to an object with the
  65371. * following (optional) properties: precision, width, height. If a single number is passed,
  65372. * it will be used for both width and height. If an object is passed, the screenshot size
  65373. * will be derived from the parameters. The precision property is a multiplier allowing
  65374. * rendering at a higher or lower resolution
  65375. * @param successCallback The callback receives a single parameter which contains the
  65376. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65377. * src parameter of an <img> to display it
  65378. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65379. * Check your browser for supported MIME types
  65380. * @param samples Texture samples (default: 1)
  65381. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65382. * @param fileName A name for for the downloaded file.
  65383. */
  65384. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65385. /**
  65386. * Generates an image screenshot from the specified camera.
  65387. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65388. * @param engine The engine to use for rendering
  65389. * @param camera The camera to use for rendering
  65390. * @param size This parameter can be set to a single number or to an object with the
  65391. * following (optional) properties: precision, width, height. If a single number is passed,
  65392. * it will be used for both width and height. If an object is passed, the screenshot size
  65393. * will be derived from the parameters. The precision property is a multiplier allowing
  65394. * rendering at a higher or lower resolution
  65395. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65396. * Check your browser for supported MIME types
  65397. * @param samples Texture samples (default: 1)
  65398. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65399. * @param fileName A name for for the downloaded file.
  65400. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65401. * to the src parameter of an <img> to display it
  65402. */
  65403. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65404. /**
  65405. * Gets height and width for screenshot size
  65406. * @private
  65407. */
  65408. private static _getScreenshotSize;
  65409. }
  65410. }
  65411. declare module "babylonjs/Misc/index" {
  65412. export * from "babylonjs/Misc/andOrNotEvaluator";
  65413. export * from "babylonjs/Misc/assetsManager";
  65414. export * from "babylonjs/Misc/dds";
  65415. export * from "babylonjs/Misc/decorators";
  65416. export * from "babylonjs/Misc/deferred";
  65417. export * from "babylonjs/Misc/environmentTextureTools";
  65418. export * from "babylonjs/Misc/meshExploder";
  65419. export * from "babylonjs/Misc/filesInput";
  65420. export * from "babylonjs/Misc/HighDynamicRange/index";
  65421. export * from "babylonjs/Misc/khronosTextureContainer";
  65422. export * from "babylonjs/Misc/observable";
  65423. export * from "babylonjs/Misc/performanceMonitor";
  65424. export * from "babylonjs/Misc/promise";
  65425. export * from "babylonjs/Misc/sceneOptimizer";
  65426. export * from "babylonjs/Misc/sceneSerializer";
  65427. export * from "babylonjs/Misc/smartArray";
  65428. export * from "babylonjs/Misc/stringDictionary";
  65429. export * from "babylonjs/Misc/tags";
  65430. export * from "babylonjs/Misc/textureTools";
  65431. export * from "babylonjs/Misc/tga";
  65432. export * from "babylonjs/Misc/tools";
  65433. export * from "babylonjs/Misc/videoRecorder";
  65434. export * from "babylonjs/Misc/virtualJoystick";
  65435. export * from "babylonjs/Misc/workerPool";
  65436. export * from "babylonjs/Misc/logger";
  65437. export * from "babylonjs/Misc/typeStore";
  65438. export * from "babylonjs/Misc/filesInputStore";
  65439. export * from "babylonjs/Misc/deepCopier";
  65440. export * from "babylonjs/Misc/pivotTools";
  65441. export * from "babylonjs/Misc/precisionDate";
  65442. export * from "babylonjs/Misc/screenshotTools";
  65443. export * from "babylonjs/Misc/typeStore";
  65444. export * from "babylonjs/Misc/webRequest";
  65445. export * from "babylonjs/Misc/iInspectable";
  65446. export * from "babylonjs/Misc/brdfTextureTools";
  65447. export * from "babylonjs/Misc/rgbdTextureTools";
  65448. export * from "babylonjs/Misc/gradients";
  65449. export * from "babylonjs/Misc/perfCounter";
  65450. export * from "babylonjs/Misc/fileRequest";
  65451. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65452. export * from "babylonjs/Misc/retryStrategy";
  65453. export * from "babylonjs/Misc/loadFileError";
  65454. }
  65455. declare module "babylonjs/index" {
  65456. export * from "babylonjs/abstractScene";
  65457. export * from "babylonjs/Actions/index";
  65458. export * from "babylonjs/Animations/index";
  65459. export * from "babylonjs/assetContainer";
  65460. export * from "babylonjs/Audio/index";
  65461. export * from "babylonjs/Behaviors/index";
  65462. export * from "babylonjs/Bones/index";
  65463. export * from "babylonjs/Cameras/index";
  65464. export * from "babylonjs/Collisions/index";
  65465. export * from "babylonjs/Culling/index";
  65466. export * from "babylonjs/Debug/index";
  65467. export * from "babylonjs/Engines/index";
  65468. export * from "babylonjs/Events/index";
  65469. export * from "babylonjs/Gamepads/index";
  65470. export * from "babylonjs/Gizmos/index";
  65471. export * from "babylonjs/Helpers/index";
  65472. export * from "babylonjs/Instrumentation/index";
  65473. export * from "babylonjs/Layers/index";
  65474. export * from "babylonjs/LensFlares/index";
  65475. export * from "babylonjs/Lights/index";
  65476. export * from "babylonjs/Loading/index";
  65477. export * from "babylonjs/Materials/index";
  65478. export * from "babylonjs/Maths/index";
  65479. export * from "babylonjs/Meshes/index";
  65480. export * from "babylonjs/Morph/index";
  65481. export * from "babylonjs/Navigation/index";
  65482. export * from "babylonjs/node";
  65483. export * from "babylonjs/Offline/index";
  65484. export * from "babylonjs/Particles/index";
  65485. export * from "babylonjs/Physics/index";
  65486. export * from "babylonjs/PostProcesses/index";
  65487. export * from "babylonjs/Probes/index";
  65488. export * from "babylonjs/Rendering/index";
  65489. export * from "babylonjs/scene";
  65490. export * from "babylonjs/sceneComponent";
  65491. export * from "babylonjs/Sprites/index";
  65492. export * from "babylonjs/States/index";
  65493. export * from "babylonjs/Misc/index";
  65494. export * from "babylonjs/types";
  65495. }
  65496. declare module "babylonjs/Animations/pathCursor" {
  65497. import { Vector3 } from "babylonjs/Maths/math.vector";
  65498. import { Path2 } from "babylonjs/Maths/math.path";
  65499. /**
  65500. * A cursor which tracks a point on a path
  65501. */
  65502. export class PathCursor {
  65503. private path;
  65504. /**
  65505. * Stores path cursor callbacks for when an onchange event is triggered
  65506. */
  65507. private _onchange;
  65508. /**
  65509. * The value of the path cursor
  65510. */
  65511. value: number;
  65512. /**
  65513. * The animation array of the path cursor
  65514. */
  65515. animations: Animation[];
  65516. /**
  65517. * Initializes the path cursor
  65518. * @param path The path to track
  65519. */
  65520. constructor(path: Path2);
  65521. /**
  65522. * Gets the cursor point on the path
  65523. * @returns A point on the path cursor at the cursor location
  65524. */
  65525. getPoint(): Vector3;
  65526. /**
  65527. * Moves the cursor ahead by the step amount
  65528. * @param step The amount to move the cursor forward
  65529. * @returns This path cursor
  65530. */
  65531. moveAhead(step?: number): PathCursor;
  65532. /**
  65533. * Moves the cursor behind by the step amount
  65534. * @param step The amount to move the cursor back
  65535. * @returns This path cursor
  65536. */
  65537. moveBack(step?: number): PathCursor;
  65538. /**
  65539. * Moves the cursor by the step amount
  65540. * If the step amount is greater than one, an exception is thrown
  65541. * @param step The amount to move the cursor
  65542. * @returns This path cursor
  65543. */
  65544. move(step: number): PathCursor;
  65545. /**
  65546. * Ensures that the value is limited between zero and one
  65547. * @returns This path cursor
  65548. */
  65549. private ensureLimits;
  65550. /**
  65551. * Runs onchange callbacks on change (used by the animation engine)
  65552. * @returns This path cursor
  65553. */
  65554. private raiseOnChange;
  65555. /**
  65556. * Executes a function on change
  65557. * @param f A path cursor onchange callback
  65558. * @returns This path cursor
  65559. */
  65560. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65561. }
  65562. }
  65563. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65564. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65565. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65566. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65567. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65568. }
  65569. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65570. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65571. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65572. }
  65573. declare module "babylonjs/Engines/Processors/index" {
  65574. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65575. export * from "babylonjs/Engines/Processors/Expressions/index";
  65576. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65577. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65578. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65579. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65580. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65581. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65582. }
  65583. declare module "babylonjs/Legacy/legacy" {
  65584. import * as Babylon from "babylonjs/index";
  65585. export * from "babylonjs/index";
  65586. }
  65587. declare module "babylonjs/Shaders/blur.fragment" {
  65588. /** @hidden */
  65589. export var blurPixelShader: {
  65590. name: string;
  65591. shader: string;
  65592. };
  65593. }
  65594. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65595. /** @hidden */
  65596. export var pointCloudVertexDeclaration: {
  65597. name: string;
  65598. shader: string;
  65599. };
  65600. }
  65601. declare module "babylonjs" {
  65602. export * from "babylonjs/Legacy/legacy";
  65603. }
  65604. declare module BABYLON {
  65605. /** Alias type for value that can be null */
  65606. export type Nullable<T> = T | null;
  65607. /**
  65608. * Alias type for number that are floats
  65609. * @ignorenaming
  65610. */
  65611. export type float = number;
  65612. /**
  65613. * Alias type for number that are doubles.
  65614. * @ignorenaming
  65615. */
  65616. export type double = number;
  65617. /**
  65618. * Alias type for number that are integer
  65619. * @ignorenaming
  65620. */
  65621. export type int = number;
  65622. /** Alias type for number array or Float32Array */
  65623. export type FloatArray = number[] | Float32Array;
  65624. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65625. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65626. /**
  65627. * Alias for types that can be used by a Buffer or VertexBuffer.
  65628. */
  65629. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65630. /**
  65631. * Alias type for primitive types
  65632. * @ignorenaming
  65633. */
  65634. type Primitive = undefined | null | boolean | string | number | Function;
  65635. /**
  65636. * Type modifier to make all the properties of an object Readonly
  65637. */
  65638. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65639. /**
  65640. * Type modifier to make all the properties of an object Readonly recursively
  65641. */
  65642. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65643. /** @hidden */
  65644. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65645. }
  65646. /** @hidden */
  65647. /** @hidden */
  65648. type DeepImmutableObject<T> = {
  65649. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65650. };
  65651. }
  65652. declare module BABYLON {
  65653. /**
  65654. * A class serves as a medium between the observable and its observers
  65655. */
  65656. export class EventState {
  65657. /**
  65658. * Create a new EventState
  65659. * @param mask defines the mask associated with this state
  65660. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65661. * @param target defines the original target of the state
  65662. * @param currentTarget defines the current target of the state
  65663. */
  65664. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65665. /**
  65666. * Initialize the current event state
  65667. * @param mask defines the mask associated with this state
  65668. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65669. * @param target defines the original target of the state
  65670. * @param currentTarget defines the current target of the state
  65671. * @returns the current event state
  65672. */
  65673. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65674. /**
  65675. * An Observer can set this property to true to prevent subsequent observers of being notified
  65676. */
  65677. skipNextObservers: boolean;
  65678. /**
  65679. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65680. */
  65681. mask: number;
  65682. /**
  65683. * The object that originally notified the event
  65684. */
  65685. target?: any;
  65686. /**
  65687. * The current object in the bubbling phase
  65688. */
  65689. currentTarget?: any;
  65690. /**
  65691. * This will be populated with the return value of the last function that was executed.
  65692. * If it is the first function in the callback chain it will be the event data.
  65693. */
  65694. lastReturnValue?: any;
  65695. }
  65696. /**
  65697. * Represent an Observer registered to a given Observable object.
  65698. */
  65699. export class Observer<T> {
  65700. /**
  65701. * Defines the callback to call when the observer is notified
  65702. */
  65703. callback: (eventData: T, eventState: EventState) => void;
  65704. /**
  65705. * Defines the mask of the observer (used to filter notifications)
  65706. */
  65707. mask: number;
  65708. /**
  65709. * Defines the current scope used to restore the JS context
  65710. */
  65711. scope: any;
  65712. /** @hidden */
  65713. _willBeUnregistered: boolean;
  65714. /**
  65715. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65716. */
  65717. unregisterOnNextCall: boolean;
  65718. /**
  65719. * Creates a new observer
  65720. * @param callback defines the callback to call when the observer is notified
  65721. * @param mask defines the mask of the observer (used to filter notifications)
  65722. * @param scope defines the current scope used to restore the JS context
  65723. */
  65724. constructor(
  65725. /**
  65726. * Defines the callback to call when the observer is notified
  65727. */
  65728. callback: (eventData: T, eventState: EventState) => void,
  65729. /**
  65730. * Defines the mask of the observer (used to filter notifications)
  65731. */
  65732. mask: number,
  65733. /**
  65734. * Defines the current scope used to restore the JS context
  65735. */
  65736. scope?: any);
  65737. }
  65738. /**
  65739. * Represent a list of observers registered to multiple Observables object.
  65740. */
  65741. export class MultiObserver<T> {
  65742. private _observers;
  65743. private _observables;
  65744. /**
  65745. * Release associated resources
  65746. */
  65747. dispose(): void;
  65748. /**
  65749. * Raise a callback when one of the observable will notify
  65750. * @param observables defines a list of observables to watch
  65751. * @param callback defines the callback to call on notification
  65752. * @param mask defines the mask used to filter notifications
  65753. * @param scope defines the current scope used to restore the JS context
  65754. * @returns the new MultiObserver
  65755. */
  65756. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65757. }
  65758. /**
  65759. * The Observable class is a simple implementation of the Observable pattern.
  65760. *
  65761. * 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.
  65762. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65763. * 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).
  65764. * 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.
  65765. */
  65766. export class Observable<T> {
  65767. private _observers;
  65768. private _eventState;
  65769. private _onObserverAdded;
  65770. /**
  65771. * Gets the list of observers
  65772. */
  65773. readonly observers: Array<Observer<T>>;
  65774. /**
  65775. * Creates a new observable
  65776. * @param onObserverAdded defines a callback to call when a new observer is added
  65777. */
  65778. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65779. /**
  65780. * Create a new Observer with the specified callback
  65781. * @param callback the callback that will be executed for that Observer
  65782. * @param mask the mask used to filter observers
  65783. * @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.
  65784. * @param scope optional scope for the callback to be called from
  65785. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65786. * @returns the new observer created for the callback
  65787. */
  65788. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65789. /**
  65790. * Create a new Observer with the specified callback and unregisters after the next notification
  65791. * @param callback the callback that will be executed for that Observer
  65792. * @returns the new observer created for the callback
  65793. */
  65794. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65795. /**
  65796. * Remove an Observer from the Observable object
  65797. * @param observer the instance of the Observer to remove
  65798. * @returns false if it doesn't belong to this Observable
  65799. */
  65800. remove(observer: Nullable<Observer<T>>): boolean;
  65801. /**
  65802. * Remove a callback from the Observable object
  65803. * @param callback the callback to remove
  65804. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65805. * @returns false if it doesn't belong to this Observable
  65806. */
  65807. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65808. private _deferUnregister;
  65809. private _remove;
  65810. /**
  65811. * Moves the observable to the top of the observer list making it get called first when notified
  65812. * @param observer the observer to move
  65813. */
  65814. makeObserverTopPriority(observer: Observer<T>): void;
  65815. /**
  65816. * Moves the observable to the bottom of the observer list making it get called last when notified
  65817. * @param observer the observer to move
  65818. */
  65819. makeObserverBottomPriority(observer: Observer<T>): void;
  65820. /**
  65821. * Notify all Observers by calling their respective callback with the given data
  65822. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  65823. * @param eventData defines the data to send to all observers
  65824. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  65825. * @param target defines the original target of the state
  65826. * @param currentTarget defines the current target of the state
  65827. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  65828. */
  65829. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  65830. /**
  65831. * Calling this will execute each callback, expecting it to be a promise or return a value.
  65832. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  65833. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  65834. * and it is crucial that all callbacks will be executed.
  65835. * The order of the callbacks is kept, callbacks are not executed parallel.
  65836. *
  65837. * @param eventData The data to be sent to each callback
  65838. * @param mask is used to filter observers defaults to -1
  65839. * @param target defines the callback target (see EventState)
  65840. * @param currentTarget defines he current object in the bubbling phase
  65841. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  65842. */
  65843. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  65844. /**
  65845. * Notify a specific observer
  65846. * @param observer defines the observer to notify
  65847. * @param eventData defines the data to be sent to each callback
  65848. * @param mask is used to filter observers defaults to -1
  65849. */
  65850. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  65851. /**
  65852. * Gets a boolean indicating if the observable has at least one observer
  65853. * @returns true is the Observable has at least one Observer registered
  65854. */
  65855. hasObservers(): boolean;
  65856. /**
  65857. * Clear the list of observers
  65858. */
  65859. clear(): void;
  65860. /**
  65861. * Clone the current observable
  65862. * @returns a new observable
  65863. */
  65864. clone(): Observable<T>;
  65865. /**
  65866. * Does this observable handles observer registered with a given mask
  65867. * @param mask defines the mask to be tested
  65868. * @return whether or not one observer registered with the given mask is handeled
  65869. **/
  65870. hasSpecificMask(mask?: number): boolean;
  65871. }
  65872. }
  65873. declare module BABYLON {
  65874. /**
  65875. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  65876. * Babylon.js
  65877. */
  65878. export class DomManagement {
  65879. /**
  65880. * Checks if the window object exists
  65881. * @returns true if the window object exists
  65882. */
  65883. static IsWindowObjectExist(): boolean;
  65884. /**
  65885. * Checks if the navigator object exists
  65886. * @returns true if the navigator object exists
  65887. */
  65888. static IsNavigatorAvailable(): boolean;
  65889. /**
  65890. * Extracts text content from a DOM element hierarchy
  65891. * @param element defines the root element
  65892. * @returns a string
  65893. */
  65894. static GetDOMTextContent(element: HTMLElement): string;
  65895. }
  65896. }
  65897. declare module BABYLON {
  65898. /**
  65899. * Logger used througouht the application to allow configuration of
  65900. * the log level required for the messages.
  65901. */
  65902. export class Logger {
  65903. /**
  65904. * No log
  65905. */
  65906. static readonly NoneLogLevel: number;
  65907. /**
  65908. * Only message logs
  65909. */
  65910. static readonly MessageLogLevel: number;
  65911. /**
  65912. * Only warning logs
  65913. */
  65914. static readonly WarningLogLevel: number;
  65915. /**
  65916. * Only error logs
  65917. */
  65918. static readonly ErrorLogLevel: number;
  65919. /**
  65920. * All logs
  65921. */
  65922. static readonly AllLogLevel: number;
  65923. private static _LogCache;
  65924. /**
  65925. * Gets a value indicating the number of loading errors
  65926. * @ignorenaming
  65927. */
  65928. static errorsCount: number;
  65929. /**
  65930. * Callback called when a new log is added
  65931. */
  65932. static OnNewCacheEntry: (entry: string) => void;
  65933. private static _AddLogEntry;
  65934. private static _FormatMessage;
  65935. private static _LogDisabled;
  65936. private static _LogEnabled;
  65937. private static _WarnDisabled;
  65938. private static _WarnEnabled;
  65939. private static _ErrorDisabled;
  65940. private static _ErrorEnabled;
  65941. /**
  65942. * Log a message to the console
  65943. */
  65944. static Log: (message: string) => void;
  65945. /**
  65946. * Write a warning message to the console
  65947. */
  65948. static Warn: (message: string) => void;
  65949. /**
  65950. * Write an error message to the console
  65951. */
  65952. static Error: (message: string) => void;
  65953. /**
  65954. * Gets current log cache (list of logs)
  65955. */
  65956. static readonly LogCache: string;
  65957. /**
  65958. * Clears the log cache
  65959. */
  65960. static ClearLogCache(): void;
  65961. /**
  65962. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  65963. */
  65964. static LogLevels: number;
  65965. }
  65966. }
  65967. declare module BABYLON {
  65968. /** @hidden */
  65969. export class _TypeStore {
  65970. /** @hidden */
  65971. static RegisteredTypes: {
  65972. [key: string]: Object;
  65973. };
  65974. /** @hidden */
  65975. static GetClass(fqdn: string): any;
  65976. }
  65977. }
  65978. declare module BABYLON {
  65979. /**
  65980. * Class containing a set of static utilities functions for deep copy.
  65981. */
  65982. export class DeepCopier {
  65983. /**
  65984. * Tries to copy an object by duplicating every property
  65985. * @param source defines the source object
  65986. * @param destination defines the target object
  65987. * @param doNotCopyList defines a list of properties to avoid
  65988. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  65989. */
  65990. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  65991. }
  65992. }
  65993. declare module BABYLON {
  65994. /**
  65995. * Class containing a set of static utilities functions for precision date
  65996. */
  65997. export class PrecisionDate {
  65998. /**
  65999. * Gets either window.performance.now() if supported or Date.now() else
  66000. */
  66001. static readonly Now: number;
  66002. }
  66003. }
  66004. declare module BABYLON {
  66005. /** @hidden */
  66006. export class _DevTools {
  66007. static WarnImport(name: string): string;
  66008. }
  66009. }
  66010. declare module BABYLON {
  66011. /**
  66012. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66013. */
  66014. export class WebRequest {
  66015. private _xhr;
  66016. /**
  66017. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66018. * i.e. when loading files, where the server/service expects an Authorization header
  66019. */
  66020. static CustomRequestHeaders: {
  66021. [key: string]: string;
  66022. };
  66023. /**
  66024. * Add callback functions in this array to update all the requests before they get sent to the network
  66025. */
  66026. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66027. private _injectCustomRequestHeaders;
  66028. /**
  66029. * Gets or sets a function to be called when loading progress changes
  66030. */
  66031. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66032. /**
  66033. * Returns client's state
  66034. */
  66035. readonly readyState: number;
  66036. /**
  66037. * Returns client's status
  66038. */
  66039. readonly status: number;
  66040. /**
  66041. * Returns client's status as a text
  66042. */
  66043. readonly statusText: string;
  66044. /**
  66045. * Returns client's response
  66046. */
  66047. readonly response: any;
  66048. /**
  66049. * Returns client's response url
  66050. */
  66051. readonly responseURL: string;
  66052. /**
  66053. * Returns client's response as text
  66054. */
  66055. readonly responseText: string;
  66056. /**
  66057. * Gets or sets the expected response type
  66058. */
  66059. responseType: XMLHttpRequestResponseType;
  66060. /** @hidden */
  66061. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66062. /** @hidden */
  66063. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66064. /**
  66065. * Cancels any network activity
  66066. */
  66067. abort(): void;
  66068. /**
  66069. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66070. * @param body defines an optional request body
  66071. */
  66072. send(body?: Document | BodyInit | null): void;
  66073. /**
  66074. * Sets the request method, request URL
  66075. * @param method defines the method to use (GET, POST, etc..)
  66076. * @param url defines the url to connect with
  66077. */
  66078. open(method: string, url: string): void;
  66079. }
  66080. }
  66081. declare module BABYLON {
  66082. /**
  66083. * File request interface
  66084. */
  66085. export interface IFileRequest {
  66086. /**
  66087. * Raised when the request is complete (success or error).
  66088. */
  66089. onCompleteObservable: Observable<IFileRequest>;
  66090. /**
  66091. * Aborts the request for a file.
  66092. */
  66093. abort: () => void;
  66094. }
  66095. }
  66096. declare module BABYLON {
  66097. /**
  66098. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66099. */
  66100. export class PerformanceMonitor {
  66101. private _enabled;
  66102. private _rollingFrameTime;
  66103. private _lastFrameTimeMs;
  66104. /**
  66105. * constructor
  66106. * @param frameSampleSize The number of samples required to saturate the sliding window
  66107. */
  66108. constructor(frameSampleSize?: number);
  66109. /**
  66110. * Samples current frame
  66111. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66112. */
  66113. sampleFrame(timeMs?: number): void;
  66114. /**
  66115. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66116. */
  66117. readonly averageFrameTime: number;
  66118. /**
  66119. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66120. */
  66121. readonly averageFrameTimeVariance: number;
  66122. /**
  66123. * Returns the frame time of the most recent frame
  66124. */
  66125. readonly instantaneousFrameTime: number;
  66126. /**
  66127. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66128. */
  66129. readonly averageFPS: number;
  66130. /**
  66131. * Returns the average framerate in frames per second using the most recent frame time
  66132. */
  66133. readonly instantaneousFPS: number;
  66134. /**
  66135. * Returns true if enough samples have been taken to completely fill the sliding window
  66136. */
  66137. readonly isSaturated: boolean;
  66138. /**
  66139. * Enables contributions to the sliding window sample set
  66140. */
  66141. enable(): void;
  66142. /**
  66143. * Disables contributions to the sliding window sample set
  66144. * Samples will not be interpolated over the disabled period
  66145. */
  66146. disable(): void;
  66147. /**
  66148. * Returns true if sampling is enabled
  66149. */
  66150. readonly isEnabled: boolean;
  66151. /**
  66152. * Resets performance monitor
  66153. */
  66154. reset(): void;
  66155. }
  66156. /**
  66157. * RollingAverage
  66158. *
  66159. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66160. */
  66161. export class RollingAverage {
  66162. /**
  66163. * Current average
  66164. */
  66165. average: number;
  66166. /**
  66167. * Current variance
  66168. */
  66169. variance: number;
  66170. protected _samples: Array<number>;
  66171. protected _sampleCount: number;
  66172. protected _pos: number;
  66173. protected _m2: number;
  66174. /**
  66175. * constructor
  66176. * @param length The number of samples required to saturate the sliding window
  66177. */
  66178. constructor(length: number);
  66179. /**
  66180. * Adds a sample to the sample set
  66181. * @param v The sample value
  66182. */
  66183. add(v: number): void;
  66184. /**
  66185. * Returns previously added values or null if outside of history or outside the sliding window domain
  66186. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66187. * @return Value previously recorded with add() or null if outside of range
  66188. */
  66189. history(i: number): number;
  66190. /**
  66191. * Returns true if enough samples have been taken to completely fill the sliding window
  66192. * @return true if sample-set saturated
  66193. */
  66194. isSaturated(): boolean;
  66195. /**
  66196. * Resets the rolling average (equivalent to 0 samples taken so far)
  66197. */
  66198. reset(): void;
  66199. /**
  66200. * Wraps a value around the sample range boundaries
  66201. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66202. * @return Wrapped position in sample range
  66203. */
  66204. protected _wrapPosition(i: number): number;
  66205. }
  66206. }
  66207. declare module BABYLON {
  66208. /**
  66209. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66210. * The underlying implementation relies on an associative array to ensure the best performances.
  66211. * The value can be anything including 'null' but except 'undefined'
  66212. */
  66213. export class StringDictionary<T> {
  66214. /**
  66215. * This will clear this dictionary and copy the content from the 'source' one.
  66216. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66217. * @param source the dictionary to take the content from and copy to this dictionary
  66218. */
  66219. copyFrom(source: StringDictionary<T>): void;
  66220. /**
  66221. * Get a value based from its key
  66222. * @param key the given key to get the matching value from
  66223. * @return the value if found, otherwise undefined is returned
  66224. */
  66225. get(key: string): T | undefined;
  66226. /**
  66227. * Get a value from its key or add it if it doesn't exist.
  66228. * This method will ensure you that a given key/data will be present in the dictionary.
  66229. * @param key the given key to get the matching value from
  66230. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66231. * The factory will only be invoked if there's no data for the given key.
  66232. * @return the value corresponding to the key.
  66233. */
  66234. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66235. /**
  66236. * Get a value from its key if present in the dictionary otherwise add it
  66237. * @param key the key to get the value from
  66238. * @param val if there's no such key/value pair in the dictionary add it with this value
  66239. * @return the value corresponding to the key
  66240. */
  66241. getOrAdd(key: string, val: T): T;
  66242. /**
  66243. * Check if there's a given key in the dictionary
  66244. * @param key the key to check for
  66245. * @return true if the key is present, false otherwise
  66246. */
  66247. contains(key: string): boolean;
  66248. /**
  66249. * Add a new key and its corresponding value
  66250. * @param key the key to add
  66251. * @param value the value corresponding to the key
  66252. * @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
  66253. */
  66254. add(key: string, value: T): boolean;
  66255. /**
  66256. * Update a specific value associated to a key
  66257. * @param key defines the key to use
  66258. * @param value defines the value to store
  66259. * @returns true if the value was updated (or false if the key was not found)
  66260. */
  66261. set(key: string, value: T): boolean;
  66262. /**
  66263. * Get the element of the given key and remove it from the dictionary
  66264. * @param key defines the key to search
  66265. * @returns the value associated with the key or null if not found
  66266. */
  66267. getAndRemove(key: string): Nullable<T>;
  66268. /**
  66269. * Remove a key/value from the dictionary.
  66270. * @param key the key to remove
  66271. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66272. */
  66273. remove(key: string): boolean;
  66274. /**
  66275. * Clear the whole content of the dictionary
  66276. */
  66277. clear(): void;
  66278. /**
  66279. * Gets the current count
  66280. */
  66281. readonly count: number;
  66282. /**
  66283. * Execute a callback on each key/val of the dictionary.
  66284. * Note that you can remove any element in this dictionary in the callback implementation
  66285. * @param callback the callback to execute on a given key/value pair
  66286. */
  66287. forEach(callback: (key: string, val: T) => void): void;
  66288. /**
  66289. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66290. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66291. * Note that you can remove any element in this dictionary in the callback implementation
  66292. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66293. * @returns the first item
  66294. */
  66295. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66296. private _count;
  66297. private _data;
  66298. }
  66299. }
  66300. declare module BABYLON {
  66301. /**
  66302. * Class used to store gfx data (like WebGLBuffer)
  66303. */
  66304. export class DataBuffer {
  66305. /**
  66306. * Gets or sets the number of objects referencing this buffer
  66307. */
  66308. references: number;
  66309. /** Gets or sets the size of the underlying buffer */
  66310. capacity: number;
  66311. /**
  66312. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66313. */
  66314. is32Bits: boolean;
  66315. /**
  66316. * Gets the underlying buffer
  66317. */
  66318. readonly underlyingResource: any;
  66319. }
  66320. }
  66321. declare module BABYLON {
  66322. /**
  66323. * Class used to store data that will be store in GPU memory
  66324. */
  66325. export class Buffer {
  66326. private _engine;
  66327. private _buffer;
  66328. /** @hidden */
  66329. _data: Nullable<DataArray>;
  66330. private _updatable;
  66331. private _instanced;
  66332. /**
  66333. * Gets the byte stride.
  66334. */
  66335. readonly byteStride: number;
  66336. /**
  66337. * Constructor
  66338. * @param engine the engine
  66339. * @param data the data to use for this buffer
  66340. * @param updatable whether the data is updatable
  66341. * @param stride the stride (optional)
  66342. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66343. * @param instanced whether the buffer is instanced (optional)
  66344. * @param useBytes set to true if the stride in in bytes (optional)
  66345. */
  66346. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66347. /**
  66348. * Create a new VertexBuffer based on the current buffer
  66349. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66350. * @param offset defines offset in the buffer (0 by default)
  66351. * @param size defines the size in floats of attributes (position is 3 for instance)
  66352. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66353. * @param instanced defines if the vertex buffer contains indexed data
  66354. * @param useBytes defines if the offset and stride are in bytes
  66355. * @returns the new vertex buffer
  66356. */
  66357. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66358. /**
  66359. * Gets a boolean indicating if the Buffer is updatable?
  66360. * @returns true if the buffer is updatable
  66361. */
  66362. isUpdatable(): boolean;
  66363. /**
  66364. * Gets current buffer's data
  66365. * @returns a DataArray or null
  66366. */
  66367. getData(): Nullable<DataArray>;
  66368. /**
  66369. * Gets underlying native buffer
  66370. * @returns underlying native buffer
  66371. */
  66372. getBuffer(): Nullable<DataBuffer>;
  66373. /**
  66374. * Gets the stride in float32 units (i.e. byte stride / 4).
  66375. * May not be an integer if the byte stride is not divisible by 4.
  66376. * DEPRECATED. Use byteStride instead.
  66377. * @returns the stride in float32 units
  66378. */
  66379. getStrideSize(): number;
  66380. /**
  66381. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66382. * @param data defines the data to store
  66383. */
  66384. create(data?: Nullable<DataArray>): void;
  66385. /** @hidden */
  66386. _rebuild(): void;
  66387. /**
  66388. * Update current buffer data
  66389. * @param data defines the data to store
  66390. */
  66391. update(data: DataArray): void;
  66392. /**
  66393. * Updates the data directly.
  66394. * @param data the new data
  66395. * @param offset the new offset
  66396. * @param vertexCount the vertex count (optional)
  66397. * @param useBytes set to true if the offset is in bytes
  66398. */
  66399. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66400. /**
  66401. * Release all resources
  66402. */
  66403. dispose(): void;
  66404. }
  66405. /**
  66406. * Specialized buffer used to store vertex data
  66407. */
  66408. export class VertexBuffer {
  66409. /** @hidden */
  66410. _buffer: Buffer;
  66411. private _kind;
  66412. private _size;
  66413. private _ownsBuffer;
  66414. private _instanced;
  66415. private _instanceDivisor;
  66416. /**
  66417. * The byte type.
  66418. */
  66419. static readonly BYTE: number;
  66420. /**
  66421. * The unsigned byte type.
  66422. */
  66423. static readonly UNSIGNED_BYTE: number;
  66424. /**
  66425. * The short type.
  66426. */
  66427. static readonly SHORT: number;
  66428. /**
  66429. * The unsigned short type.
  66430. */
  66431. static readonly UNSIGNED_SHORT: number;
  66432. /**
  66433. * The integer type.
  66434. */
  66435. static readonly INT: number;
  66436. /**
  66437. * The unsigned integer type.
  66438. */
  66439. static readonly UNSIGNED_INT: number;
  66440. /**
  66441. * The float type.
  66442. */
  66443. static readonly FLOAT: number;
  66444. /**
  66445. * Gets or sets the instance divisor when in instanced mode
  66446. */
  66447. instanceDivisor: number;
  66448. /**
  66449. * Gets the byte stride.
  66450. */
  66451. readonly byteStride: number;
  66452. /**
  66453. * Gets the byte offset.
  66454. */
  66455. readonly byteOffset: number;
  66456. /**
  66457. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66458. */
  66459. readonly normalized: boolean;
  66460. /**
  66461. * Gets the data type of each component in the array.
  66462. */
  66463. readonly type: number;
  66464. /**
  66465. * Constructor
  66466. * @param engine the engine
  66467. * @param data the data to use for this vertex buffer
  66468. * @param kind the vertex buffer kind
  66469. * @param updatable whether the data is updatable
  66470. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66471. * @param stride the stride (optional)
  66472. * @param instanced whether the buffer is instanced (optional)
  66473. * @param offset the offset of the data (optional)
  66474. * @param size the number of components (optional)
  66475. * @param type the type of the component (optional)
  66476. * @param normalized whether the data contains normalized data (optional)
  66477. * @param useBytes set to true if stride and offset are in bytes (optional)
  66478. */
  66479. 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);
  66480. /** @hidden */
  66481. _rebuild(): void;
  66482. /**
  66483. * Returns the kind of the VertexBuffer (string)
  66484. * @returns a string
  66485. */
  66486. getKind(): string;
  66487. /**
  66488. * Gets a boolean indicating if the VertexBuffer is updatable?
  66489. * @returns true if the buffer is updatable
  66490. */
  66491. isUpdatable(): boolean;
  66492. /**
  66493. * Gets current buffer's data
  66494. * @returns a DataArray or null
  66495. */
  66496. getData(): Nullable<DataArray>;
  66497. /**
  66498. * Gets underlying native buffer
  66499. * @returns underlying native buffer
  66500. */
  66501. getBuffer(): Nullable<DataBuffer>;
  66502. /**
  66503. * Gets the stride in float32 units (i.e. byte stride / 4).
  66504. * May not be an integer if the byte stride is not divisible by 4.
  66505. * DEPRECATED. Use byteStride instead.
  66506. * @returns the stride in float32 units
  66507. */
  66508. getStrideSize(): number;
  66509. /**
  66510. * Returns the offset as a multiple of the type byte length.
  66511. * DEPRECATED. Use byteOffset instead.
  66512. * @returns the offset in bytes
  66513. */
  66514. getOffset(): number;
  66515. /**
  66516. * Returns the number of components per vertex attribute (integer)
  66517. * @returns the size in float
  66518. */
  66519. getSize(): number;
  66520. /**
  66521. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66522. * @returns true if this buffer is instanced
  66523. */
  66524. getIsInstanced(): boolean;
  66525. /**
  66526. * Returns the instancing divisor, zero for non-instanced (integer).
  66527. * @returns a number
  66528. */
  66529. getInstanceDivisor(): number;
  66530. /**
  66531. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66532. * @param data defines the data to store
  66533. */
  66534. create(data?: DataArray): void;
  66535. /**
  66536. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66537. * This function will create a new buffer if the current one is not updatable
  66538. * @param data defines the data to store
  66539. */
  66540. update(data: DataArray): void;
  66541. /**
  66542. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66543. * Returns the directly updated WebGLBuffer.
  66544. * @param data the new data
  66545. * @param offset the new offset
  66546. * @param useBytes set to true if the offset is in bytes
  66547. */
  66548. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66549. /**
  66550. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66551. */
  66552. dispose(): void;
  66553. /**
  66554. * Enumerates each value of this vertex buffer as numbers.
  66555. * @param count the number of values to enumerate
  66556. * @param callback the callback function called for each value
  66557. */
  66558. forEach(count: number, callback: (value: number, index: number) => void): void;
  66559. /**
  66560. * Positions
  66561. */
  66562. static readonly PositionKind: string;
  66563. /**
  66564. * Normals
  66565. */
  66566. static readonly NormalKind: string;
  66567. /**
  66568. * Tangents
  66569. */
  66570. static readonly TangentKind: string;
  66571. /**
  66572. * Texture coordinates
  66573. */
  66574. static readonly UVKind: string;
  66575. /**
  66576. * Texture coordinates 2
  66577. */
  66578. static readonly UV2Kind: string;
  66579. /**
  66580. * Texture coordinates 3
  66581. */
  66582. static readonly UV3Kind: string;
  66583. /**
  66584. * Texture coordinates 4
  66585. */
  66586. static readonly UV4Kind: string;
  66587. /**
  66588. * Texture coordinates 5
  66589. */
  66590. static readonly UV5Kind: string;
  66591. /**
  66592. * Texture coordinates 6
  66593. */
  66594. static readonly UV6Kind: string;
  66595. /**
  66596. * Colors
  66597. */
  66598. static readonly ColorKind: string;
  66599. /**
  66600. * Matrix indices (for bones)
  66601. */
  66602. static readonly MatricesIndicesKind: string;
  66603. /**
  66604. * Matrix weights (for bones)
  66605. */
  66606. static readonly MatricesWeightsKind: string;
  66607. /**
  66608. * Additional matrix indices (for bones)
  66609. */
  66610. static readonly MatricesIndicesExtraKind: string;
  66611. /**
  66612. * Additional matrix weights (for bones)
  66613. */
  66614. static readonly MatricesWeightsExtraKind: string;
  66615. /**
  66616. * Deduces the stride given a kind.
  66617. * @param kind The kind string to deduce
  66618. * @returns The deduced stride
  66619. */
  66620. static DeduceStride(kind: string): number;
  66621. /**
  66622. * Gets the byte length of the given type.
  66623. * @param type the type
  66624. * @returns the number of bytes
  66625. */
  66626. static GetTypeByteLength(type: number): number;
  66627. /**
  66628. * Enumerates each value of the given parameters as numbers.
  66629. * @param data the data to enumerate
  66630. * @param byteOffset the byte offset of the data
  66631. * @param byteStride the byte stride of the data
  66632. * @param componentCount the number of components per element
  66633. * @param componentType the type of the component
  66634. * @param count the number of values to enumerate
  66635. * @param normalized whether the data is normalized
  66636. * @param callback the callback function called for each value
  66637. */
  66638. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66639. private static _GetFloatValue;
  66640. }
  66641. }
  66642. declare module BABYLON {
  66643. /**
  66644. * Scalar computation library
  66645. */
  66646. export class Scalar {
  66647. /**
  66648. * Two pi constants convenient for computation.
  66649. */
  66650. static TwoPi: number;
  66651. /**
  66652. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66653. * @param a number
  66654. * @param b number
  66655. * @param epsilon (default = 1.401298E-45)
  66656. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66657. */
  66658. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66659. /**
  66660. * Returns a string : the upper case translation of the number i to hexadecimal.
  66661. * @param i number
  66662. * @returns the upper case translation of the number i to hexadecimal.
  66663. */
  66664. static ToHex(i: number): string;
  66665. /**
  66666. * Returns -1 if value is negative and +1 is value is positive.
  66667. * @param value the value
  66668. * @returns the value itself if it's equal to zero.
  66669. */
  66670. static Sign(value: number): number;
  66671. /**
  66672. * Returns the value itself if it's between min and max.
  66673. * Returns min if the value is lower than min.
  66674. * Returns max if the value is greater than max.
  66675. * @param value the value to clmap
  66676. * @param min the min value to clamp to (default: 0)
  66677. * @param max the max value to clamp to (default: 1)
  66678. * @returns the clamped value
  66679. */
  66680. static Clamp(value: number, min?: number, max?: number): number;
  66681. /**
  66682. * the log2 of value.
  66683. * @param value the value to compute log2 of
  66684. * @returns the log2 of value.
  66685. */
  66686. static Log2(value: number): number;
  66687. /**
  66688. * Loops the value, so that it is never larger than length and never smaller than 0.
  66689. *
  66690. * This is similar to the modulo operator but it works with floating point numbers.
  66691. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66692. * With t = 5 and length = 2.5, the result would be 0.0.
  66693. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66694. * @param value the value
  66695. * @param length the length
  66696. * @returns the looped value
  66697. */
  66698. static Repeat(value: number, length: number): number;
  66699. /**
  66700. * Normalize the value between 0.0 and 1.0 using min and max values
  66701. * @param value value to normalize
  66702. * @param min max to normalize between
  66703. * @param max min to normalize between
  66704. * @returns the normalized value
  66705. */
  66706. static Normalize(value: number, min: number, max: number): number;
  66707. /**
  66708. * Denormalize the value from 0.0 and 1.0 using min and max values
  66709. * @param normalized value to denormalize
  66710. * @param min max to denormalize between
  66711. * @param max min to denormalize between
  66712. * @returns the denormalized value
  66713. */
  66714. static Denormalize(normalized: number, min: number, max: number): number;
  66715. /**
  66716. * Calculates the shortest difference between two given angles given in degrees.
  66717. * @param current current angle in degrees
  66718. * @param target target angle in degrees
  66719. * @returns the delta
  66720. */
  66721. static DeltaAngle(current: number, target: number): number;
  66722. /**
  66723. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66724. * @param tx value
  66725. * @param length length
  66726. * @returns The returned value will move back and forth between 0 and length
  66727. */
  66728. static PingPong(tx: number, length: number): number;
  66729. /**
  66730. * Interpolates between min and max with smoothing at the limits.
  66731. *
  66732. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66733. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66734. * @param from from
  66735. * @param to to
  66736. * @param tx value
  66737. * @returns the smooth stepped value
  66738. */
  66739. static SmoothStep(from: number, to: number, tx: number): number;
  66740. /**
  66741. * Moves a value current towards target.
  66742. *
  66743. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66744. * Negative values of maxDelta pushes the value away from target.
  66745. * @param current current value
  66746. * @param target target value
  66747. * @param maxDelta max distance to move
  66748. * @returns resulting value
  66749. */
  66750. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66751. /**
  66752. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66753. *
  66754. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66755. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66756. * @param current current value
  66757. * @param target target value
  66758. * @param maxDelta max distance to move
  66759. * @returns resulting angle
  66760. */
  66761. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66762. /**
  66763. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66764. * @param start start value
  66765. * @param end target value
  66766. * @param amount amount to lerp between
  66767. * @returns the lerped value
  66768. */
  66769. static Lerp(start: number, end: number, amount: number): number;
  66770. /**
  66771. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66772. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66773. * @param start start value
  66774. * @param end target value
  66775. * @param amount amount to lerp between
  66776. * @returns the lerped value
  66777. */
  66778. static LerpAngle(start: number, end: number, amount: number): number;
  66779. /**
  66780. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66781. * @param a start value
  66782. * @param b target value
  66783. * @param value value between a and b
  66784. * @returns the inverseLerp value
  66785. */
  66786. static InverseLerp(a: number, b: number, value: number): number;
  66787. /**
  66788. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66789. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66790. * @param value1 spline value
  66791. * @param tangent1 spline value
  66792. * @param value2 spline value
  66793. * @param tangent2 spline value
  66794. * @param amount input value
  66795. * @returns hermite result
  66796. */
  66797. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66798. /**
  66799. * Returns a random float number between and min and max values
  66800. * @param min min value of random
  66801. * @param max max value of random
  66802. * @returns random value
  66803. */
  66804. static RandomRange(min: number, max: number): number;
  66805. /**
  66806. * This function returns percentage of a number in a given range.
  66807. *
  66808. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66809. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66810. * @param number to convert to percentage
  66811. * @param min min range
  66812. * @param max max range
  66813. * @returns the percentage
  66814. */
  66815. static RangeToPercent(number: number, min: number, max: number): number;
  66816. /**
  66817. * This function returns number that corresponds to the percentage in a given range.
  66818. *
  66819. * PercentToRange(0.34,0,100) will return 34.
  66820. * @param percent to convert to number
  66821. * @param min min range
  66822. * @param max max range
  66823. * @returns the number
  66824. */
  66825. static PercentToRange(percent: number, min: number, max: number): number;
  66826. /**
  66827. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66828. * @param angle The angle to normalize in radian.
  66829. * @return The converted angle.
  66830. */
  66831. static NormalizeRadians(angle: number): number;
  66832. }
  66833. }
  66834. declare module BABYLON {
  66835. /**
  66836. * Constant used to convert a value to gamma space
  66837. * @ignorenaming
  66838. */
  66839. export const ToGammaSpace: number;
  66840. /**
  66841. * Constant used to convert a value to linear space
  66842. * @ignorenaming
  66843. */
  66844. export const ToLinearSpace = 2.2;
  66845. /**
  66846. * Constant used to define the minimal number value in Babylon.js
  66847. * @ignorenaming
  66848. */
  66849. let Epsilon: number;
  66850. }
  66851. declare module BABYLON {
  66852. /**
  66853. * Class used to represent a viewport on screen
  66854. */
  66855. export class Viewport {
  66856. /** viewport left coordinate */
  66857. x: number;
  66858. /** viewport top coordinate */
  66859. y: number;
  66860. /**viewport width */
  66861. width: number;
  66862. /** viewport height */
  66863. height: number;
  66864. /**
  66865. * Creates a Viewport object located at (x, y) and sized (width, height)
  66866. * @param x defines viewport left coordinate
  66867. * @param y defines viewport top coordinate
  66868. * @param width defines the viewport width
  66869. * @param height defines the viewport height
  66870. */
  66871. constructor(
  66872. /** viewport left coordinate */
  66873. x: number,
  66874. /** viewport top coordinate */
  66875. y: number,
  66876. /**viewport width */
  66877. width: number,
  66878. /** viewport height */
  66879. height: number);
  66880. /**
  66881. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66882. * @param renderWidth defines the rendering width
  66883. * @param renderHeight defines the rendering height
  66884. * @returns a new Viewport
  66885. */
  66886. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66887. /**
  66888. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66889. * @param renderWidth defines the rendering width
  66890. * @param renderHeight defines the rendering height
  66891. * @param ref defines the target viewport
  66892. * @returns the current viewport
  66893. */
  66894. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66895. /**
  66896. * Returns a new Viewport copied from the current one
  66897. * @returns a new Viewport
  66898. */
  66899. clone(): Viewport;
  66900. }
  66901. }
  66902. declare module BABYLON {
  66903. /**
  66904. * Class containing a set of static utilities functions for arrays.
  66905. */
  66906. export class ArrayTools {
  66907. /**
  66908. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66909. * @param size the number of element to construct and put in the array
  66910. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66911. * @returns a new array filled with new objects
  66912. */
  66913. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66914. }
  66915. }
  66916. declare module BABYLON {
  66917. /**
  66918. * @hidden
  66919. */
  66920. export interface IColor4Like {
  66921. r: float;
  66922. g: float;
  66923. b: float;
  66924. a: float;
  66925. }
  66926. /**
  66927. * @hidden
  66928. */
  66929. export interface IColor3Like {
  66930. r: float;
  66931. g: float;
  66932. b: float;
  66933. }
  66934. /**
  66935. * @hidden
  66936. */
  66937. export interface IVector4Like {
  66938. x: float;
  66939. y: float;
  66940. z: float;
  66941. w: float;
  66942. }
  66943. /**
  66944. * @hidden
  66945. */
  66946. export interface IVector3Like {
  66947. x: float;
  66948. y: float;
  66949. z: float;
  66950. }
  66951. /**
  66952. * @hidden
  66953. */
  66954. export interface IVector2Like {
  66955. x: float;
  66956. y: float;
  66957. }
  66958. /**
  66959. * @hidden
  66960. */
  66961. export interface IMatrixLike {
  66962. toArray(): DeepImmutable<Float32Array>;
  66963. updateFlag: int;
  66964. }
  66965. /**
  66966. * @hidden
  66967. */
  66968. export interface IViewportLike {
  66969. x: float;
  66970. y: float;
  66971. width: float;
  66972. height: float;
  66973. }
  66974. /**
  66975. * @hidden
  66976. */
  66977. export interface IPlaneLike {
  66978. normal: IVector3Like;
  66979. d: float;
  66980. normalize(): void;
  66981. }
  66982. }
  66983. declare module BABYLON {
  66984. /**
  66985. * Class representing a vector containing 2 coordinates
  66986. */
  66987. export class Vector2 {
  66988. /** defines the first coordinate */
  66989. x: number;
  66990. /** defines the second coordinate */
  66991. y: number;
  66992. /**
  66993. * Creates a new Vector2 from the given x and y coordinates
  66994. * @param x defines the first coordinate
  66995. * @param y defines the second coordinate
  66996. */
  66997. constructor(
  66998. /** defines the first coordinate */
  66999. x?: number,
  67000. /** defines the second coordinate */
  67001. y?: number);
  67002. /**
  67003. * Gets a string with the Vector2 coordinates
  67004. * @returns a string with the Vector2 coordinates
  67005. */
  67006. toString(): string;
  67007. /**
  67008. * Gets class name
  67009. * @returns the string "Vector2"
  67010. */
  67011. getClassName(): string;
  67012. /**
  67013. * Gets current vector hash code
  67014. * @returns the Vector2 hash code as a number
  67015. */
  67016. getHashCode(): number;
  67017. /**
  67018. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67019. * @param array defines the source array
  67020. * @param index defines the offset in source array
  67021. * @returns the current Vector2
  67022. */
  67023. toArray(array: FloatArray, index?: number): Vector2;
  67024. /**
  67025. * Copy the current vector to an array
  67026. * @returns a new array with 2 elements: the Vector2 coordinates.
  67027. */
  67028. asArray(): number[];
  67029. /**
  67030. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67031. * @param source defines the source Vector2
  67032. * @returns the current updated Vector2
  67033. */
  67034. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67035. /**
  67036. * Sets the Vector2 coordinates with the given floats
  67037. * @param x defines the first coordinate
  67038. * @param y defines the second coordinate
  67039. * @returns the current updated Vector2
  67040. */
  67041. copyFromFloats(x: number, y: number): Vector2;
  67042. /**
  67043. * Sets the Vector2 coordinates with the given floats
  67044. * @param x defines the first coordinate
  67045. * @param y defines the second coordinate
  67046. * @returns the current updated Vector2
  67047. */
  67048. set(x: number, y: number): Vector2;
  67049. /**
  67050. * Add another vector with the current one
  67051. * @param otherVector defines the other vector
  67052. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67053. */
  67054. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67055. /**
  67056. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67057. * @param otherVector defines the other vector
  67058. * @param result defines the target vector
  67059. * @returns the unmodified current Vector2
  67060. */
  67061. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67062. /**
  67063. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67064. * @param otherVector defines the other vector
  67065. * @returns the current updated Vector2
  67066. */
  67067. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67068. /**
  67069. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67070. * @param otherVector defines the other vector
  67071. * @returns a new Vector2
  67072. */
  67073. addVector3(otherVector: Vector3): Vector2;
  67074. /**
  67075. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67076. * @param otherVector defines the other vector
  67077. * @returns a new Vector2
  67078. */
  67079. subtract(otherVector: Vector2): Vector2;
  67080. /**
  67081. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67082. * @param otherVector defines the other vector
  67083. * @param result defines the target vector
  67084. * @returns the unmodified current Vector2
  67085. */
  67086. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67087. /**
  67088. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67089. * @param otherVector defines the other vector
  67090. * @returns the current updated Vector2
  67091. */
  67092. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67093. /**
  67094. * Multiplies in place the current Vector2 coordinates by the given ones
  67095. * @param otherVector defines the other vector
  67096. * @returns the current updated Vector2
  67097. */
  67098. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67099. /**
  67100. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67101. * @param otherVector defines the other vector
  67102. * @returns a new Vector2
  67103. */
  67104. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67105. /**
  67106. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67107. * @param otherVector defines the other vector
  67108. * @param result defines the target vector
  67109. * @returns the unmodified current Vector2
  67110. */
  67111. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67112. /**
  67113. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67114. * @param x defines the first coordinate
  67115. * @param y defines the second coordinate
  67116. * @returns a new Vector2
  67117. */
  67118. multiplyByFloats(x: number, y: number): Vector2;
  67119. /**
  67120. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67121. * @param otherVector defines the other vector
  67122. * @returns a new Vector2
  67123. */
  67124. divide(otherVector: Vector2): Vector2;
  67125. /**
  67126. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67127. * @param otherVector defines the other vector
  67128. * @param result defines the target vector
  67129. * @returns the unmodified current Vector2
  67130. */
  67131. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67132. /**
  67133. * Divides the current Vector2 coordinates by the given ones
  67134. * @param otherVector defines the other vector
  67135. * @returns the current updated Vector2
  67136. */
  67137. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67138. /**
  67139. * Gets a new Vector2 with current Vector2 negated coordinates
  67140. * @returns a new Vector2
  67141. */
  67142. negate(): Vector2;
  67143. /**
  67144. * Multiply the Vector2 coordinates by scale
  67145. * @param scale defines the scaling factor
  67146. * @returns the current updated Vector2
  67147. */
  67148. scaleInPlace(scale: number): Vector2;
  67149. /**
  67150. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67151. * @param scale defines the scaling factor
  67152. * @returns a new Vector2
  67153. */
  67154. scale(scale: number): Vector2;
  67155. /**
  67156. * Scale the current Vector2 values by a factor to a given Vector2
  67157. * @param scale defines the scale factor
  67158. * @param result defines the Vector2 object where to store the result
  67159. * @returns the unmodified current Vector2
  67160. */
  67161. scaleToRef(scale: number, result: Vector2): Vector2;
  67162. /**
  67163. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67164. * @param scale defines the scale factor
  67165. * @param result defines the Vector2 object where to store the result
  67166. * @returns the unmodified current Vector2
  67167. */
  67168. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67169. /**
  67170. * Gets a boolean if two vectors are equals
  67171. * @param otherVector defines the other vector
  67172. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67173. */
  67174. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67175. /**
  67176. * Gets a boolean if two vectors are equals (using an epsilon value)
  67177. * @param otherVector defines the other vector
  67178. * @param epsilon defines the minimal distance to consider equality
  67179. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67180. */
  67181. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67182. /**
  67183. * Gets a new Vector2 from current Vector2 floored values
  67184. * @returns a new Vector2
  67185. */
  67186. floor(): Vector2;
  67187. /**
  67188. * Gets a new Vector2 from current Vector2 floored values
  67189. * @returns a new Vector2
  67190. */
  67191. fract(): Vector2;
  67192. /**
  67193. * Gets the length of the vector
  67194. * @returns the vector length (float)
  67195. */
  67196. length(): number;
  67197. /**
  67198. * Gets the vector squared length
  67199. * @returns the vector squared length (float)
  67200. */
  67201. lengthSquared(): number;
  67202. /**
  67203. * Normalize the vector
  67204. * @returns the current updated Vector2
  67205. */
  67206. normalize(): Vector2;
  67207. /**
  67208. * Gets a new Vector2 copied from the Vector2
  67209. * @returns a new Vector2
  67210. */
  67211. clone(): Vector2;
  67212. /**
  67213. * Gets a new Vector2(0, 0)
  67214. * @returns a new Vector2
  67215. */
  67216. static Zero(): Vector2;
  67217. /**
  67218. * Gets a new Vector2(1, 1)
  67219. * @returns a new Vector2
  67220. */
  67221. static One(): Vector2;
  67222. /**
  67223. * Gets a new Vector2 set from the given index element of the given array
  67224. * @param array defines the data source
  67225. * @param offset defines the offset in the data source
  67226. * @returns a new Vector2
  67227. */
  67228. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67229. /**
  67230. * Sets "result" from the given index element of the given array
  67231. * @param array defines the data source
  67232. * @param offset defines the offset in the data source
  67233. * @param result defines the target vector
  67234. */
  67235. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67236. /**
  67237. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67238. * @param value1 defines 1st point of control
  67239. * @param value2 defines 2nd point of control
  67240. * @param value3 defines 3rd point of control
  67241. * @param value4 defines 4th point of control
  67242. * @param amount defines the interpolation factor
  67243. * @returns a new Vector2
  67244. */
  67245. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67246. /**
  67247. * 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".
  67248. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67249. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67250. * @param value defines the value to clamp
  67251. * @param min defines the lower limit
  67252. * @param max defines the upper limit
  67253. * @returns a new Vector2
  67254. */
  67255. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67256. /**
  67257. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67258. * @param value1 defines the 1st control point
  67259. * @param tangent1 defines the outgoing tangent
  67260. * @param value2 defines the 2nd control point
  67261. * @param tangent2 defines the incoming tangent
  67262. * @param amount defines the interpolation factor
  67263. * @returns a new Vector2
  67264. */
  67265. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67266. /**
  67267. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67268. * @param start defines the start vector
  67269. * @param end defines the end vector
  67270. * @param amount defines the interpolation factor
  67271. * @returns a new Vector2
  67272. */
  67273. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67274. /**
  67275. * Gets the dot product of the vector "left" and the vector "right"
  67276. * @param left defines first vector
  67277. * @param right defines second vector
  67278. * @returns the dot product (float)
  67279. */
  67280. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67281. /**
  67282. * Returns a new Vector2 equal to the normalized given vector
  67283. * @param vector defines the vector to normalize
  67284. * @returns a new Vector2
  67285. */
  67286. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67287. /**
  67288. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67289. * @param left defines 1st vector
  67290. * @param right defines 2nd vector
  67291. * @returns a new Vector2
  67292. */
  67293. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67294. /**
  67295. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67296. * @param left defines 1st vector
  67297. * @param right defines 2nd vector
  67298. * @returns a new Vector2
  67299. */
  67300. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67301. /**
  67302. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67303. * @param vector defines the vector to transform
  67304. * @param transformation defines the matrix to apply
  67305. * @returns a new Vector2
  67306. */
  67307. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67308. /**
  67309. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67310. * @param vector defines the vector to transform
  67311. * @param transformation defines the matrix to apply
  67312. * @param result defines the target vector
  67313. */
  67314. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67315. /**
  67316. * Determines if a given vector is included in a triangle
  67317. * @param p defines the vector to test
  67318. * @param p0 defines 1st triangle point
  67319. * @param p1 defines 2nd triangle point
  67320. * @param p2 defines 3rd triangle point
  67321. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67322. */
  67323. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67324. /**
  67325. * Gets the distance between the vectors "value1" and "value2"
  67326. * @param value1 defines first vector
  67327. * @param value2 defines second vector
  67328. * @returns the distance between vectors
  67329. */
  67330. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67331. /**
  67332. * Returns the squared distance between the vectors "value1" and "value2"
  67333. * @param value1 defines first vector
  67334. * @param value2 defines second vector
  67335. * @returns the squared distance between vectors
  67336. */
  67337. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67338. /**
  67339. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67340. * @param value1 defines first vector
  67341. * @param value2 defines second vector
  67342. * @returns a new Vector2
  67343. */
  67344. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67345. /**
  67346. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67347. * @param p defines the middle point
  67348. * @param segA defines one point of the segment
  67349. * @param segB defines the other point of the segment
  67350. * @returns the shortest distance
  67351. */
  67352. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67353. }
  67354. /**
  67355. * Classed used to store (x,y,z) vector representation
  67356. * A Vector3 is the main object used in 3D geometry
  67357. * It can represent etiher the coordinates of a point the space, either a direction
  67358. * Reminder: js uses a left handed forward facing system
  67359. */
  67360. export class Vector3 {
  67361. /**
  67362. * Defines the first coordinates (on X axis)
  67363. */
  67364. x: number;
  67365. /**
  67366. * Defines the second coordinates (on Y axis)
  67367. */
  67368. y: number;
  67369. /**
  67370. * Defines the third coordinates (on Z axis)
  67371. */
  67372. z: number;
  67373. private static _UpReadOnly;
  67374. private static _ZeroReadOnly;
  67375. /**
  67376. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67377. * @param x defines the first coordinates (on X axis)
  67378. * @param y defines the second coordinates (on Y axis)
  67379. * @param z defines the third coordinates (on Z axis)
  67380. */
  67381. constructor(
  67382. /**
  67383. * Defines the first coordinates (on X axis)
  67384. */
  67385. x?: number,
  67386. /**
  67387. * Defines the second coordinates (on Y axis)
  67388. */
  67389. y?: number,
  67390. /**
  67391. * Defines the third coordinates (on Z axis)
  67392. */
  67393. z?: number);
  67394. /**
  67395. * Creates a string representation of the Vector3
  67396. * @returns a string with the Vector3 coordinates.
  67397. */
  67398. toString(): string;
  67399. /**
  67400. * Gets the class name
  67401. * @returns the string "Vector3"
  67402. */
  67403. getClassName(): string;
  67404. /**
  67405. * Creates the Vector3 hash code
  67406. * @returns a number which tends to be unique between Vector3 instances
  67407. */
  67408. getHashCode(): number;
  67409. /**
  67410. * Creates an array containing three elements : the coordinates of the Vector3
  67411. * @returns a new array of numbers
  67412. */
  67413. asArray(): number[];
  67414. /**
  67415. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67416. * @param array defines the destination array
  67417. * @param index defines the offset in the destination array
  67418. * @returns the current Vector3
  67419. */
  67420. toArray(array: FloatArray, index?: number): Vector3;
  67421. /**
  67422. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67423. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67424. */
  67425. toQuaternion(): Quaternion;
  67426. /**
  67427. * Adds the given vector to the current Vector3
  67428. * @param otherVector defines the second operand
  67429. * @returns the current updated Vector3
  67430. */
  67431. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67432. /**
  67433. * Adds the given coordinates to the current Vector3
  67434. * @param x defines the x coordinate of the operand
  67435. * @param y defines the y coordinate of the operand
  67436. * @param z defines the z coordinate of the operand
  67437. * @returns the current updated Vector3
  67438. */
  67439. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67440. /**
  67441. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67442. * @param otherVector defines the second operand
  67443. * @returns the resulting Vector3
  67444. */
  67445. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67446. /**
  67447. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67448. * @param otherVector defines the second operand
  67449. * @param result defines the Vector3 object where to store the result
  67450. * @returns the current Vector3
  67451. */
  67452. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67453. /**
  67454. * Subtract the given vector from the current Vector3
  67455. * @param otherVector defines the second operand
  67456. * @returns the current updated Vector3
  67457. */
  67458. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67459. /**
  67460. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67461. * @param otherVector defines the second operand
  67462. * @returns the resulting Vector3
  67463. */
  67464. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67465. /**
  67466. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67467. * @param otherVector defines the second operand
  67468. * @param result defines the Vector3 object where to store the result
  67469. * @returns the current Vector3
  67470. */
  67471. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67472. /**
  67473. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67474. * @param x defines the x coordinate of the operand
  67475. * @param y defines the y coordinate of the operand
  67476. * @param z defines the z coordinate of the operand
  67477. * @returns the resulting Vector3
  67478. */
  67479. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67480. /**
  67481. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67482. * @param x defines the x coordinate of the operand
  67483. * @param y defines the y coordinate of the operand
  67484. * @param z defines the z coordinate of the operand
  67485. * @param result defines the Vector3 object where to store the result
  67486. * @returns the current Vector3
  67487. */
  67488. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67489. /**
  67490. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67491. * @returns a new Vector3
  67492. */
  67493. negate(): Vector3;
  67494. /**
  67495. * Multiplies the Vector3 coordinates by the float "scale"
  67496. * @param scale defines the multiplier factor
  67497. * @returns the current updated Vector3
  67498. */
  67499. scaleInPlace(scale: number): Vector3;
  67500. /**
  67501. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67502. * @param scale defines the multiplier factor
  67503. * @returns a new Vector3
  67504. */
  67505. scale(scale: number): Vector3;
  67506. /**
  67507. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67508. * @param scale defines the multiplier factor
  67509. * @param result defines the Vector3 object where to store the result
  67510. * @returns the current Vector3
  67511. */
  67512. scaleToRef(scale: number, result: Vector3): Vector3;
  67513. /**
  67514. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67515. * @param scale defines the scale factor
  67516. * @param result defines the Vector3 object where to store the result
  67517. * @returns the unmodified current Vector3
  67518. */
  67519. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67520. /**
  67521. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67522. * @param otherVector defines the second operand
  67523. * @returns true if both vectors are equals
  67524. */
  67525. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67526. /**
  67527. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67528. * @param otherVector defines the second operand
  67529. * @param epsilon defines the minimal distance to define values as equals
  67530. * @returns true if both vectors are distant less than epsilon
  67531. */
  67532. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67533. /**
  67534. * Returns true if the current Vector3 coordinates equals the given floats
  67535. * @param x defines the x coordinate of the operand
  67536. * @param y defines the y coordinate of the operand
  67537. * @param z defines the z coordinate of the operand
  67538. * @returns true if both vectors are equals
  67539. */
  67540. equalsToFloats(x: number, y: number, z: number): boolean;
  67541. /**
  67542. * Multiplies the current Vector3 coordinates by the given ones
  67543. * @param otherVector defines the second operand
  67544. * @returns the current updated Vector3
  67545. */
  67546. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67547. /**
  67548. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67549. * @param otherVector defines the second operand
  67550. * @returns the new Vector3
  67551. */
  67552. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67553. /**
  67554. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67555. * @param otherVector defines the second operand
  67556. * @param result defines the Vector3 object where to store the result
  67557. * @returns the current Vector3
  67558. */
  67559. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67560. /**
  67561. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67562. * @param x defines the x coordinate of the operand
  67563. * @param y defines the y coordinate of the operand
  67564. * @param z defines the z coordinate of the operand
  67565. * @returns the new Vector3
  67566. */
  67567. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67568. /**
  67569. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67570. * @param otherVector defines the second operand
  67571. * @returns the new Vector3
  67572. */
  67573. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67574. /**
  67575. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67576. * @param otherVector defines the second operand
  67577. * @param result defines the Vector3 object where to store the result
  67578. * @returns the current Vector3
  67579. */
  67580. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67581. /**
  67582. * Divides the current Vector3 coordinates by the given ones.
  67583. * @param otherVector defines the second operand
  67584. * @returns the current updated Vector3
  67585. */
  67586. divideInPlace(otherVector: Vector3): Vector3;
  67587. /**
  67588. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67589. * @param other defines the second operand
  67590. * @returns the current updated Vector3
  67591. */
  67592. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67593. /**
  67594. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67595. * @param other defines the second operand
  67596. * @returns the current updated Vector3
  67597. */
  67598. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67599. /**
  67600. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67601. * @param x defines the x coordinate of the operand
  67602. * @param y defines the y coordinate of the operand
  67603. * @param z defines the z coordinate of the operand
  67604. * @returns the current updated Vector3
  67605. */
  67606. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67607. /**
  67608. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67609. * @param x defines the x coordinate of the operand
  67610. * @param y defines the y coordinate of the operand
  67611. * @param z defines the z coordinate of the operand
  67612. * @returns the current updated Vector3
  67613. */
  67614. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67615. /**
  67616. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67617. * Check if is non uniform within a certain amount of decimal places to account for this
  67618. * @param epsilon the amount the values can differ
  67619. * @returns if the the vector is non uniform to a certain number of decimal places
  67620. */
  67621. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67622. /**
  67623. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67624. */
  67625. readonly isNonUniform: boolean;
  67626. /**
  67627. * Gets a new Vector3 from current Vector3 floored values
  67628. * @returns a new Vector3
  67629. */
  67630. floor(): Vector3;
  67631. /**
  67632. * Gets a new Vector3 from current Vector3 floored values
  67633. * @returns a new Vector3
  67634. */
  67635. fract(): Vector3;
  67636. /**
  67637. * Gets the length of the Vector3
  67638. * @returns the length of the Vector3
  67639. */
  67640. length(): number;
  67641. /**
  67642. * Gets the squared length of the Vector3
  67643. * @returns squared length of the Vector3
  67644. */
  67645. lengthSquared(): number;
  67646. /**
  67647. * Normalize the current Vector3.
  67648. * Please note that this is an in place operation.
  67649. * @returns the current updated Vector3
  67650. */
  67651. normalize(): Vector3;
  67652. /**
  67653. * Reorders the x y z properties of the vector in place
  67654. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67655. * @returns the current updated vector
  67656. */
  67657. reorderInPlace(order: string): this;
  67658. /**
  67659. * Rotates the vector around 0,0,0 by a quaternion
  67660. * @param quaternion the rotation quaternion
  67661. * @param result vector to store the result
  67662. * @returns the resulting vector
  67663. */
  67664. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67665. /**
  67666. * Rotates a vector around a given point
  67667. * @param quaternion the rotation quaternion
  67668. * @param point the point to rotate around
  67669. * @param result vector to store the result
  67670. * @returns the resulting vector
  67671. */
  67672. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67673. /**
  67674. * Normalize the current Vector3 with the given input length.
  67675. * Please note that this is an in place operation.
  67676. * @param len the length of the vector
  67677. * @returns the current updated Vector3
  67678. */
  67679. normalizeFromLength(len: number): Vector3;
  67680. /**
  67681. * Normalize the current Vector3 to a new vector
  67682. * @returns the new Vector3
  67683. */
  67684. normalizeToNew(): Vector3;
  67685. /**
  67686. * Normalize the current Vector3 to the reference
  67687. * @param reference define the Vector3 to update
  67688. * @returns the updated Vector3
  67689. */
  67690. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67691. /**
  67692. * Creates a new Vector3 copied from the current Vector3
  67693. * @returns the new Vector3
  67694. */
  67695. clone(): Vector3;
  67696. /**
  67697. * Copies the given vector coordinates to the current Vector3 ones
  67698. * @param source defines the source Vector3
  67699. * @returns the current updated Vector3
  67700. */
  67701. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67702. /**
  67703. * Copies the given floats to the current Vector3 coordinates
  67704. * @param x defines the x coordinate of the operand
  67705. * @param y defines the y coordinate of the operand
  67706. * @param z defines the z coordinate of the operand
  67707. * @returns the current updated Vector3
  67708. */
  67709. copyFromFloats(x: number, y: number, z: number): Vector3;
  67710. /**
  67711. * Copies the given floats to the current Vector3 coordinates
  67712. * @param x defines the x coordinate of the operand
  67713. * @param y defines the y coordinate of the operand
  67714. * @param z defines the z coordinate of the operand
  67715. * @returns the current updated Vector3
  67716. */
  67717. set(x: number, y: number, z: number): Vector3;
  67718. /**
  67719. * Copies the given float to the current Vector3 coordinates
  67720. * @param v defines the x, y and z coordinates of the operand
  67721. * @returns the current updated Vector3
  67722. */
  67723. setAll(v: number): Vector3;
  67724. /**
  67725. * Get the clip factor between two vectors
  67726. * @param vector0 defines the first operand
  67727. * @param vector1 defines the second operand
  67728. * @param axis defines the axis to use
  67729. * @param size defines the size along the axis
  67730. * @returns the clip factor
  67731. */
  67732. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67733. /**
  67734. * Get angle between two vectors
  67735. * @param vector0 angle between vector0 and vector1
  67736. * @param vector1 angle between vector0 and vector1
  67737. * @param normal direction of the normal
  67738. * @return the angle between vector0 and vector1
  67739. */
  67740. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67741. /**
  67742. * Returns a new Vector3 set from the index "offset" of the given array
  67743. * @param array defines the source array
  67744. * @param offset defines the offset in the source array
  67745. * @returns the new Vector3
  67746. */
  67747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67748. /**
  67749. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67750. * This function is deprecated. Use FromArray instead
  67751. * @param array defines the source array
  67752. * @param offset defines the offset in the source array
  67753. * @returns the new Vector3
  67754. */
  67755. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67756. /**
  67757. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67758. * @param array defines the source array
  67759. * @param offset defines the offset in the source array
  67760. * @param result defines the Vector3 where to store the result
  67761. */
  67762. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67763. /**
  67764. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67765. * This function is deprecated. Use FromArrayToRef instead.
  67766. * @param array defines the source array
  67767. * @param offset defines the offset in the source array
  67768. * @param result defines the Vector3 where to store the result
  67769. */
  67770. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67771. /**
  67772. * Sets the given vector "result" with the given floats.
  67773. * @param x defines the x coordinate of the source
  67774. * @param y defines the y coordinate of the source
  67775. * @param z defines the z coordinate of the source
  67776. * @param result defines the Vector3 where to store the result
  67777. */
  67778. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67779. /**
  67780. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67781. * @returns a new empty Vector3
  67782. */
  67783. static Zero(): Vector3;
  67784. /**
  67785. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67786. * @returns a new unit Vector3
  67787. */
  67788. static One(): Vector3;
  67789. /**
  67790. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67791. * @returns a new up Vector3
  67792. */
  67793. static Up(): Vector3;
  67794. /**
  67795. * Gets a up Vector3 that must not be updated
  67796. */
  67797. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67798. /**
  67799. * Gets a zero Vector3 that must not be updated
  67800. */
  67801. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67802. /**
  67803. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67804. * @returns a new down Vector3
  67805. */
  67806. static Down(): Vector3;
  67807. /**
  67808. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67809. * @returns a new forward Vector3
  67810. */
  67811. static Forward(): Vector3;
  67812. /**
  67813. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67814. * @returns a new forward Vector3
  67815. */
  67816. static Backward(): Vector3;
  67817. /**
  67818. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67819. * @returns a new right Vector3
  67820. */
  67821. static Right(): Vector3;
  67822. /**
  67823. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67824. * @returns a new left Vector3
  67825. */
  67826. static Left(): Vector3;
  67827. /**
  67828. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67829. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67830. * @param vector defines the Vector3 to transform
  67831. * @param transformation defines the transformation matrix
  67832. * @returns the transformed Vector3
  67833. */
  67834. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67835. /**
  67836. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67837. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67838. * @param vector defines the Vector3 to transform
  67839. * @param transformation defines the transformation matrix
  67840. * @param result defines the Vector3 where to store the result
  67841. */
  67842. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67843. /**
  67844. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67845. * This method computes tranformed coordinates only, not transformed direction vectors
  67846. * @param x define the x coordinate of the source vector
  67847. * @param y define the y coordinate of the source vector
  67848. * @param z define the z coordinate of the source vector
  67849. * @param transformation defines the transformation matrix
  67850. * @param result defines the Vector3 where to store the result
  67851. */
  67852. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67853. /**
  67854. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67855. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67856. * @param vector defines the Vector3 to transform
  67857. * @param transformation defines the transformation matrix
  67858. * @returns the new Vector3
  67859. */
  67860. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67861. /**
  67862. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67863. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67864. * @param vector defines the Vector3 to transform
  67865. * @param transformation defines the transformation matrix
  67866. * @param result defines the Vector3 where to store the result
  67867. */
  67868. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67869. /**
  67870. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67871. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67872. * @param x define the x coordinate of the source vector
  67873. * @param y define the y coordinate of the source vector
  67874. * @param z define the z coordinate of the source vector
  67875. * @param transformation defines the transformation matrix
  67876. * @param result defines the Vector3 where to store the result
  67877. */
  67878. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67879. /**
  67880. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67881. * @param value1 defines the first control point
  67882. * @param value2 defines the second control point
  67883. * @param value3 defines the third control point
  67884. * @param value4 defines the fourth control point
  67885. * @param amount defines the amount on the spline to use
  67886. * @returns the new Vector3
  67887. */
  67888. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67889. /**
  67890. * 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"
  67891. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67892. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67893. * @param value defines the current value
  67894. * @param min defines the lower range value
  67895. * @param max defines the upper range value
  67896. * @returns the new Vector3
  67897. */
  67898. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67899. /**
  67900. * 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"
  67901. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67902. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67903. * @param value defines the current value
  67904. * @param min defines the lower range value
  67905. * @param max defines the upper range value
  67906. * @param result defines the Vector3 where to store the result
  67907. */
  67908. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67909. /**
  67910. * Checks if a given vector is inside a specific range
  67911. * @param v defines the vector to test
  67912. * @param min defines the minimum range
  67913. * @param max defines the maximum range
  67914. */
  67915. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67916. /**
  67917. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67918. * @param value1 defines the first control point
  67919. * @param tangent1 defines the first tangent vector
  67920. * @param value2 defines the second control point
  67921. * @param tangent2 defines the second tangent vector
  67922. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67923. * @returns the new Vector3
  67924. */
  67925. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67926. /**
  67927. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67928. * @param start defines the start value
  67929. * @param end defines the end value
  67930. * @param amount max defines amount between both (between 0 and 1)
  67931. * @returns the new Vector3
  67932. */
  67933. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  67934. /**
  67935. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  67936. * @param start defines the start value
  67937. * @param end defines the end value
  67938. * @param amount max defines amount between both (between 0 and 1)
  67939. * @param result defines the Vector3 where to store the result
  67940. */
  67941. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  67942. /**
  67943. * Returns the dot product (float) between the vectors "left" and "right"
  67944. * @param left defines the left operand
  67945. * @param right defines the right operand
  67946. * @returns the dot product
  67947. */
  67948. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  67949. /**
  67950. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  67951. * The cross product is then orthogonal to both "left" and "right"
  67952. * @param left defines the left operand
  67953. * @param right defines the right operand
  67954. * @returns the cross product
  67955. */
  67956. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  67957. /**
  67958. * Sets the given vector "result" with the cross product of "left" and "right"
  67959. * The cross product is then orthogonal to both "left" and "right"
  67960. * @param left defines the left operand
  67961. * @param right defines the right operand
  67962. * @param result defines the Vector3 where to store the result
  67963. */
  67964. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  67965. /**
  67966. * Returns a new Vector3 as the normalization of the given vector
  67967. * @param vector defines the Vector3 to normalize
  67968. * @returns the new Vector3
  67969. */
  67970. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  67971. /**
  67972. * Sets the given vector "result" with the normalization of the given first vector
  67973. * @param vector defines the Vector3 to normalize
  67974. * @param result defines the Vector3 where to store the result
  67975. */
  67976. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  67977. /**
  67978. * Project a Vector3 onto screen space
  67979. * @param vector defines the Vector3 to project
  67980. * @param world defines the world matrix to use
  67981. * @param transform defines the transform (view x projection) matrix to use
  67982. * @param viewport defines the screen viewport to use
  67983. * @returns the new Vector3
  67984. */
  67985. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  67986. /** @hidden */
  67987. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  67988. /**
  67989. * Unproject from screen space to object space
  67990. * @param source defines the screen space Vector3 to use
  67991. * @param viewportWidth defines the current width of the viewport
  67992. * @param viewportHeight defines the current height of the viewport
  67993. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  67994. * @param transform defines the transform (view x projection) matrix to use
  67995. * @returns the new Vector3
  67996. */
  67997. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  67998. /**
  67999. * Unproject from screen space to object space
  68000. * @param source defines the screen space Vector3 to use
  68001. * @param viewportWidth defines the current width of the viewport
  68002. * @param viewportHeight defines the current height of the viewport
  68003. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68004. * @param view defines the view matrix to use
  68005. * @param projection defines the projection matrix to use
  68006. * @returns the new Vector3
  68007. */
  68008. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68009. /**
  68010. * Unproject from screen space to object space
  68011. * @param source defines the screen space Vector3 to use
  68012. * @param viewportWidth defines the current width of the viewport
  68013. * @param viewportHeight defines the current height of the viewport
  68014. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68015. * @param view defines the view matrix to use
  68016. * @param projection defines the projection matrix to use
  68017. * @param result defines the Vector3 where to store the result
  68018. */
  68019. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68020. /**
  68021. * Unproject from screen space to object space
  68022. * @param sourceX defines the screen space x coordinate to use
  68023. * @param sourceY defines the screen space y coordinate to use
  68024. * @param sourceZ defines the screen space z coordinate to use
  68025. * @param viewportWidth defines the current width of the viewport
  68026. * @param viewportHeight defines the current height of the viewport
  68027. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68028. * @param view defines the view matrix to use
  68029. * @param projection defines the projection matrix to use
  68030. * @param result defines the Vector3 where to store the result
  68031. */
  68032. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68033. /**
  68034. * Gets the minimal coordinate values between two Vector3
  68035. * @param left defines the first operand
  68036. * @param right defines the second operand
  68037. * @returns the new Vector3
  68038. */
  68039. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68040. /**
  68041. * Gets the maximal coordinate values between two Vector3
  68042. * @param left defines the first operand
  68043. * @param right defines the second operand
  68044. * @returns the new Vector3
  68045. */
  68046. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68047. /**
  68048. * Returns the distance between the vectors "value1" and "value2"
  68049. * @param value1 defines the first operand
  68050. * @param value2 defines the second operand
  68051. * @returns the distance
  68052. */
  68053. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68054. /**
  68055. * Returns the squared distance between the vectors "value1" and "value2"
  68056. * @param value1 defines the first operand
  68057. * @param value2 defines the second operand
  68058. * @returns the squared distance
  68059. */
  68060. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68061. /**
  68062. * Returns a new Vector3 located at the center between "value1" and "value2"
  68063. * @param value1 defines the first operand
  68064. * @param value2 defines the second operand
  68065. * @returns the new Vector3
  68066. */
  68067. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68068. /**
  68069. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68070. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68071. * to something in order to rotate it from its local system to the given target system
  68072. * Note: axis1, axis2 and axis3 are normalized during this operation
  68073. * @param axis1 defines the first axis
  68074. * @param axis2 defines the second axis
  68075. * @param axis3 defines the third axis
  68076. * @returns a new Vector3
  68077. */
  68078. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68079. /**
  68080. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68081. * @param axis1 defines the first axis
  68082. * @param axis2 defines the second axis
  68083. * @param axis3 defines the third axis
  68084. * @param ref defines the Vector3 where to store the result
  68085. */
  68086. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68087. }
  68088. /**
  68089. * Vector4 class created for EulerAngle class conversion to Quaternion
  68090. */
  68091. export class Vector4 {
  68092. /** x value of the vector */
  68093. x: number;
  68094. /** y value of the vector */
  68095. y: number;
  68096. /** z value of the vector */
  68097. z: number;
  68098. /** w value of the vector */
  68099. w: number;
  68100. /**
  68101. * Creates a Vector4 object from the given floats.
  68102. * @param x x value of the vector
  68103. * @param y y value of the vector
  68104. * @param z z value of the vector
  68105. * @param w w value of the vector
  68106. */
  68107. constructor(
  68108. /** x value of the vector */
  68109. x: number,
  68110. /** y value of the vector */
  68111. y: number,
  68112. /** z value of the vector */
  68113. z: number,
  68114. /** w value of the vector */
  68115. w: number);
  68116. /**
  68117. * Returns the string with the Vector4 coordinates.
  68118. * @returns a string containing all the vector values
  68119. */
  68120. toString(): string;
  68121. /**
  68122. * Returns the string "Vector4".
  68123. * @returns "Vector4"
  68124. */
  68125. getClassName(): string;
  68126. /**
  68127. * Returns the Vector4 hash code.
  68128. * @returns a unique hash code
  68129. */
  68130. getHashCode(): number;
  68131. /**
  68132. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68133. * @returns the resulting array
  68134. */
  68135. asArray(): number[];
  68136. /**
  68137. * Populates the given array from the given index with the Vector4 coordinates.
  68138. * @param array array to populate
  68139. * @param index index of the array to start at (default: 0)
  68140. * @returns the Vector4.
  68141. */
  68142. toArray(array: FloatArray, index?: number): Vector4;
  68143. /**
  68144. * Adds the given vector to the current Vector4.
  68145. * @param otherVector the vector to add
  68146. * @returns the updated Vector4.
  68147. */
  68148. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68149. /**
  68150. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68151. * @param otherVector the vector to add
  68152. * @returns the resulting vector
  68153. */
  68154. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68155. /**
  68156. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68157. * @param otherVector the vector to add
  68158. * @param result the vector to store the result
  68159. * @returns the current Vector4.
  68160. */
  68161. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68162. /**
  68163. * Subtract in place the given vector from the current Vector4.
  68164. * @param otherVector the vector to subtract
  68165. * @returns the updated Vector4.
  68166. */
  68167. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68168. /**
  68169. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68170. * @param otherVector the vector to add
  68171. * @returns the new vector with the result
  68172. */
  68173. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68174. /**
  68175. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68176. * @param otherVector the vector to subtract
  68177. * @param result the vector to store the result
  68178. * @returns the current Vector4.
  68179. */
  68180. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68181. /**
  68182. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68183. */
  68184. /**
  68185. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68186. * @param x value to subtract
  68187. * @param y value to subtract
  68188. * @param z value to subtract
  68189. * @param w value to subtract
  68190. * @returns new vector containing the result
  68191. */
  68192. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68193. /**
  68194. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68195. * @param x value to subtract
  68196. * @param y value to subtract
  68197. * @param z value to subtract
  68198. * @param w value to subtract
  68199. * @param result the vector to store the result in
  68200. * @returns the current Vector4.
  68201. */
  68202. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68203. /**
  68204. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68205. * @returns a new vector with the negated values
  68206. */
  68207. negate(): Vector4;
  68208. /**
  68209. * Multiplies the current Vector4 coordinates by scale (float).
  68210. * @param scale the number to scale with
  68211. * @returns the updated Vector4.
  68212. */
  68213. scaleInPlace(scale: number): Vector4;
  68214. /**
  68215. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68216. * @param scale the number to scale with
  68217. * @returns a new vector with the result
  68218. */
  68219. scale(scale: number): Vector4;
  68220. /**
  68221. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68222. * @param scale the number to scale with
  68223. * @param result a vector to store the result in
  68224. * @returns the current Vector4.
  68225. */
  68226. scaleToRef(scale: number, result: Vector4): Vector4;
  68227. /**
  68228. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68229. * @param scale defines the scale factor
  68230. * @param result defines the Vector4 object where to store the result
  68231. * @returns the unmodified current Vector4
  68232. */
  68233. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68234. /**
  68235. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68236. * @param otherVector the vector to compare against
  68237. * @returns true if they are equal
  68238. */
  68239. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68240. /**
  68241. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68242. * @param otherVector vector to compare against
  68243. * @param epsilon (Default: very small number)
  68244. * @returns true if they are equal
  68245. */
  68246. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68247. /**
  68248. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68249. * @param x x value to compare against
  68250. * @param y y value to compare against
  68251. * @param z z value to compare against
  68252. * @param w w value to compare against
  68253. * @returns true if equal
  68254. */
  68255. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68256. /**
  68257. * Multiplies in place the current Vector4 by the given one.
  68258. * @param otherVector vector to multiple with
  68259. * @returns the updated Vector4.
  68260. */
  68261. multiplyInPlace(otherVector: Vector4): Vector4;
  68262. /**
  68263. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68264. * @param otherVector vector to multiple with
  68265. * @returns resulting new vector
  68266. */
  68267. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68268. /**
  68269. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68270. * @param otherVector vector to multiple with
  68271. * @param result vector to store the result
  68272. * @returns the current Vector4.
  68273. */
  68274. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68275. /**
  68276. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68277. * @param x x value multiply with
  68278. * @param y y value multiply with
  68279. * @param z z value multiply with
  68280. * @param w w value multiply with
  68281. * @returns resulting new vector
  68282. */
  68283. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68284. /**
  68285. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68286. * @param otherVector vector to devide with
  68287. * @returns resulting new vector
  68288. */
  68289. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68290. /**
  68291. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68292. * @param otherVector vector to devide with
  68293. * @param result vector to store the result
  68294. * @returns the current Vector4.
  68295. */
  68296. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68297. /**
  68298. * Divides the current Vector3 coordinates by the given ones.
  68299. * @param otherVector vector to devide with
  68300. * @returns the updated Vector3.
  68301. */
  68302. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68303. /**
  68304. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68305. * @param other defines the second operand
  68306. * @returns the current updated Vector4
  68307. */
  68308. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68309. /**
  68310. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68311. * @param other defines the second operand
  68312. * @returns the current updated Vector4
  68313. */
  68314. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68315. /**
  68316. * Gets a new Vector4 from current Vector4 floored values
  68317. * @returns a new Vector4
  68318. */
  68319. floor(): Vector4;
  68320. /**
  68321. * Gets a new Vector4 from current Vector3 floored values
  68322. * @returns a new Vector4
  68323. */
  68324. fract(): Vector4;
  68325. /**
  68326. * Returns the Vector4 length (float).
  68327. * @returns the length
  68328. */
  68329. length(): number;
  68330. /**
  68331. * Returns the Vector4 squared length (float).
  68332. * @returns the length squared
  68333. */
  68334. lengthSquared(): number;
  68335. /**
  68336. * Normalizes in place the Vector4.
  68337. * @returns the updated Vector4.
  68338. */
  68339. normalize(): Vector4;
  68340. /**
  68341. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68342. * @returns this converted to a new vector3
  68343. */
  68344. toVector3(): Vector3;
  68345. /**
  68346. * Returns a new Vector4 copied from the current one.
  68347. * @returns the new cloned vector
  68348. */
  68349. clone(): Vector4;
  68350. /**
  68351. * Updates the current Vector4 with the given one coordinates.
  68352. * @param source the source vector to copy from
  68353. * @returns the updated Vector4.
  68354. */
  68355. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68356. /**
  68357. * Updates the current Vector4 coordinates with the given floats.
  68358. * @param x float to copy from
  68359. * @param y float to copy from
  68360. * @param z float to copy from
  68361. * @param w float to copy from
  68362. * @returns the updated Vector4.
  68363. */
  68364. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68365. /**
  68366. * Updates the current Vector4 coordinates with the given floats.
  68367. * @param x float to set from
  68368. * @param y float to set from
  68369. * @param z float to set from
  68370. * @param w float to set from
  68371. * @returns the updated Vector4.
  68372. */
  68373. set(x: number, y: number, z: number, w: number): Vector4;
  68374. /**
  68375. * Copies the given float to the current Vector3 coordinates
  68376. * @param v defines the x, y, z and w coordinates of the operand
  68377. * @returns the current updated Vector3
  68378. */
  68379. setAll(v: number): Vector4;
  68380. /**
  68381. * Returns a new Vector4 set from the starting index of the given array.
  68382. * @param array the array to pull values from
  68383. * @param offset the offset into the array to start at
  68384. * @returns the new vector
  68385. */
  68386. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68387. /**
  68388. * Updates the given vector "result" from the starting index of the given array.
  68389. * @param array the array to pull values from
  68390. * @param offset the offset into the array to start at
  68391. * @param result the vector to store the result in
  68392. */
  68393. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68394. /**
  68395. * Updates the given vector "result" from the starting index of the given Float32Array.
  68396. * @param array the array to pull values from
  68397. * @param offset the offset into the array to start at
  68398. * @param result the vector to store the result in
  68399. */
  68400. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68401. /**
  68402. * Updates the given vector "result" coordinates from the given floats.
  68403. * @param x float to set from
  68404. * @param y float to set from
  68405. * @param z float to set from
  68406. * @param w float to set from
  68407. * @param result the vector to the floats in
  68408. */
  68409. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68410. /**
  68411. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68412. * @returns the new vector
  68413. */
  68414. static Zero(): Vector4;
  68415. /**
  68416. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68417. * @returns the new vector
  68418. */
  68419. static One(): Vector4;
  68420. /**
  68421. * Returns a new normalized Vector4 from the given one.
  68422. * @param vector the vector to normalize
  68423. * @returns the vector
  68424. */
  68425. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68426. /**
  68427. * Updates the given vector "result" from the normalization of the given one.
  68428. * @param vector the vector to normalize
  68429. * @param result the vector to store the result in
  68430. */
  68431. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68432. /**
  68433. * Returns a vector with the minimum values from the left and right vectors
  68434. * @param left left vector to minimize
  68435. * @param right right vector to minimize
  68436. * @returns a new vector with the minimum of the left and right vector values
  68437. */
  68438. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68439. /**
  68440. * Returns a vector with the maximum values from the left and right vectors
  68441. * @param left left vector to maximize
  68442. * @param right right vector to maximize
  68443. * @returns a new vector with the maximum of the left and right vector values
  68444. */
  68445. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68446. /**
  68447. * Returns the distance (float) between the vectors "value1" and "value2".
  68448. * @param value1 value to calulate the distance between
  68449. * @param value2 value to calulate the distance between
  68450. * @return the distance between the two vectors
  68451. */
  68452. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68453. /**
  68454. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68455. * @param value1 value to calulate the distance between
  68456. * @param value2 value to calulate the distance between
  68457. * @return the distance between the two vectors squared
  68458. */
  68459. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68460. /**
  68461. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68462. * @param value1 value to calulate the center between
  68463. * @param value2 value to calulate the center between
  68464. * @return the center between the two vectors
  68465. */
  68466. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68467. /**
  68468. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68469. * This methods computes transformed normalized direction vectors only.
  68470. * @param vector the vector to transform
  68471. * @param transformation the transformation matrix to apply
  68472. * @returns the new vector
  68473. */
  68474. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68475. /**
  68476. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68477. * This methods computes transformed normalized direction vectors only.
  68478. * @param vector the vector to transform
  68479. * @param transformation the transformation matrix to apply
  68480. * @param result the vector to store the result in
  68481. */
  68482. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68483. /**
  68484. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68485. * This methods computes transformed normalized direction vectors only.
  68486. * @param x value to transform
  68487. * @param y value to transform
  68488. * @param z value to transform
  68489. * @param w value to transform
  68490. * @param transformation the transformation matrix to apply
  68491. * @param result the vector to store the results in
  68492. */
  68493. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68494. /**
  68495. * Creates a new Vector4 from a Vector3
  68496. * @param source defines the source data
  68497. * @param w defines the 4th component (default is 0)
  68498. * @returns a new Vector4
  68499. */
  68500. static FromVector3(source: Vector3, w?: number): Vector4;
  68501. }
  68502. /**
  68503. * Class used to store quaternion data
  68504. * @see https://en.wikipedia.org/wiki/Quaternion
  68505. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68506. */
  68507. export class Quaternion {
  68508. /** defines the first component (0 by default) */
  68509. x: number;
  68510. /** defines the second component (0 by default) */
  68511. y: number;
  68512. /** defines the third component (0 by default) */
  68513. z: number;
  68514. /** defines the fourth component (1.0 by default) */
  68515. w: number;
  68516. /**
  68517. * Creates a new Quaternion from the given floats
  68518. * @param x defines the first component (0 by default)
  68519. * @param y defines the second component (0 by default)
  68520. * @param z defines the third component (0 by default)
  68521. * @param w defines the fourth component (1.0 by default)
  68522. */
  68523. constructor(
  68524. /** defines the first component (0 by default) */
  68525. x?: number,
  68526. /** defines the second component (0 by default) */
  68527. y?: number,
  68528. /** defines the third component (0 by default) */
  68529. z?: number,
  68530. /** defines the fourth component (1.0 by default) */
  68531. w?: number);
  68532. /**
  68533. * Gets a string representation for the current quaternion
  68534. * @returns a string with the Quaternion coordinates
  68535. */
  68536. toString(): string;
  68537. /**
  68538. * Gets the class name of the quaternion
  68539. * @returns the string "Quaternion"
  68540. */
  68541. getClassName(): string;
  68542. /**
  68543. * Gets a hash code for this quaternion
  68544. * @returns the quaternion hash code
  68545. */
  68546. getHashCode(): number;
  68547. /**
  68548. * Copy the quaternion to an array
  68549. * @returns a new array populated with 4 elements from the quaternion coordinates
  68550. */
  68551. asArray(): number[];
  68552. /**
  68553. * Check if two quaternions are equals
  68554. * @param otherQuaternion defines the second operand
  68555. * @return true if the current quaternion and the given one coordinates are strictly equals
  68556. */
  68557. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68558. /**
  68559. * Clone the current quaternion
  68560. * @returns a new quaternion copied from the current one
  68561. */
  68562. clone(): Quaternion;
  68563. /**
  68564. * Copy a quaternion to the current one
  68565. * @param other defines the other quaternion
  68566. * @returns the updated current quaternion
  68567. */
  68568. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68569. /**
  68570. * Updates the current quaternion with the given float coordinates
  68571. * @param x defines the x coordinate
  68572. * @param y defines the y coordinate
  68573. * @param z defines the z coordinate
  68574. * @param w defines the w coordinate
  68575. * @returns the updated current quaternion
  68576. */
  68577. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68578. /**
  68579. * Updates the current quaternion from the given float coordinates
  68580. * @param x defines the x coordinate
  68581. * @param y defines the y coordinate
  68582. * @param z defines the z coordinate
  68583. * @param w defines the w coordinate
  68584. * @returns the updated current quaternion
  68585. */
  68586. set(x: number, y: number, z: number, w: number): Quaternion;
  68587. /**
  68588. * Adds two quaternions
  68589. * @param other defines the second operand
  68590. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68591. */
  68592. add(other: DeepImmutable<Quaternion>): Quaternion;
  68593. /**
  68594. * Add a quaternion to the current one
  68595. * @param other defines the quaternion to add
  68596. * @returns the current quaternion
  68597. */
  68598. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68599. /**
  68600. * Subtract two quaternions
  68601. * @param other defines the second operand
  68602. * @returns a new quaternion as the subtraction result of the given one from the current one
  68603. */
  68604. subtract(other: Quaternion): Quaternion;
  68605. /**
  68606. * Multiplies the current quaternion by a scale factor
  68607. * @param value defines the scale factor
  68608. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68609. */
  68610. scale(value: number): Quaternion;
  68611. /**
  68612. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68613. * @param scale defines the scale factor
  68614. * @param result defines the Quaternion object where to store the result
  68615. * @returns the unmodified current quaternion
  68616. */
  68617. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68618. /**
  68619. * Multiplies in place the current quaternion by a scale factor
  68620. * @param value defines the scale factor
  68621. * @returns the current modified quaternion
  68622. */
  68623. scaleInPlace(value: number): Quaternion;
  68624. /**
  68625. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68626. * @param scale defines the scale factor
  68627. * @param result defines the Quaternion object where to store the result
  68628. * @returns the unmodified current quaternion
  68629. */
  68630. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68631. /**
  68632. * Multiplies two quaternions
  68633. * @param q1 defines the second operand
  68634. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68635. */
  68636. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68637. /**
  68638. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68639. * @param q1 defines the second operand
  68640. * @param result defines the target quaternion
  68641. * @returns the current quaternion
  68642. */
  68643. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68644. /**
  68645. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68646. * @param q1 defines the second operand
  68647. * @returns the currentupdated quaternion
  68648. */
  68649. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68650. /**
  68651. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68652. * @param ref defines the target quaternion
  68653. * @returns the current quaternion
  68654. */
  68655. conjugateToRef(ref: Quaternion): Quaternion;
  68656. /**
  68657. * Conjugates in place (1-q) the current quaternion
  68658. * @returns the current updated quaternion
  68659. */
  68660. conjugateInPlace(): Quaternion;
  68661. /**
  68662. * Conjugates in place (1-q) the current quaternion
  68663. * @returns a new quaternion
  68664. */
  68665. conjugate(): Quaternion;
  68666. /**
  68667. * Gets length of current quaternion
  68668. * @returns the quaternion length (float)
  68669. */
  68670. length(): number;
  68671. /**
  68672. * Normalize in place the current quaternion
  68673. * @returns the current updated quaternion
  68674. */
  68675. normalize(): Quaternion;
  68676. /**
  68677. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68678. * @param order is a reserved parameter and is ignore for now
  68679. * @returns a new Vector3 containing the Euler angles
  68680. */
  68681. toEulerAngles(order?: string): Vector3;
  68682. /**
  68683. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68684. * @param result defines the vector which will be filled with the Euler angles
  68685. * @param order is a reserved parameter and is ignore for now
  68686. * @returns the current unchanged quaternion
  68687. */
  68688. toEulerAnglesToRef(result: Vector3): Quaternion;
  68689. /**
  68690. * Updates the given rotation matrix with the current quaternion values
  68691. * @param result defines the target matrix
  68692. * @returns the current unchanged quaternion
  68693. */
  68694. toRotationMatrix(result: Matrix): Quaternion;
  68695. /**
  68696. * Updates the current quaternion from the given rotation matrix values
  68697. * @param matrix defines the source matrix
  68698. * @returns the current updated quaternion
  68699. */
  68700. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68701. /**
  68702. * Creates a new quaternion from a rotation matrix
  68703. * @param matrix defines the source matrix
  68704. * @returns a new quaternion created from the given rotation matrix values
  68705. */
  68706. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68707. /**
  68708. * Updates the given quaternion with the given rotation matrix values
  68709. * @param matrix defines the source matrix
  68710. * @param result defines the target quaternion
  68711. */
  68712. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68713. /**
  68714. * Returns the dot product (float) between the quaternions "left" and "right"
  68715. * @param left defines the left operand
  68716. * @param right defines the right operand
  68717. * @returns the dot product
  68718. */
  68719. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68720. /**
  68721. * Checks if the two quaternions are close to each other
  68722. * @param quat0 defines the first quaternion to check
  68723. * @param quat1 defines the second quaternion to check
  68724. * @returns true if the two quaternions are close to each other
  68725. */
  68726. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68727. /**
  68728. * Creates an empty quaternion
  68729. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68730. */
  68731. static Zero(): Quaternion;
  68732. /**
  68733. * Inverse a given quaternion
  68734. * @param q defines the source quaternion
  68735. * @returns a new quaternion as the inverted current quaternion
  68736. */
  68737. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68738. /**
  68739. * Inverse a given quaternion
  68740. * @param q defines the source quaternion
  68741. * @param result the quaternion the result will be stored in
  68742. * @returns the result quaternion
  68743. */
  68744. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68745. /**
  68746. * Creates an identity quaternion
  68747. * @returns the identity quaternion
  68748. */
  68749. static Identity(): Quaternion;
  68750. /**
  68751. * Gets a boolean indicating if the given quaternion is identity
  68752. * @param quaternion defines the quaternion to check
  68753. * @returns true if the quaternion is identity
  68754. */
  68755. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68756. /**
  68757. * Creates a quaternion from a rotation around an axis
  68758. * @param axis defines the axis to use
  68759. * @param angle defines the angle to use
  68760. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68761. */
  68762. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68763. /**
  68764. * Creates a rotation around an axis and stores it into the given quaternion
  68765. * @param axis defines the axis to use
  68766. * @param angle defines the angle to use
  68767. * @param result defines the target quaternion
  68768. * @returns the target quaternion
  68769. */
  68770. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68771. /**
  68772. * Creates a new quaternion from data stored into an array
  68773. * @param array defines the data source
  68774. * @param offset defines the offset in the source array where the data starts
  68775. * @returns a new quaternion
  68776. */
  68777. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68778. /**
  68779. * Create a quaternion from Euler rotation angles
  68780. * @param x Pitch
  68781. * @param y Yaw
  68782. * @param z Roll
  68783. * @returns the new Quaternion
  68784. */
  68785. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68786. /**
  68787. * Updates a quaternion from Euler rotation angles
  68788. * @param x Pitch
  68789. * @param y Yaw
  68790. * @param z Roll
  68791. * @param result the quaternion to store the result
  68792. * @returns the updated quaternion
  68793. */
  68794. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68795. /**
  68796. * Create a quaternion from Euler rotation vector
  68797. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68798. * @returns the new Quaternion
  68799. */
  68800. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68801. /**
  68802. * Updates a quaternion from Euler rotation vector
  68803. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68804. * @param result the quaternion to store the result
  68805. * @returns the updated quaternion
  68806. */
  68807. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68808. /**
  68809. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68810. * @param yaw defines the rotation around Y axis
  68811. * @param pitch defines the rotation around X axis
  68812. * @param roll defines the rotation around Z axis
  68813. * @returns the new quaternion
  68814. */
  68815. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68816. /**
  68817. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68818. * @param yaw defines the rotation around Y axis
  68819. * @param pitch defines the rotation around X axis
  68820. * @param roll defines the rotation around Z axis
  68821. * @param result defines the target quaternion
  68822. */
  68823. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68824. /**
  68825. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68826. * @param alpha defines the rotation around first axis
  68827. * @param beta defines the rotation around second axis
  68828. * @param gamma defines the rotation around third axis
  68829. * @returns the new quaternion
  68830. */
  68831. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68832. /**
  68833. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68834. * @param alpha defines the rotation around first axis
  68835. * @param beta defines the rotation around second axis
  68836. * @param gamma defines the rotation around third axis
  68837. * @param result defines the target quaternion
  68838. */
  68839. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68840. /**
  68841. * 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)
  68842. * @param axis1 defines the first axis
  68843. * @param axis2 defines the second axis
  68844. * @param axis3 defines the third axis
  68845. * @returns the new quaternion
  68846. */
  68847. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68848. /**
  68849. * 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
  68850. * @param axis1 defines the first axis
  68851. * @param axis2 defines the second axis
  68852. * @param axis3 defines the third axis
  68853. * @param ref defines the target quaternion
  68854. */
  68855. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68856. /**
  68857. * Interpolates between two quaternions
  68858. * @param left defines first quaternion
  68859. * @param right defines second quaternion
  68860. * @param amount defines the gradient to use
  68861. * @returns the new interpolated quaternion
  68862. */
  68863. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68864. /**
  68865. * Interpolates between two quaternions and stores it into a target quaternion
  68866. * @param left defines first quaternion
  68867. * @param right defines second quaternion
  68868. * @param amount defines the gradient to use
  68869. * @param result defines the target quaternion
  68870. */
  68871. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68872. /**
  68873. * Interpolate between two quaternions using Hermite interpolation
  68874. * @param value1 defines first quaternion
  68875. * @param tangent1 defines the incoming tangent
  68876. * @param value2 defines second quaternion
  68877. * @param tangent2 defines the outgoing tangent
  68878. * @param amount defines the target quaternion
  68879. * @returns the new interpolated quaternion
  68880. */
  68881. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68882. }
  68883. /**
  68884. * Class used to store matrix data (4x4)
  68885. */
  68886. export class Matrix {
  68887. private static _updateFlagSeed;
  68888. private static _identityReadOnly;
  68889. private _isIdentity;
  68890. private _isIdentityDirty;
  68891. private _isIdentity3x2;
  68892. private _isIdentity3x2Dirty;
  68893. /**
  68894. * Gets the update flag of the matrix which is an unique number for the matrix.
  68895. * It will be incremented every time the matrix data change.
  68896. * You can use it to speed the comparison between two versions of the same matrix.
  68897. */
  68898. updateFlag: number;
  68899. private readonly _m;
  68900. /**
  68901. * Gets the internal data of the matrix
  68902. */
  68903. readonly m: DeepImmutable<Float32Array>;
  68904. /** @hidden */
  68905. _markAsUpdated(): void;
  68906. /** @hidden */
  68907. private _updateIdentityStatus;
  68908. /**
  68909. * Creates an empty matrix (filled with zeros)
  68910. */
  68911. constructor();
  68912. /**
  68913. * Check if the current matrix is identity
  68914. * @returns true is the matrix is the identity matrix
  68915. */
  68916. isIdentity(): boolean;
  68917. /**
  68918. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68919. * @returns true is the matrix is the identity matrix
  68920. */
  68921. isIdentityAs3x2(): boolean;
  68922. /**
  68923. * Gets the determinant of the matrix
  68924. * @returns the matrix determinant
  68925. */
  68926. determinant(): number;
  68927. /**
  68928. * Returns the matrix as a Float32Array
  68929. * @returns the matrix underlying array
  68930. */
  68931. toArray(): DeepImmutable<Float32Array>;
  68932. /**
  68933. * Returns the matrix as a Float32Array
  68934. * @returns the matrix underlying array.
  68935. */
  68936. asArray(): DeepImmutable<Float32Array>;
  68937. /**
  68938. * Inverts the current matrix in place
  68939. * @returns the current inverted matrix
  68940. */
  68941. invert(): Matrix;
  68942. /**
  68943. * Sets all the matrix elements to zero
  68944. * @returns the current matrix
  68945. */
  68946. reset(): Matrix;
  68947. /**
  68948. * Adds the current matrix with a second one
  68949. * @param other defines the matrix to add
  68950. * @returns a new matrix as the addition of the current matrix and the given one
  68951. */
  68952. add(other: DeepImmutable<Matrix>): Matrix;
  68953. /**
  68954. * Sets the given matrix "result" to the addition of the current matrix and the given one
  68955. * @param other defines the matrix to add
  68956. * @param result defines the target matrix
  68957. * @returns the current matrix
  68958. */
  68959. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  68960. /**
  68961. * Adds in place the given matrix to the current matrix
  68962. * @param other defines the second operand
  68963. * @returns the current updated matrix
  68964. */
  68965. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  68966. /**
  68967. * Sets the given matrix to the current inverted Matrix
  68968. * @param other defines the target matrix
  68969. * @returns the unmodified current matrix
  68970. */
  68971. invertToRef(other: Matrix): Matrix;
  68972. /**
  68973. * add a value at the specified position in the current Matrix
  68974. * @param index the index of the value within the matrix. between 0 and 15.
  68975. * @param value the value to be added
  68976. * @returns the current updated matrix
  68977. */
  68978. addAtIndex(index: number, value: number): Matrix;
  68979. /**
  68980. * mutiply the specified position in the current Matrix by a value
  68981. * @param index the index of the value within the matrix. between 0 and 15.
  68982. * @param value the value to be added
  68983. * @returns the current updated matrix
  68984. */
  68985. multiplyAtIndex(index: number, value: number): Matrix;
  68986. /**
  68987. * Inserts the translation vector (using 3 floats) in the current matrix
  68988. * @param x defines the 1st component of the translation
  68989. * @param y defines the 2nd component of the translation
  68990. * @param z defines the 3rd component of the translation
  68991. * @returns the current updated matrix
  68992. */
  68993. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  68994. /**
  68995. * Adds the translation vector (using 3 floats) in the current matrix
  68996. * @param x defines the 1st component of the translation
  68997. * @param y defines the 2nd component of the translation
  68998. * @param z defines the 3rd component of the translation
  68999. * @returns the current updated matrix
  69000. */
  69001. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69002. /**
  69003. * Inserts the translation vector in the current matrix
  69004. * @param vector3 defines the translation to insert
  69005. * @returns the current updated matrix
  69006. */
  69007. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69008. /**
  69009. * Gets the translation value of the current matrix
  69010. * @returns a new Vector3 as the extracted translation from the matrix
  69011. */
  69012. getTranslation(): Vector3;
  69013. /**
  69014. * Fill a Vector3 with the extracted translation from the matrix
  69015. * @param result defines the Vector3 where to store the translation
  69016. * @returns the current matrix
  69017. */
  69018. getTranslationToRef(result: Vector3): Matrix;
  69019. /**
  69020. * Remove rotation and scaling part from the matrix
  69021. * @returns the updated matrix
  69022. */
  69023. removeRotationAndScaling(): Matrix;
  69024. /**
  69025. * Multiply two matrices
  69026. * @param other defines the second operand
  69027. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69028. */
  69029. multiply(other: DeepImmutable<Matrix>): Matrix;
  69030. /**
  69031. * Copy the current matrix from the given one
  69032. * @param other defines the source matrix
  69033. * @returns the current updated matrix
  69034. */
  69035. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69036. /**
  69037. * Populates the given array from the starting index with the current matrix values
  69038. * @param array defines the target array
  69039. * @param offset defines the offset in the target array where to start storing values
  69040. * @returns the current matrix
  69041. */
  69042. copyToArray(array: Float32Array, offset?: number): Matrix;
  69043. /**
  69044. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69045. * @param other defines the second operand
  69046. * @param result defines the matrix where to store the multiplication
  69047. * @returns the current matrix
  69048. */
  69049. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69050. /**
  69051. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69052. * @param other defines the second operand
  69053. * @param result defines the array where to store the multiplication
  69054. * @param offset defines the offset in the target array where to start storing values
  69055. * @returns the current matrix
  69056. */
  69057. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69058. /**
  69059. * Check equality between this matrix and a second one
  69060. * @param value defines the second matrix to compare
  69061. * @returns true is the current matrix and the given one values are strictly equal
  69062. */
  69063. equals(value: DeepImmutable<Matrix>): boolean;
  69064. /**
  69065. * Clone the current matrix
  69066. * @returns a new matrix from the current matrix
  69067. */
  69068. clone(): Matrix;
  69069. /**
  69070. * Returns the name of the current matrix class
  69071. * @returns the string "Matrix"
  69072. */
  69073. getClassName(): string;
  69074. /**
  69075. * Gets the hash code of the current matrix
  69076. * @returns the hash code
  69077. */
  69078. getHashCode(): number;
  69079. /**
  69080. * Decomposes the current Matrix into a translation, rotation and scaling components
  69081. * @param scale defines the scale vector3 given as a reference to update
  69082. * @param rotation defines the rotation quaternion given as a reference to update
  69083. * @param translation defines the translation vector3 given as a reference to update
  69084. * @returns true if operation was successful
  69085. */
  69086. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69087. /**
  69088. * Gets specific row of the matrix
  69089. * @param index defines the number of the row to get
  69090. * @returns the index-th row of the current matrix as a new Vector4
  69091. */
  69092. getRow(index: number): Nullable<Vector4>;
  69093. /**
  69094. * Sets the index-th row of the current matrix to the vector4 values
  69095. * @param index defines the number of the row to set
  69096. * @param row defines the target vector4
  69097. * @returns the updated current matrix
  69098. */
  69099. setRow(index: number, row: Vector4): Matrix;
  69100. /**
  69101. * Compute the transpose of the matrix
  69102. * @returns the new transposed matrix
  69103. */
  69104. transpose(): Matrix;
  69105. /**
  69106. * Compute the transpose of the matrix and store it in a given matrix
  69107. * @param result defines the target matrix
  69108. * @returns the current matrix
  69109. */
  69110. transposeToRef(result: Matrix): Matrix;
  69111. /**
  69112. * Sets the index-th row of the current matrix with the given 4 x float values
  69113. * @param index defines the row index
  69114. * @param x defines the x component to set
  69115. * @param y defines the y component to set
  69116. * @param z defines the z component to set
  69117. * @param w defines the w component to set
  69118. * @returns the updated current matrix
  69119. */
  69120. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69121. /**
  69122. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69123. * @param scale defines the scale factor
  69124. * @returns a new matrix
  69125. */
  69126. scale(scale: number): Matrix;
  69127. /**
  69128. * Scale the current matrix values by a factor to a given result matrix
  69129. * @param scale defines the scale factor
  69130. * @param result defines the matrix to store the result
  69131. * @returns the current matrix
  69132. */
  69133. scaleToRef(scale: number, result: Matrix): Matrix;
  69134. /**
  69135. * Scale the current matrix values by a factor and add the result to a given matrix
  69136. * @param scale defines the scale factor
  69137. * @param result defines the Matrix to store the result
  69138. * @returns the current matrix
  69139. */
  69140. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69141. /**
  69142. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69143. * @param ref matrix to store the result
  69144. */
  69145. toNormalMatrix(ref: Matrix): void;
  69146. /**
  69147. * Gets only rotation part of the current matrix
  69148. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69149. */
  69150. getRotationMatrix(): Matrix;
  69151. /**
  69152. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69153. * @param result defines the target matrix to store data to
  69154. * @returns the current matrix
  69155. */
  69156. getRotationMatrixToRef(result: Matrix): Matrix;
  69157. /**
  69158. * Toggles model matrix from being right handed to left handed in place and vice versa
  69159. */
  69160. toggleModelMatrixHandInPlace(): void;
  69161. /**
  69162. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69163. */
  69164. toggleProjectionMatrixHandInPlace(): void;
  69165. /**
  69166. * Creates a matrix from an array
  69167. * @param array defines the source array
  69168. * @param offset defines an offset in the source array
  69169. * @returns a new Matrix set from the starting index of the given array
  69170. */
  69171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69172. /**
  69173. * Copy the content of an array into a given matrix
  69174. * @param array defines the source array
  69175. * @param offset defines an offset in the source array
  69176. * @param result defines the target matrix
  69177. */
  69178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69179. /**
  69180. * Stores an array into a matrix after having multiplied each component by a given factor
  69181. * @param array defines the source array
  69182. * @param offset defines the offset in the source array
  69183. * @param scale defines the scaling factor
  69184. * @param result defines the target matrix
  69185. */
  69186. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69187. /**
  69188. * Gets an identity matrix that must not be updated
  69189. */
  69190. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69191. /**
  69192. * Stores a list of values (16) inside a given matrix
  69193. * @param initialM11 defines 1st value of 1st row
  69194. * @param initialM12 defines 2nd value of 1st row
  69195. * @param initialM13 defines 3rd value of 1st row
  69196. * @param initialM14 defines 4th value of 1st row
  69197. * @param initialM21 defines 1st value of 2nd row
  69198. * @param initialM22 defines 2nd value of 2nd row
  69199. * @param initialM23 defines 3rd value of 2nd row
  69200. * @param initialM24 defines 4th value of 2nd row
  69201. * @param initialM31 defines 1st value of 3rd row
  69202. * @param initialM32 defines 2nd value of 3rd row
  69203. * @param initialM33 defines 3rd value of 3rd row
  69204. * @param initialM34 defines 4th value of 3rd row
  69205. * @param initialM41 defines 1st value of 4th row
  69206. * @param initialM42 defines 2nd value of 4th row
  69207. * @param initialM43 defines 3rd value of 4th row
  69208. * @param initialM44 defines 4th value of 4th row
  69209. * @param result defines the target matrix
  69210. */
  69211. 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;
  69212. /**
  69213. * Creates new matrix from a list of values (16)
  69214. * @param initialM11 defines 1st value of 1st row
  69215. * @param initialM12 defines 2nd value of 1st row
  69216. * @param initialM13 defines 3rd value of 1st row
  69217. * @param initialM14 defines 4th value of 1st row
  69218. * @param initialM21 defines 1st value of 2nd row
  69219. * @param initialM22 defines 2nd value of 2nd row
  69220. * @param initialM23 defines 3rd value of 2nd row
  69221. * @param initialM24 defines 4th value of 2nd row
  69222. * @param initialM31 defines 1st value of 3rd row
  69223. * @param initialM32 defines 2nd value of 3rd row
  69224. * @param initialM33 defines 3rd value of 3rd row
  69225. * @param initialM34 defines 4th value of 3rd row
  69226. * @param initialM41 defines 1st value of 4th row
  69227. * @param initialM42 defines 2nd value of 4th row
  69228. * @param initialM43 defines 3rd value of 4th row
  69229. * @param initialM44 defines 4th value of 4th row
  69230. * @returns the new matrix
  69231. */
  69232. 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;
  69233. /**
  69234. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69235. * @param scale defines the scale vector3
  69236. * @param rotation defines the rotation quaternion
  69237. * @param translation defines the translation vector3
  69238. * @returns a new matrix
  69239. */
  69240. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69241. /**
  69242. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69243. * @param scale defines the scale vector3
  69244. * @param rotation defines the rotation quaternion
  69245. * @param translation defines the translation vector3
  69246. * @param result defines the target matrix
  69247. */
  69248. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69249. /**
  69250. * Creates a new identity matrix
  69251. * @returns a new identity matrix
  69252. */
  69253. static Identity(): Matrix;
  69254. /**
  69255. * Creates a new identity matrix and stores the result in a given matrix
  69256. * @param result defines the target matrix
  69257. */
  69258. static IdentityToRef(result: Matrix): void;
  69259. /**
  69260. * Creates a new zero matrix
  69261. * @returns a new zero matrix
  69262. */
  69263. static Zero(): Matrix;
  69264. /**
  69265. * Creates a new rotation matrix for "angle" radians around the X axis
  69266. * @param angle defines the angle (in radians) to use
  69267. * @return the new matrix
  69268. */
  69269. static RotationX(angle: number): Matrix;
  69270. /**
  69271. * Creates a new matrix as the invert of a given matrix
  69272. * @param source defines the source matrix
  69273. * @returns the new matrix
  69274. */
  69275. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69276. /**
  69277. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69278. * @param angle defines the angle (in radians) to use
  69279. * @param result defines the target matrix
  69280. */
  69281. static RotationXToRef(angle: number, result: Matrix): void;
  69282. /**
  69283. * Creates a new rotation matrix for "angle" radians around the Y axis
  69284. * @param angle defines the angle (in radians) to use
  69285. * @return the new matrix
  69286. */
  69287. static RotationY(angle: number): Matrix;
  69288. /**
  69289. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69290. * @param angle defines the angle (in radians) to use
  69291. * @param result defines the target matrix
  69292. */
  69293. static RotationYToRef(angle: number, result: Matrix): void;
  69294. /**
  69295. * Creates a new rotation matrix for "angle" radians around the Z axis
  69296. * @param angle defines the angle (in radians) to use
  69297. * @return the new matrix
  69298. */
  69299. static RotationZ(angle: number): Matrix;
  69300. /**
  69301. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69302. * @param angle defines the angle (in radians) to use
  69303. * @param result defines the target matrix
  69304. */
  69305. static RotationZToRef(angle: number, result: Matrix): void;
  69306. /**
  69307. * Creates a new rotation matrix for "angle" radians around the given axis
  69308. * @param axis defines the axis to use
  69309. * @param angle defines the angle (in radians) to use
  69310. * @return the new matrix
  69311. */
  69312. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69313. /**
  69314. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69315. * @param axis defines the axis to use
  69316. * @param angle defines the angle (in radians) to use
  69317. * @param result defines the target matrix
  69318. */
  69319. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69320. /**
  69321. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69322. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69323. * @param from defines the vector to align
  69324. * @param to defines the vector to align to
  69325. * @param result defines the target matrix
  69326. */
  69327. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69328. /**
  69329. * Creates a rotation matrix
  69330. * @param yaw defines the yaw angle in radians (Y axis)
  69331. * @param pitch defines the pitch angle in radians (X axis)
  69332. * @param roll defines the roll angle in radians (X axis)
  69333. * @returns the new rotation matrix
  69334. */
  69335. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69336. /**
  69337. * Creates a rotation matrix and stores it in a given matrix
  69338. * @param yaw defines the yaw angle in radians (Y axis)
  69339. * @param pitch defines the pitch angle in radians (X axis)
  69340. * @param roll defines the roll angle in radians (X axis)
  69341. * @param result defines the target matrix
  69342. */
  69343. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69344. /**
  69345. * Creates a scaling matrix
  69346. * @param x defines the scale factor on X axis
  69347. * @param y defines the scale factor on Y axis
  69348. * @param z defines the scale factor on Z axis
  69349. * @returns the new matrix
  69350. */
  69351. static Scaling(x: number, y: number, z: number): Matrix;
  69352. /**
  69353. * Creates a scaling matrix and stores it in a given matrix
  69354. * @param x defines the scale factor on X axis
  69355. * @param y defines the scale factor on Y axis
  69356. * @param z defines the scale factor on Z axis
  69357. * @param result defines the target matrix
  69358. */
  69359. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69360. /**
  69361. * Creates a translation matrix
  69362. * @param x defines the translation on X axis
  69363. * @param y defines the translation on Y axis
  69364. * @param z defines the translationon Z axis
  69365. * @returns the new matrix
  69366. */
  69367. static Translation(x: number, y: number, z: number): Matrix;
  69368. /**
  69369. * Creates a translation matrix and stores it in a given matrix
  69370. * @param x defines the translation on X axis
  69371. * @param y defines the translation on Y axis
  69372. * @param z defines the translationon Z axis
  69373. * @param result defines the target matrix
  69374. */
  69375. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69376. /**
  69377. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69378. * @param startValue defines the start value
  69379. * @param endValue defines the end value
  69380. * @param gradient defines the gradient factor
  69381. * @returns the new matrix
  69382. */
  69383. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69384. /**
  69385. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69386. * @param startValue defines the start value
  69387. * @param endValue defines the end value
  69388. * @param gradient defines the gradient factor
  69389. * @param result defines the Matrix object where to store data
  69390. */
  69391. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69392. /**
  69393. * Builds a new matrix whose values are computed by:
  69394. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69395. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69396. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69397. * @param startValue defines the first matrix
  69398. * @param endValue defines the second matrix
  69399. * @param gradient defines the gradient between the two matrices
  69400. * @returns the new matrix
  69401. */
  69402. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69403. /**
  69404. * Update a matrix to values which are computed by:
  69405. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69406. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69407. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69408. * @param startValue defines the first matrix
  69409. * @param endValue defines the second matrix
  69410. * @param gradient defines the gradient between the two matrices
  69411. * @param result defines the target matrix
  69412. */
  69413. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69414. /**
  69415. * 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"
  69416. * This function works in left handed mode
  69417. * @param eye defines the final position of the entity
  69418. * @param target defines where the entity should look at
  69419. * @param up defines the up vector for the entity
  69420. * @returns the new matrix
  69421. */
  69422. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69423. /**
  69424. * 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".
  69425. * This function works in left handed mode
  69426. * @param eye defines the final position of the entity
  69427. * @param target defines where the entity should look at
  69428. * @param up defines the up vector for the entity
  69429. * @param result defines the target matrix
  69430. */
  69431. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69432. /**
  69433. * 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"
  69434. * This function works in right handed mode
  69435. * @param eye defines the final position of the entity
  69436. * @param target defines where the entity should look at
  69437. * @param up defines the up vector for the entity
  69438. * @returns the new matrix
  69439. */
  69440. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69441. /**
  69442. * 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".
  69443. * This function works in right handed mode
  69444. * @param eye defines the final position of the entity
  69445. * @param target defines where the entity should look at
  69446. * @param up defines the up vector for the entity
  69447. * @param result defines the target matrix
  69448. */
  69449. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69450. /**
  69451. * Create a left-handed orthographic projection matrix
  69452. * @param width defines the viewport width
  69453. * @param height defines the viewport height
  69454. * @param znear defines the near clip plane
  69455. * @param zfar defines the far clip plane
  69456. * @returns a new matrix as a left-handed orthographic projection matrix
  69457. */
  69458. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69459. /**
  69460. * Store a left-handed orthographic projection to a given matrix
  69461. * @param width defines the viewport width
  69462. * @param height defines the viewport height
  69463. * @param znear defines the near clip plane
  69464. * @param zfar defines the far clip plane
  69465. * @param result defines the target matrix
  69466. */
  69467. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69468. /**
  69469. * Create a left-handed orthographic projection matrix
  69470. * @param left defines the viewport left coordinate
  69471. * @param right defines the viewport right coordinate
  69472. * @param bottom defines the viewport bottom coordinate
  69473. * @param top defines the viewport top coordinate
  69474. * @param znear defines the near clip plane
  69475. * @param zfar defines the far clip plane
  69476. * @returns a new matrix as a left-handed orthographic projection matrix
  69477. */
  69478. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69479. /**
  69480. * Stores a left-handed orthographic projection into a given matrix
  69481. * @param left defines the viewport left coordinate
  69482. * @param right defines the viewport right coordinate
  69483. * @param bottom defines the viewport bottom coordinate
  69484. * @param top defines the viewport top coordinate
  69485. * @param znear defines the near clip plane
  69486. * @param zfar defines the far clip plane
  69487. * @param result defines the target matrix
  69488. */
  69489. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69490. /**
  69491. * Creates a right-handed orthographic projection matrix
  69492. * @param left defines the viewport left coordinate
  69493. * @param right defines the viewport right coordinate
  69494. * @param bottom defines the viewport bottom coordinate
  69495. * @param top defines the viewport top coordinate
  69496. * @param znear defines the near clip plane
  69497. * @param zfar defines the far clip plane
  69498. * @returns a new matrix as a right-handed orthographic projection matrix
  69499. */
  69500. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69501. /**
  69502. * Stores a right-handed orthographic projection into a given matrix
  69503. * @param left defines the viewport left coordinate
  69504. * @param right defines the viewport right coordinate
  69505. * @param bottom defines the viewport bottom coordinate
  69506. * @param top defines the viewport top coordinate
  69507. * @param znear defines the near clip plane
  69508. * @param zfar defines the far clip plane
  69509. * @param result defines the target matrix
  69510. */
  69511. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69512. /**
  69513. * Creates a left-handed perspective projection matrix
  69514. * @param width defines the viewport width
  69515. * @param height defines the viewport height
  69516. * @param znear defines the near clip plane
  69517. * @param zfar defines the far clip plane
  69518. * @returns a new matrix as a left-handed perspective projection matrix
  69519. */
  69520. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69521. /**
  69522. * Creates a left-handed perspective projection matrix
  69523. * @param fov defines the horizontal field of view
  69524. * @param aspect defines the aspect ratio
  69525. * @param znear defines the near clip plane
  69526. * @param zfar defines the far clip plane
  69527. * @returns a new matrix as a left-handed perspective projection matrix
  69528. */
  69529. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69530. /**
  69531. * Stores a left-handed perspective projection into a given matrix
  69532. * @param fov defines the horizontal field of view
  69533. * @param aspect defines the aspect ratio
  69534. * @param znear defines the near clip plane
  69535. * @param zfar defines the far clip plane
  69536. * @param result defines the target matrix
  69537. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69538. */
  69539. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69540. /**
  69541. * Creates a right-handed perspective projection matrix
  69542. * @param fov defines the horizontal field of view
  69543. * @param aspect defines the aspect ratio
  69544. * @param znear defines the near clip plane
  69545. * @param zfar defines the far clip plane
  69546. * @returns a new matrix as a right-handed perspective projection matrix
  69547. */
  69548. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69549. /**
  69550. * Stores a right-handed perspective projection into a given matrix
  69551. * @param fov defines the horizontal field of view
  69552. * @param aspect defines the aspect ratio
  69553. * @param znear defines the near clip plane
  69554. * @param zfar defines the far clip plane
  69555. * @param result defines the target matrix
  69556. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69557. */
  69558. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69559. /**
  69560. * Stores a perspective projection for WebVR info a given matrix
  69561. * @param fov defines the field of view
  69562. * @param znear defines the near clip plane
  69563. * @param zfar defines the far clip plane
  69564. * @param result defines the target matrix
  69565. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69566. */
  69567. static PerspectiveFovWebVRToRef(fov: {
  69568. upDegrees: number;
  69569. downDegrees: number;
  69570. leftDegrees: number;
  69571. rightDegrees: number;
  69572. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69573. /**
  69574. * Computes a complete transformation matrix
  69575. * @param viewport defines the viewport to use
  69576. * @param world defines the world matrix
  69577. * @param view defines the view matrix
  69578. * @param projection defines the projection matrix
  69579. * @param zmin defines the near clip plane
  69580. * @param zmax defines the far clip plane
  69581. * @returns the transformation matrix
  69582. */
  69583. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69584. /**
  69585. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69586. * @param matrix defines the matrix to use
  69587. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69588. */
  69589. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69590. /**
  69591. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69592. * @param matrix defines the matrix to use
  69593. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69594. */
  69595. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69596. /**
  69597. * Compute the transpose of a given matrix
  69598. * @param matrix defines the matrix to transpose
  69599. * @returns the new matrix
  69600. */
  69601. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69602. /**
  69603. * Compute the transpose of a matrix and store it in a target matrix
  69604. * @param matrix defines the matrix to transpose
  69605. * @param result defines the target matrix
  69606. */
  69607. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69608. /**
  69609. * Computes a reflection matrix from a plane
  69610. * @param plane defines the reflection plane
  69611. * @returns a new matrix
  69612. */
  69613. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69614. /**
  69615. * Computes a reflection matrix from a plane
  69616. * @param plane defines the reflection plane
  69617. * @param result defines the target matrix
  69618. */
  69619. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69620. /**
  69621. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69622. * @param xaxis defines the value of the 1st axis
  69623. * @param yaxis defines the value of the 2nd axis
  69624. * @param zaxis defines the value of the 3rd axis
  69625. * @param result defines the target matrix
  69626. */
  69627. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69628. /**
  69629. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69630. * @param quat defines the quaternion to use
  69631. * @param result defines the target matrix
  69632. */
  69633. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69634. }
  69635. /**
  69636. * @hidden
  69637. */
  69638. export class TmpVectors {
  69639. static Vector2: Vector2[];
  69640. static Vector3: Vector3[];
  69641. static Vector4: Vector4[];
  69642. static Quaternion: Quaternion[];
  69643. static Matrix: Matrix[];
  69644. }
  69645. }
  69646. declare module BABYLON {
  69647. /** Defines the cross module used constants to avoid circular dependncies */
  69648. export class Constants {
  69649. /** Defines that alpha blending is disabled */
  69650. static readonly ALPHA_DISABLE: number;
  69651. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69652. static readonly ALPHA_ADD: number;
  69653. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69654. static readonly ALPHA_COMBINE: number;
  69655. /** Defines that alpha blending to DEST - SRC * DEST */
  69656. static readonly ALPHA_SUBTRACT: number;
  69657. /** Defines that alpha blending to SRC * DEST */
  69658. static readonly ALPHA_MULTIPLY: number;
  69659. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69660. static readonly ALPHA_MAXIMIZED: number;
  69661. /** Defines that alpha blending to SRC + DEST */
  69662. static readonly ALPHA_ONEONE: number;
  69663. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69664. static readonly ALPHA_PREMULTIPLIED: number;
  69665. /**
  69666. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69667. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69668. */
  69669. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69670. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69671. static readonly ALPHA_INTERPOLATE: number;
  69672. /**
  69673. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69674. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69675. */
  69676. static readonly ALPHA_SCREENMODE: number;
  69677. /** Defines that the ressource is not delayed*/
  69678. static readonly DELAYLOADSTATE_NONE: number;
  69679. /** Defines that the ressource was successfully delay loaded */
  69680. static readonly DELAYLOADSTATE_LOADED: number;
  69681. /** Defines that the ressource is currently delay loading */
  69682. static readonly DELAYLOADSTATE_LOADING: number;
  69683. /** Defines that the ressource is delayed and has not started loading */
  69684. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69686. static readonly NEVER: number;
  69687. /** 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 */
  69688. static readonly ALWAYS: number;
  69689. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69690. static readonly LESS: number;
  69691. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69692. static readonly EQUAL: number;
  69693. /** 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 */
  69694. static readonly LEQUAL: number;
  69695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69696. static readonly GREATER: number;
  69697. /** 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 */
  69698. static readonly GEQUAL: number;
  69699. /** 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 */
  69700. static readonly NOTEQUAL: number;
  69701. /** Passed to stencilOperation to specify that stencil value must be kept */
  69702. static readonly KEEP: number;
  69703. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69704. static readonly REPLACE: number;
  69705. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69706. static readonly INCR: number;
  69707. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69708. static readonly DECR: number;
  69709. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69710. static readonly INVERT: number;
  69711. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69712. static readonly INCR_WRAP: number;
  69713. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69714. static readonly DECR_WRAP: number;
  69715. /** Texture is not repeating outside of 0..1 UVs */
  69716. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69717. /** Texture is repeating outside of 0..1 UVs */
  69718. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69719. /** Texture is repeating and mirrored */
  69720. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69721. /** ALPHA */
  69722. static readonly TEXTUREFORMAT_ALPHA: number;
  69723. /** LUMINANCE */
  69724. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69725. /** LUMINANCE_ALPHA */
  69726. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69727. /** RGB */
  69728. static readonly TEXTUREFORMAT_RGB: number;
  69729. /** RGBA */
  69730. static readonly TEXTUREFORMAT_RGBA: number;
  69731. /** RED */
  69732. static readonly TEXTUREFORMAT_RED: number;
  69733. /** RED (2nd reference) */
  69734. static readonly TEXTUREFORMAT_R: number;
  69735. /** RG */
  69736. static readonly TEXTUREFORMAT_RG: number;
  69737. /** RED_INTEGER */
  69738. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69739. /** RED_INTEGER (2nd reference) */
  69740. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69741. /** RG_INTEGER */
  69742. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69743. /** RGB_INTEGER */
  69744. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69745. /** RGBA_INTEGER */
  69746. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69747. /** UNSIGNED_BYTE */
  69748. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69749. /** UNSIGNED_BYTE (2nd reference) */
  69750. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69751. /** FLOAT */
  69752. static readonly TEXTURETYPE_FLOAT: number;
  69753. /** HALF_FLOAT */
  69754. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69755. /** BYTE */
  69756. static readonly TEXTURETYPE_BYTE: number;
  69757. /** SHORT */
  69758. static readonly TEXTURETYPE_SHORT: number;
  69759. /** UNSIGNED_SHORT */
  69760. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69761. /** INT */
  69762. static readonly TEXTURETYPE_INT: number;
  69763. /** UNSIGNED_INT */
  69764. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69765. /** UNSIGNED_SHORT_4_4_4_4 */
  69766. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69767. /** UNSIGNED_SHORT_5_5_5_1 */
  69768. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69769. /** UNSIGNED_SHORT_5_6_5 */
  69770. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69771. /** UNSIGNED_INT_2_10_10_10_REV */
  69772. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69773. /** UNSIGNED_INT_24_8 */
  69774. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69775. /** UNSIGNED_INT_10F_11F_11F_REV */
  69776. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69777. /** UNSIGNED_INT_5_9_9_9_REV */
  69778. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69779. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69780. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69781. /** nearest is mag = nearest and min = nearest and mip = linear */
  69782. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69783. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69784. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69785. /** Trilinear is mag = linear and min = linear and mip = linear */
  69786. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69787. /** nearest is mag = nearest and min = nearest and mip = linear */
  69788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69789. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69790. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69791. /** Trilinear is mag = linear and min = linear and mip = linear */
  69792. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69793. /** mag = nearest and min = nearest and mip = nearest */
  69794. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69795. /** mag = nearest and min = linear and mip = nearest */
  69796. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69797. /** mag = nearest and min = linear and mip = linear */
  69798. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69799. /** mag = nearest and min = linear and mip = none */
  69800. static readonly TEXTURE_NEAREST_LINEAR: number;
  69801. /** mag = nearest and min = nearest and mip = none */
  69802. static readonly TEXTURE_NEAREST_NEAREST: number;
  69803. /** mag = linear and min = nearest and mip = nearest */
  69804. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69805. /** mag = linear and min = nearest and mip = linear */
  69806. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69807. /** mag = linear and min = linear and mip = none */
  69808. static readonly TEXTURE_LINEAR_LINEAR: number;
  69809. /** mag = linear and min = nearest and mip = none */
  69810. static readonly TEXTURE_LINEAR_NEAREST: number;
  69811. /** Explicit coordinates mode */
  69812. static readonly TEXTURE_EXPLICIT_MODE: number;
  69813. /** Spherical coordinates mode */
  69814. static readonly TEXTURE_SPHERICAL_MODE: number;
  69815. /** Planar coordinates mode */
  69816. static readonly TEXTURE_PLANAR_MODE: number;
  69817. /** Cubic coordinates mode */
  69818. static readonly TEXTURE_CUBIC_MODE: number;
  69819. /** Projection coordinates mode */
  69820. static readonly TEXTURE_PROJECTION_MODE: number;
  69821. /** Skybox coordinates mode */
  69822. static readonly TEXTURE_SKYBOX_MODE: number;
  69823. /** Inverse Cubic coordinates mode */
  69824. static readonly TEXTURE_INVCUBIC_MODE: number;
  69825. /** Equirectangular coordinates mode */
  69826. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69827. /** Equirectangular Fixed coordinates mode */
  69828. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69829. /** Equirectangular Fixed Mirrored coordinates mode */
  69830. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69831. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69832. static readonly SCALEMODE_FLOOR: number;
  69833. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69834. static readonly SCALEMODE_NEAREST: number;
  69835. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69836. static readonly SCALEMODE_CEILING: number;
  69837. /**
  69838. * The dirty texture flag value
  69839. */
  69840. static readonly MATERIAL_TextureDirtyFlag: number;
  69841. /**
  69842. * The dirty light flag value
  69843. */
  69844. static readonly MATERIAL_LightDirtyFlag: number;
  69845. /**
  69846. * The dirty fresnel flag value
  69847. */
  69848. static readonly MATERIAL_FresnelDirtyFlag: number;
  69849. /**
  69850. * The dirty attribute flag value
  69851. */
  69852. static readonly MATERIAL_AttributesDirtyFlag: number;
  69853. /**
  69854. * The dirty misc flag value
  69855. */
  69856. static readonly MATERIAL_MiscDirtyFlag: number;
  69857. /**
  69858. * The all dirty flag value
  69859. */
  69860. static readonly MATERIAL_AllDirtyFlag: number;
  69861. /**
  69862. * Returns the triangle fill mode
  69863. */
  69864. static readonly MATERIAL_TriangleFillMode: number;
  69865. /**
  69866. * Returns the wireframe mode
  69867. */
  69868. static readonly MATERIAL_WireFrameFillMode: number;
  69869. /**
  69870. * Returns the point fill mode
  69871. */
  69872. static readonly MATERIAL_PointFillMode: number;
  69873. /**
  69874. * Returns the point list draw mode
  69875. */
  69876. static readonly MATERIAL_PointListDrawMode: number;
  69877. /**
  69878. * Returns the line list draw mode
  69879. */
  69880. static readonly MATERIAL_LineListDrawMode: number;
  69881. /**
  69882. * Returns the line loop draw mode
  69883. */
  69884. static readonly MATERIAL_LineLoopDrawMode: number;
  69885. /**
  69886. * Returns the line strip draw mode
  69887. */
  69888. static readonly MATERIAL_LineStripDrawMode: number;
  69889. /**
  69890. * Returns the triangle strip draw mode
  69891. */
  69892. static readonly MATERIAL_TriangleStripDrawMode: number;
  69893. /**
  69894. * Returns the triangle fan draw mode
  69895. */
  69896. static readonly MATERIAL_TriangleFanDrawMode: number;
  69897. /**
  69898. * Stores the clock-wise side orientation
  69899. */
  69900. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69901. /**
  69902. * Stores the counter clock-wise side orientation
  69903. */
  69904. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69905. /**
  69906. * Nothing
  69907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69908. */
  69909. static readonly ACTION_NothingTrigger: number;
  69910. /**
  69911. * On pick
  69912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69913. */
  69914. static readonly ACTION_OnPickTrigger: number;
  69915. /**
  69916. * On left pick
  69917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69918. */
  69919. static readonly ACTION_OnLeftPickTrigger: number;
  69920. /**
  69921. * On right pick
  69922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69923. */
  69924. static readonly ACTION_OnRightPickTrigger: number;
  69925. /**
  69926. * On center pick
  69927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69928. */
  69929. static readonly ACTION_OnCenterPickTrigger: number;
  69930. /**
  69931. * On pick down
  69932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69933. */
  69934. static readonly ACTION_OnPickDownTrigger: number;
  69935. /**
  69936. * On double pick
  69937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69938. */
  69939. static readonly ACTION_OnDoublePickTrigger: number;
  69940. /**
  69941. * On pick up
  69942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69943. */
  69944. static readonly ACTION_OnPickUpTrigger: number;
  69945. /**
  69946. * On pick out.
  69947. * This trigger will only be raised if you also declared a OnPickDown
  69948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69949. */
  69950. static readonly ACTION_OnPickOutTrigger: number;
  69951. /**
  69952. * On long press
  69953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69954. */
  69955. static readonly ACTION_OnLongPressTrigger: number;
  69956. /**
  69957. * On pointer over
  69958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69959. */
  69960. static readonly ACTION_OnPointerOverTrigger: number;
  69961. /**
  69962. * On pointer out
  69963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69964. */
  69965. static readonly ACTION_OnPointerOutTrigger: number;
  69966. /**
  69967. * On every frame
  69968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69969. */
  69970. static readonly ACTION_OnEveryFrameTrigger: number;
  69971. /**
  69972. * On intersection enter
  69973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69974. */
  69975. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69976. /**
  69977. * On intersection exit
  69978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69979. */
  69980. static readonly ACTION_OnIntersectionExitTrigger: number;
  69981. /**
  69982. * On key down
  69983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69984. */
  69985. static readonly ACTION_OnKeyDownTrigger: number;
  69986. /**
  69987. * On key up
  69988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69989. */
  69990. static readonly ACTION_OnKeyUpTrigger: number;
  69991. /**
  69992. * Billboard mode will only apply to Y axis
  69993. */
  69994. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69995. /**
  69996. * Billboard mode will apply to all axes
  69997. */
  69998. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69999. /**
  70000. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70001. */
  70002. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70003. /**
  70004. * Gets or sets base Assets URL
  70005. */
  70006. static PARTICLES_BaseAssetsUrl: string;
  70007. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70008. * Test order :
  70009. * Is the bounding sphere outside the frustum ?
  70010. * If not, are the bounding box vertices outside the frustum ?
  70011. * It not, then the cullable object is in the frustum.
  70012. */
  70013. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70014. /** Culling strategy : Bounding Sphere Only.
  70015. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70016. * It's also less accurate than the standard because some not visible objects can still be selected.
  70017. * Test : is the bounding sphere outside the frustum ?
  70018. * If not, then the cullable object is in the frustum.
  70019. */
  70020. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70021. /** Culling strategy : Optimistic Inclusion.
  70022. * This in an inclusion test first, then the standard exclusion test.
  70023. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70024. * 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.
  70025. * Anyway, it's as accurate as the standard strategy.
  70026. * Test :
  70027. * Is the cullable object bounding sphere center in the frustum ?
  70028. * If not, apply the default culling strategy.
  70029. */
  70030. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70031. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70032. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70033. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70034. * 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.
  70035. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70036. * Test :
  70037. * Is the cullable object bounding sphere center in the frustum ?
  70038. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70039. */
  70040. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70041. /**
  70042. * No logging while loading
  70043. */
  70044. static readonly SCENELOADER_NO_LOGGING: number;
  70045. /**
  70046. * Minimal logging while loading
  70047. */
  70048. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70049. /**
  70050. * Summary logging while loading
  70051. */
  70052. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70053. /**
  70054. * Detailled logging while loading
  70055. */
  70056. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70057. }
  70058. }
  70059. declare module BABYLON {
  70060. /**
  70061. * Class used to store and describe the pipeline context associated with an effect
  70062. */
  70063. export interface IPipelineContext {
  70064. /**
  70065. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70066. */
  70067. isAsync: boolean;
  70068. /**
  70069. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70070. */
  70071. isReady: boolean;
  70072. /** @hidden */
  70073. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70074. }
  70075. }
  70076. declare module BABYLON {
  70077. /** @hidden */
  70078. export interface IShaderProcessor {
  70079. attributeProcessor?: (attribute: string) => string;
  70080. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70081. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70082. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70083. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70084. lineProcessor?: (line: string, isFragment: boolean) => string;
  70085. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70086. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70087. }
  70088. }
  70089. declare module BABYLON {
  70090. /** @hidden */
  70091. export interface ProcessingOptions {
  70092. defines: string[];
  70093. indexParameters: any;
  70094. isFragment: boolean;
  70095. shouldUseHighPrecisionShader: boolean;
  70096. supportsUniformBuffers: boolean;
  70097. shadersRepository: string;
  70098. includesShadersStore: {
  70099. [key: string]: string;
  70100. };
  70101. processor?: IShaderProcessor;
  70102. version: string;
  70103. platformName: string;
  70104. lookForClosingBracketForUniformBuffer?: boolean;
  70105. }
  70106. }
  70107. declare module BABYLON {
  70108. /**
  70109. * Helper to manipulate strings
  70110. */
  70111. export class StringTools {
  70112. /**
  70113. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70114. * @param str Source string
  70115. * @param suffix Suffix to search for in the source string
  70116. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70117. */
  70118. static EndsWith(str: string, suffix: string): boolean;
  70119. /**
  70120. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70121. * @param str Source string
  70122. * @param suffix Suffix to search for in the source string
  70123. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70124. */
  70125. static StartsWith(str: string, suffix: string): boolean;
  70126. }
  70127. }
  70128. declare module BABYLON {
  70129. /** @hidden */
  70130. export class ShaderCodeNode {
  70131. line: string;
  70132. children: ShaderCodeNode[];
  70133. additionalDefineKey?: string;
  70134. additionalDefineValue?: string;
  70135. isValid(preprocessors: {
  70136. [key: string]: string;
  70137. }): boolean;
  70138. process(preprocessors: {
  70139. [key: string]: string;
  70140. }, options: ProcessingOptions): string;
  70141. }
  70142. }
  70143. declare module BABYLON {
  70144. /** @hidden */
  70145. export class ShaderCodeCursor {
  70146. private _lines;
  70147. lineIndex: number;
  70148. readonly currentLine: string;
  70149. readonly canRead: boolean;
  70150. lines: string[];
  70151. }
  70152. }
  70153. declare module BABYLON {
  70154. /** @hidden */
  70155. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70156. process(preprocessors: {
  70157. [key: string]: string;
  70158. }, options: ProcessingOptions): string;
  70159. }
  70160. }
  70161. declare module BABYLON {
  70162. /** @hidden */
  70163. export class ShaderDefineExpression {
  70164. isTrue(preprocessors: {
  70165. [key: string]: string;
  70166. }): boolean;
  70167. }
  70168. }
  70169. declare module BABYLON {
  70170. /** @hidden */
  70171. export class ShaderCodeTestNode extends ShaderCodeNode {
  70172. testExpression: ShaderDefineExpression;
  70173. isValid(preprocessors: {
  70174. [key: string]: string;
  70175. }): boolean;
  70176. }
  70177. }
  70178. declare module BABYLON {
  70179. /** @hidden */
  70180. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70181. define: string;
  70182. not: boolean;
  70183. constructor(define: string, not?: boolean);
  70184. isTrue(preprocessors: {
  70185. [key: string]: string;
  70186. }): boolean;
  70187. }
  70188. }
  70189. declare module BABYLON {
  70190. /** @hidden */
  70191. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70192. leftOperand: ShaderDefineExpression;
  70193. rightOperand: ShaderDefineExpression;
  70194. isTrue(preprocessors: {
  70195. [key: string]: string;
  70196. }): boolean;
  70197. }
  70198. }
  70199. declare module BABYLON {
  70200. /** @hidden */
  70201. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70202. leftOperand: ShaderDefineExpression;
  70203. rightOperand: ShaderDefineExpression;
  70204. isTrue(preprocessors: {
  70205. [key: string]: string;
  70206. }): boolean;
  70207. }
  70208. }
  70209. declare module BABYLON {
  70210. /** @hidden */
  70211. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70212. define: string;
  70213. operand: string;
  70214. testValue: string;
  70215. constructor(define: string, operand: string, testValue: string);
  70216. isTrue(preprocessors: {
  70217. [key: string]: string;
  70218. }): boolean;
  70219. }
  70220. }
  70221. declare module BABYLON {
  70222. /**
  70223. * @ignore
  70224. * Application error to support additional information when loading a file
  70225. */
  70226. export class LoadFileError extends Error {
  70227. /** defines the optional web request */
  70228. request?: WebRequest | undefined;
  70229. private static _setPrototypeOf;
  70230. /**
  70231. * Creates a new LoadFileError
  70232. * @param message defines the message of the error
  70233. * @param request defines the optional web request
  70234. */
  70235. constructor(message: string,
  70236. /** defines the optional web request */
  70237. request?: WebRequest | undefined);
  70238. }
  70239. }
  70240. declare module BABYLON {
  70241. /**
  70242. * Class used to enable access to offline support
  70243. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70244. */
  70245. export interface IOfflineProvider {
  70246. /**
  70247. * Gets a boolean indicating if scene must be saved in the database
  70248. */
  70249. enableSceneOffline: boolean;
  70250. /**
  70251. * Gets a boolean indicating if textures must be saved in the database
  70252. */
  70253. enableTexturesOffline: boolean;
  70254. /**
  70255. * Open the offline support and make it available
  70256. * @param successCallback defines the callback to call on success
  70257. * @param errorCallback defines the callback to call on error
  70258. */
  70259. open(successCallback: () => void, errorCallback: () => void): void;
  70260. /**
  70261. * Loads an image from the offline support
  70262. * @param url defines the url to load from
  70263. * @param image defines the target DOM image
  70264. */
  70265. loadImage(url: string, image: HTMLImageElement): void;
  70266. /**
  70267. * Loads a file from offline support
  70268. * @param url defines the URL to load from
  70269. * @param sceneLoaded defines a callback to call on success
  70270. * @param progressCallBack defines a callback to call when progress changed
  70271. * @param errorCallback defines a callback to call on error
  70272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70273. */
  70274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70275. }
  70276. }
  70277. declare module BABYLON {
  70278. /**
  70279. * Class used to help managing file picking and drag'n'drop
  70280. * File Storage
  70281. */
  70282. export class FilesInputStore {
  70283. /**
  70284. * List of files ready to be loaded
  70285. */
  70286. static FilesToLoad: {
  70287. [key: string]: File;
  70288. };
  70289. }
  70290. }
  70291. declare module BABYLON {
  70292. /**
  70293. * Class used to define a retry strategy when error happens while loading assets
  70294. */
  70295. export class RetryStrategy {
  70296. /**
  70297. * Function used to defines an exponential back off strategy
  70298. * @param maxRetries defines the maximum number of retries (3 by default)
  70299. * @param baseInterval defines the interval between retries
  70300. * @returns the strategy function to use
  70301. */
  70302. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70303. }
  70304. }
  70305. declare module BABYLON {
  70306. /**
  70307. * @hidden
  70308. */
  70309. export class FileTools {
  70310. /**
  70311. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70312. */
  70313. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70314. /**
  70315. * Gets or sets the base URL to use to load assets
  70316. */
  70317. static BaseUrl: string;
  70318. /**
  70319. * Default behaviour for cors in the application.
  70320. * It can be a string if the expected behavior is identical in the entire app.
  70321. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70322. */
  70323. static CorsBehavior: string | ((url: string | string[]) => string);
  70324. /**
  70325. * Gets or sets a function used to pre-process url before using them to load assets
  70326. */
  70327. static PreprocessUrl: (url: string) => string;
  70328. /**
  70329. * Removes unwanted characters from an url
  70330. * @param url defines the url to clean
  70331. * @returns the cleaned url
  70332. */
  70333. private static _CleanUrl;
  70334. /**
  70335. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70336. * @param url define the url we are trying
  70337. * @param element define the dom element where to configure the cors policy
  70338. */
  70339. static SetCorsBehavior(url: string | string[], element: {
  70340. crossOrigin: string | null;
  70341. }): void;
  70342. /**
  70343. * Loads an image as an HTMLImageElement.
  70344. * @param input url string, ArrayBuffer, or Blob to load
  70345. * @param onLoad callback called when the image successfully loads
  70346. * @param onError callback called when the image fails to load
  70347. * @param offlineProvider offline provider for caching
  70348. * @returns the HTMLImageElement of the loaded image
  70349. */
  70350. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70351. /**
  70352. * Loads a file
  70353. * @param fileToLoad defines the file to load
  70354. * @param callback defines the callback to call when data is loaded
  70355. * @param progressCallBack defines the callback to call during loading process
  70356. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70357. * @returns a file request object
  70358. */
  70359. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70360. /**
  70361. * Loads a file
  70362. * @param url url string, ArrayBuffer, or Blob to load
  70363. * @param onSuccess callback called when the file successfully loads
  70364. * @param onProgress callback called while file is loading (if the server supports this mode)
  70365. * @param offlineProvider defines the offline provider for caching
  70366. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70367. * @param onError callback called when the file fails to load
  70368. * @returns a file request object
  70369. */
  70370. 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;
  70371. /**
  70372. * Checks if the loaded document was accessed via `file:`-Protocol.
  70373. * @returns boolean
  70374. */
  70375. static IsFileURL(): boolean;
  70376. }
  70377. }
  70378. declare module BABYLON {
  70379. /** @hidden */
  70380. export class ShaderProcessor {
  70381. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70382. private static _ProcessPrecision;
  70383. private static _ExtractOperation;
  70384. private static _BuildSubExpression;
  70385. private static _BuildExpression;
  70386. private static _MoveCursorWithinIf;
  70387. private static _MoveCursor;
  70388. private static _EvaluatePreProcessors;
  70389. private static _PreparePreProcessors;
  70390. private static _ProcessShaderConversion;
  70391. private static _ProcessIncludes;
  70392. }
  70393. }
  70394. declare module BABYLON {
  70395. /**
  70396. * Class used to hold a RBG color
  70397. */
  70398. export class Color3 {
  70399. /**
  70400. * Defines the red component (between 0 and 1, default is 0)
  70401. */
  70402. r: number;
  70403. /**
  70404. * Defines the green component (between 0 and 1, default is 0)
  70405. */
  70406. g: number;
  70407. /**
  70408. * Defines the blue component (between 0 and 1, default is 0)
  70409. */
  70410. b: number;
  70411. /**
  70412. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70413. * @param r defines the red component (between 0 and 1, default is 0)
  70414. * @param g defines the green component (between 0 and 1, default is 0)
  70415. * @param b defines the blue component (between 0 and 1, default is 0)
  70416. */
  70417. constructor(
  70418. /**
  70419. * Defines the red component (between 0 and 1, default is 0)
  70420. */
  70421. r?: number,
  70422. /**
  70423. * Defines the green component (between 0 and 1, default is 0)
  70424. */
  70425. g?: number,
  70426. /**
  70427. * Defines the blue component (between 0 and 1, default is 0)
  70428. */
  70429. b?: number);
  70430. /**
  70431. * Creates a string with the Color3 current values
  70432. * @returns the string representation of the Color3 object
  70433. */
  70434. toString(): string;
  70435. /**
  70436. * Returns the string "Color3"
  70437. * @returns "Color3"
  70438. */
  70439. getClassName(): string;
  70440. /**
  70441. * Compute the Color3 hash code
  70442. * @returns an unique number that can be used to hash Color3 objects
  70443. */
  70444. getHashCode(): number;
  70445. /**
  70446. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70447. * @param array defines the array where to store the r,g,b components
  70448. * @param index defines an optional index in the target array to define where to start storing values
  70449. * @returns the current Color3 object
  70450. */
  70451. toArray(array: FloatArray, index?: number): Color3;
  70452. /**
  70453. * Returns a new Color4 object from the current Color3 and the given alpha
  70454. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70455. * @returns a new Color4 object
  70456. */
  70457. toColor4(alpha?: number): Color4;
  70458. /**
  70459. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70460. * @returns the new array
  70461. */
  70462. asArray(): number[];
  70463. /**
  70464. * Returns the luminance value
  70465. * @returns a float value
  70466. */
  70467. toLuminance(): number;
  70468. /**
  70469. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70470. * @param otherColor defines the second operand
  70471. * @returns the new Color3 object
  70472. */
  70473. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70474. /**
  70475. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70476. * @param otherColor defines the second operand
  70477. * @param result defines the Color3 object where to store the result
  70478. * @returns the current Color3
  70479. */
  70480. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70481. /**
  70482. * Determines equality between Color3 objects
  70483. * @param otherColor defines the second operand
  70484. * @returns true if the rgb values are equal to the given ones
  70485. */
  70486. equals(otherColor: DeepImmutable<Color3>): boolean;
  70487. /**
  70488. * Determines equality between the current Color3 object and a set of r,b,g values
  70489. * @param r defines the red component to check
  70490. * @param g defines the green component to check
  70491. * @param b defines the blue component to check
  70492. * @returns true if the rgb values are equal to the given ones
  70493. */
  70494. equalsFloats(r: number, g: number, b: number): boolean;
  70495. /**
  70496. * Multiplies in place each rgb value by scale
  70497. * @param scale defines the scaling factor
  70498. * @returns the updated Color3
  70499. */
  70500. scale(scale: number): Color3;
  70501. /**
  70502. * Multiplies the rgb values by scale and stores the result into "result"
  70503. * @param scale defines the scaling factor
  70504. * @param result defines the Color3 object where to store the result
  70505. * @returns the unmodified current Color3
  70506. */
  70507. scaleToRef(scale: number, result: Color3): Color3;
  70508. /**
  70509. * Scale the current Color3 values by a factor and add the result to a given Color3
  70510. * @param scale defines the scale factor
  70511. * @param result defines color to store the result into
  70512. * @returns the unmodified current Color3
  70513. */
  70514. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70515. /**
  70516. * Clamps the rgb values by the min and max values and stores the result into "result"
  70517. * @param min defines minimum clamping value (default is 0)
  70518. * @param max defines maximum clamping value (default is 1)
  70519. * @param result defines color to store the result into
  70520. * @returns the original Color3
  70521. */
  70522. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70523. /**
  70524. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70525. * @param otherColor defines the second operand
  70526. * @returns the new Color3
  70527. */
  70528. add(otherColor: DeepImmutable<Color3>): Color3;
  70529. /**
  70530. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70531. * @param otherColor defines the second operand
  70532. * @param result defines Color3 object to store the result into
  70533. * @returns the unmodified current Color3
  70534. */
  70535. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70536. /**
  70537. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70538. * @param otherColor defines the second operand
  70539. * @returns the new Color3
  70540. */
  70541. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70542. /**
  70543. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70544. * @param otherColor defines the second operand
  70545. * @param result defines Color3 object to store the result into
  70546. * @returns the unmodified current Color3
  70547. */
  70548. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70549. /**
  70550. * Copy the current object
  70551. * @returns a new Color3 copied the current one
  70552. */
  70553. clone(): Color3;
  70554. /**
  70555. * Copies the rgb values from the source in the current Color3
  70556. * @param source defines the source Color3 object
  70557. * @returns the updated Color3 object
  70558. */
  70559. copyFrom(source: DeepImmutable<Color3>): Color3;
  70560. /**
  70561. * Updates the Color3 rgb values from the given floats
  70562. * @param r defines the red component to read from
  70563. * @param g defines the green component to read from
  70564. * @param b defines the blue component to read from
  70565. * @returns the current Color3 object
  70566. */
  70567. copyFromFloats(r: number, g: number, b: number): Color3;
  70568. /**
  70569. * Updates the Color3 rgb values from the given floats
  70570. * @param r defines the red component to read from
  70571. * @param g defines the green component to read from
  70572. * @param b defines the blue component to read from
  70573. * @returns the current Color3 object
  70574. */
  70575. set(r: number, g: number, b: number): Color3;
  70576. /**
  70577. * Compute the Color3 hexadecimal code as a string
  70578. * @returns a string containing the hexadecimal representation of the Color3 object
  70579. */
  70580. toHexString(): string;
  70581. /**
  70582. * Computes a new Color3 converted from the current one to linear space
  70583. * @returns a new Color3 object
  70584. */
  70585. toLinearSpace(): Color3;
  70586. /**
  70587. * Converts current color in rgb space to HSV values
  70588. * @returns a new color3 representing the HSV values
  70589. */
  70590. toHSV(): Color3;
  70591. /**
  70592. * Converts current color in rgb space to HSV values
  70593. * @param result defines the Color3 where to store the HSV values
  70594. */
  70595. toHSVToRef(result: Color3): void;
  70596. /**
  70597. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70598. * @param convertedColor defines the Color3 object where to store the linear space version
  70599. * @returns the unmodified Color3
  70600. */
  70601. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70602. /**
  70603. * Computes a new Color3 converted from the current one to gamma space
  70604. * @returns a new Color3 object
  70605. */
  70606. toGammaSpace(): Color3;
  70607. /**
  70608. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70609. * @param convertedColor defines the Color3 object where to store the gamma space version
  70610. * @returns the unmodified Color3
  70611. */
  70612. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70613. private static _BlackReadOnly;
  70614. /**
  70615. * Convert Hue, saturation and value to a Color3 (RGB)
  70616. * @param hue defines the hue
  70617. * @param saturation defines the saturation
  70618. * @param value defines the value
  70619. * @param result defines the Color3 where to store the RGB values
  70620. */
  70621. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70622. /**
  70623. * Creates a new Color3 from the string containing valid hexadecimal values
  70624. * @param hex defines a string containing valid hexadecimal values
  70625. * @returns a new Color3 object
  70626. */
  70627. static FromHexString(hex: string): Color3;
  70628. /**
  70629. * Creates a new Color3 from the starting index of the given array
  70630. * @param array defines the source array
  70631. * @param offset defines an offset in the source array
  70632. * @returns a new Color3 object
  70633. */
  70634. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70635. /**
  70636. * Creates a new Color3 from integer values (< 256)
  70637. * @param r defines the red component to read from (value between 0 and 255)
  70638. * @param g defines the green component to read from (value between 0 and 255)
  70639. * @param b defines the blue component to read from (value between 0 and 255)
  70640. * @returns a new Color3 object
  70641. */
  70642. static FromInts(r: number, g: number, b: number): Color3;
  70643. /**
  70644. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70645. * @param start defines the start Color3 value
  70646. * @param end defines the end Color3 value
  70647. * @param amount defines the gradient value between start and end
  70648. * @returns a new Color3 object
  70649. */
  70650. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70651. /**
  70652. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70653. * @param left defines the start value
  70654. * @param right defines the end value
  70655. * @param amount defines the gradient factor
  70656. * @param result defines the Color3 object where to store the result
  70657. */
  70658. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70659. /**
  70660. * Returns a Color3 value containing a red color
  70661. * @returns a new Color3 object
  70662. */
  70663. static Red(): Color3;
  70664. /**
  70665. * Returns a Color3 value containing a green color
  70666. * @returns a new Color3 object
  70667. */
  70668. static Green(): Color3;
  70669. /**
  70670. * Returns a Color3 value containing a blue color
  70671. * @returns a new Color3 object
  70672. */
  70673. static Blue(): Color3;
  70674. /**
  70675. * Returns a Color3 value containing a black color
  70676. * @returns a new Color3 object
  70677. */
  70678. static Black(): Color3;
  70679. /**
  70680. * Gets a Color3 value containing a black color that must not be updated
  70681. */
  70682. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70683. /**
  70684. * Returns a Color3 value containing a white color
  70685. * @returns a new Color3 object
  70686. */
  70687. static White(): Color3;
  70688. /**
  70689. * Returns a Color3 value containing a purple color
  70690. * @returns a new Color3 object
  70691. */
  70692. static Purple(): Color3;
  70693. /**
  70694. * Returns a Color3 value containing a magenta color
  70695. * @returns a new Color3 object
  70696. */
  70697. static Magenta(): Color3;
  70698. /**
  70699. * Returns a Color3 value containing a yellow color
  70700. * @returns a new Color3 object
  70701. */
  70702. static Yellow(): Color3;
  70703. /**
  70704. * Returns a Color3 value containing a gray color
  70705. * @returns a new Color3 object
  70706. */
  70707. static Gray(): Color3;
  70708. /**
  70709. * Returns a Color3 value containing a teal color
  70710. * @returns a new Color3 object
  70711. */
  70712. static Teal(): Color3;
  70713. /**
  70714. * Returns a Color3 value containing a random color
  70715. * @returns a new Color3 object
  70716. */
  70717. static Random(): Color3;
  70718. }
  70719. /**
  70720. * Class used to hold a RBGA color
  70721. */
  70722. export class Color4 {
  70723. /**
  70724. * Defines the red component (between 0 and 1, default is 0)
  70725. */
  70726. r: number;
  70727. /**
  70728. * Defines the green component (between 0 and 1, default is 0)
  70729. */
  70730. g: number;
  70731. /**
  70732. * Defines the blue component (between 0 and 1, default is 0)
  70733. */
  70734. b: number;
  70735. /**
  70736. * Defines the alpha component (between 0 and 1, default is 1)
  70737. */
  70738. a: number;
  70739. /**
  70740. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70741. * @param r defines the red component (between 0 and 1, default is 0)
  70742. * @param g defines the green component (between 0 and 1, default is 0)
  70743. * @param b defines the blue component (between 0 and 1, default is 0)
  70744. * @param a defines the alpha component (between 0 and 1, default is 1)
  70745. */
  70746. constructor(
  70747. /**
  70748. * Defines the red component (between 0 and 1, default is 0)
  70749. */
  70750. r?: number,
  70751. /**
  70752. * Defines the green component (between 0 and 1, default is 0)
  70753. */
  70754. g?: number,
  70755. /**
  70756. * Defines the blue component (between 0 and 1, default is 0)
  70757. */
  70758. b?: number,
  70759. /**
  70760. * Defines the alpha component (between 0 and 1, default is 1)
  70761. */
  70762. a?: number);
  70763. /**
  70764. * Adds in place the given Color4 values to the current Color4 object
  70765. * @param right defines the second operand
  70766. * @returns the current updated Color4 object
  70767. */
  70768. addInPlace(right: DeepImmutable<Color4>): Color4;
  70769. /**
  70770. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70771. * @returns the new array
  70772. */
  70773. asArray(): number[];
  70774. /**
  70775. * Stores from the starting index in the given array the Color4 successive values
  70776. * @param array defines the array where to store the r,g,b components
  70777. * @param index defines an optional index in the target array to define where to start storing values
  70778. * @returns the current Color4 object
  70779. */
  70780. toArray(array: number[], index?: number): Color4;
  70781. /**
  70782. * Determines equality between Color4 objects
  70783. * @param otherColor defines the second operand
  70784. * @returns true if the rgba values are equal to the given ones
  70785. */
  70786. equals(otherColor: DeepImmutable<Color4>): boolean;
  70787. /**
  70788. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70789. * @param right defines the second operand
  70790. * @returns a new Color4 object
  70791. */
  70792. add(right: DeepImmutable<Color4>): Color4;
  70793. /**
  70794. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70795. * @param right defines the second operand
  70796. * @returns a new Color4 object
  70797. */
  70798. subtract(right: DeepImmutable<Color4>): Color4;
  70799. /**
  70800. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70801. * @param right defines the second operand
  70802. * @param result defines the Color4 object where to store the result
  70803. * @returns the current Color4 object
  70804. */
  70805. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70806. /**
  70807. * Creates a new Color4 with the current Color4 values multiplied by scale
  70808. * @param scale defines the scaling factor to apply
  70809. * @returns a new Color4 object
  70810. */
  70811. scale(scale: number): Color4;
  70812. /**
  70813. * Multiplies the current Color4 values by scale and stores the result in "result"
  70814. * @param scale defines the scaling factor to apply
  70815. * @param result defines the Color4 object where to store the result
  70816. * @returns the current unmodified Color4
  70817. */
  70818. scaleToRef(scale: number, result: Color4): Color4;
  70819. /**
  70820. * Scale the current Color4 values by a factor and add the result to a given Color4
  70821. * @param scale defines the scale factor
  70822. * @param result defines the Color4 object where to store the result
  70823. * @returns the unmodified current Color4
  70824. */
  70825. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70826. /**
  70827. * Clamps the rgb values by the min and max values and stores the result into "result"
  70828. * @param min defines minimum clamping value (default is 0)
  70829. * @param max defines maximum clamping value (default is 1)
  70830. * @param result defines color to store the result into.
  70831. * @returns the cuurent Color4
  70832. */
  70833. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70834. /**
  70835. * Multipy an Color4 value by another and return a new Color4 object
  70836. * @param color defines the Color4 value to multiply by
  70837. * @returns a new Color4 object
  70838. */
  70839. multiply(color: Color4): Color4;
  70840. /**
  70841. * Multipy a Color4 value by another and push the result in a reference value
  70842. * @param color defines the Color4 value to multiply by
  70843. * @param result defines the Color4 to fill the result in
  70844. * @returns the result Color4
  70845. */
  70846. multiplyToRef(color: Color4, result: Color4): Color4;
  70847. /**
  70848. * Creates a string with the Color4 current values
  70849. * @returns the string representation of the Color4 object
  70850. */
  70851. toString(): string;
  70852. /**
  70853. * Returns the string "Color4"
  70854. * @returns "Color4"
  70855. */
  70856. getClassName(): string;
  70857. /**
  70858. * Compute the Color4 hash code
  70859. * @returns an unique number that can be used to hash Color4 objects
  70860. */
  70861. getHashCode(): number;
  70862. /**
  70863. * Creates a new Color4 copied from the current one
  70864. * @returns a new Color4 object
  70865. */
  70866. clone(): Color4;
  70867. /**
  70868. * Copies the given Color4 values into the current one
  70869. * @param source defines the source Color4 object
  70870. * @returns the current updated Color4 object
  70871. */
  70872. copyFrom(source: Color4): Color4;
  70873. /**
  70874. * Copies the given float values into the current one
  70875. * @param r defines the red component to read from
  70876. * @param g defines the green component to read from
  70877. * @param b defines the blue component to read from
  70878. * @param a defines the alpha component to read from
  70879. * @returns the current updated Color4 object
  70880. */
  70881. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70882. /**
  70883. * Copies the given float values into the current one
  70884. * @param r defines the red component to read from
  70885. * @param g defines the green component to read from
  70886. * @param b defines the blue component to read from
  70887. * @param a defines the alpha component to read from
  70888. * @returns the current updated Color4 object
  70889. */
  70890. set(r: number, g: number, b: number, a: number): Color4;
  70891. /**
  70892. * Compute the Color4 hexadecimal code as a string
  70893. * @returns a string containing the hexadecimal representation of the Color4 object
  70894. */
  70895. toHexString(): string;
  70896. /**
  70897. * Computes a new Color4 converted from the current one to linear space
  70898. * @returns a new Color4 object
  70899. */
  70900. toLinearSpace(): Color4;
  70901. /**
  70902. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70903. * @param convertedColor defines the Color4 object where to store the linear space version
  70904. * @returns the unmodified Color4
  70905. */
  70906. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70907. /**
  70908. * Computes a new Color4 converted from the current one to gamma space
  70909. * @returns a new Color4 object
  70910. */
  70911. toGammaSpace(): Color4;
  70912. /**
  70913. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70914. * @param convertedColor defines the Color4 object where to store the gamma space version
  70915. * @returns the unmodified Color4
  70916. */
  70917. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70918. /**
  70919. * Creates a new Color4 from the string containing valid hexadecimal values
  70920. * @param hex defines a string containing valid hexadecimal values
  70921. * @returns a new Color4 object
  70922. */
  70923. static FromHexString(hex: string): Color4;
  70924. /**
  70925. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70926. * @param left defines the start value
  70927. * @param right defines the end value
  70928. * @param amount defines the gradient factor
  70929. * @returns a new Color4 object
  70930. */
  70931. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70932. /**
  70933. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70934. * @param left defines the start value
  70935. * @param right defines the end value
  70936. * @param amount defines the gradient factor
  70937. * @param result defines the Color4 object where to store data
  70938. */
  70939. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70940. /**
  70941. * Creates a new Color4 from a Color3 and an alpha value
  70942. * @param color3 defines the source Color3 to read from
  70943. * @param alpha defines the alpha component (1.0 by default)
  70944. * @returns a new Color4 object
  70945. */
  70946. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70947. /**
  70948. * Creates a new Color4 from the starting index element of the given array
  70949. * @param array defines the source array to read from
  70950. * @param offset defines the offset in the source array
  70951. * @returns a new Color4 object
  70952. */
  70953. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70954. /**
  70955. * Creates a new Color3 from integer values (< 256)
  70956. * @param r defines the red component to read from (value between 0 and 255)
  70957. * @param g defines the green component to read from (value between 0 and 255)
  70958. * @param b defines the blue component to read from (value between 0 and 255)
  70959. * @param a defines the alpha component to read from (value between 0 and 255)
  70960. * @returns a new Color3 object
  70961. */
  70962. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70963. /**
  70964. * Check the content of a given array and convert it to an array containing RGBA data
  70965. * If the original array was already containing count * 4 values then it is returned directly
  70966. * @param colors defines the array to check
  70967. * @param count defines the number of RGBA data to expect
  70968. * @returns an array containing count * 4 values (RGBA)
  70969. */
  70970. static CheckColors4(colors: number[], count: number): number[];
  70971. }
  70972. /**
  70973. * @hidden
  70974. */
  70975. export class TmpColors {
  70976. static Color3: Color3[];
  70977. static Color4: Color4[];
  70978. }
  70979. }
  70980. declare module BABYLON {
  70981. /**
  70982. * Class representing spherical harmonics coefficients to the 3rd degree
  70983. */
  70984. export class SphericalHarmonics {
  70985. /**
  70986. * Defines whether or not the harmonics have been prescaled for rendering.
  70987. */
  70988. preScaled: boolean;
  70989. /**
  70990. * The l0,0 coefficients of the spherical harmonics
  70991. */
  70992. l00: Vector3;
  70993. /**
  70994. * The l1,-1 coefficients of the spherical harmonics
  70995. */
  70996. l1_1: Vector3;
  70997. /**
  70998. * The l1,0 coefficients of the spherical harmonics
  70999. */
  71000. l10: Vector3;
  71001. /**
  71002. * The l1,1 coefficients of the spherical harmonics
  71003. */
  71004. l11: Vector3;
  71005. /**
  71006. * The l2,-2 coefficients of the spherical harmonics
  71007. */
  71008. l2_2: Vector3;
  71009. /**
  71010. * The l2,-1 coefficients of the spherical harmonics
  71011. */
  71012. l2_1: Vector3;
  71013. /**
  71014. * The l2,0 coefficients of the spherical harmonics
  71015. */
  71016. l20: Vector3;
  71017. /**
  71018. * The l2,1 coefficients of the spherical harmonics
  71019. */
  71020. l21: Vector3;
  71021. /**
  71022. * The l2,2 coefficients of the spherical harmonics
  71023. */
  71024. l22: Vector3;
  71025. /**
  71026. * Adds a light to the spherical harmonics
  71027. * @param direction the direction of the light
  71028. * @param color the color of the light
  71029. * @param deltaSolidAngle the delta solid angle of the light
  71030. */
  71031. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71032. /**
  71033. * Scales the spherical harmonics by the given amount
  71034. * @param scale the amount to scale
  71035. */
  71036. scaleInPlace(scale: number): void;
  71037. /**
  71038. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71039. *
  71040. * ```
  71041. * E_lm = A_l * L_lm
  71042. * ```
  71043. *
  71044. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71045. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71046. * the scaling factors are given in equation 9.
  71047. */
  71048. convertIncidentRadianceToIrradiance(): void;
  71049. /**
  71050. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71051. *
  71052. * ```
  71053. * L = (1/pi) * E * rho
  71054. * ```
  71055. *
  71056. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71057. */
  71058. convertIrradianceToLambertianRadiance(): void;
  71059. /**
  71060. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71061. * required operations at run time.
  71062. *
  71063. * This is simply done by scaling back the SH with Ylm constants parameter.
  71064. * The trigonometric part being applied by the shader at run time.
  71065. */
  71066. preScaleForRendering(): void;
  71067. /**
  71068. * Constructs a spherical harmonics from an array.
  71069. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71070. * @returns the spherical harmonics
  71071. */
  71072. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71073. /**
  71074. * Gets the spherical harmonics from polynomial
  71075. * @param polynomial the spherical polynomial
  71076. * @returns the spherical harmonics
  71077. */
  71078. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71079. }
  71080. /**
  71081. * Class representing spherical polynomial coefficients to the 3rd degree
  71082. */
  71083. export class SphericalPolynomial {
  71084. private _harmonics;
  71085. /**
  71086. * The spherical harmonics used to create the polynomials.
  71087. */
  71088. readonly preScaledHarmonics: SphericalHarmonics;
  71089. /**
  71090. * The x coefficients of the spherical polynomial
  71091. */
  71092. x: Vector3;
  71093. /**
  71094. * The y coefficients of the spherical polynomial
  71095. */
  71096. y: Vector3;
  71097. /**
  71098. * The z coefficients of the spherical polynomial
  71099. */
  71100. z: Vector3;
  71101. /**
  71102. * The xx coefficients of the spherical polynomial
  71103. */
  71104. xx: Vector3;
  71105. /**
  71106. * The yy coefficients of the spherical polynomial
  71107. */
  71108. yy: Vector3;
  71109. /**
  71110. * The zz coefficients of the spherical polynomial
  71111. */
  71112. zz: Vector3;
  71113. /**
  71114. * The xy coefficients of the spherical polynomial
  71115. */
  71116. xy: Vector3;
  71117. /**
  71118. * The yz coefficients of the spherical polynomial
  71119. */
  71120. yz: Vector3;
  71121. /**
  71122. * The zx coefficients of the spherical polynomial
  71123. */
  71124. zx: Vector3;
  71125. /**
  71126. * Adds an ambient color to the spherical polynomial
  71127. * @param color the color to add
  71128. */
  71129. addAmbient(color: Color3): void;
  71130. /**
  71131. * Scales the spherical polynomial by the given amount
  71132. * @param scale the amount to scale
  71133. */
  71134. scaleInPlace(scale: number): void;
  71135. /**
  71136. * Gets the spherical polynomial from harmonics
  71137. * @param harmonics the spherical harmonics
  71138. * @returns the spherical polynomial
  71139. */
  71140. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71141. /**
  71142. * Constructs a spherical polynomial from an array.
  71143. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71144. * @returns the spherical polynomial
  71145. */
  71146. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71147. }
  71148. }
  71149. declare module BABYLON {
  71150. /**
  71151. * Define options used to create a render target texture
  71152. */
  71153. export class RenderTargetCreationOptions {
  71154. /**
  71155. * Specifies is mipmaps must be generated
  71156. */
  71157. generateMipMaps?: boolean;
  71158. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71159. generateDepthBuffer?: boolean;
  71160. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71161. generateStencilBuffer?: boolean;
  71162. /** Defines texture type (int by default) */
  71163. type?: number;
  71164. /** Defines sampling mode (trilinear by default) */
  71165. samplingMode?: number;
  71166. /** Defines format (RGBA by default) */
  71167. format?: number;
  71168. }
  71169. }
  71170. declare module BABYLON {
  71171. /**
  71172. * @hidden
  71173. **/
  71174. export class _AlphaState {
  71175. private _isAlphaBlendDirty;
  71176. private _isBlendFunctionParametersDirty;
  71177. private _isBlendEquationParametersDirty;
  71178. private _isBlendConstantsDirty;
  71179. private _alphaBlend;
  71180. private _blendFunctionParameters;
  71181. private _blendEquationParameters;
  71182. private _blendConstants;
  71183. /**
  71184. * Initializes the state.
  71185. */
  71186. constructor();
  71187. readonly isDirty: boolean;
  71188. alphaBlend: boolean;
  71189. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71190. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71191. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71192. reset(): void;
  71193. apply(gl: WebGLRenderingContext): void;
  71194. }
  71195. }
  71196. declare module BABYLON {
  71197. /**
  71198. * @hidden
  71199. **/
  71200. export class _DepthCullingState {
  71201. private _isDepthTestDirty;
  71202. private _isDepthMaskDirty;
  71203. private _isDepthFuncDirty;
  71204. private _isCullFaceDirty;
  71205. private _isCullDirty;
  71206. private _isZOffsetDirty;
  71207. private _isFrontFaceDirty;
  71208. private _depthTest;
  71209. private _depthMask;
  71210. private _depthFunc;
  71211. private _cull;
  71212. private _cullFace;
  71213. private _zOffset;
  71214. private _frontFace;
  71215. /**
  71216. * Initializes the state.
  71217. */
  71218. constructor();
  71219. readonly isDirty: boolean;
  71220. zOffset: number;
  71221. cullFace: Nullable<number>;
  71222. cull: Nullable<boolean>;
  71223. depthFunc: Nullable<number>;
  71224. depthMask: boolean;
  71225. depthTest: boolean;
  71226. frontFace: Nullable<number>;
  71227. reset(): void;
  71228. apply(gl: WebGLRenderingContext): void;
  71229. }
  71230. }
  71231. declare module BABYLON {
  71232. /**
  71233. * @hidden
  71234. **/
  71235. export class _StencilState {
  71236. /** 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 */
  71237. static readonly ALWAYS: number;
  71238. /** Passed to stencilOperation to specify that stencil value must be kept */
  71239. static readonly KEEP: number;
  71240. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71241. static readonly REPLACE: number;
  71242. private _isStencilTestDirty;
  71243. private _isStencilMaskDirty;
  71244. private _isStencilFuncDirty;
  71245. private _isStencilOpDirty;
  71246. private _stencilTest;
  71247. private _stencilMask;
  71248. private _stencilFunc;
  71249. private _stencilFuncRef;
  71250. private _stencilFuncMask;
  71251. private _stencilOpStencilFail;
  71252. private _stencilOpDepthFail;
  71253. private _stencilOpStencilDepthPass;
  71254. readonly isDirty: boolean;
  71255. stencilFunc: number;
  71256. stencilFuncRef: number;
  71257. stencilFuncMask: number;
  71258. stencilOpStencilFail: number;
  71259. stencilOpDepthFail: number;
  71260. stencilOpStencilDepthPass: number;
  71261. stencilMask: number;
  71262. stencilTest: boolean;
  71263. constructor();
  71264. reset(): void;
  71265. apply(gl: WebGLRenderingContext): void;
  71266. }
  71267. }
  71268. declare module BABYLON {
  71269. /**
  71270. * @hidden
  71271. **/
  71272. export class _TimeToken {
  71273. _startTimeQuery: Nullable<WebGLQuery>;
  71274. _endTimeQuery: Nullable<WebGLQuery>;
  71275. _timeElapsedQuery: Nullable<WebGLQuery>;
  71276. _timeElapsedQueryEnded: boolean;
  71277. }
  71278. }
  71279. declare module BABYLON {
  71280. /**
  71281. * Class used to evalaute queries containing `and` and `or` operators
  71282. */
  71283. export class AndOrNotEvaluator {
  71284. /**
  71285. * Evaluate a query
  71286. * @param query defines the query to evaluate
  71287. * @param evaluateCallback defines the callback used to filter result
  71288. * @returns true if the query matches
  71289. */
  71290. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71291. private static _HandleParenthesisContent;
  71292. private static _SimplifyNegation;
  71293. }
  71294. }
  71295. declare module BABYLON {
  71296. /**
  71297. * Class used to store custom tags
  71298. */
  71299. export class Tags {
  71300. /**
  71301. * Adds support for tags on the given object
  71302. * @param obj defines the object to use
  71303. */
  71304. static EnableFor(obj: any): void;
  71305. /**
  71306. * Removes tags support
  71307. * @param obj defines the object to use
  71308. */
  71309. static DisableFor(obj: any): void;
  71310. /**
  71311. * Gets a boolean indicating if the given object has tags
  71312. * @param obj defines the object to use
  71313. * @returns a boolean
  71314. */
  71315. static HasTags(obj: any): boolean;
  71316. /**
  71317. * Gets the tags available on a given object
  71318. * @param obj defines the object to use
  71319. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71320. * @returns the tags
  71321. */
  71322. static GetTags(obj: any, asString?: boolean): any;
  71323. /**
  71324. * Adds tags to an object
  71325. * @param obj defines the object to use
  71326. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71327. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71328. */
  71329. static AddTagsTo(obj: any, tagsString: string): void;
  71330. /**
  71331. * @hidden
  71332. */
  71333. static _AddTagTo(obj: any, tag: string): void;
  71334. /**
  71335. * Removes specific tags from a specific object
  71336. * @param obj defines the object to use
  71337. * @param tagsString defines the tags to remove
  71338. */
  71339. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71340. /**
  71341. * @hidden
  71342. */
  71343. static _RemoveTagFrom(obj: any, tag: string): void;
  71344. /**
  71345. * Defines if tags hosted on an object match a given query
  71346. * @param obj defines the object to use
  71347. * @param tagsQuery defines the tag query
  71348. * @returns a boolean
  71349. */
  71350. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71351. }
  71352. }
  71353. declare module BABYLON {
  71354. /**
  71355. * Defines potential orientation for back face culling
  71356. */
  71357. export enum Orientation {
  71358. /**
  71359. * Clockwise
  71360. */
  71361. CW = 0,
  71362. /** Counter clockwise */
  71363. CCW = 1
  71364. }
  71365. /** Class used to represent a Bezier curve */
  71366. export class BezierCurve {
  71367. /**
  71368. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71369. * @param t defines the time
  71370. * @param x1 defines the left coordinate on X axis
  71371. * @param y1 defines the left coordinate on Y axis
  71372. * @param x2 defines the right coordinate on X axis
  71373. * @param y2 defines the right coordinate on Y axis
  71374. * @returns the interpolated value
  71375. */
  71376. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71377. }
  71378. /**
  71379. * Defines angle representation
  71380. */
  71381. export class Angle {
  71382. private _radians;
  71383. /**
  71384. * Creates an Angle object of "radians" radians (float).
  71385. * @param radians the angle in radians
  71386. */
  71387. constructor(radians: number);
  71388. /**
  71389. * Get value in degrees
  71390. * @returns the Angle value in degrees (float)
  71391. */
  71392. degrees(): number;
  71393. /**
  71394. * Get value in radians
  71395. * @returns the Angle value in radians (float)
  71396. */
  71397. radians(): number;
  71398. /**
  71399. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71400. * @param a defines first vector
  71401. * @param b defines second vector
  71402. * @returns a new Angle
  71403. */
  71404. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71405. /**
  71406. * Gets a new Angle object from the given float in radians
  71407. * @param radians defines the angle value in radians
  71408. * @returns a new Angle
  71409. */
  71410. static FromRadians(radians: number): Angle;
  71411. /**
  71412. * Gets a new Angle object from the given float in degrees
  71413. * @param degrees defines the angle value in degrees
  71414. * @returns a new Angle
  71415. */
  71416. static FromDegrees(degrees: number): Angle;
  71417. }
  71418. /**
  71419. * This represents an arc in a 2d space.
  71420. */
  71421. export class Arc2 {
  71422. /** Defines the start point of the arc */
  71423. startPoint: Vector2;
  71424. /** Defines the mid point of the arc */
  71425. midPoint: Vector2;
  71426. /** Defines the end point of the arc */
  71427. endPoint: Vector2;
  71428. /**
  71429. * Defines the center point of the arc.
  71430. */
  71431. centerPoint: Vector2;
  71432. /**
  71433. * Defines the radius of the arc.
  71434. */
  71435. radius: number;
  71436. /**
  71437. * Defines the angle of the arc (from mid point to end point).
  71438. */
  71439. angle: Angle;
  71440. /**
  71441. * Defines the start angle of the arc (from start point to middle point).
  71442. */
  71443. startAngle: Angle;
  71444. /**
  71445. * Defines the orientation of the arc (clock wise/counter clock wise).
  71446. */
  71447. orientation: Orientation;
  71448. /**
  71449. * Creates an Arc object from the three given points : start, middle and end.
  71450. * @param startPoint Defines the start point of the arc
  71451. * @param midPoint Defines the midlle point of the arc
  71452. * @param endPoint Defines the end point of the arc
  71453. */
  71454. constructor(
  71455. /** Defines the start point of the arc */
  71456. startPoint: Vector2,
  71457. /** Defines the mid point of the arc */
  71458. midPoint: Vector2,
  71459. /** Defines the end point of the arc */
  71460. endPoint: Vector2);
  71461. }
  71462. /**
  71463. * Represents a 2D path made up of multiple 2D points
  71464. */
  71465. export class Path2 {
  71466. private _points;
  71467. private _length;
  71468. /**
  71469. * If the path start and end point are the same
  71470. */
  71471. closed: boolean;
  71472. /**
  71473. * Creates a Path2 object from the starting 2D coordinates x and y.
  71474. * @param x the starting points x value
  71475. * @param y the starting points y value
  71476. */
  71477. constructor(x: number, y: number);
  71478. /**
  71479. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71480. * @param x the added points x value
  71481. * @param y the added points y value
  71482. * @returns the updated Path2.
  71483. */
  71484. addLineTo(x: number, y: number): Path2;
  71485. /**
  71486. * 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.
  71487. * @param midX middle point x value
  71488. * @param midY middle point y value
  71489. * @param endX end point x value
  71490. * @param endY end point y value
  71491. * @param numberOfSegments (default: 36)
  71492. * @returns the updated Path2.
  71493. */
  71494. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71495. /**
  71496. * Closes the Path2.
  71497. * @returns the Path2.
  71498. */
  71499. close(): Path2;
  71500. /**
  71501. * Gets the sum of the distance between each sequential point in the path
  71502. * @returns the Path2 total length (float).
  71503. */
  71504. length(): number;
  71505. /**
  71506. * Gets the points which construct the path
  71507. * @returns the Path2 internal array of points.
  71508. */
  71509. getPoints(): Vector2[];
  71510. /**
  71511. * Retreives the point at the distance aways from the starting point
  71512. * @param normalizedLengthPosition the length along the path to retreive the point from
  71513. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71514. */
  71515. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71516. /**
  71517. * Creates a new path starting from an x and y position
  71518. * @param x starting x value
  71519. * @param y starting y value
  71520. * @returns a new Path2 starting at the coordinates (x, y).
  71521. */
  71522. static StartingAt(x: number, y: number): Path2;
  71523. }
  71524. /**
  71525. * Represents a 3D path made up of multiple 3D points
  71526. */
  71527. export class Path3D {
  71528. /**
  71529. * an array of Vector3, the curve axis of the Path3D
  71530. */
  71531. path: Vector3[];
  71532. private _curve;
  71533. private _distances;
  71534. private _tangents;
  71535. private _normals;
  71536. private _binormals;
  71537. private _raw;
  71538. /**
  71539. * new Path3D(path, normal, raw)
  71540. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71541. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71542. * @param path an array of Vector3, the curve axis of the Path3D
  71543. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71544. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71545. */
  71546. constructor(
  71547. /**
  71548. * an array of Vector3, the curve axis of the Path3D
  71549. */
  71550. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71551. /**
  71552. * Returns the Path3D array of successive Vector3 designing its curve.
  71553. * @returns the Path3D array of successive Vector3 designing its curve.
  71554. */
  71555. getCurve(): Vector3[];
  71556. /**
  71557. * Returns an array populated with tangent vectors on each Path3D curve point.
  71558. * @returns an array populated with tangent vectors on each Path3D curve point.
  71559. */
  71560. getTangents(): Vector3[];
  71561. /**
  71562. * Returns an array populated with normal vectors on each Path3D curve point.
  71563. * @returns an array populated with normal vectors on each Path3D curve point.
  71564. */
  71565. getNormals(): Vector3[];
  71566. /**
  71567. * Returns an array populated with binormal vectors on each Path3D curve point.
  71568. * @returns an array populated with binormal vectors on each Path3D curve point.
  71569. */
  71570. getBinormals(): Vector3[];
  71571. /**
  71572. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71573. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71574. */
  71575. getDistances(): number[];
  71576. /**
  71577. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71578. * @param path path which all values are copied into the curves points
  71579. * @param firstNormal which should be projected onto the curve
  71580. * @returns the same object updated.
  71581. */
  71582. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71583. private _compute;
  71584. private _getFirstNonNullVector;
  71585. private _getLastNonNullVector;
  71586. private _normalVector;
  71587. }
  71588. /**
  71589. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71590. * A Curve3 is designed from a series of successive Vector3.
  71591. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71592. */
  71593. export class Curve3 {
  71594. private _points;
  71595. private _length;
  71596. /**
  71597. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71598. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71599. * @param v1 (Vector3) the control point
  71600. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71601. * @param nbPoints (integer) the wanted number of points in the curve
  71602. * @returns the created Curve3
  71603. */
  71604. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71605. /**
  71606. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71607. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71608. * @param v1 (Vector3) the first control point
  71609. * @param v2 (Vector3) the second control point
  71610. * @param v3 (Vector3) the end point of the Cubic Bezier
  71611. * @param nbPoints (integer) the wanted number of points in the curve
  71612. * @returns the created Curve3
  71613. */
  71614. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71615. /**
  71616. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71617. * @param p1 (Vector3) the origin point of the Hermite Spline
  71618. * @param t1 (Vector3) the tangent vector at the origin point
  71619. * @param p2 (Vector3) the end point of the Hermite Spline
  71620. * @param t2 (Vector3) the tangent vector at the end point
  71621. * @param nbPoints (integer) the wanted number of points in the curve
  71622. * @returns the created Curve3
  71623. */
  71624. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71625. /**
  71626. * Returns a Curve3 object along a CatmullRom Spline curve :
  71627. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71628. * @param nbPoints (integer) the wanted number of points between each curve control points
  71629. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71630. * @returns the created Curve3
  71631. */
  71632. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71633. /**
  71634. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71635. * A Curve3 is designed from a series of successive Vector3.
  71636. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71637. * @param points points which make up the curve
  71638. */
  71639. constructor(points: Vector3[]);
  71640. /**
  71641. * @returns the Curve3 stored array of successive Vector3
  71642. */
  71643. getPoints(): Vector3[];
  71644. /**
  71645. * @returns the computed length (float) of the curve.
  71646. */
  71647. length(): number;
  71648. /**
  71649. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71650. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71651. * curveA and curveB keep unchanged.
  71652. * @param curve the curve to continue from this curve
  71653. * @returns the newly constructed curve
  71654. */
  71655. continue(curve: DeepImmutable<Curve3>): Curve3;
  71656. private _computeLength;
  71657. }
  71658. }
  71659. declare module BABYLON {
  71660. /**
  71661. * This represents the main contract an easing function should follow.
  71662. * Easing functions are used throughout the animation system.
  71663. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71664. */
  71665. export interface IEasingFunction {
  71666. /**
  71667. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71668. * of the easing function.
  71669. * The link below provides some of the most common examples of easing functions.
  71670. * @see https://easings.net/
  71671. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71672. * @returns the corresponding value on the curve defined by the easing function
  71673. */
  71674. ease(gradient: number): number;
  71675. }
  71676. /**
  71677. * Base class used for every default easing function.
  71678. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71679. */
  71680. export class EasingFunction implements IEasingFunction {
  71681. /**
  71682. * Interpolation follows the mathematical formula associated with the easing function.
  71683. */
  71684. static readonly EASINGMODE_EASEIN: number;
  71685. /**
  71686. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71687. */
  71688. static readonly EASINGMODE_EASEOUT: number;
  71689. /**
  71690. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71691. */
  71692. static readonly EASINGMODE_EASEINOUT: number;
  71693. private _easingMode;
  71694. /**
  71695. * Sets the easing mode of the current function.
  71696. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71697. */
  71698. setEasingMode(easingMode: number): void;
  71699. /**
  71700. * Gets the current easing mode.
  71701. * @returns the easing mode
  71702. */
  71703. getEasingMode(): number;
  71704. /**
  71705. * @hidden
  71706. */
  71707. easeInCore(gradient: number): number;
  71708. /**
  71709. * Given an input gradient between 0 and 1, this returns the corresponding value
  71710. * of the easing function.
  71711. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71712. * @returns the corresponding value on the curve defined by the easing function
  71713. */
  71714. ease(gradient: number): number;
  71715. }
  71716. /**
  71717. * Easing function with a circle shape (see link below).
  71718. * @see https://easings.net/#easeInCirc
  71719. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71720. */
  71721. export class CircleEase extends EasingFunction implements IEasingFunction {
  71722. /** @hidden */
  71723. easeInCore(gradient: number): number;
  71724. }
  71725. /**
  71726. * Easing function with a ease back shape (see link below).
  71727. * @see https://easings.net/#easeInBack
  71728. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71729. */
  71730. export class BackEase extends EasingFunction implements IEasingFunction {
  71731. /** Defines the amplitude of the function */
  71732. amplitude: number;
  71733. /**
  71734. * Instantiates a back ease easing
  71735. * @see https://easings.net/#easeInBack
  71736. * @param amplitude Defines the amplitude of the function
  71737. */
  71738. constructor(
  71739. /** Defines the amplitude of the function */
  71740. amplitude?: number);
  71741. /** @hidden */
  71742. easeInCore(gradient: number): number;
  71743. }
  71744. /**
  71745. * Easing function with a bouncing shape (see link below).
  71746. * @see https://easings.net/#easeInBounce
  71747. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71748. */
  71749. export class BounceEase extends EasingFunction implements IEasingFunction {
  71750. /** Defines the number of bounces */
  71751. bounces: number;
  71752. /** Defines the amplitude of the bounce */
  71753. bounciness: number;
  71754. /**
  71755. * Instantiates a bounce easing
  71756. * @see https://easings.net/#easeInBounce
  71757. * @param bounces Defines the number of bounces
  71758. * @param bounciness Defines the amplitude of the bounce
  71759. */
  71760. constructor(
  71761. /** Defines the number of bounces */
  71762. bounces?: number,
  71763. /** Defines the amplitude of the bounce */
  71764. bounciness?: number);
  71765. /** @hidden */
  71766. easeInCore(gradient: number): number;
  71767. }
  71768. /**
  71769. * Easing function with a power of 3 shape (see link below).
  71770. * @see https://easings.net/#easeInCubic
  71771. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71772. */
  71773. export class CubicEase extends EasingFunction implements IEasingFunction {
  71774. /** @hidden */
  71775. easeInCore(gradient: number): number;
  71776. }
  71777. /**
  71778. * Easing function with an elastic shape (see link below).
  71779. * @see https://easings.net/#easeInElastic
  71780. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71781. */
  71782. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71783. /** Defines the number of oscillations*/
  71784. oscillations: number;
  71785. /** Defines the amplitude of the oscillations*/
  71786. springiness: number;
  71787. /**
  71788. * Instantiates an elastic easing function
  71789. * @see https://easings.net/#easeInElastic
  71790. * @param oscillations Defines the number of oscillations
  71791. * @param springiness Defines the amplitude of the oscillations
  71792. */
  71793. constructor(
  71794. /** Defines the number of oscillations*/
  71795. oscillations?: number,
  71796. /** Defines the amplitude of the oscillations*/
  71797. springiness?: number);
  71798. /** @hidden */
  71799. easeInCore(gradient: number): number;
  71800. }
  71801. /**
  71802. * Easing function with an exponential shape (see link below).
  71803. * @see https://easings.net/#easeInExpo
  71804. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71805. */
  71806. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71807. /** Defines the exponent of the function */
  71808. exponent: number;
  71809. /**
  71810. * Instantiates an exponential easing function
  71811. * @see https://easings.net/#easeInExpo
  71812. * @param exponent Defines the exponent of the function
  71813. */
  71814. constructor(
  71815. /** Defines the exponent of the function */
  71816. exponent?: number);
  71817. /** @hidden */
  71818. easeInCore(gradient: number): number;
  71819. }
  71820. /**
  71821. * Easing function with a power shape (see link below).
  71822. * @see https://easings.net/#easeInQuad
  71823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71824. */
  71825. export class PowerEase extends EasingFunction implements IEasingFunction {
  71826. /** Defines the power of the function */
  71827. power: number;
  71828. /**
  71829. * Instantiates an power base easing function
  71830. * @see https://easings.net/#easeInQuad
  71831. * @param power Defines the power of the function
  71832. */
  71833. constructor(
  71834. /** Defines the power of the function */
  71835. power?: number);
  71836. /** @hidden */
  71837. easeInCore(gradient: number): number;
  71838. }
  71839. /**
  71840. * Easing function with a power of 2 shape (see link below).
  71841. * @see https://easings.net/#easeInQuad
  71842. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71843. */
  71844. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71845. /** @hidden */
  71846. easeInCore(gradient: number): number;
  71847. }
  71848. /**
  71849. * Easing function with a power of 4 shape (see link below).
  71850. * @see https://easings.net/#easeInQuart
  71851. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71852. */
  71853. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71854. /** @hidden */
  71855. easeInCore(gradient: number): number;
  71856. }
  71857. /**
  71858. * Easing function with a power of 5 shape (see link below).
  71859. * @see https://easings.net/#easeInQuint
  71860. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71861. */
  71862. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71863. /** @hidden */
  71864. easeInCore(gradient: number): number;
  71865. }
  71866. /**
  71867. * Easing function with a sin shape (see link below).
  71868. * @see https://easings.net/#easeInSine
  71869. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71870. */
  71871. export class SineEase extends EasingFunction implements IEasingFunction {
  71872. /** @hidden */
  71873. easeInCore(gradient: number): number;
  71874. }
  71875. /**
  71876. * Easing function with a bezier shape (see link below).
  71877. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71879. */
  71880. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71881. /** Defines the x component of the start tangent in the bezier curve */
  71882. x1: number;
  71883. /** Defines the y component of the start tangent in the bezier curve */
  71884. y1: number;
  71885. /** Defines the x component of the end tangent in the bezier curve */
  71886. x2: number;
  71887. /** Defines the y component of the end tangent in the bezier curve */
  71888. y2: number;
  71889. /**
  71890. * Instantiates a bezier function
  71891. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71892. * @param x1 Defines the x component of the start tangent in the bezier curve
  71893. * @param y1 Defines the y component of the start tangent in the bezier curve
  71894. * @param x2 Defines the x component of the end tangent in the bezier curve
  71895. * @param y2 Defines the y component of the end tangent in the bezier curve
  71896. */
  71897. constructor(
  71898. /** Defines the x component of the start tangent in the bezier curve */
  71899. x1?: number,
  71900. /** Defines the y component of the start tangent in the bezier curve */
  71901. y1?: number,
  71902. /** Defines the x component of the end tangent in the bezier curve */
  71903. x2?: number,
  71904. /** Defines the y component of the end tangent in the bezier curve */
  71905. y2?: number);
  71906. /** @hidden */
  71907. easeInCore(gradient: number): number;
  71908. }
  71909. }
  71910. declare module BABYLON {
  71911. /**
  71912. * Defines an interface which represents an animation key frame
  71913. */
  71914. export interface IAnimationKey {
  71915. /**
  71916. * Frame of the key frame
  71917. */
  71918. frame: number;
  71919. /**
  71920. * Value at the specifies key frame
  71921. */
  71922. value: any;
  71923. /**
  71924. * The input tangent for the cubic hermite spline
  71925. */
  71926. inTangent?: any;
  71927. /**
  71928. * The output tangent for the cubic hermite spline
  71929. */
  71930. outTangent?: any;
  71931. /**
  71932. * The animation interpolation type
  71933. */
  71934. interpolation?: AnimationKeyInterpolation;
  71935. }
  71936. /**
  71937. * Enum for the animation key frame interpolation type
  71938. */
  71939. export enum AnimationKeyInterpolation {
  71940. /**
  71941. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  71942. */
  71943. STEP = 1
  71944. }
  71945. }
  71946. declare module BABYLON {
  71947. /**
  71948. * Represents the range of an animation
  71949. */
  71950. export class AnimationRange {
  71951. /**The name of the animation range**/
  71952. name: string;
  71953. /**The starting frame of the animation */
  71954. from: number;
  71955. /**The ending frame of the animation*/
  71956. to: number;
  71957. /**
  71958. * Initializes the range of an animation
  71959. * @param name The name of the animation range
  71960. * @param from The starting frame of the animation
  71961. * @param to The ending frame of the animation
  71962. */
  71963. constructor(
  71964. /**The name of the animation range**/
  71965. name: string,
  71966. /**The starting frame of the animation */
  71967. from: number,
  71968. /**The ending frame of the animation*/
  71969. to: number);
  71970. /**
  71971. * Makes a copy of the animation range
  71972. * @returns A copy of the animation range
  71973. */
  71974. clone(): AnimationRange;
  71975. }
  71976. }
  71977. declare module BABYLON {
  71978. /**
  71979. * Composed of a frame, and an action function
  71980. */
  71981. export class AnimationEvent {
  71982. /** The frame for which the event is triggered **/
  71983. frame: number;
  71984. /** The event to perform when triggered **/
  71985. action: (currentFrame: number) => void;
  71986. /** Specifies if the event should be triggered only once**/
  71987. onlyOnce?: boolean | undefined;
  71988. /**
  71989. * Specifies if the animation event is done
  71990. */
  71991. isDone: boolean;
  71992. /**
  71993. * Initializes the animation event
  71994. * @param frame The frame for which the event is triggered
  71995. * @param action The event to perform when triggered
  71996. * @param onlyOnce Specifies if the event should be triggered only once
  71997. */
  71998. constructor(
  71999. /** The frame for which the event is triggered **/
  72000. frame: number,
  72001. /** The event to perform when triggered **/
  72002. action: (currentFrame: number) => void,
  72003. /** Specifies if the event should be triggered only once**/
  72004. onlyOnce?: boolean | undefined);
  72005. /** @hidden */
  72006. _clone(): AnimationEvent;
  72007. }
  72008. }
  72009. declare module BABYLON {
  72010. /**
  72011. * Interface used to define a behavior
  72012. */
  72013. export interface Behavior<T> {
  72014. /** gets or sets behavior's name */
  72015. name: string;
  72016. /**
  72017. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72018. */
  72019. init(): void;
  72020. /**
  72021. * Called when the behavior is attached to a target
  72022. * @param target defines the target where the behavior is attached to
  72023. */
  72024. attach(target: T): void;
  72025. /**
  72026. * Called when the behavior is detached from its target
  72027. */
  72028. detach(): void;
  72029. }
  72030. /**
  72031. * Interface implemented by classes supporting behaviors
  72032. */
  72033. export interface IBehaviorAware<T> {
  72034. /**
  72035. * Attach a behavior
  72036. * @param behavior defines the behavior to attach
  72037. * @returns the current host
  72038. */
  72039. addBehavior(behavior: Behavior<T>): T;
  72040. /**
  72041. * Remove a behavior from the current object
  72042. * @param behavior defines the behavior to detach
  72043. * @returns the current host
  72044. */
  72045. removeBehavior(behavior: Behavior<T>): T;
  72046. /**
  72047. * Gets a behavior using its name to search
  72048. * @param name defines the name to search
  72049. * @returns the behavior or null if not found
  72050. */
  72051. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72052. }
  72053. }
  72054. declare module BABYLON {
  72055. /**
  72056. * Defines an array and its length.
  72057. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72058. */
  72059. export interface ISmartArrayLike<T> {
  72060. /**
  72061. * The data of the array.
  72062. */
  72063. data: Array<T>;
  72064. /**
  72065. * The active length of the array.
  72066. */
  72067. length: number;
  72068. }
  72069. /**
  72070. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72071. */
  72072. export class SmartArray<T> implements ISmartArrayLike<T> {
  72073. /**
  72074. * The full set of data from the array.
  72075. */
  72076. data: Array<T>;
  72077. /**
  72078. * The active length of the array.
  72079. */
  72080. length: number;
  72081. protected _id: number;
  72082. /**
  72083. * Instantiates a Smart Array.
  72084. * @param capacity defines the default capacity of the array.
  72085. */
  72086. constructor(capacity: number);
  72087. /**
  72088. * Pushes a value at the end of the active data.
  72089. * @param value defines the object to push in the array.
  72090. */
  72091. push(value: T): void;
  72092. /**
  72093. * Iterates over the active data and apply the lambda to them.
  72094. * @param func defines the action to apply on each value.
  72095. */
  72096. forEach(func: (content: T) => void): void;
  72097. /**
  72098. * Sorts the full sets of data.
  72099. * @param compareFn defines the comparison function to apply.
  72100. */
  72101. sort(compareFn: (a: T, b: T) => number): void;
  72102. /**
  72103. * Resets the active data to an empty array.
  72104. */
  72105. reset(): void;
  72106. /**
  72107. * Releases all the data from the array as well as the array.
  72108. */
  72109. dispose(): void;
  72110. /**
  72111. * Concats the active data with a given array.
  72112. * @param array defines the data to concatenate with.
  72113. */
  72114. concat(array: any): void;
  72115. /**
  72116. * Returns the position of a value in the active data.
  72117. * @param value defines the value to find the index for
  72118. * @returns the index if found in the active data otherwise -1
  72119. */
  72120. indexOf(value: T): number;
  72121. /**
  72122. * Returns whether an element is part of the active data.
  72123. * @param value defines the value to look for
  72124. * @returns true if found in the active data otherwise false
  72125. */
  72126. contains(value: T): boolean;
  72127. private static _GlobalId;
  72128. }
  72129. /**
  72130. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72131. * The data in this array can only be present once
  72132. */
  72133. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72134. private _duplicateId;
  72135. /**
  72136. * Pushes a value at the end of the active data.
  72137. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72138. * @param value defines the object to push in the array.
  72139. */
  72140. push(value: T): void;
  72141. /**
  72142. * Pushes a value at the end of the active data.
  72143. * If the data is already present, it won t be added again
  72144. * @param value defines the object to push in the array.
  72145. * @returns true if added false if it was already present
  72146. */
  72147. pushNoDuplicate(value: T): boolean;
  72148. /**
  72149. * Resets the active data to an empty array.
  72150. */
  72151. reset(): void;
  72152. /**
  72153. * Concats the active data with a given array.
  72154. * This ensures no dupplicate will be present in the result.
  72155. * @param array defines the data to concatenate with.
  72156. */
  72157. concatWithNoDuplicate(array: any): void;
  72158. }
  72159. }
  72160. declare module BABYLON {
  72161. /**
  72162. * @ignore
  72163. * This is a list of all the different input types that are available in the application.
  72164. * Fo instance: ArcRotateCameraGamepadInput...
  72165. */
  72166. export var CameraInputTypes: {};
  72167. /**
  72168. * This is the contract to implement in order to create a new input class.
  72169. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72170. */
  72171. export interface ICameraInput<TCamera extends Camera> {
  72172. /**
  72173. * Defines the camera the input is attached to.
  72174. */
  72175. camera: Nullable<TCamera>;
  72176. /**
  72177. * Gets the class name of the current intput.
  72178. * @returns the class name
  72179. */
  72180. getClassName(): string;
  72181. /**
  72182. * Get the friendly name associated with the input class.
  72183. * @returns the input friendly name
  72184. */
  72185. getSimpleName(): string;
  72186. /**
  72187. * Attach the input controls to a specific dom element to get the input from.
  72188. * @param element Defines the element the controls should be listened from
  72189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72190. */
  72191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72192. /**
  72193. * Detach the current controls from the specified dom element.
  72194. * @param element Defines the element to stop listening the inputs from
  72195. */
  72196. detachControl(element: Nullable<HTMLElement>): void;
  72197. /**
  72198. * Update the current camera state depending on the inputs that have been used this frame.
  72199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72200. */
  72201. checkInputs?: () => void;
  72202. }
  72203. /**
  72204. * Represents a map of input types to input instance or input index to input instance.
  72205. */
  72206. export interface CameraInputsMap<TCamera extends Camera> {
  72207. /**
  72208. * Accessor to the input by input type.
  72209. */
  72210. [name: string]: ICameraInput<TCamera>;
  72211. /**
  72212. * Accessor to the input by input index.
  72213. */
  72214. [idx: number]: ICameraInput<TCamera>;
  72215. }
  72216. /**
  72217. * This represents the input manager used within a camera.
  72218. * It helps dealing with all the different kind of input attached to a camera.
  72219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72220. */
  72221. export class CameraInputsManager<TCamera extends Camera> {
  72222. /**
  72223. * Defines the list of inputs attahed to the camera.
  72224. */
  72225. attached: CameraInputsMap<TCamera>;
  72226. /**
  72227. * Defines the dom element the camera is collecting inputs from.
  72228. * This is null if the controls have not been attached.
  72229. */
  72230. attachedElement: Nullable<HTMLElement>;
  72231. /**
  72232. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72233. */
  72234. noPreventDefault: boolean;
  72235. /**
  72236. * Defined the camera the input manager belongs to.
  72237. */
  72238. camera: TCamera;
  72239. /**
  72240. * Update the current camera state depending on the inputs that have been used this frame.
  72241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72242. */
  72243. checkInputs: () => void;
  72244. /**
  72245. * Instantiate a new Camera Input Manager.
  72246. * @param camera Defines the camera the input manager blongs to
  72247. */
  72248. constructor(camera: TCamera);
  72249. /**
  72250. * Add an input method to a camera
  72251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72252. * @param input camera input method
  72253. */
  72254. add(input: ICameraInput<TCamera>): void;
  72255. /**
  72256. * Remove a specific input method from a camera
  72257. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72258. * @param inputToRemove camera input method
  72259. */
  72260. remove(inputToRemove: ICameraInput<TCamera>): void;
  72261. /**
  72262. * Remove a specific input type from a camera
  72263. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72264. * @param inputType the type of the input to remove
  72265. */
  72266. removeByType(inputType: string): void;
  72267. private _addCheckInputs;
  72268. /**
  72269. * Attach the input controls to the currently attached dom element to listen the events from.
  72270. * @param input Defines the input to attach
  72271. */
  72272. attachInput(input: ICameraInput<TCamera>): void;
  72273. /**
  72274. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72275. * @param element Defines the dom element to collect the events from
  72276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72277. */
  72278. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72279. /**
  72280. * Detach the current manager inputs controls from a specific dom element.
  72281. * @param element Defines the dom element to collect the events from
  72282. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72283. */
  72284. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72285. /**
  72286. * Rebuild the dynamic inputCheck function from the current list of
  72287. * defined inputs in the manager.
  72288. */
  72289. rebuildInputCheck(): void;
  72290. /**
  72291. * Remove all attached input methods from a camera
  72292. */
  72293. clear(): void;
  72294. /**
  72295. * Serialize the current input manager attached to a camera.
  72296. * This ensures than once parsed,
  72297. * the input associated to the camera will be identical to the current ones
  72298. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72299. */
  72300. serialize(serializedCamera: any): void;
  72301. /**
  72302. * Parses an input manager serialized JSON to restore the previous list of inputs
  72303. * and states associated to a camera.
  72304. * @param parsedCamera Defines the JSON to parse
  72305. */
  72306. parse(parsedCamera: any): void;
  72307. }
  72308. }
  72309. declare module BABYLON {
  72310. /**
  72311. * @hidden
  72312. */
  72313. export class IntersectionInfo {
  72314. bu: Nullable<number>;
  72315. bv: Nullable<number>;
  72316. distance: number;
  72317. faceId: number;
  72318. subMeshId: number;
  72319. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72320. }
  72321. }
  72322. declare module BABYLON {
  72323. /**
  72324. * Represens a plane by the equation ax + by + cz + d = 0
  72325. */
  72326. export class Plane {
  72327. private static _TmpMatrix;
  72328. /**
  72329. * Normal of the plane (a,b,c)
  72330. */
  72331. normal: Vector3;
  72332. /**
  72333. * d component of the plane
  72334. */
  72335. d: number;
  72336. /**
  72337. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72338. * @param a a component of the plane
  72339. * @param b b component of the plane
  72340. * @param c c component of the plane
  72341. * @param d d component of the plane
  72342. */
  72343. constructor(a: number, b: number, c: number, d: number);
  72344. /**
  72345. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72346. */
  72347. asArray(): number[];
  72348. /**
  72349. * @returns a new plane copied from the current Plane.
  72350. */
  72351. clone(): Plane;
  72352. /**
  72353. * @returns the string "Plane".
  72354. */
  72355. getClassName(): string;
  72356. /**
  72357. * @returns the Plane hash code.
  72358. */
  72359. getHashCode(): number;
  72360. /**
  72361. * Normalize the current Plane in place.
  72362. * @returns the updated Plane.
  72363. */
  72364. normalize(): Plane;
  72365. /**
  72366. * Applies a transformation the plane and returns the result
  72367. * @param transformation the transformation matrix to be applied to the plane
  72368. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72369. */
  72370. transform(transformation: DeepImmutable<Matrix>): Plane;
  72371. /**
  72372. * Calcualtte the dot product between the point and the plane normal
  72373. * @param point point to calculate the dot product with
  72374. * @returns the dot product (float) of the point coordinates and the plane normal.
  72375. */
  72376. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72377. /**
  72378. * Updates the current Plane from the plane defined by the three given points.
  72379. * @param point1 one of the points used to contruct the plane
  72380. * @param point2 one of the points used to contruct the plane
  72381. * @param point3 one of the points used to contruct the plane
  72382. * @returns the updated Plane.
  72383. */
  72384. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72385. /**
  72386. * Checks if the plane is facing a given direction
  72387. * @param direction the direction to check if the plane is facing
  72388. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72389. * @returns True is the vector "direction" is the same side than the plane normal.
  72390. */
  72391. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72392. /**
  72393. * Calculates the distance to a point
  72394. * @param point point to calculate distance to
  72395. * @returns the signed distance (float) from the given point to the Plane.
  72396. */
  72397. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72398. /**
  72399. * Creates a plane from an array
  72400. * @param array the array to create a plane from
  72401. * @returns a new Plane from the given array.
  72402. */
  72403. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72404. /**
  72405. * Creates a plane from three points
  72406. * @param point1 point used to create the plane
  72407. * @param point2 point used to create the plane
  72408. * @param point3 point used to create the plane
  72409. * @returns a new Plane defined by the three given points.
  72410. */
  72411. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72412. /**
  72413. * Creates a plane from an origin point and a normal
  72414. * @param origin origin of the plane to be constructed
  72415. * @param normal normal of the plane to be constructed
  72416. * @returns a new Plane the normal vector to this plane at the given origin point.
  72417. * Note : the vector "normal" is updated because normalized.
  72418. */
  72419. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72420. /**
  72421. * Calculates the distance from a plane and a point
  72422. * @param origin origin of the plane to be constructed
  72423. * @param normal normal of the plane to be constructed
  72424. * @param point point to calculate distance to
  72425. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72426. */
  72427. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72428. }
  72429. }
  72430. declare module BABYLON {
  72431. /**
  72432. * Class used to store bounding sphere information
  72433. */
  72434. export class BoundingSphere {
  72435. /**
  72436. * Gets the center of the bounding sphere in local space
  72437. */
  72438. readonly center: Vector3;
  72439. /**
  72440. * Radius of the bounding sphere in local space
  72441. */
  72442. radius: number;
  72443. /**
  72444. * Gets the center of the bounding sphere in world space
  72445. */
  72446. readonly centerWorld: Vector3;
  72447. /**
  72448. * Radius of the bounding sphere in world space
  72449. */
  72450. radiusWorld: number;
  72451. /**
  72452. * Gets the minimum vector in local space
  72453. */
  72454. readonly minimum: Vector3;
  72455. /**
  72456. * Gets the maximum vector in local space
  72457. */
  72458. readonly maximum: Vector3;
  72459. private _worldMatrix;
  72460. private static readonly TmpVector3;
  72461. /**
  72462. * Creates a new bounding sphere
  72463. * @param min defines the minimum vector (in local space)
  72464. * @param max defines the maximum vector (in local space)
  72465. * @param worldMatrix defines the new world matrix
  72466. */
  72467. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72468. /**
  72469. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72470. * @param min defines the new minimum vector (in local space)
  72471. * @param max defines the new maximum vector (in local space)
  72472. * @param worldMatrix defines the new world matrix
  72473. */
  72474. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72475. /**
  72476. * Scale the current bounding sphere by applying a scale factor
  72477. * @param factor defines the scale factor to apply
  72478. * @returns the current bounding box
  72479. */
  72480. scale(factor: number): BoundingSphere;
  72481. /**
  72482. * Gets the world matrix of the bounding box
  72483. * @returns a matrix
  72484. */
  72485. getWorldMatrix(): DeepImmutable<Matrix>;
  72486. /** @hidden */
  72487. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72488. /**
  72489. * Tests if the bounding sphere is intersecting the frustum planes
  72490. * @param frustumPlanes defines the frustum planes to test
  72491. * @returns true if there is an intersection
  72492. */
  72493. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72494. /**
  72495. * Tests if the bounding sphere center is in between the frustum planes.
  72496. * Used for optimistic fast inclusion.
  72497. * @param frustumPlanes defines the frustum planes to test
  72498. * @returns true if the sphere center is in between the frustum planes
  72499. */
  72500. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72501. /**
  72502. * Tests if a point is inside the bounding sphere
  72503. * @param point defines the point to test
  72504. * @returns true if the point is inside the bounding sphere
  72505. */
  72506. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72507. /**
  72508. * Checks if two sphere intersct
  72509. * @param sphere0 sphere 0
  72510. * @param sphere1 sphere 1
  72511. * @returns true if the speres intersect
  72512. */
  72513. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72514. }
  72515. }
  72516. declare module BABYLON {
  72517. /**
  72518. * Class used to store bounding box information
  72519. */
  72520. export class BoundingBox implements ICullable {
  72521. /**
  72522. * Gets the 8 vectors representing the bounding box in local space
  72523. */
  72524. readonly vectors: Vector3[];
  72525. /**
  72526. * Gets the center of the bounding box in local space
  72527. */
  72528. readonly center: Vector3;
  72529. /**
  72530. * Gets the center of the bounding box in world space
  72531. */
  72532. readonly centerWorld: Vector3;
  72533. /**
  72534. * Gets the extend size in local space
  72535. */
  72536. readonly extendSize: Vector3;
  72537. /**
  72538. * Gets the extend size in world space
  72539. */
  72540. readonly extendSizeWorld: Vector3;
  72541. /**
  72542. * Gets the OBB (object bounding box) directions
  72543. */
  72544. readonly directions: Vector3[];
  72545. /**
  72546. * Gets the 8 vectors representing the bounding box in world space
  72547. */
  72548. readonly vectorsWorld: Vector3[];
  72549. /**
  72550. * Gets the minimum vector in world space
  72551. */
  72552. readonly minimumWorld: Vector3;
  72553. /**
  72554. * Gets the maximum vector in world space
  72555. */
  72556. readonly maximumWorld: Vector3;
  72557. /**
  72558. * Gets the minimum vector in local space
  72559. */
  72560. readonly minimum: Vector3;
  72561. /**
  72562. * Gets the maximum vector in local space
  72563. */
  72564. readonly maximum: Vector3;
  72565. private _worldMatrix;
  72566. private static readonly TmpVector3;
  72567. /**
  72568. * @hidden
  72569. */
  72570. _tag: number;
  72571. /**
  72572. * Creates a new bounding box
  72573. * @param min defines the minimum vector (in local space)
  72574. * @param max defines the maximum vector (in local space)
  72575. * @param worldMatrix defines the new world matrix
  72576. */
  72577. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72578. /**
  72579. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72580. * @param min defines the new minimum vector (in local space)
  72581. * @param max defines the new maximum vector (in local space)
  72582. * @param worldMatrix defines the new world matrix
  72583. */
  72584. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72585. /**
  72586. * Scale the current bounding box by applying a scale factor
  72587. * @param factor defines the scale factor to apply
  72588. * @returns the current bounding box
  72589. */
  72590. scale(factor: number): BoundingBox;
  72591. /**
  72592. * Gets the world matrix of the bounding box
  72593. * @returns a matrix
  72594. */
  72595. getWorldMatrix(): DeepImmutable<Matrix>;
  72596. /** @hidden */
  72597. _update(world: DeepImmutable<Matrix>): void;
  72598. /**
  72599. * Tests if the bounding box is intersecting the frustum planes
  72600. * @param frustumPlanes defines the frustum planes to test
  72601. * @returns true if there is an intersection
  72602. */
  72603. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72604. /**
  72605. * Tests if the bounding box is entirely inside the frustum planes
  72606. * @param frustumPlanes defines the frustum planes to test
  72607. * @returns true if there is an inclusion
  72608. */
  72609. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72610. /**
  72611. * Tests if a point is inside the bounding box
  72612. * @param point defines the point to test
  72613. * @returns true if the point is inside the bounding box
  72614. */
  72615. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72616. /**
  72617. * Tests if the bounding box intersects with a bounding sphere
  72618. * @param sphere defines the sphere to test
  72619. * @returns true if there is an intersection
  72620. */
  72621. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72622. /**
  72623. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72624. * @param min defines the min vector to use
  72625. * @param max defines the max vector to use
  72626. * @returns true if there is an intersection
  72627. */
  72628. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72629. /**
  72630. * Tests if two bounding boxes are intersections
  72631. * @param box0 defines the first box to test
  72632. * @param box1 defines the second box to test
  72633. * @returns true if there is an intersection
  72634. */
  72635. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72636. /**
  72637. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72638. * @param minPoint defines the minimum vector of the bounding box
  72639. * @param maxPoint defines the maximum vector of the bounding box
  72640. * @param sphereCenter defines the sphere center
  72641. * @param sphereRadius defines the sphere radius
  72642. * @returns true if there is an intersection
  72643. */
  72644. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72645. /**
  72646. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72647. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72648. * @param frustumPlanes defines the frustum planes to test
  72649. * @return true if there is an inclusion
  72650. */
  72651. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72652. /**
  72653. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72654. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72655. * @param frustumPlanes defines the frustum planes to test
  72656. * @return true if there is an intersection
  72657. */
  72658. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72659. }
  72660. }
  72661. declare module BABYLON {
  72662. /** @hidden */
  72663. export class Collider {
  72664. /** Define if a collision was found */
  72665. collisionFound: boolean;
  72666. /**
  72667. * Define last intersection point in local space
  72668. */
  72669. intersectionPoint: Vector3;
  72670. /**
  72671. * Define last collided mesh
  72672. */
  72673. collidedMesh: Nullable<AbstractMesh>;
  72674. private _collisionPoint;
  72675. private _planeIntersectionPoint;
  72676. private _tempVector;
  72677. private _tempVector2;
  72678. private _tempVector3;
  72679. private _tempVector4;
  72680. private _edge;
  72681. private _baseToVertex;
  72682. private _destinationPoint;
  72683. private _slidePlaneNormal;
  72684. private _displacementVector;
  72685. /** @hidden */
  72686. _radius: Vector3;
  72687. /** @hidden */
  72688. _retry: number;
  72689. private _velocity;
  72690. private _basePoint;
  72691. private _epsilon;
  72692. /** @hidden */
  72693. _velocityWorldLength: number;
  72694. /** @hidden */
  72695. _basePointWorld: Vector3;
  72696. private _velocityWorld;
  72697. private _normalizedVelocity;
  72698. /** @hidden */
  72699. _initialVelocity: Vector3;
  72700. /** @hidden */
  72701. _initialPosition: Vector3;
  72702. private _nearestDistance;
  72703. private _collisionMask;
  72704. collisionMask: number;
  72705. /**
  72706. * Gets the plane normal used to compute the sliding response (in local space)
  72707. */
  72708. readonly slidePlaneNormal: Vector3;
  72709. /** @hidden */
  72710. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72711. /** @hidden */
  72712. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72713. /** @hidden */
  72714. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72715. /** @hidden */
  72716. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72717. /** @hidden */
  72718. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72719. /** @hidden */
  72720. _getResponse(pos: Vector3, vel: Vector3): void;
  72721. }
  72722. }
  72723. declare module BABYLON {
  72724. /**
  72725. * Interface for cullable objects
  72726. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72727. */
  72728. export interface ICullable {
  72729. /**
  72730. * Checks if the object or part of the object is in the frustum
  72731. * @param frustumPlanes Camera near/planes
  72732. * @returns true if the object is in frustum otherwise false
  72733. */
  72734. isInFrustum(frustumPlanes: Plane[]): boolean;
  72735. /**
  72736. * Checks if a cullable object (mesh...) is in the camera frustum
  72737. * Unlike isInFrustum this cheks the full bounding box
  72738. * @param frustumPlanes Camera near/planes
  72739. * @returns true if the object is in frustum otherwise false
  72740. */
  72741. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72742. }
  72743. /**
  72744. * Info for a bounding data of a mesh
  72745. */
  72746. export class BoundingInfo implements ICullable {
  72747. /**
  72748. * Bounding box for the mesh
  72749. */
  72750. readonly boundingBox: BoundingBox;
  72751. /**
  72752. * Bounding sphere for the mesh
  72753. */
  72754. readonly boundingSphere: BoundingSphere;
  72755. private _isLocked;
  72756. private static readonly TmpVector3;
  72757. /**
  72758. * Constructs bounding info
  72759. * @param minimum min vector of the bounding box/sphere
  72760. * @param maximum max vector of the bounding box/sphere
  72761. * @param worldMatrix defines the new world matrix
  72762. */
  72763. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72764. /**
  72765. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72766. * @param min defines the new minimum vector (in local space)
  72767. * @param max defines the new maximum vector (in local space)
  72768. * @param worldMatrix defines the new world matrix
  72769. */
  72770. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72771. /**
  72772. * min vector of the bounding box/sphere
  72773. */
  72774. readonly minimum: Vector3;
  72775. /**
  72776. * max vector of the bounding box/sphere
  72777. */
  72778. readonly maximum: Vector3;
  72779. /**
  72780. * If the info is locked and won't be updated to avoid perf overhead
  72781. */
  72782. isLocked: boolean;
  72783. /**
  72784. * Updates the bounding sphere and box
  72785. * @param world world matrix to be used to update
  72786. */
  72787. update(world: DeepImmutable<Matrix>): void;
  72788. /**
  72789. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72790. * @param center New center of the bounding info
  72791. * @param extend New extend of the bounding info
  72792. * @returns the current bounding info
  72793. */
  72794. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72795. /**
  72796. * Scale the current bounding info by applying a scale factor
  72797. * @param factor defines the scale factor to apply
  72798. * @returns the current bounding info
  72799. */
  72800. scale(factor: number): BoundingInfo;
  72801. /**
  72802. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72803. * @param frustumPlanes defines the frustum to test
  72804. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72805. * @returns true if the bounding info is in the frustum planes
  72806. */
  72807. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72808. /**
  72809. * Gets the world distance between the min and max points of the bounding box
  72810. */
  72811. readonly diagonalLength: number;
  72812. /**
  72813. * Checks if a cullable object (mesh...) is in the camera frustum
  72814. * Unlike isInFrustum this cheks the full bounding box
  72815. * @param frustumPlanes Camera near/planes
  72816. * @returns true if the object is in frustum otherwise false
  72817. */
  72818. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72819. /** @hidden */
  72820. _checkCollision(collider: Collider): boolean;
  72821. /**
  72822. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72823. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72824. * @param point the point to check intersection with
  72825. * @returns if the point intersects
  72826. */
  72827. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72828. /**
  72829. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72830. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72831. * @param boundingInfo the bounding info to check intersection with
  72832. * @param precise if the intersection should be done using OBB
  72833. * @returns if the bounding info intersects
  72834. */
  72835. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  72836. }
  72837. }
  72838. declare module BABYLON {
  72839. /**
  72840. * Extracts minimum and maximum values from a list of indexed positions
  72841. * @param positions defines the positions to use
  72842. * @param indices defines the indices to the positions
  72843. * @param indexStart defines the start index
  72844. * @param indexCount defines the end index
  72845. * @param bias defines bias value to add to the result
  72846. * @return minimum and maximum values
  72847. */
  72848. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  72849. minimum: Vector3;
  72850. maximum: Vector3;
  72851. };
  72852. /**
  72853. * Extracts minimum and maximum values from a list of positions
  72854. * @param positions defines the positions to use
  72855. * @param start defines the start index in the positions array
  72856. * @param count defines the number of positions to handle
  72857. * @param bias defines bias value to add to the result
  72858. * @param stride defines the stride size to use (distance between two positions in the positions array)
  72859. * @return minimum and maximum values
  72860. */
  72861. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  72862. minimum: Vector3;
  72863. maximum: Vector3;
  72864. };
  72865. }
  72866. declare module BABYLON {
  72867. /**
  72868. * Enum that determines the text-wrapping mode to use.
  72869. */
  72870. export enum InspectableType {
  72871. /**
  72872. * Checkbox for booleans
  72873. */
  72874. Checkbox = 0,
  72875. /**
  72876. * Sliders for numbers
  72877. */
  72878. Slider = 1,
  72879. /**
  72880. * Vector3
  72881. */
  72882. Vector3 = 2,
  72883. /**
  72884. * Quaternions
  72885. */
  72886. Quaternion = 3,
  72887. /**
  72888. * Color3
  72889. */
  72890. Color3 = 4,
  72891. /**
  72892. * String
  72893. */
  72894. String = 5
  72895. }
  72896. /**
  72897. * Interface used to define custom inspectable properties.
  72898. * This interface is used by the inspector to display custom property grids
  72899. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72900. */
  72901. export interface IInspectable {
  72902. /**
  72903. * Gets the label to display
  72904. */
  72905. label: string;
  72906. /**
  72907. * Gets the name of the property to edit
  72908. */
  72909. propertyName: string;
  72910. /**
  72911. * Gets the type of the editor to use
  72912. */
  72913. type: InspectableType;
  72914. /**
  72915. * Gets the minimum value of the property when using in "slider" mode
  72916. */
  72917. min?: number;
  72918. /**
  72919. * Gets the maximum value of the property when using in "slider" mode
  72920. */
  72921. max?: number;
  72922. /**
  72923. * Gets the setp to use when using in "slider" mode
  72924. */
  72925. step?: number;
  72926. }
  72927. }
  72928. declare module BABYLON {
  72929. /**
  72930. * Class used to provide helper for timing
  72931. */
  72932. export class TimingTools {
  72933. /**
  72934. * Polyfill for setImmediate
  72935. * @param action defines the action to execute after the current execution block
  72936. */
  72937. static SetImmediate(action: () => void): void;
  72938. }
  72939. }
  72940. declare module BABYLON {
  72941. /**
  72942. * Class used to enable instatition of objects by class name
  72943. */
  72944. export class InstantiationTools {
  72945. /**
  72946. * Use this object to register external classes like custom textures or material
  72947. * to allow the laoders to instantiate them
  72948. */
  72949. static RegisteredExternalClasses: {
  72950. [key: string]: Object;
  72951. };
  72952. /**
  72953. * Tries to instantiate a new object from a given class name
  72954. * @param className defines the class name to instantiate
  72955. * @returns the new object or null if the system was not able to do the instantiation
  72956. */
  72957. static Instantiate(className: string): any;
  72958. }
  72959. }
  72960. declare module BABYLON {
  72961. /**
  72962. * This represents the required contract to create a new type of texture loader.
  72963. */
  72964. export interface IInternalTextureLoader {
  72965. /**
  72966. * Defines wether the loader supports cascade loading the different faces.
  72967. */
  72968. supportCascades: boolean;
  72969. /**
  72970. * This returns if the loader support the current file information.
  72971. * @param extension defines the file extension of the file being loaded
  72972. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72973. * @param fallback defines the fallback internal texture if any
  72974. * @param isBase64 defines whether the texture is encoded as a base64
  72975. * @param isBuffer defines whether the texture data are stored as a buffer
  72976. * @returns true if the loader can load the specified file
  72977. */
  72978. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72979. /**
  72980. * Transform the url before loading if required.
  72981. * @param rootUrl the url of the texture
  72982. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72983. * @returns the transformed texture
  72984. */
  72985. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72986. /**
  72987. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72988. * @param rootUrl the url of the texture
  72989. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72990. * @returns the fallback texture
  72991. */
  72992. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72993. /**
  72994. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72995. * @param data contains the texture data
  72996. * @param texture defines the BabylonJS internal texture
  72997. * @param createPolynomials will be true if polynomials have been requested
  72998. * @param onLoad defines the callback to trigger once the texture is ready
  72999. * @param onError defines the callback to trigger in case of error
  73000. */
  73001. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73002. /**
  73003. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73004. * @param data contains the texture data
  73005. * @param texture defines the BabylonJS internal texture
  73006. * @param callback defines the method to call once ready to upload
  73007. */
  73008. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73009. }
  73010. }
  73011. declare module BABYLON {
  73012. interface Engine {
  73013. /**
  73014. * Creates a depth stencil cube texture.
  73015. * This is only available in WebGL 2.
  73016. * @param size The size of face edge in the cube texture.
  73017. * @param options The options defining the cube texture.
  73018. * @returns The cube texture
  73019. */
  73020. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73021. /**
  73022. * Creates a cube texture
  73023. * @param rootUrl defines the url where the files to load is located
  73024. * @param scene defines the current scene
  73025. * @param files defines the list of files to load (1 per face)
  73026. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73027. * @param onLoad defines an optional callback raised when the texture is loaded
  73028. * @param onError defines an optional callback raised if there is an issue to load the texture
  73029. * @param format defines the format of the data
  73030. * @param forcedExtension defines the extension to use to pick the right loader
  73031. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73032. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73033. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73034. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73035. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73036. * @returns the cube texture as an InternalTexture
  73037. */
  73038. 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;
  73039. /**
  73040. * Creates a cube texture
  73041. * @param rootUrl defines the url where the files to load is located
  73042. * @param scene defines the current scene
  73043. * @param files defines the list of files to load (1 per face)
  73044. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73045. * @param onLoad defines an optional callback raised when the texture is loaded
  73046. * @param onError defines an optional callback raised if there is an issue to load the texture
  73047. * @param format defines the format of the data
  73048. * @param forcedExtension defines the extension to use to pick the right loader
  73049. * @returns the cube texture as an InternalTexture
  73050. */
  73051. 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;
  73052. /**
  73053. * Creates a cube texture
  73054. * @param rootUrl defines the url where the files to load is located
  73055. * @param scene defines the current scene
  73056. * @param files defines the list of files to load (1 per face)
  73057. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73058. * @param onLoad defines an optional callback raised when the texture is loaded
  73059. * @param onError defines an optional callback raised if there is an issue to load the texture
  73060. * @param format defines the format of the data
  73061. * @param forcedExtension defines the extension to use to pick the right loader
  73062. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73063. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73064. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73065. * @returns the cube texture as an InternalTexture
  73066. */
  73067. 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;
  73068. /** @hidden */
  73069. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73070. /** @hidden */
  73071. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73072. /** @hidden */
  73073. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73074. /** @hidden */
  73075. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73076. }
  73077. }
  73078. declare module BABYLON {
  73079. /**
  73080. * Class for creating a cube texture
  73081. */
  73082. export class CubeTexture extends BaseTexture {
  73083. private _delayedOnLoad;
  73084. /**
  73085. * The url of the texture
  73086. */
  73087. url: string;
  73088. /**
  73089. * Gets or sets the center of the bounding box associated with the cube texture.
  73090. * It must define where the camera used to render the texture was set
  73091. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73092. */
  73093. boundingBoxPosition: Vector3;
  73094. private _boundingBoxSize;
  73095. /**
  73096. * Gets or sets the size of the bounding box associated with the cube texture
  73097. * When defined, the cubemap will switch to local mode
  73098. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73099. * @example https://www.babylonjs-playground.com/#RNASML
  73100. */
  73101. /**
  73102. * Returns the bounding box size
  73103. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73104. */
  73105. boundingBoxSize: Vector3;
  73106. protected _rotationY: number;
  73107. /**
  73108. * Sets texture matrix rotation angle around Y axis in radians.
  73109. */
  73110. /**
  73111. * Gets texture matrix rotation angle around Y axis radians.
  73112. */
  73113. rotationY: number;
  73114. /**
  73115. * Are mip maps generated for this texture or not.
  73116. */
  73117. readonly noMipmap: boolean;
  73118. private _noMipmap;
  73119. private _files;
  73120. private _extensions;
  73121. private _textureMatrix;
  73122. private _format;
  73123. private _createPolynomials;
  73124. /** @hidden */
  73125. _prefiltered: boolean;
  73126. /**
  73127. * Creates a cube texture from an array of image urls
  73128. * @param files defines an array of image urls
  73129. * @param scene defines the hosting scene
  73130. * @param noMipmap specifies if mip maps are not used
  73131. * @returns a cube texture
  73132. */
  73133. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73134. /**
  73135. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73136. * @param url defines the url of the prefiltered texture
  73137. * @param scene defines the scene the texture is attached to
  73138. * @param forcedExtension defines the extension of the file if different from the url
  73139. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73140. * @return the prefiltered texture
  73141. */
  73142. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73143. /**
  73144. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73145. * as prefiltered data.
  73146. * @param rootUrl defines the url of the texture or the root name of the six images
  73147. * @param scene defines the scene the texture is attached to
  73148. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73149. * @param noMipmap defines if mipmaps should be created or not
  73150. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73151. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73152. * @param onError defines a callback triggered in case of error during load
  73153. * @param format defines the internal format to use for the texture once loaded
  73154. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73155. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73156. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73157. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73158. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73159. * @return the cube texture
  73160. */
  73161. 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);
  73162. /**
  73163. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73164. */
  73165. readonly isPrefiltered: boolean;
  73166. /**
  73167. * Get the current class name of the texture useful for serialization or dynamic coding.
  73168. * @returns "CubeTexture"
  73169. */
  73170. getClassName(): string;
  73171. /**
  73172. * Update the url (and optional buffer) of this texture if url was null during construction.
  73173. * @param url the url of the texture
  73174. * @param forcedExtension defines the extension to use
  73175. * @param onLoad callback called when the texture is loaded (defaults to null)
  73176. */
  73177. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73178. /**
  73179. * Delays loading of the cube texture
  73180. * @param forcedExtension defines the extension to use
  73181. */
  73182. delayLoad(forcedExtension?: string): void;
  73183. /**
  73184. * Returns the reflection texture matrix
  73185. * @returns the reflection texture matrix
  73186. */
  73187. getReflectionTextureMatrix(): Matrix;
  73188. /**
  73189. * Sets the reflection texture matrix
  73190. * @param value Reflection texture matrix
  73191. */
  73192. setReflectionTextureMatrix(value: Matrix): void;
  73193. /**
  73194. * Parses text to create a cube texture
  73195. * @param parsedTexture define the serialized text to read from
  73196. * @param scene defines the hosting scene
  73197. * @param rootUrl defines the root url of the cube texture
  73198. * @returns a cube texture
  73199. */
  73200. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73201. /**
  73202. * Makes a clone, or deep copy, of the cube texture
  73203. * @returns a new cube texture
  73204. */
  73205. clone(): CubeTexture;
  73206. }
  73207. }
  73208. declare module BABYLON {
  73209. /**
  73210. * Manages the defines for the Material
  73211. */
  73212. export class MaterialDefines {
  73213. /** @hidden */
  73214. protected _keys: string[];
  73215. private _isDirty;
  73216. /** @hidden */
  73217. _renderId: number;
  73218. /** @hidden */
  73219. _areLightsDirty: boolean;
  73220. /** @hidden */
  73221. _areLightsDisposed: boolean;
  73222. /** @hidden */
  73223. _areAttributesDirty: boolean;
  73224. /** @hidden */
  73225. _areTexturesDirty: boolean;
  73226. /** @hidden */
  73227. _areFresnelDirty: boolean;
  73228. /** @hidden */
  73229. _areMiscDirty: boolean;
  73230. /** @hidden */
  73231. _areImageProcessingDirty: boolean;
  73232. /** @hidden */
  73233. _normals: boolean;
  73234. /** @hidden */
  73235. _uvs: boolean;
  73236. /** @hidden */
  73237. _needNormals: boolean;
  73238. /** @hidden */
  73239. _needUVs: boolean;
  73240. [id: string]: any;
  73241. /**
  73242. * Specifies if the material needs to be re-calculated
  73243. */
  73244. readonly isDirty: boolean;
  73245. /**
  73246. * Marks the material to indicate that it has been re-calculated
  73247. */
  73248. markAsProcessed(): void;
  73249. /**
  73250. * Marks the material to indicate that it needs to be re-calculated
  73251. */
  73252. markAsUnprocessed(): void;
  73253. /**
  73254. * Marks the material to indicate all of its defines need to be re-calculated
  73255. */
  73256. markAllAsDirty(): void;
  73257. /**
  73258. * Marks the material to indicate that image processing needs to be re-calculated
  73259. */
  73260. markAsImageProcessingDirty(): void;
  73261. /**
  73262. * Marks the material to indicate the lights need to be re-calculated
  73263. * @param disposed Defines whether the light is dirty due to dispose or not
  73264. */
  73265. markAsLightDirty(disposed?: boolean): void;
  73266. /**
  73267. * Marks the attribute state as changed
  73268. */
  73269. markAsAttributesDirty(): void;
  73270. /**
  73271. * Marks the texture state as changed
  73272. */
  73273. markAsTexturesDirty(): void;
  73274. /**
  73275. * Marks the fresnel state as changed
  73276. */
  73277. markAsFresnelDirty(): void;
  73278. /**
  73279. * Marks the misc state as changed
  73280. */
  73281. markAsMiscDirty(): void;
  73282. /**
  73283. * Rebuilds the material defines
  73284. */
  73285. rebuild(): void;
  73286. /**
  73287. * Specifies if two material defines are equal
  73288. * @param other - A material define instance to compare to
  73289. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73290. */
  73291. isEqual(other: MaterialDefines): boolean;
  73292. /**
  73293. * Clones this instance's defines to another instance
  73294. * @param other - material defines to clone values to
  73295. */
  73296. cloneTo(other: MaterialDefines): void;
  73297. /**
  73298. * Resets the material define values
  73299. */
  73300. reset(): void;
  73301. /**
  73302. * Converts the material define values to a string
  73303. * @returns - String of material define information
  73304. */
  73305. toString(): string;
  73306. }
  73307. }
  73308. declare module BABYLON {
  73309. /**
  73310. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73311. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73312. * 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;
  73313. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73314. */
  73315. export class ColorCurves {
  73316. private _dirty;
  73317. private _tempColor;
  73318. private _globalCurve;
  73319. private _highlightsCurve;
  73320. private _midtonesCurve;
  73321. private _shadowsCurve;
  73322. private _positiveCurve;
  73323. private _negativeCurve;
  73324. private _globalHue;
  73325. private _globalDensity;
  73326. private _globalSaturation;
  73327. private _globalExposure;
  73328. /**
  73329. * Gets the global Hue value.
  73330. * 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).
  73331. */
  73332. /**
  73333. * Sets the global Hue value.
  73334. * 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).
  73335. */
  73336. globalHue: number;
  73337. /**
  73338. * Gets the global Density value.
  73339. * 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.
  73340. * Values less than zero provide a filter of opposite hue.
  73341. */
  73342. /**
  73343. * Sets the global Density value.
  73344. * 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.
  73345. * Values less than zero provide a filter of opposite hue.
  73346. */
  73347. globalDensity: number;
  73348. /**
  73349. * Gets the global Saturation value.
  73350. * 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.
  73351. */
  73352. /**
  73353. * Sets the global Saturation value.
  73354. * 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.
  73355. */
  73356. globalSaturation: number;
  73357. /**
  73358. * Gets the global Exposure value.
  73359. * 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.
  73360. */
  73361. /**
  73362. * Sets the global Exposure value.
  73363. * 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.
  73364. */
  73365. globalExposure: number;
  73366. private _highlightsHue;
  73367. private _highlightsDensity;
  73368. private _highlightsSaturation;
  73369. private _highlightsExposure;
  73370. /**
  73371. * Gets the highlights Hue value.
  73372. * 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).
  73373. */
  73374. /**
  73375. * Sets the highlights Hue value.
  73376. * 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).
  73377. */
  73378. highlightsHue: number;
  73379. /**
  73380. * Gets the highlights Density value.
  73381. * 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.
  73382. * Values less than zero provide a filter of opposite hue.
  73383. */
  73384. /**
  73385. * Sets the highlights Density value.
  73386. * 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.
  73387. * Values less than zero provide a filter of opposite hue.
  73388. */
  73389. highlightsDensity: number;
  73390. /**
  73391. * Gets the highlights Saturation value.
  73392. * 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.
  73393. */
  73394. /**
  73395. * Sets the highlights Saturation value.
  73396. * 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.
  73397. */
  73398. highlightsSaturation: number;
  73399. /**
  73400. * Gets the highlights Exposure value.
  73401. * 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.
  73402. */
  73403. /**
  73404. * Sets the highlights Exposure value.
  73405. * 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.
  73406. */
  73407. highlightsExposure: number;
  73408. private _midtonesHue;
  73409. private _midtonesDensity;
  73410. private _midtonesSaturation;
  73411. private _midtonesExposure;
  73412. /**
  73413. * Gets the midtones Hue value.
  73414. * 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).
  73415. */
  73416. /**
  73417. * Sets the midtones Hue value.
  73418. * 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).
  73419. */
  73420. midtonesHue: number;
  73421. /**
  73422. * Gets the midtones Density value.
  73423. * 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.
  73424. * Values less than zero provide a filter of opposite hue.
  73425. */
  73426. /**
  73427. * Sets the midtones Density value.
  73428. * 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.
  73429. * Values less than zero provide a filter of opposite hue.
  73430. */
  73431. midtonesDensity: number;
  73432. /**
  73433. * Gets the midtones Saturation value.
  73434. * 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.
  73435. */
  73436. /**
  73437. * Sets the midtones Saturation value.
  73438. * 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.
  73439. */
  73440. midtonesSaturation: number;
  73441. /**
  73442. * Gets the midtones Exposure value.
  73443. * 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.
  73444. */
  73445. /**
  73446. * Sets the midtones Exposure value.
  73447. * 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.
  73448. */
  73449. midtonesExposure: number;
  73450. private _shadowsHue;
  73451. private _shadowsDensity;
  73452. private _shadowsSaturation;
  73453. private _shadowsExposure;
  73454. /**
  73455. * Gets the shadows Hue value.
  73456. * 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).
  73457. */
  73458. /**
  73459. * Sets the shadows Hue value.
  73460. * 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).
  73461. */
  73462. shadowsHue: number;
  73463. /**
  73464. * Gets the shadows Density value.
  73465. * 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.
  73466. * Values less than zero provide a filter of opposite hue.
  73467. */
  73468. /**
  73469. * Sets the shadows Density value.
  73470. * 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.
  73471. * Values less than zero provide a filter of opposite hue.
  73472. */
  73473. shadowsDensity: number;
  73474. /**
  73475. * Gets the shadows Saturation value.
  73476. * 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.
  73477. */
  73478. /**
  73479. * Sets the shadows Saturation value.
  73480. * 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.
  73481. */
  73482. shadowsSaturation: number;
  73483. /**
  73484. * Gets the shadows Exposure value.
  73485. * 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.
  73486. */
  73487. /**
  73488. * Sets the shadows Exposure value.
  73489. * 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.
  73490. */
  73491. shadowsExposure: number;
  73492. /**
  73493. * Returns the class name
  73494. * @returns The class name
  73495. */
  73496. getClassName(): string;
  73497. /**
  73498. * Binds the color curves to the shader.
  73499. * @param colorCurves The color curve to bind
  73500. * @param effect The effect to bind to
  73501. * @param positiveUniform The positive uniform shader parameter
  73502. * @param neutralUniform The neutral uniform shader parameter
  73503. * @param negativeUniform The negative uniform shader parameter
  73504. */
  73505. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73506. /**
  73507. * Prepare the list of uniforms associated with the ColorCurves effects.
  73508. * @param uniformsList The list of uniforms used in the effect
  73509. */
  73510. static PrepareUniforms(uniformsList: string[]): void;
  73511. /**
  73512. * Returns color grading data based on a hue, density, saturation and exposure value.
  73513. * @param filterHue The hue of the color filter.
  73514. * @param filterDensity The density of the color filter.
  73515. * @param saturation The saturation.
  73516. * @param exposure The exposure.
  73517. * @param result The result data container.
  73518. */
  73519. private getColorGradingDataToRef;
  73520. /**
  73521. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73522. * @param value The input slider value in range [-100,100].
  73523. * @returns Adjusted value.
  73524. */
  73525. private static applyColorGradingSliderNonlinear;
  73526. /**
  73527. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73528. * @param hue The hue (H) input.
  73529. * @param saturation The saturation (S) input.
  73530. * @param brightness The brightness (B) input.
  73531. * @result An RGBA color represented as Vector4.
  73532. */
  73533. private static fromHSBToRef;
  73534. /**
  73535. * Returns a value clamped between min and max
  73536. * @param value The value to clamp
  73537. * @param min The minimum of value
  73538. * @param max The maximum of value
  73539. * @returns The clamped value.
  73540. */
  73541. private static clamp;
  73542. /**
  73543. * Clones the current color curve instance.
  73544. * @return The cloned curves
  73545. */
  73546. clone(): ColorCurves;
  73547. /**
  73548. * Serializes the current color curve instance to a json representation.
  73549. * @return a JSON representation
  73550. */
  73551. serialize(): any;
  73552. /**
  73553. * Parses the color curve from a json representation.
  73554. * @param source the JSON source to parse
  73555. * @return The parsed curves
  73556. */
  73557. static Parse(source: any): ColorCurves;
  73558. }
  73559. }
  73560. declare module BABYLON {
  73561. /**
  73562. * Interface to follow in your material defines to integrate easily the
  73563. * Image proccessing functions.
  73564. * @hidden
  73565. */
  73566. export interface IImageProcessingConfigurationDefines {
  73567. IMAGEPROCESSING: boolean;
  73568. VIGNETTE: boolean;
  73569. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73570. VIGNETTEBLENDMODEOPAQUE: boolean;
  73571. TONEMAPPING: boolean;
  73572. TONEMAPPING_ACES: boolean;
  73573. CONTRAST: boolean;
  73574. EXPOSURE: boolean;
  73575. COLORCURVES: boolean;
  73576. COLORGRADING: boolean;
  73577. COLORGRADING3D: boolean;
  73578. SAMPLER3DGREENDEPTH: boolean;
  73579. SAMPLER3DBGRMAP: boolean;
  73580. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73581. }
  73582. /**
  73583. * @hidden
  73584. */
  73585. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73586. IMAGEPROCESSING: boolean;
  73587. VIGNETTE: boolean;
  73588. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73589. VIGNETTEBLENDMODEOPAQUE: boolean;
  73590. TONEMAPPING: boolean;
  73591. TONEMAPPING_ACES: boolean;
  73592. CONTRAST: boolean;
  73593. COLORCURVES: boolean;
  73594. COLORGRADING: boolean;
  73595. COLORGRADING3D: boolean;
  73596. SAMPLER3DGREENDEPTH: boolean;
  73597. SAMPLER3DBGRMAP: boolean;
  73598. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73599. EXPOSURE: boolean;
  73600. constructor();
  73601. }
  73602. /**
  73603. * This groups together the common properties used for image processing either in direct forward pass
  73604. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73605. * or not.
  73606. */
  73607. export class ImageProcessingConfiguration {
  73608. /**
  73609. * Default tone mapping applied in BabylonJS.
  73610. */
  73611. static readonly TONEMAPPING_STANDARD: number;
  73612. /**
  73613. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73614. * to other engines rendering to increase portability.
  73615. */
  73616. static readonly TONEMAPPING_ACES: number;
  73617. /**
  73618. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73619. */
  73620. colorCurves: Nullable<ColorCurves>;
  73621. private _colorCurvesEnabled;
  73622. /**
  73623. * Gets wether the color curves effect is enabled.
  73624. */
  73625. /**
  73626. * Sets wether the color curves effect is enabled.
  73627. */
  73628. colorCurvesEnabled: boolean;
  73629. private _colorGradingTexture;
  73630. /**
  73631. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73632. */
  73633. /**
  73634. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73635. */
  73636. colorGradingTexture: Nullable<BaseTexture>;
  73637. private _colorGradingEnabled;
  73638. /**
  73639. * Gets wether the color grading effect is enabled.
  73640. */
  73641. /**
  73642. * Sets wether the color grading effect is enabled.
  73643. */
  73644. colorGradingEnabled: boolean;
  73645. private _colorGradingWithGreenDepth;
  73646. /**
  73647. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73648. */
  73649. /**
  73650. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73651. */
  73652. colorGradingWithGreenDepth: boolean;
  73653. private _colorGradingBGR;
  73654. /**
  73655. * Gets wether the color grading texture contains BGR values.
  73656. */
  73657. /**
  73658. * Sets wether the color grading texture contains BGR values.
  73659. */
  73660. colorGradingBGR: boolean;
  73661. /** @hidden */
  73662. _exposure: number;
  73663. /**
  73664. * Gets the Exposure used in the effect.
  73665. */
  73666. /**
  73667. * Sets the Exposure used in the effect.
  73668. */
  73669. exposure: number;
  73670. private _toneMappingEnabled;
  73671. /**
  73672. * Gets wether the tone mapping effect is enabled.
  73673. */
  73674. /**
  73675. * Sets wether the tone mapping effect is enabled.
  73676. */
  73677. toneMappingEnabled: boolean;
  73678. private _toneMappingType;
  73679. /**
  73680. * Gets the type of tone mapping effect.
  73681. */
  73682. /**
  73683. * Sets the type of tone mapping effect used in BabylonJS.
  73684. */
  73685. toneMappingType: number;
  73686. protected _contrast: number;
  73687. /**
  73688. * Gets the contrast used in the effect.
  73689. */
  73690. /**
  73691. * Sets the contrast used in the effect.
  73692. */
  73693. contrast: number;
  73694. /**
  73695. * Vignette stretch size.
  73696. */
  73697. vignetteStretch: number;
  73698. /**
  73699. * Vignette centre X Offset.
  73700. */
  73701. vignetteCentreX: number;
  73702. /**
  73703. * Vignette centre Y Offset.
  73704. */
  73705. vignetteCentreY: number;
  73706. /**
  73707. * Vignette weight or intensity of the vignette effect.
  73708. */
  73709. vignetteWeight: number;
  73710. /**
  73711. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73712. * if vignetteEnabled is set to true.
  73713. */
  73714. vignetteColor: Color4;
  73715. /**
  73716. * Camera field of view used by the Vignette effect.
  73717. */
  73718. vignetteCameraFov: number;
  73719. private _vignetteBlendMode;
  73720. /**
  73721. * Gets the vignette blend mode allowing different kind of effect.
  73722. */
  73723. /**
  73724. * Sets the vignette blend mode allowing different kind of effect.
  73725. */
  73726. vignetteBlendMode: number;
  73727. private _vignetteEnabled;
  73728. /**
  73729. * Gets wether the vignette effect is enabled.
  73730. */
  73731. /**
  73732. * Sets wether the vignette effect is enabled.
  73733. */
  73734. vignetteEnabled: boolean;
  73735. private _applyByPostProcess;
  73736. /**
  73737. * Gets wether the image processing is applied through a post process or not.
  73738. */
  73739. /**
  73740. * Sets wether the image processing is applied through a post process or not.
  73741. */
  73742. applyByPostProcess: boolean;
  73743. private _isEnabled;
  73744. /**
  73745. * Gets wether the image processing is enabled or not.
  73746. */
  73747. /**
  73748. * Sets wether the image processing is enabled or not.
  73749. */
  73750. isEnabled: boolean;
  73751. /**
  73752. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73753. */
  73754. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73755. /**
  73756. * Method called each time the image processing information changes requires to recompile the effect.
  73757. */
  73758. protected _updateParameters(): void;
  73759. /**
  73760. * Gets the current class name.
  73761. * @return "ImageProcessingConfiguration"
  73762. */
  73763. getClassName(): string;
  73764. /**
  73765. * Prepare the list of uniforms associated with the Image Processing effects.
  73766. * @param uniforms The list of uniforms used in the effect
  73767. * @param defines the list of defines currently in use
  73768. */
  73769. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73770. /**
  73771. * Prepare the list of samplers associated with the Image Processing effects.
  73772. * @param samplersList The list of uniforms used in the effect
  73773. * @param defines the list of defines currently in use
  73774. */
  73775. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73776. /**
  73777. * Prepare the list of defines associated to the shader.
  73778. * @param defines the list of defines to complete
  73779. * @param forPostProcess Define if we are currently in post process mode or not
  73780. */
  73781. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73782. /**
  73783. * Returns true if all the image processing information are ready.
  73784. * @returns True if ready, otherwise, false
  73785. */
  73786. isReady(): boolean;
  73787. /**
  73788. * Binds the image processing to the shader.
  73789. * @param effect The effect to bind to
  73790. * @param aspectRatio Define the current aspect ratio of the effect
  73791. */
  73792. bind(effect: Effect, aspectRatio?: number): void;
  73793. /**
  73794. * Clones the current image processing instance.
  73795. * @return The cloned image processing
  73796. */
  73797. clone(): ImageProcessingConfiguration;
  73798. /**
  73799. * Serializes the current image processing instance to a json representation.
  73800. * @return a JSON representation
  73801. */
  73802. serialize(): any;
  73803. /**
  73804. * Parses the image processing from a json representation.
  73805. * @param source the JSON source to parse
  73806. * @return The parsed image processing
  73807. */
  73808. static Parse(source: any): ImageProcessingConfiguration;
  73809. private static _VIGNETTEMODE_MULTIPLY;
  73810. private static _VIGNETTEMODE_OPAQUE;
  73811. /**
  73812. * Used to apply the vignette as a mix with the pixel color.
  73813. */
  73814. static readonly VIGNETTEMODE_MULTIPLY: number;
  73815. /**
  73816. * Used to apply the vignette as a replacement of the pixel color.
  73817. */
  73818. static readonly VIGNETTEMODE_OPAQUE: number;
  73819. }
  73820. }
  73821. declare module BABYLON {
  73822. /** @hidden */
  73823. export var postprocessVertexShader: {
  73824. name: string;
  73825. shader: string;
  73826. };
  73827. }
  73828. declare module BABYLON {
  73829. /** Defines supported spaces */
  73830. export enum Space {
  73831. /** Local (object) space */
  73832. LOCAL = 0,
  73833. /** World space */
  73834. WORLD = 1,
  73835. /** Bone space */
  73836. BONE = 2
  73837. }
  73838. /** Defines the 3 main axes */
  73839. export class Axis {
  73840. /** X axis */
  73841. static X: Vector3;
  73842. /** Y axis */
  73843. static Y: Vector3;
  73844. /** Z axis */
  73845. static Z: Vector3;
  73846. }
  73847. }
  73848. declare module BABYLON {
  73849. /**
  73850. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  73851. * This is the base of the follow, arc rotate cameras and Free camera
  73852. * @see http://doc.babylonjs.com/features/cameras
  73853. */
  73854. export class TargetCamera extends Camera {
  73855. private static _RigCamTransformMatrix;
  73856. private static _TargetTransformMatrix;
  73857. private static _TargetFocalPoint;
  73858. /**
  73859. * Define the current direction the camera is moving to
  73860. */
  73861. cameraDirection: Vector3;
  73862. /**
  73863. * Define the current rotation the camera is rotating to
  73864. */
  73865. cameraRotation: Vector2;
  73866. /**
  73867. * When set, the up vector of the camera will be updated by the rotation of the camera
  73868. */
  73869. updateUpVectorFromRotation: boolean;
  73870. private _tmpQuaternion;
  73871. /**
  73872. * Define the current rotation of the camera
  73873. */
  73874. rotation: Vector3;
  73875. /**
  73876. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  73877. */
  73878. rotationQuaternion: Quaternion;
  73879. /**
  73880. * Define the current speed of the camera
  73881. */
  73882. speed: number;
  73883. /**
  73884. * Add cconstraint to the camera to prevent it to move freely in all directions and
  73885. * around all axis.
  73886. */
  73887. noRotationConstraint: boolean;
  73888. /**
  73889. * Define the current target of the camera as an object or a position.
  73890. */
  73891. lockedTarget: any;
  73892. /** @hidden */
  73893. _currentTarget: Vector3;
  73894. /** @hidden */
  73895. _initialFocalDistance: number;
  73896. /** @hidden */
  73897. _viewMatrix: Matrix;
  73898. /** @hidden */
  73899. _camMatrix: Matrix;
  73900. /** @hidden */
  73901. _cameraTransformMatrix: Matrix;
  73902. /** @hidden */
  73903. _cameraRotationMatrix: Matrix;
  73904. /** @hidden */
  73905. _referencePoint: Vector3;
  73906. /** @hidden */
  73907. _transformedReferencePoint: Vector3;
  73908. protected _globalCurrentTarget: Vector3;
  73909. protected _globalCurrentUpVector: Vector3;
  73910. /** @hidden */
  73911. _reset: () => void;
  73912. private _defaultUp;
  73913. /**
  73914. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  73915. * This is the base of the follow, arc rotate cameras and Free camera
  73916. * @see http://doc.babylonjs.com/features/cameras
  73917. * @param name Defines the name of the camera in the scene
  73918. * @param position Defines the start position of the camera in the scene
  73919. * @param scene Defines the scene the camera belongs to
  73920. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  73921. */
  73922. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  73923. /**
  73924. * Gets the position in front of the camera at a given distance.
  73925. * @param distance The distance from the camera we want the position to be
  73926. * @returns the position
  73927. */
  73928. getFrontPosition(distance: number): Vector3;
  73929. /** @hidden */
  73930. _getLockedTargetPosition(): Nullable<Vector3>;
  73931. private _storedPosition;
  73932. private _storedRotation;
  73933. private _storedRotationQuaternion;
  73934. /**
  73935. * Store current camera state of the camera (fov, position, rotation, etc..)
  73936. * @returns the camera
  73937. */
  73938. storeState(): Camera;
  73939. /**
  73940. * Restored camera state. You must call storeState() first
  73941. * @returns whether it was successful or not
  73942. * @hidden
  73943. */
  73944. _restoreStateValues(): boolean;
  73945. /** @hidden */
  73946. _initCache(): void;
  73947. /** @hidden */
  73948. _updateCache(ignoreParentClass?: boolean): void;
  73949. /** @hidden */
  73950. _isSynchronizedViewMatrix(): boolean;
  73951. /** @hidden */
  73952. _computeLocalCameraSpeed(): number;
  73953. /**
  73954. * Defines the target the camera should look at.
  73955. * @param target Defines the new target as a Vector or a mesh
  73956. */
  73957. setTarget(target: Vector3): void;
  73958. /**
  73959. * Return the current target position of the camera. This value is expressed in local space.
  73960. * @returns the target position
  73961. */
  73962. getTarget(): Vector3;
  73963. /** @hidden */
  73964. _decideIfNeedsToMove(): boolean;
  73965. /** @hidden */
  73966. _updatePosition(): void;
  73967. /** @hidden */
  73968. _checkInputs(): void;
  73969. protected _updateCameraRotationMatrix(): void;
  73970. /**
  73971. * 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)
  73972. * @returns the current camera
  73973. */
  73974. private _rotateUpVectorWithCameraRotationMatrix;
  73975. private _cachedRotationZ;
  73976. private _cachedQuaternionRotationZ;
  73977. /** @hidden */
  73978. _getViewMatrix(): Matrix;
  73979. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  73980. /**
  73981. * @hidden
  73982. */
  73983. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  73984. /**
  73985. * @hidden
  73986. */
  73987. _updateRigCameras(): void;
  73988. private _getRigCamPositionAndTarget;
  73989. /**
  73990. * Gets the current object class name.
  73991. * @return the class name
  73992. */
  73993. getClassName(): string;
  73994. }
  73995. }
  73996. declare module BABYLON {
  73997. /**
  73998. * Gather the list of keyboard event types as constants.
  73999. */
  74000. export class KeyboardEventTypes {
  74001. /**
  74002. * The keydown event is fired when a key becomes active (pressed).
  74003. */
  74004. static readonly KEYDOWN: number;
  74005. /**
  74006. * The keyup event is fired when a key has been released.
  74007. */
  74008. static readonly KEYUP: number;
  74009. }
  74010. /**
  74011. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74012. */
  74013. export class KeyboardInfo {
  74014. /**
  74015. * Defines the type of event (KeyboardEventTypes)
  74016. */
  74017. type: number;
  74018. /**
  74019. * Defines the related dom event
  74020. */
  74021. event: KeyboardEvent;
  74022. /**
  74023. * Instantiates a new keyboard info.
  74024. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74025. * @param type Defines the type of event (KeyboardEventTypes)
  74026. * @param event Defines the related dom event
  74027. */
  74028. constructor(
  74029. /**
  74030. * Defines the type of event (KeyboardEventTypes)
  74031. */
  74032. type: number,
  74033. /**
  74034. * Defines the related dom event
  74035. */
  74036. event: KeyboardEvent);
  74037. }
  74038. /**
  74039. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74040. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74041. */
  74042. export class KeyboardInfoPre extends KeyboardInfo {
  74043. /**
  74044. * Defines the type of event (KeyboardEventTypes)
  74045. */
  74046. type: number;
  74047. /**
  74048. * Defines the related dom event
  74049. */
  74050. event: KeyboardEvent;
  74051. /**
  74052. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74053. */
  74054. skipOnPointerObservable: boolean;
  74055. /**
  74056. * Instantiates a new keyboard pre info.
  74057. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74058. * @param type Defines the type of event (KeyboardEventTypes)
  74059. * @param event Defines the related dom event
  74060. */
  74061. constructor(
  74062. /**
  74063. * Defines the type of event (KeyboardEventTypes)
  74064. */
  74065. type: number,
  74066. /**
  74067. * Defines the related dom event
  74068. */
  74069. event: KeyboardEvent);
  74070. }
  74071. }
  74072. declare module BABYLON {
  74073. /**
  74074. * Manage the keyboard inputs to control the movement of a free camera.
  74075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74076. */
  74077. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74078. /**
  74079. * Defines the camera the input is attached to.
  74080. */
  74081. camera: FreeCamera;
  74082. /**
  74083. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74084. */
  74085. keysUp: number[];
  74086. /**
  74087. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74088. */
  74089. keysDown: number[];
  74090. /**
  74091. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74092. */
  74093. keysLeft: number[];
  74094. /**
  74095. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74096. */
  74097. keysRight: number[];
  74098. private _keys;
  74099. private _onCanvasBlurObserver;
  74100. private _onKeyboardObserver;
  74101. private _engine;
  74102. private _scene;
  74103. /**
  74104. * Attach the input controls to a specific dom element to get the input from.
  74105. * @param element Defines the element the controls should be listened from
  74106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74107. */
  74108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74109. /**
  74110. * Detach the current controls from the specified dom element.
  74111. * @param element Defines the element to stop listening the inputs from
  74112. */
  74113. detachControl(element: Nullable<HTMLElement>): void;
  74114. /**
  74115. * Update the current camera state depending on the inputs that have been used this frame.
  74116. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74117. */
  74118. checkInputs(): void;
  74119. /**
  74120. * Gets the class name of the current intput.
  74121. * @returns the class name
  74122. */
  74123. getClassName(): string;
  74124. /** @hidden */
  74125. _onLostFocus(): void;
  74126. /**
  74127. * Get the friendly name associated with the input class.
  74128. * @returns the input friendly name
  74129. */
  74130. getSimpleName(): string;
  74131. }
  74132. }
  74133. declare module BABYLON {
  74134. /**
  74135. * Interface describing all the common properties and methods a shadow light needs to implement.
  74136. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74137. * as well as binding the different shadow properties to the effects.
  74138. */
  74139. export interface IShadowLight extends Light {
  74140. /**
  74141. * The light id in the scene (used in scene.findLighById for instance)
  74142. */
  74143. id: string;
  74144. /**
  74145. * The position the shdow will be casted from.
  74146. */
  74147. position: Vector3;
  74148. /**
  74149. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74150. */
  74151. direction: Vector3;
  74152. /**
  74153. * The transformed position. Position of the light in world space taking parenting in account.
  74154. */
  74155. transformedPosition: Vector3;
  74156. /**
  74157. * The transformed direction. Direction of the light in world space taking parenting in account.
  74158. */
  74159. transformedDirection: Vector3;
  74160. /**
  74161. * The friendly name of the light in the scene.
  74162. */
  74163. name: string;
  74164. /**
  74165. * Defines the shadow projection clipping minimum z value.
  74166. */
  74167. shadowMinZ: number;
  74168. /**
  74169. * Defines the shadow projection clipping maximum z value.
  74170. */
  74171. shadowMaxZ: number;
  74172. /**
  74173. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74174. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74175. */
  74176. computeTransformedInformation(): boolean;
  74177. /**
  74178. * Gets the scene the light belongs to.
  74179. * @returns The scene
  74180. */
  74181. getScene(): Scene;
  74182. /**
  74183. * Callback defining a custom Projection Matrix Builder.
  74184. * This can be used to override the default projection matrix computation.
  74185. */
  74186. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74187. /**
  74188. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74189. * @param matrix The materix to updated with the projection information
  74190. * @param viewMatrix The transform matrix of the light
  74191. * @param renderList The list of mesh to render in the map
  74192. * @returns The current light
  74193. */
  74194. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74195. /**
  74196. * Gets the current depth scale used in ESM.
  74197. * @returns The scale
  74198. */
  74199. getDepthScale(): number;
  74200. /**
  74201. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74202. * @returns true if a cube texture needs to be use
  74203. */
  74204. needCube(): boolean;
  74205. /**
  74206. * Detects if the projection matrix requires to be recomputed this frame.
  74207. * @returns true if it requires to be recomputed otherwise, false.
  74208. */
  74209. needProjectionMatrixCompute(): boolean;
  74210. /**
  74211. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74212. */
  74213. forceProjectionMatrixCompute(): void;
  74214. /**
  74215. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74216. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74217. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74218. */
  74219. getShadowDirection(faceIndex?: number): Vector3;
  74220. /**
  74221. * Gets the minZ used for shadow according to both the scene and the light.
  74222. * @param activeCamera The camera we are returning the min for
  74223. * @returns the depth min z
  74224. */
  74225. getDepthMinZ(activeCamera: Camera): number;
  74226. /**
  74227. * Gets the maxZ used for shadow according to both the scene and the light.
  74228. * @param activeCamera The camera we are returning the max for
  74229. * @returns the depth max z
  74230. */
  74231. getDepthMaxZ(activeCamera: Camera): number;
  74232. }
  74233. /**
  74234. * Base implementation IShadowLight
  74235. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74236. */
  74237. export abstract class ShadowLight extends Light implements IShadowLight {
  74238. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74239. protected _position: Vector3;
  74240. protected _setPosition(value: Vector3): void;
  74241. /**
  74242. * Sets the position the shadow will be casted from. Also use as the light position for both
  74243. * point and spot lights.
  74244. */
  74245. /**
  74246. * Sets the position the shadow will be casted from. Also use as the light position for both
  74247. * point and spot lights.
  74248. */
  74249. position: Vector3;
  74250. protected _direction: Vector3;
  74251. protected _setDirection(value: Vector3): void;
  74252. /**
  74253. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74254. * Also use as the light direction on spot and directional lights.
  74255. */
  74256. /**
  74257. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74258. * Also use as the light direction on spot and directional lights.
  74259. */
  74260. direction: Vector3;
  74261. private _shadowMinZ;
  74262. /**
  74263. * Gets the shadow projection clipping minimum z value.
  74264. */
  74265. /**
  74266. * Sets the shadow projection clipping minimum z value.
  74267. */
  74268. shadowMinZ: number;
  74269. private _shadowMaxZ;
  74270. /**
  74271. * Sets the shadow projection clipping maximum z value.
  74272. */
  74273. /**
  74274. * Gets the shadow projection clipping maximum z value.
  74275. */
  74276. shadowMaxZ: number;
  74277. /**
  74278. * Callback defining a custom Projection Matrix Builder.
  74279. * This can be used to override the default projection matrix computation.
  74280. */
  74281. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74282. /**
  74283. * The transformed position. Position of the light in world space taking parenting in account.
  74284. */
  74285. transformedPosition: Vector3;
  74286. /**
  74287. * The transformed direction. Direction of the light in world space taking parenting in account.
  74288. */
  74289. transformedDirection: Vector3;
  74290. private _needProjectionMatrixCompute;
  74291. /**
  74292. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74293. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74294. */
  74295. computeTransformedInformation(): boolean;
  74296. /**
  74297. * Return the depth scale used for the shadow map.
  74298. * @returns the depth scale.
  74299. */
  74300. getDepthScale(): number;
  74301. /**
  74302. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74303. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74304. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74305. */
  74306. getShadowDirection(faceIndex?: number): Vector3;
  74307. /**
  74308. * Returns the ShadowLight absolute position in the World.
  74309. * @returns the position vector in world space
  74310. */
  74311. getAbsolutePosition(): Vector3;
  74312. /**
  74313. * Sets the ShadowLight direction toward the passed target.
  74314. * @param target The point to target in local space
  74315. * @returns the updated ShadowLight direction
  74316. */
  74317. setDirectionToTarget(target: Vector3): Vector3;
  74318. /**
  74319. * Returns the light rotation in euler definition.
  74320. * @returns the x y z rotation in local space.
  74321. */
  74322. getRotation(): Vector3;
  74323. /**
  74324. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74325. * @returns true if a cube texture needs to be use
  74326. */
  74327. needCube(): boolean;
  74328. /**
  74329. * Detects if the projection matrix requires to be recomputed this frame.
  74330. * @returns true if it requires to be recomputed otherwise, false.
  74331. */
  74332. needProjectionMatrixCompute(): boolean;
  74333. /**
  74334. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74335. */
  74336. forceProjectionMatrixCompute(): void;
  74337. /** @hidden */
  74338. _initCache(): void;
  74339. /** @hidden */
  74340. _isSynchronized(): boolean;
  74341. /**
  74342. * Computes the world matrix of the node
  74343. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74344. * @returns the world matrix
  74345. */
  74346. computeWorldMatrix(force?: boolean): Matrix;
  74347. /**
  74348. * Gets the minZ used for shadow according to both the scene and the light.
  74349. * @param activeCamera The camera we are returning the min for
  74350. * @returns the depth min z
  74351. */
  74352. getDepthMinZ(activeCamera: Camera): number;
  74353. /**
  74354. * Gets the maxZ used for shadow according to both the scene and the light.
  74355. * @param activeCamera The camera we are returning the max for
  74356. * @returns the depth max z
  74357. */
  74358. getDepthMaxZ(activeCamera: Camera): number;
  74359. /**
  74360. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74361. * @param matrix The materix to updated with the projection information
  74362. * @param viewMatrix The transform matrix of the light
  74363. * @param renderList The list of mesh to render in the map
  74364. * @returns The current light
  74365. */
  74366. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74367. }
  74368. }
  74369. declare module BABYLON {
  74370. /**
  74371. * "Static Class" containing the most commonly used helper while dealing with material for
  74372. * rendering purpose.
  74373. *
  74374. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74375. *
  74376. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74377. */
  74378. export class MaterialHelper {
  74379. /**
  74380. * Bind the current view position to an effect.
  74381. * @param effect The effect to be bound
  74382. * @param scene The scene the eyes position is used from
  74383. */
  74384. static BindEyePosition(effect: Effect, scene: Scene): void;
  74385. /**
  74386. * Helps preparing the defines values about the UVs in used in the effect.
  74387. * UVs are shared as much as we can accross channels in the shaders.
  74388. * @param texture The texture we are preparing the UVs for
  74389. * @param defines The defines to update
  74390. * @param key The channel key "diffuse", "specular"... used in the shader
  74391. */
  74392. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74393. /**
  74394. * Binds a texture matrix value to its corrsponding uniform
  74395. * @param texture The texture to bind the matrix for
  74396. * @param uniformBuffer The uniform buffer receivin the data
  74397. * @param key The channel key "diffuse", "specular"... used in the shader
  74398. */
  74399. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74400. /**
  74401. * Gets the current status of the fog (should it be enabled?)
  74402. * @param mesh defines the mesh to evaluate for fog support
  74403. * @param scene defines the hosting scene
  74404. * @returns true if fog must be enabled
  74405. */
  74406. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74407. /**
  74408. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74409. * @param mesh defines the current mesh
  74410. * @param scene defines the current scene
  74411. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74412. * @param pointsCloud defines if point cloud rendering has to be turned on
  74413. * @param fogEnabled defines if fog has to be turned on
  74414. * @param alphaTest defines if alpha testing has to be turned on
  74415. * @param defines defines the current list of defines
  74416. */
  74417. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74418. /**
  74419. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74420. * @param scene defines the current scene
  74421. * @param engine defines the current engine
  74422. * @param defines specifies the list of active defines
  74423. * @param useInstances defines if instances have to be turned on
  74424. * @param useClipPlane defines if clip plane have to be turned on
  74425. */
  74426. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74427. /**
  74428. * Prepares the defines for bones
  74429. * @param mesh The mesh containing the geometry data we will draw
  74430. * @param defines The defines to update
  74431. */
  74432. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74433. /**
  74434. * Prepares the defines for morph targets
  74435. * @param mesh The mesh containing the geometry data we will draw
  74436. * @param defines The defines to update
  74437. */
  74438. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74439. /**
  74440. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74441. * @param mesh The mesh containing the geometry data we will draw
  74442. * @param defines The defines to update
  74443. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74444. * @param useBones Precise whether bones should be used or not (override mesh info)
  74445. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74446. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74447. * @returns false if defines are considered not dirty and have not been checked
  74448. */
  74449. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74450. /**
  74451. * Prepares the defines related to multiview
  74452. * @param scene The scene we are intending to draw
  74453. * @param defines The defines to update
  74454. */
  74455. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74456. /**
  74457. * Prepares the defines related to the light information passed in parameter
  74458. * @param scene The scene we are intending to draw
  74459. * @param mesh The mesh the effect is compiling for
  74460. * @param light The light the effect is compiling for
  74461. * @param lightIndex The index of the light
  74462. * @param defines The defines to update
  74463. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74464. * @param state Defines the current state regarding what is needed (normals, etc...)
  74465. */
  74466. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74467. needNormals: boolean;
  74468. needRebuild: boolean;
  74469. shadowEnabled: boolean;
  74470. specularEnabled: boolean;
  74471. lightmapMode: boolean;
  74472. }): void;
  74473. /**
  74474. * Prepares the defines related to the light information passed in parameter
  74475. * @param scene The scene we are intending to draw
  74476. * @param mesh The mesh the effect is compiling for
  74477. * @param defines The defines to update
  74478. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74479. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74480. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74481. * @returns true if normals will be required for the rest of the effect
  74482. */
  74483. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74484. /**
  74485. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74486. * @param lightIndex defines the light index
  74487. * @param uniformsList The uniform list
  74488. * @param samplersList The sampler list
  74489. * @param projectedLightTexture defines if projected texture must be used
  74490. * @param uniformBuffersList defines an optional list of uniform buffers
  74491. */
  74492. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74493. /**
  74494. * Prepares the uniforms and samplers list to be used in the effect
  74495. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74496. * @param samplersList The sampler list
  74497. * @param defines The defines helping in the list generation
  74498. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74499. */
  74500. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74501. /**
  74502. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74503. * @param defines The defines to update while falling back
  74504. * @param fallbacks The authorized effect fallbacks
  74505. * @param maxSimultaneousLights The maximum number of lights allowed
  74506. * @param rank the current rank of the Effect
  74507. * @returns The newly affected rank
  74508. */
  74509. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74510. private static _TmpMorphInfluencers;
  74511. /**
  74512. * Prepares the list of attributes required for morph targets according to the effect defines.
  74513. * @param attribs The current list of supported attribs
  74514. * @param mesh The mesh to prepare the morph targets attributes for
  74515. * @param influencers The number of influencers
  74516. */
  74517. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74518. /**
  74519. * Prepares the list of attributes required for morph targets according to the effect defines.
  74520. * @param attribs The current list of supported attribs
  74521. * @param mesh The mesh to prepare the morph targets attributes for
  74522. * @param defines The current Defines of the effect
  74523. */
  74524. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74525. /**
  74526. * Prepares the list of attributes required for bones according to the effect defines.
  74527. * @param attribs The current list of supported attribs
  74528. * @param mesh The mesh to prepare the bones attributes for
  74529. * @param defines The current Defines of the effect
  74530. * @param fallbacks The current efffect fallback strategy
  74531. */
  74532. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74533. /**
  74534. * Check and prepare the list of attributes required for instances according to the effect defines.
  74535. * @param attribs The current list of supported attribs
  74536. * @param defines The current MaterialDefines of the effect
  74537. */
  74538. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74539. /**
  74540. * Add the list of attributes required for instances to the attribs array.
  74541. * @param attribs The current list of supported attribs
  74542. */
  74543. static PushAttributesForInstances(attribs: string[]): void;
  74544. /**
  74545. * Binds the light shadow information to the effect for the given mesh.
  74546. * @param light The light containing the generator
  74547. * @param scene The scene the lights belongs to
  74548. * @param mesh The mesh we are binding the information to render
  74549. * @param lightIndex The light index in the effect used to render the mesh
  74550. * @param effect The effect we are binding the data to
  74551. */
  74552. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74553. /**
  74554. * Binds the light information to the effect.
  74555. * @param light The light containing the generator
  74556. * @param effect The effect we are binding the data to
  74557. * @param lightIndex The light index in the effect used to render
  74558. */
  74559. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74560. /**
  74561. * Binds the lights information from the scene to the effect for the given mesh.
  74562. * @param light Light to bind
  74563. * @param lightIndex Light index
  74564. * @param scene The scene where the light belongs to
  74565. * @param mesh The mesh we are binding the information to render
  74566. * @param effect The effect we are binding the data to
  74567. * @param useSpecular Defines if specular is supported
  74568. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74569. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74570. */
  74571. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74572. /**
  74573. * Binds the lights information from the scene to the effect for the given mesh.
  74574. * @param scene The scene the lights belongs to
  74575. * @param mesh The mesh we are binding the information to render
  74576. * @param effect The effect we are binding the data to
  74577. * @param defines The generated defines for the effect
  74578. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74579. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74580. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74581. */
  74582. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74583. private static _tempFogColor;
  74584. /**
  74585. * Binds the fog information from the scene to the effect for the given mesh.
  74586. * @param scene The scene the lights belongs to
  74587. * @param mesh The mesh we are binding the information to render
  74588. * @param effect The effect we are binding the data to
  74589. * @param linearSpace Defines if the fog effect is applied in linear space
  74590. */
  74591. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74592. /**
  74593. * Binds the bones information from the mesh to the effect.
  74594. * @param mesh The mesh we are binding the information to render
  74595. * @param effect The effect we are binding the data to
  74596. */
  74597. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74598. /**
  74599. * Binds the morph targets information from the mesh to the effect.
  74600. * @param abstractMesh The mesh we are binding the information to render
  74601. * @param effect The effect we are binding the data to
  74602. */
  74603. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74604. /**
  74605. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74606. * @param defines The generated defines used in the effect
  74607. * @param effect The effect we are binding the data to
  74608. * @param scene The scene we are willing to render with logarithmic scale for
  74609. */
  74610. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74611. /**
  74612. * Binds the clip plane information from the scene to the effect.
  74613. * @param scene The scene the clip plane information are extracted from
  74614. * @param effect The effect we are binding the data to
  74615. */
  74616. static BindClipPlane(effect: Effect, scene: Scene): void;
  74617. }
  74618. }
  74619. declare module BABYLON {
  74620. /** @hidden */
  74621. export var packingFunctions: {
  74622. name: string;
  74623. shader: string;
  74624. };
  74625. }
  74626. declare module BABYLON {
  74627. /** @hidden */
  74628. export var shadowMapPixelShader: {
  74629. name: string;
  74630. shader: string;
  74631. };
  74632. }
  74633. declare module BABYLON {
  74634. /** @hidden */
  74635. export var bonesDeclaration: {
  74636. name: string;
  74637. shader: string;
  74638. };
  74639. }
  74640. declare module BABYLON {
  74641. /** @hidden */
  74642. export var morphTargetsVertexGlobalDeclaration: {
  74643. name: string;
  74644. shader: string;
  74645. };
  74646. }
  74647. declare module BABYLON {
  74648. /** @hidden */
  74649. export var morphTargetsVertexDeclaration: {
  74650. name: string;
  74651. shader: string;
  74652. };
  74653. }
  74654. declare module BABYLON {
  74655. /** @hidden */
  74656. export var instancesDeclaration: {
  74657. name: string;
  74658. shader: string;
  74659. };
  74660. }
  74661. declare module BABYLON {
  74662. /** @hidden */
  74663. export var helperFunctions: {
  74664. name: string;
  74665. shader: string;
  74666. };
  74667. }
  74668. declare module BABYLON {
  74669. /** @hidden */
  74670. export var morphTargetsVertex: {
  74671. name: string;
  74672. shader: string;
  74673. };
  74674. }
  74675. declare module BABYLON {
  74676. /** @hidden */
  74677. export var instancesVertex: {
  74678. name: string;
  74679. shader: string;
  74680. };
  74681. }
  74682. declare module BABYLON {
  74683. /** @hidden */
  74684. export var bonesVertex: {
  74685. name: string;
  74686. shader: string;
  74687. };
  74688. }
  74689. declare module BABYLON {
  74690. /** @hidden */
  74691. export var shadowMapVertexShader: {
  74692. name: string;
  74693. shader: string;
  74694. };
  74695. }
  74696. declare module BABYLON {
  74697. /** @hidden */
  74698. export var depthBoxBlurPixelShader: {
  74699. name: string;
  74700. shader: string;
  74701. };
  74702. }
  74703. declare module BABYLON {
  74704. /**
  74705. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74706. */
  74707. export interface ICustomShaderOptions {
  74708. /**
  74709. * Gets or sets the custom shader name to use
  74710. */
  74711. shaderName: string;
  74712. /**
  74713. * The list of attribute names used in the shader
  74714. */
  74715. attributes?: string[];
  74716. /**
  74717. * The list of unifrom names used in the shader
  74718. */
  74719. uniforms?: string[];
  74720. /**
  74721. * The list of sampler names used in the shader
  74722. */
  74723. samplers?: string[];
  74724. /**
  74725. * The list of defines used in the shader
  74726. */
  74727. defines?: string[];
  74728. }
  74729. /**
  74730. * Interface to implement to create a shadow generator compatible with BJS.
  74731. */
  74732. export interface IShadowGenerator {
  74733. /**
  74734. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74735. * @returns The render target texture if present otherwise, null
  74736. */
  74737. getShadowMap(): Nullable<RenderTargetTexture>;
  74738. /**
  74739. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74740. * @returns The render target texture if the shadow map is present otherwise, null
  74741. */
  74742. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74743. /**
  74744. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74745. * @param subMesh The submesh we want to render in the shadow map
  74746. * @param useInstances Defines wether will draw in the map using instances
  74747. * @returns true if ready otherwise, false
  74748. */
  74749. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74750. /**
  74751. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74752. * @param defines Defines of the material we want to update
  74753. * @param lightIndex Index of the light in the enabled light list of the material
  74754. */
  74755. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74756. /**
  74757. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74758. * defined in the generator but impacting the effect).
  74759. * It implies the unifroms available on the materials are the standard BJS ones.
  74760. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74761. * @param effect The effect we are binfing the information for
  74762. */
  74763. bindShadowLight(lightIndex: string, effect: Effect): void;
  74764. /**
  74765. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74766. * (eq to shadow prjection matrix * light transform matrix)
  74767. * @returns The transform matrix used to create the shadow map
  74768. */
  74769. getTransformMatrix(): Matrix;
  74770. /**
  74771. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74772. * Cube and 2D textures for instance.
  74773. */
  74774. recreateShadowMap(): void;
  74775. /**
  74776. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74777. * @param onCompiled Callback triggered at the and of the effects compilation
  74778. * @param options Sets of optional options forcing the compilation with different modes
  74779. */
  74780. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74781. useInstances: boolean;
  74782. }>): void;
  74783. /**
  74784. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74785. * @param options Sets of optional options forcing the compilation with different modes
  74786. * @returns A promise that resolves when the compilation completes
  74787. */
  74788. forceCompilationAsync(options?: Partial<{
  74789. useInstances: boolean;
  74790. }>): Promise<void>;
  74791. /**
  74792. * Serializes the shadow generator setup to a json object.
  74793. * @returns The serialized JSON object
  74794. */
  74795. serialize(): any;
  74796. /**
  74797. * Disposes the Shadow map and related Textures and effects.
  74798. */
  74799. dispose(): void;
  74800. }
  74801. /**
  74802. * Default implementation IShadowGenerator.
  74803. * This is the main object responsible of generating shadows in the framework.
  74804. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74805. */
  74806. export class ShadowGenerator implements IShadowGenerator {
  74807. /**
  74808. * Shadow generator mode None: no filtering applied.
  74809. */
  74810. static readonly FILTER_NONE: number;
  74811. /**
  74812. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74813. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74814. */
  74815. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74816. /**
  74817. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74818. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74819. */
  74820. static readonly FILTER_POISSONSAMPLING: number;
  74821. /**
  74822. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74823. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74824. */
  74825. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74826. /**
  74827. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74828. * edge artifacts on steep falloff.
  74829. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74830. */
  74831. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74832. /**
  74833. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74834. * edge artifacts on steep falloff.
  74835. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74836. */
  74837. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74838. /**
  74839. * Shadow generator mode PCF: Percentage Closer Filtering
  74840. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74841. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74842. */
  74843. static readonly FILTER_PCF: number;
  74844. /**
  74845. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74846. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74847. * Contact Hardening
  74848. */
  74849. static readonly FILTER_PCSS: number;
  74850. /**
  74851. * Reserved for PCF and PCSS
  74852. * Highest Quality.
  74853. *
  74854. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74855. *
  74856. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74857. */
  74858. static readonly QUALITY_HIGH: number;
  74859. /**
  74860. * Reserved for PCF and PCSS
  74861. * Good tradeoff for quality/perf cross devices
  74862. *
  74863. * Execute PCF on a 3*3 kernel.
  74864. *
  74865. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74866. */
  74867. static readonly QUALITY_MEDIUM: number;
  74868. /**
  74869. * Reserved for PCF and PCSS
  74870. * The lowest quality but the fastest.
  74871. *
  74872. * Execute PCF on a 1*1 kernel.
  74873. *
  74874. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74875. */
  74876. static readonly QUALITY_LOW: number;
  74877. /** Gets or sets the custom shader name to use */
  74878. customShaderOptions: ICustomShaderOptions;
  74879. /**
  74880. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74881. */
  74882. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74883. /**
  74884. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74885. */
  74886. onAfterShadowMapRenderObservable: Observable<Effect>;
  74887. /**
  74888. * Observable triggered before a mesh is rendered in the shadow map.
  74889. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74890. */
  74891. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74892. /**
  74893. * Observable triggered after a mesh is rendered in the shadow map.
  74894. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  74895. */
  74896. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  74897. private _bias;
  74898. /**
  74899. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  74900. */
  74901. /**
  74902. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  74903. */
  74904. bias: number;
  74905. private _normalBias;
  74906. /**
  74907. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74908. */
  74909. /**
  74910. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  74911. */
  74912. normalBias: number;
  74913. private _blurBoxOffset;
  74914. /**
  74915. * Gets the blur box offset: offset applied during the blur pass.
  74916. * Only useful if useKernelBlur = false
  74917. */
  74918. /**
  74919. * Sets the blur box offset: offset applied during the blur pass.
  74920. * Only useful if useKernelBlur = false
  74921. */
  74922. blurBoxOffset: number;
  74923. private _blurScale;
  74924. /**
  74925. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  74926. * 2 means half of the size.
  74927. */
  74928. /**
  74929. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  74930. * 2 means half of the size.
  74931. */
  74932. blurScale: number;
  74933. private _blurKernel;
  74934. /**
  74935. * Gets the blur kernel: kernel size of the blur pass.
  74936. * Only useful if useKernelBlur = true
  74937. */
  74938. /**
  74939. * Sets the blur kernel: kernel size of the blur pass.
  74940. * Only useful if useKernelBlur = true
  74941. */
  74942. blurKernel: number;
  74943. private _useKernelBlur;
  74944. /**
  74945. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  74946. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74947. */
  74948. /**
  74949. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  74950. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  74951. */
  74952. useKernelBlur: boolean;
  74953. private _depthScale;
  74954. /**
  74955. * Gets the depth scale used in ESM mode.
  74956. */
  74957. /**
  74958. * Sets the depth scale used in ESM mode.
  74959. * This can override the scale stored on the light.
  74960. */
  74961. depthScale: number;
  74962. private _filter;
  74963. /**
  74964. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74965. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74966. */
  74967. /**
  74968. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74969. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74970. */
  74971. filter: number;
  74972. /**
  74973. * Gets if the current filter is set to Poisson Sampling.
  74974. */
  74975. /**
  74976. * Sets the current filter to Poisson Sampling.
  74977. */
  74978. usePoissonSampling: boolean;
  74979. /**
  74980. * Gets if the current filter is set to ESM.
  74981. */
  74982. /**
  74983. * Sets the current filter is to ESM.
  74984. */
  74985. useExponentialShadowMap: boolean;
  74986. /**
  74987. * Gets if the current filter is set to filtered ESM.
  74988. */
  74989. /**
  74990. * Gets if the current filter is set to filtered ESM.
  74991. */
  74992. useBlurExponentialShadowMap: boolean;
  74993. /**
  74994. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74995. * exponential to prevent steep falloff artifacts).
  74996. */
  74997. /**
  74998. * Sets the current filter to "close ESM" (using the inverse of the
  74999. * exponential to prevent steep falloff artifacts).
  75000. */
  75001. useCloseExponentialShadowMap: boolean;
  75002. /**
  75003. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75004. * exponential to prevent steep falloff artifacts).
  75005. */
  75006. /**
  75007. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75008. * exponential to prevent steep falloff artifacts).
  75009. */
  75010. useBlurCloseExponentialShadowMap: boolean;
  75011. /**
  75012. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75013. */
  75014. /**
  75015. * Sets the current filter to "PCF" (percentage closer filtering).
  75016. */
  75017. usePercentageCloserFiltering: boolean;
  75018. private _filteringQuality;
  75019. /**
  75020. * Gets the PCF or PCSS Quality.
  75021. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75022. */
  75023. /**
  75024. * Sets the PCF or PCSS Quality.
  75025. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75026. */
  75027. filteringQuality: number;
  75028. /**
  75029. * Gets if the current filter is set to "PCSS" (contact hardening).
  75030. */
  75031. /**
  75032. * Sets the current filter to "PCSS" (contact hardening).
  75033. */
  75034. useContactHardeningShadow: boolean;
  75035. private _contactHardeningLightSizeUVRatio;
  75036. /**
  75037. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75038. * Using a ratio helps keeping shape stability independently of the map size.
  75039. *
  75040. * It does not account for the light projection as it was having too much
  75041. * instability during the light setup or during light position changes.
  75042. *
  75043. * Only valid if useContactHardeningShadow is true.
  75044. */
  75045. /**
  75046. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75047. * Using a ratio helps keeping shape stability independently of the map size.
  75048. *
  75049. * It does not account for the light projection as it was having too much
  75050. * instability during the light setup or during light position changes.
  75051. *
  75052. * Only valid if useContactHardeningShadow is true.
  75053. */
  75054. contactHardeningLightSizeUVRatio: number;
  75055. private _darkness;
  75056. /** Gets or sets the actual darkness of a shadow */
  75057. darkness: number;
  75058. /**
  75059. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75060. * 0 means strongest and 1 would means no shadow.
  75061. * @returns the darkness.
  75062. */
  75063. getDarkness(): number;
  75064. /**
  75065. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75066. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75067. * @returns the shadow generator allowing fluent coding.
  75068. */
  75069. setDarkness(darkness: number): ShadowGenerator;
  75070. private _transparencyShadow;
  75071. /** Gets or sets the ability to have transparent shadow */
  75072. transparencyShadow: boolean;
  75073. /**
  75074. * Sets the ability to have transparent shadow (boolean).
  75075. * @param transparent True if transparent else False
  75076. * @returns the shadow generator allowing fluent coding
  75077. */
  75078. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75079. private _shadowMap;
  75080. private _shadowMap2;
  75081. /**
  75082. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75083. * @returns The render target texture if present otherwise, null
  75084. */
  75085. getShadowMap(): Nullable<RenderTargetTexture>;
  75086. /**
  75087. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75088. * @returns The render target texture if the shadow map is present otherwise, null
  75089. */
  75090. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75091. /**
  75092. * Gets the class name of that object
  75093. * @returns "ShadowGenerator"
  75094. */
  75095. getClassName(): string;
  75096. /**
  75097. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75098. * @param mesh Mesh to add
  75099. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75100. * @returns the Shadow Generator itself
  75101. */
  75102. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75103. /**
  75104. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75105. * @param mesh Mesh to remove
  75106. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75107. * @returns the Shadow Generator itself
  75108. */
  75109. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75110. /**
  75111. * Controls the extent to which the shadows fade out at the edge of the frustum
  75112. * Used only by directionals and spots
  75113. */
  75114. frustumEdgeFalloff: number;
  75115. private _light;
  75116. /**
  75117. * Returns the associated light object.
  75118. * @returns the light generating the shadow
  75119. */
  75120. getLight(): IShadowLight;
  75121. /**
  75122. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75123. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75124. * It might on the other hand introduce peter panning.
  75125. */
  75126. forceBackFacesOnly: boolean;
  75127. private _scene;
  75128. private _lightDirection;
  75129. private _effect;
  75130. private _viewMatrix;
  75131. private _projectionMatrix;
  75132. private _transformMatrix;
  75133. private _cachedPosition;
  75134. private _cachedDirection;
  75135. private _cachedDefines;
  75136. private _currentRenderID;
  75137. private _boxBlurPostprocess;
  75138. private _kernelBlurXPostprocess;
  75139. private _kernelBlurYPostprocess;
  75140. private _blurPostProcesses;
  75141. private _mapSize;
  75142. private _currentFaceIndex;
  75143. private _currentFaceIndexCache;
  75144. private _textureType;
  75145. private _defaultTextureMatrix;
  75146. /** @hidden */
  75147. static _SceneComponentInitialization: (scene: Scene) => void;
  75148. /**
  75149. * Creates a ShadowGenerator object.
  75150. * A ShadowGenerator is the required tool to use the shadows.
  75151. * Each light casting shadows needs to use its own ShadowGenerator.
  75152. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75153. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75154. * @param light The light object generating the shadows.
  75155. * @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.
  75156. */
  75157. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75158. private _initializeGenerator;
  75159. private _initializeShadowMap;
  75160. private _initializeBlurRTTAndPostProcesses;
  75161. private _renderForShadowMap;
  75162. private _renderSubMeshForShadowMap;
  75163. private _applyFilterValues;
  75164. /**
  75165. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75166. * @param onCompiled Callback triggered at the and of the effects compilation
  75167. * @param options Sets of optional options forcing the compilation with different modes
  75168. */
  75169. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75170. useInstances: boolean;
  75171. }>): void;
  75172. /**
  75173. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75174. * @param options Sets of optional options forcing the compilation with different modes
  75175. * @returns A promise that resolves when the compilation completes
  75176. */
  75177. forceCompilationAsync(options?: Partial<{
  75178. useInstances: boolean;
  75179. }>): Promise<void>;
  75180. /**
  75181. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75182. * @param subMesh The submesh we want to render in the shadow map
  75183. * @param useInstances Defines wether will draw in the map using instances
  75184. * @returns true if ready otherwise, false
  75185. */
  75186. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75187. /**
  75188. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75189. * @param defines Defines of the material we want to update
  75190. * @param lightIndex Index of the light in the enabled light list of the material
  75191. */
  75192. prepareDefines(defines: any, lightIndex: number): void;
  75193. /**
  75194. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75195. * defined in the generator but impacting the effect).
  75196. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75197. * @param effect The effect we are binfing the information for
  75198. */
  75199. bindShadowLight(lightIndex: string, effect: Effect): void;
  75200. /**
  75201. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75202. * (eq to shadow prjection matrix * light transform matrix)
  75203. * @returns The transform matrix used to create the shadow map
  75204. */
  75205. getTransformMatrix(): Matrix;
  75206. /**
  75207. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75208. * Cube and 2D textures for instance.
  75209. */
  75210. recreateShadowMap(): void;
  75211. private _disposeBlurPostProcesses;
  75212. private _disposeRTTandPostProcesses;
  75213. /**
  75214. * Disposes the ShadowGenerator.
  75215. * Returns nothing.
  75216. */
  75217. dispose(): void;
  75218. /**
  75219. * Serializes the shadow generator setup to a json object.
  75220. * @returns The serialized JSON object
  75221. */
  75222. serialize(): any;
  75223. /**
  75224. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75225. * @param parsedShadowGenerator The JSON object to parse
  75226. * @param scene The scene to create the shadow map for
  75227. * @returns The parsed shadow generator
  75228. */
  75229. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75230. }
  75231. }
  75232. declare module BABYLON {
  75233. /**
  75234. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75235. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75236. * 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.
  75237. */
  75238. export abstract class Light extends Node {
  75239. /**
  75240. * Falloff Default: light is falling off following the material specification:
  75241. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75242. */
  75243. static readonly FALLOFF_DEFAULT: number;
  75244. /**
  75245. * Falloff Physical: light is falling off following the inverse squared distance law.
  75246. */
  75247. static readonly FALLOFF_PHYSICAL: number;
  75248. /**
  75249. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75250. * to enhance interoperability with other engines.
  75251. */
  75252. static readonly FALLOFF_GLTF: number;
  75253. /**
  75254. * Falloff Standard: light is falling off like in the standard material
  75255. * to enhance interoperability with other materials.
  75256. */
  75257. static readonly FALLOFF_STANDARD: number;
  75258. /**
  75259. * If every light affecting the material is in this lightmapMode,
  75260. * material.lightmapTexture adds or multiplies
  75261. * (depends on material.useLightmapAsShadowmap)
  75262. * after every other light calculations.
  75263. */
  75264. static readonly LIGHTMAP_DEFAULT: number;
  75265. /**
  75266. * material.lightmapTexture as only diffuse lighting from this light
  75267. * adds only specular lighting from this light
  75268. * adds dynamic shadows
  75269. */
  75270. static readonly LIGHTMAP_SPECULAR: number;
  75271. /**
  75272. * material.lightmapTexture as only lighting
  75273. * no light calculation from this light
  75274. * only adds dynamic shadows from this light
  75275. */
  75276. static readonly LIGHTMAP_SHADOWSONLY: number;
  75277. /**
  75278. * Each light type uses the default quantity according to its type:
  75279. * point/spot lights use luminous intensity
  75280. * directional lights use illuminance
  75281. */
  75282. static readonly INTENSITYMODE_AUTOMATIC: number;
  75283. /**
  75284. * lumen (lm)
  75285. */
  75286. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75287. /**
  75288. * candela (lm/sr)
  75289. */
  75290. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75291. /**
  75292. * lux (lm/m^2)
  75293. */
  75294. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75295. /**
  75296. * nit (cd/m^2)
  75297. */
  75298. static readonly INTENSITYMODE_LUMINANCE: number;
  75299. /**
  75300. * Light type const id of the point light.
  75301. */
  75302. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75303. /**
  75304. * Light type const id of the directional light.
  75305. */
  75306. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75307. /**
  75308. * Light type const id of the spot light.
  75309. */
  75310. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75311. /**
  75312. * Light type const id of the hemispheric light.
  75313. */
  75314. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75315. /**
  75316. * Diffuse gives the basic color to an object.
  75317. */
  75318. diffuse: Color3;
  75319. /**
  75320. * Specular produces a highlight color on an object.
  75321. * Note: This is note affecting PBR materials.
  75322. */
  75323. specular: Color3;
  75324. /**
  75325. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75326. * falling off base on range or angle.
  75327. * This can be set to any values in Light.FALLOFF_x.
  75328. *
  75329. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75330. * other types of materials.
  75331. */
  75332. falloffType: number;
  75333. /**
  75334. * Strength of the light.
  75335. * Note: By default it is define in the framework own unit.
  75336. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75337. */
  75338. intensity: number;
  75339. private _range;
  75340. protected _inverseSquaredRange: number;
  75341. /**
  75342. * Defines how far from the source the light is impacting in scene units.
  75343. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75344. */
  75345. /**
  75346. * Defines how far from the source the light is impacting in scene units.
  75347. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75348. */
  75349. range: number;
  75350. /**
  75351. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75352. * of light.
  75353. */
  75354. private _photometricScale;
  75355. private _intensityMode;
  75356. /**
  75357. * Gets the photometric scale used to interpret the intensity.
  75358. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75359. */
  75360. /**
  75361. * Sets the photometric scale used to interpret the intensity.
  75362. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75363. */
  75364. intensityMode: number;
  75365. private _radius;
  75366. /**
  75367. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75368. */
  75369. /**
  75370. * sets the light radius used by PBR Materials to simulate soft area lights.
  75371. */
  75372. radius: number;
  75373. private _renderPriority;
  75374. /**
  75375. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75376. * exceeding the number allowed of the materials.
  75377. */
  75378. renderPriority: number;
  75379. private _shadowEnabled;
  75380. /**
  75381. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75382. * the current shadow generator.
  75383. */
  75384. /**
  75385. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75386. * the current shadow generator.
  75387. */
  75388. shadowEnabled: boolean;
  75389. private _includedOnlyMeshes;
  75390. /**
  75391. * Gets the only meshes impacted by this light.
  75392. */
  75393. /**
  75394. * Sets the only meshes impacted by this light.
  75395. */
  75396. includedOnlyMeshes: AbstractMesh[];
  75397. private _excludedMeshes;
  75398. /**
  75399. * Gets the meshes not impacted by this light.
  75400. */
  75401. /**
  75402. * Sets the meshes not impacted by this light.
  75403. */
  75404. excludedMeshes: AbstractMesh[];
  75405. private _excludeWithLayerMask;
  75406. /**
  75407. * Gets the layer id use to find what meshes are not impacted by the light.
  75408. * Inactive if 0
  75409. */
  75410. /**
  75411. * Sets the layer id use to find what meshes are not impacted by the light.
  75412. * Inactive if 0
  75413. */
  75414. excludeWithLayerMask: number;
  75415. private _includeOnlyWithLayerMask;
  75416. /**
  75417. * Gets the layer id use to find what meshes are impacted by the light.
  75418. * Inactive if 0
  75419. */
  75420. /**
  75421. * Sets the layer id use to find what meshes are impacted by the light.
  75422. * Inactive if 0
  75423. */
  75424. includeOnlyWithLayerMask: number;
  75425. private _lightmapMode;
  75426. /**
  75427. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75428. */
  75429. /**
  75430. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75431. */
  75432. lightmapMode: number;
  75433. /**
  75434. * Shadow generator associted to the light.
  75435. * @hidden Internal use only.
  75436. */
  75437. _shadowGenerator: Nullable<IShadowGenerator>;
  75438. /**
  75439. * @hidden Internal use only.
  75440. */
  75441. _excludedMeshesIds: string[];
  75442. /**
  75443. * @hidden Internal use only.
  75444. */
  75445. _includedOnlyMeshesIds: string[];
  75446. /**
  75447. * The current light unifom buffer.
  75448. * @hidden Internal use only.
  75449. */
  75450. _uniformBuffer: UniformBuffer;
  75451. /**
  75452. * Creates a Light object in the scene.
  75453. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75454. * @param name The firendly name of the light
  75455. * @param scene The scene the light belongs too
  75456. */
  75457. constructor(name: string, scene: Scene);
  75458. protected abstract _buildUniformLayout(): void;
  75459. /**
  75460. * Sets the passed Effect "effect" with the Light information.
  75461. * @param effect The effect to update
  75462. * @param lightIndex The index of the light in the effect to update
  75463. * @returns The light
  75464. */
  75465. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75466. /**
  75467. * Sets the passed Effect "effect" with the Light information.
  75468. * @param effect The effect to update
  75469. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75470. * @returns The light
  75471. */
  75472. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75473. /**
  75474. * Returns the string "Light".
  75475. * @returns the class name
  75476. */
  75477. getClassName(): string;
  75478. /** @hidden */
  75479. readonly _isLight: boolean;
  75480. /**
  75481. * Converts the light information to a readable string for debug purpose.
  75482. * @param fullDetails Supports for multiple levels of logging within scene loading
  75483. * @returns the human readable light info
  75484. */
  75485. toString(fullDetails?: boolean): string;
  75486. /** @hidden */
  75487. protected _syncParentEnabledState(): void;
  75488. /**
  75489. * Set the enabled state of this node.
  75490. * @param value - the new enabled state
  75491. */
  75492. setEnabled(value: boolean): void;
  75493. /**
  75494. * Returns the Light associated shadow generator if any.
  75495. * @return the associated shadow generator.
  75496. */
  75497. getShadowGenerator(): Nullable<IShadowGenerator>;
  75498. /**
  75499. * Returns a Vector3, the absolute light position in the World.
  75500. * @returns the world space position of the light
  75501. */
  75502. getAbsolutePosition(): Vector3;
  75503. /**
  75504. * Specifies if the light will affect the passed mesh.
  75505. * @param mesh The mesh to test against the light
  75506. * @return true the mesh is affected otherwise, false.
  75507. */
  75508. canAffectMesh(mesh: AbstractMesh): boolean;
  75509. /**
  75510. * Sort function to order lights for rendering.
  75511. * @param a First Light object to compare to second.
  75512. * @param b Second Light object to compare first.
  75513. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75514. */
  75515. static CompareLightsPriority(a: Light, b: Light): number;
  75516. /**
  75517. * Releases resources associated with this node.
  75518. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75519. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75520. */
  75521. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75522. /**
  75523. * Returns the light type ID (integer).
  75524. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75525. */
  75526. getTypeID(): number;
  75527. /**
  75528. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75529. * @returns the scaled intensity in intensity mode unit
  75530. */
  75531. getScaledIntensity(): number;
  75532. /**
  75533. * Returns a new Light object, named "name", from the current one.
  75534. * @param name The name of the cloned light
  75535. * @returns the new created light
  75536. */
  75537. clone(name: string): Nullable<Light>;
  75538. /**
  75539. * Serializes the current light into a Serialization object.
  75540. * @returns the serialized object.
  75541. */
  75542. serialize(): any;
  75543. /**
  75544. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75545. * This new light is named "name" and added to the passed scene.
  75546. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75547. * @param name The friendly name of the light
  75548. * @param scene The scene the new light will belong to
  75549. * @returns the constructor function
  75550. */
  75551. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75552. /**
  75553. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75554. * @param parsedLight The JSON representation of the light
  75555. * @param scene The scene to create the parsed light in
  75556. * @returns the created light after parsing
  75557. */
  75558. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75559. private _hookArrayForExcluded;
  75560. private _hookArrayForIncludedOnly;
  75561. private _resyncMeshes;
  75562. /**
  75563. * Forces the meshes to update their light related information in their rendering used effects
  75564. * @hidden Internal Use Only
  75565. */
  75566. _markMeshesAsLightDirty(): void;
  75567. /**
  75568. * Recomputes the cached photometric scale if needed.
  75569. */
  75570. private _computePhotometricScale;
  75571. /**
  75572. * Returns the Photometric Scale according to the light type and intensity mode.
  75573. */
  75574. private _getPhotometricScale;
  75575. /**
  75576. * Reorder the light in the scene according to their defined priority.
  75577. * @hidden Internal Use Only
  75578. */
  75579. _reorderLightsInScene(): void;
  75580. /**
  75581. * Prepares the list of defines specific to the light type.
  75582. * @param defines the list of defines
  75583. * @param lightIndex defines the index of the light for the effect
  75584. */
  75585. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75586. }
  75587. }
  75588. declare module BABYLON {
  75589. /**
  75590. * Interface used to define Action
  75591. */
  75592. export interface IAction {
  75593. /**
  75594. * Trigger for the action
  75595. */
  75596. trigger: number;
  75597. /** Options of the trigger */
  75598. triggerOptions: any;
  75599. /**
  75600. * Gets the trigger parameters
  75601. * @returns the trigger parameters
  75602. */
  75603. getTriggerParameter(): any;
  75604. /**
  75605. * Internal only - executes current action event
  75606. * @hidden
  75607. */
  75608. _executeCurrent(evt?: ActionEvent): void;
  75609. /**
  75610. * Serialize placeholder for child classes
  75611. * @param parent of child
  75612. * @returns the serialized object
  75613. */
  75614. serialize(parent: any): any;
  75615. /**
  75616. * Internal only
  75617. * @hidden
  75618. */
  75619. _prepare(): void;
  75620. /**
  75621. * Internal only - manager for action
  75622. * @hidden
  75623. */
  75624. _actionManager: AbstractActionManager;
  75625. /**
  75626. * Adds action to chain of actions, may be a DoNothingAction
  75627. * @param action defines the next action to execute
  75628. * @returns The action passed in
  75629. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75630. */
  75631. then(action: IAction): IAction;
  75632. }
  75633. /**
  75634. * The action to be carried out following a trigger
  75635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75636. */
  75637. export class Action implements IAction {
  75638. /** the trigger, with or without parameters, for the action */
  75639. triggerOptions: any;
  75640. /**
  75641. * Trigger for the action
  75642. */
  75643. trigger: number;
  75644. /**
  75645. * Internal only - manager for action
  75646. * @hidden
  75647. */
  75648. _actionManager: ActionManager;
  75649. private _nextActiveAction;
  75650. private _child;
  75651. private _condition?;
  75652. private _triggerParameter;
  75653. /**
  75654. * An event triggered prior to action being executed.
  75655. */
  75656. onBeforeExecuteObservable: Observable<Action>;
  75657. /**
  75658. * Creates a new Action
  75659. * @param triggerOptions the trigger, with or without parameters, for the action
  75660. * @param condition an optional determinant of action
  75661. */
  75662. constructor(
  75663. /** the trigger, with or without parameters, for the action */
  75664. triggerOptions: any, condition?: Condition);
  75665. /**
  75666. * Internal only
  75667. * @hidden
  75668. */
  75669. _prepare(): void;
  75670. /**
  75671. * Gets the trigger parameters
  75672. * @returns the trigger parameters
  75673. */
  75674. getTriggerParameter(): any;
  75675. /**
  75676. * Internal only - executes current action event
  75677. * @hidden
  75678. */
  75679. _executeCurrent(evt?: ActionEvent): void;
  75680. /**
  75681. * Execute placeholder for child classes
  75682. * @param evt optional action event
  75683. */
  75684. execute(evt?: ActionEvent): void;
  75685. /**
  75686. * Skips to next active action
  75687. */
  75688. skipToNextActiveAction(): void;
  75689. /**
  75690. * Adds action to chain of actions, may be a DoNothingAction
  75691. * @param action defines the next action to execute
  75692. * @returns The action passed in
  75693. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75694. */
  75695. then(action: Action): Action;
  75696. /**
  75697. * Internal only
  75698. * @hidden
  75699. */
  75700. _getProperty(propertyPath: string): string;
  75701. /**
  75702. * Internal only
  75703. * @hidden
  75704. */
  75705. _getEffectiveTarget(target: any, propertyPath: string): any;
  75706. /**
  75707. * Serialize placeholder for child classes
  75708. * @param parent of child
  75709. * @returns the serialized object
  75710. */
  75711. serialize(parent: any): any;
  75712. /**
  75713. * Internal only called by serialize
  75714. * @hidden
  75715. */
  75716. protected _serialize(serializedAction: any, parent?: any): any;
  75717. /**
  75718. * Internal only
  75719. * @hidden
  75720. */
  75721. static _SerializeValueAsString: (value: any) => string;
  75722. /**
  75723. * Internal only
  75724. * @hidden
  75725. */
  75726. static _GetTargetProperty: (target: Node | Scene) => {
  75727. name: string;
  75728. targetType: string;
  75729. value: string;
  75730. };
  75731. }
  75732. }
  75733. declare module BABYLON {
  75734. /**
  75735. * A Condition applied to an Action
  75736. */
  75737. export class Condition {
  75738. /**
  75739. * Internal only - manager for action
  75740. * @hidden
  75741. */
  75742. _actionManager: ActionManager;
  75743. /**
  75744. * Internal only
  75745. * @hidden
  75746. */
  75747. _evaluationId: number;
  75748. /**
  75749. * Internal only
  75750. * @hidden
  75751. */
  75752. _currentResult: boolean;
  75753. /**
  75754. * Creates a new Condition
  75755. * @param actionManager the manager of the action the condition is applied to
  75756. */
  75757. constructor(actionManager: ActionManager);
  75758. /**
  75759. * Check if the current condition is valid
  75760. * @returns a boolean
  75761. */
  75762. isValid(): boolean;
  75763. /**
  75764. * Internal only
  75765. * @hidden
  75766. */
  75767. _getProperty(propertyPath: string): string;
  75768. /**
  75769. * Internal only
  75770. * @hidden
  75771. */
  75772. _getEffectiveTarget(target: any, propertyPath: string): any;
  75773. /**
  75774. * Serialize placeholder for child classes
  75775. * @returns the serialized object
  75776. */
  75777. serialize(): any;
  75778. /**
  75779. * Internal only
  75780. * @hidden
  75781. */
  75782. protected _serialize(serializedCondition: any): any;
  75783. }
  75784. /**
  75785. * Defines specific conditional operators as extensions of Condition
  75786. */
  75787. export class ValueCondition extends Condition {
  75788. /** path to specify the property of the target the conditional operator uses */
  75789. propertyPath: string;
  75790. /** the value compared by the conditional operator against the current value of the property */
  75791. value: any;
  75792. /** the conditional operator, default ValueCondition.IsEqual */
  75793. operator: number;
  75794. /**
  75795. * Internal only
  75796. * @hidden
  75797. */
  75798. private static _IsEqual;
  75799. /**
  75800. * Internal only
  75801. * @hidden
  75802. */
  75803. private static _IsDifferent;
  75804. /**
  75805. * Internal only
  75806. * @hidden
  75807. */
  75808. private static _IsGreater;
  75809. /**
  75810. * Internal only
  75811. * @hidden
  75812. */
  75813. private static _IsLesser;
  75814. /**
  75815. * returns the number for IsEqual
  75816. */
  75817. static readonly IsEqual: number;
  75818. /**
  75819. * Returns the number for IsDifferent
  75820. */
  75821. static readonly IsDifferent: number;
  75822. /**
  75823. * Returns the number for IsGreater
  75824. */
  75825. static readonly IsGreater: number;
  75826. /**
  75827. * Returns the number for IsLesser
  75828. */
  75829. static readonly IsLesser: number;
  75830. /**
  75831. * Internal only The action manager for the condition
  75832. * @hidden
  75833. */
  75834. _actionManager: ActionManager;
  75835. /**
  75836. * Internal only
  75837. * @hidden
  75838. */
  75839. private _target;
  75840. /**
  75841. * Internal only
  75842. * @hidden
  75843. */
  75844. private _effectiveTarget;
  75845. /**
  75846. * Internal only
  75847. * @hidden
  75848. */
  75849. private _property;
  75850. /**
  75851. * Creates a new ValueCondition
  75852. * @param actionManager manager for the action the condition applies to
  75853. * @param target for the action
  75854. * @param propertyPath path to specify the property of the target the conditional operator uses
  75855. * @param value the value compared by the conditional operator against the current value of the property
  75856. * @param operator the conditional operator, default ValueCondition.IsEqual
  75857. */
  75858. constructor(actionManager: ActionManager, target: any,
  75859. /** path to specify the property of the target the conditional operator uses */
  75860. propertyPath: string,
  75861. /** the value compared by the conditional operator against the current value of the property */
  75862. value: any,
  75863. /** the conditional operator, default ValueCondition.IsEqual */
  75864. operator?: number);
  75865. /**
  75866. * Compares the given value with the property value for the specified conditional operator
  75867. * @returns the result of the comparison
  75868. */
  75869. isValid(): boolean;
  75870. /**
  75871. * Serialize the ValueCondition into a JSON compatible object
  75872. * @returns serialization object
  75873. */
  75874. serialize(): any;
  75875. /**
  75876. * Gets the name of the conditional operator for the ValueCondition
  75877. * @param operator the conditional operator
  75878. * @returns the name
  75879. */
  75880. static GetOperatorName(operator: number): string;
  75881. }
  75882. /**
  75883. * Defines a predicate condition as an extension of Condition
  75884. */
  75885. export class PredicateCondition extends Condition {
  75886. /** defines the predicate function used to validate the condition */
  75887. predicate: () => boolean;
  75888. /**
  75889. * Internal only - manager for action
  75890. * @hidden
  75891. */
  75892. _actionManager: ActionManager;
  75893. /**
  75894. * Creates a new PredicateCondition
  75895. * @param actionManager manager for the action the condition applies to
  75896. * @param predicate defines the predicate function used to validate the condition
  75897. */
  75898. constructor(actionManager: ActionManager,
  75899. /** defines the predicate function used to validate the condition */
  75900. predicate: () => boolean);
  75901. /**
  75902. * @returns the validity of the predicate condition
  75903. */
  75904. isValid(): boolean;
  75905. }
  75906. /**
  75907. * Defines a state condition as an extension of Condition
  75908. */
  75909. export class StateCondition extends Condition {
  75910. /** Value to compare with target state */
  75911. value: string;
  75912. /**
  75913. * Internal only - manager for action
  75914. * @hidden
  75915. */
  75916. _actionManager: ActionManager;
  75917. /**
  75918. * Internal only
  75919. * @hidden
  75920. */
  75921. private _target;
  75922. /**
  75923. * Creates a new StateCondition
  75924. * @param actionManager manager for the action the condition applies to
  75925. * @param target of the condition
  75926. * @param value to compare with target state
  75927. */
  75928. constructor(actionManager: ActionManager, target: any,
  75929. /** Value to compare with target state */
  75930. value: string);
  75931. /**
  75932. * Gets a boolean indicating if the current condition is met
  75933. * @returns the validity of the state
  75934. */
  75935. isValid(): boolean;
  75936. /**
  75937. * Serialize the StateCondition into a JSON compatible object
  75938. * @returns serialization object
  75939. */
  75940. serialize(): any;
  75941. }
  75942. }
  75943. declare module BABYLON {
  75944. /**
  75945. * This defines an action responsible to toggle a boolean once triggered.
  75946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75947. */
  75948. export class SwitchBooleanAction extends Action {
  75949. /**
  75950. * The path to the boolean property in the target object
  75951. */
  75952. propertyPath: string;
  75953. private _target;
  75954. private _effectiveTarget;
  75955. private _property;
  75956. /**
  75957. * Instantiate the action
  75958. * @param triggerOptions defines the trigger options
  75959. * @param target defines the object containing the boolean
  75960. * @param propertyPath defines the path to the boolean property in the target object
  75961. * @param condition defines the trigger related conditions
  75962. */
  75963. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  75964. /** @hidden */
  75965. _prepare(): void;
  75966. /**
  75967. * Execute the action toggle the boolean value.
  75968. */
  75969. execute(): void;
  75970. /**
  75971. * Serializes the actions and its related information.
  75972. * @param parent defines the object to serialize in
  75973. * @returns the serialized object
  75974. */
  75975. serialize(parent: any): any;
  75976. }
  75977. /**
  75978. * This defines an action responsible to set a the state field of the target
  75979. * to a desired value once triggered.
  75980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  75981. */
  75982. export class SetStateAction extends Action {
  75983. /**
  75984. * The value to store in the state field.
  75985. */
  75986. value: string;
  75987. private _target;
  75988. /**
  75989. * Instantiate the action
  75990. * @param triggerOptions defines the trigger options
  75991. * @param target defines the object containing the state property
  75992. * @param value defines the value to store in the state field
  75993. * @param condition defines the trigger related conditions
  75994. */
  75995. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  75996. /**
  75997. * Execute the action and store the value on the target state property.
  75998. */
  75999. execute(): void;
  76000. /**
  76001. * Serializes the actions and its related information.
  76002. * @param parent defines the object to serialize in
  76003. * @returns the serialized object
  76004. */
  76005. serialize(parent: any): any;
  76006. }
  76007. /**
  76008. * This defines an action responsible to set a property of the target
  76009. * to a desired value once triggered.
  76010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76011. */
  76012. export class SetValueAction extends Action {
  76013. /**
  76014. * The path of the property to set in the target.
  76015. */
  76016. propertyPath: string;
  76017. /**
  76018. * The value to set in the property
  76019. */
  76020. value: any;
  76021. private _target;
  76022. private _effectiveTarget;
  76023. private _property;
  76024. /**
  76025. * Instantiate the action
  76026. * @param triggerOptions defines the trigger options
  76027. * @param target defines the object containing the property
  76028. * @param propertyPath defines the path of the property to set in the target
  76029. * @param value defines the value to set in the property
  76030. * @param condition defines the trigger related conditions
  76031. */
  76032. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76033. /** @hidden */
  76034. _prepare(): void;
  76035. /**
  76036. * Execute the action and set the targetted property to the desired value.
  76037. */
  76038. execute(): void;
  76039. /**
  76040. * Serializes the actions and its related information.
  76041. * @param parent defines the object to serialize in
  76042. * @returns the serialized object
  76043. */
  76044. serialize(parent: any): any;
  76045. }
  76046. /**
  76047. * This defines an action responsible to increment the target value
  76048. * to a desired value once triggered.
  76049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76050. */
  76051. export class IncrementValueAction extends Action {
  76052. /**
  76053. * The path of the property to increment in the target.
  76054. */
  76055. propertyPath: string;
  76056. /**
  76057. * The value we should increment the property by.
  76058. */
  76059. value: any;
  76060. private _target;
  76061. private _effectiveTarget;
  76062. private _property;
  76063. /**
  76064. * Instantiate the action
  76065. * @param triggerOptions defines the trigger options
  76066. * @param target defines the object containing the property
  76067. * @param propertyPath defines the path of the property to increment in the target
  76068. * @param value defines the value value we should increment the property by
  76069. * @param condition defines the trigger related conditions
  76070. */
  76071. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76072. /** @hidden */
  76073. _prepare(): void;
  76074. /**
  76075. * Execute the action and increment the target of the value amount.
  76076. */
  76077. execute(): void;
  76078. /**
  76079. * Serializes the actions and its related information.
  76080. * @param parent defines the object to serialize in
  76081. * @returns the serialized object
  76082. */
  76083. serialize(parent: any): any;
  76084. }
  76085. /**
  76086. * This defines an action responsible to start an animation once triggered.
  76087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76088. */
  76089. export class PlayAnimationAction extends Action {
  76090. /**
  76091. * Where the animation should start (animation frame)
  76092. */
  76093. from: number;
  76094. /**
  76095. * Where the animation should stop (animation frame)
  76096. */
  76097. to: number;
  76098. /**
  76099. * Define if the animation should loop or stop after the first play.
  76100. */
  76101. loop?: boolean;
  76102. private _target;
  76103. /**
  76104. * Instantiate the action
  76105. * @param triggerOptions defines the trigger options
  76106. * @param target defines the target animation or animation name
  76107. * @param from defines from where the animation should start (animation frame)
  76108. * @param end defines where the animation should stop (animation frame)
  76109. * @param loop defines if the animation should loop or stop after the first play
  76110. * @param condition defines the trigger related conditions
  76111. */
  76112. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76113. /** @hidden */
  76114. _prepare(): void;
  76115. /**
  76116. * Execute the action and play the animation.
  76117. */
  76118. execute(): void;
  76119. /**
  76120. * Serializes the actions and its related information.
  76121. * @param parent defines the object to serialize in
  76122. * @returns the serialized object
  76123. */
  76124. serialize(parent: any): any;
  76125. }
  76126. /**
  76127. * This defines an action responsible to stop an animation once triggered.
  76128. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76129. */
  76130. export class StopAnimationAction extends Action {
  76131. private _target;
  76132. /**
  76133. * Instantiate the action
  76134. * @param triggerOptions defines the trigger options
  76135. * @param target defines the target animation or animation name
  76136. * @param condition defines the trigger related conditions
  76137. */
  76138. constructor(triggerOptions: any, target: any, condition?: Condition);
  76139. /** @hidden */
  76140. _prepare(): void;
  76141. /**
  76142. * Execute the action and stop the animation.
  76143. */
  76144. execute(): void;
  76145. /**
  76146. * Serializes the actions and its related information.
  76147. * @param parent defines the object to serialize in
  76148. * @returns the serialized object
  76149. */
  76150. serialize(parent: any): any;
  76151. }
  76152. /**
  76153. * This defines an action responsible that does nothing once triggered.
  76154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76155. */
  76156. export class DoNothingAction extends Action {
  76157. /**
  76158. * Instantiate the action
  76159. * @param triggerOptions defines the trigger options
  76160. * @param condition defines the trigger related conditions
  76161. */
  76162. constructor(triggerOptions?: any, condition?: Condition);
  76163. /**
  76164. * Execute the action and do nothing.
  76165. */
  76166. execute(): void;
  76167. /**
  76168. * Serializes the actions and its related information.
  76169. * @param parent defines the object to serialize in
  76170. * @returns the serialized object
  76171. */
  76172. serialize(parent: any): any;
  76173. }
  76174. /**
  76175. * This defines an action responsible to trigger several actions once triggered.
  76176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76177. */
  76178. export class CombineAction extends Action {
  76179. /**
  76180. * The list of aggregated animations to run.
  76181. */
  76182. children: Action[];
  76183. /**
  76184. * Instantiate the action
  76185. * @param triggerOptions defines the trigger options
  76186. * @param children defines the list of aggregated animations to run
  76187. * @param condition defines the trigger related conditions
  76188. */
  76189. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76190. /** @hidden */
  76191. _prepare(): void;
  76192. /**
  76193. * Execute the action and executes all the aggregated actions.
  76194. */
  76195. execute(evt: ActionEvent): void;
  76196. /**
  76197. * Serializes the actions and its related information.
  76198. * @param parent defines the object to serialize in
  76199. * @returns the serialized object
  76200. */
  76201. serialize(parent: any): any;
  76202. }
  76203. /**
  76204. * This defines an action responsible to run code (external event) once triggered.
  76205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76206. */
  76207. export class ExecuteCodeAction extends Action {
  76208. /**
  76209. * The callback function to run.
  76210. */
  76211. func: (evt: ActionEvent) => void;
  76212. /**
  76213. * Instantiate the action
  76214. * @param triggerOptions defines the trigger options
  76215. * @param func defines the callback function to run
  76216. * @param condition defines the trigger related conditions
  76217. */
  76218. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76219. /**
  76220. * Execute the action and run the attached code.
  76221. */
  76222. execute(evt: ActionEvent): void;
  76223. }
  76224. /**
  76225. * This defines an action responsible to set the parent property of the target once triggered.
  76226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76227. */
  76228. export class SetParentAction extends Action {
  76229. private _parent;
  76230. private _target;
  76231. /**
  76232. * Instantiate the action
  76233. * @param triggerOptions defines the trigger options
  76234. * @param target defines the target containing the parent property
  76235. * @param parent defines from where the animation should start (animation frame)
  76236. * @param condition defines the trigger related conditions
  76237. */
  76238. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76239. /** @hidden */
  76240. _prepare(): void;
  76241. /**
  76242. * Execute the action and set the parent property.
  76243. */
  76244. execute(): void;
  76245. /**
  76246. * Serializes the actions and its related information.
  76247. * @param parent defines the object to serialize in
  76248. * @returns the serialized object
  76249. */
  76250. serialize(parent: any): any;
  76251. }
  76252. }
  76253. declare module BABYLON {
  76254. /**
  76255. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76256. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76258. */
  76259. export class ActionManager extends AbstractActionManager {
  76260. /**
  76261. * Nothing
  76262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76263. */
  76264. static readonly NothingTrigger: number;
  76265. /**
  76266. * On pick
  76267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76268. */
  76269. static readonly OnPickTrigger: number;
  76270. /**
  76271. * On left pick
  76272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76273. */
  76274. static readonly OnLeftPickTrigger: number;
  76275. /**
  76276. * On right pick
  76277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76278. */
  76279. static readonly OnRightPickTrigger: number;
  76280. /**
  76281. * On center pick
  76282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76283. */
  76284. static readonly OnCenterPickTrigger: number;
  76285. /**
  76286. * On pick down
  76287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76288. */
  76289. static readonly OnPickDownTrigger: number;
  76290. /**
  76291. * On double pick
  76292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76293. */
  76294. static readonly OnDoublePickTrigger: number;
  76295. /**
  76296. * On pick up
  76297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76298. */
  76299. static readonly OnPickUpTrigger: number;
  76300. /**
  76301. * On pick out.
  76302. * This trigger will only be raised if you also declared a OnPickDown
  76303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76304. */
  76305. static readonly OnPickOutTrigger: number;
  76306. /**
  76307. * On long press
  76308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76309. */
  76310. static readonly OnLongPressTrigger: number;
  76311. /**
  76312. * On pointer over
  76313. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76314. */
  76315. static readonly OnPointerOverTrigger: number;
  76316. /**
  76317. * On pointer out
  76318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76319. */
  76320. static readonly OnPointerOutTrigger: number;
  76321. /**
  76322. * On every frame
  76323. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76324. */
  76325. static readonly OnEveryFrameTrigger: number;
  76326. /**
  76327. * On intersection enter
  76328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76329. */
  76330. static readonly OnIntersectionEnterTrigger: number;
  76331. /**
  76332. * On intersection exit
  76333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76334. */
  76335. static readonly OnIntersectionExitTrigger: number;
  76336. /**
  76337. * On key down
  76338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76339. */
  76340. static readonly OnKeyDownTrigger: number;
  76341. /**
  76342. * On key up
  76343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76344. */
  76345. static readonly OnKeyUpTrigger: number;
  76346. private _scene;
  76347. /**
  76348. * Creates a new action manager
  76349. * @param scene defines the hosting scene
  76350. */
  76351. constructor(scene: Scene);
  76352. /**
  76353. * Releases all associated resources
  76354. */
  76355. dispose(): void;
  76356. /**
  76357. * Gets hosting scene
  76358. * @returns the hosting scene
  76359. */
  76360. getScene(): Scene;
  76361. /**
  76362. * Does this action manager handles actions of any of the given triggers
  76363. * @param triggers defines the triggers to be tested
  76364. * @return a boolean indicating whether one (or more) of the triggers is handled
  76365. */
  76366. hasSpecificTriggers(triggers: number[]): boolean;
  76367. /**
  76368. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76369. * speed.
  76370. * @param triggerA defines the trigger to be tested
  76371. * @param triggerB defines the trigger to be tested
  76372. * @return a boolean indicating whether one (or more) of the triggers is handled
  76373. */
  76374. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76375. /**
  76376. * Does this action manager handles actions of a given trigger
  76377. * @param trigger defines the trigger to be tested
  76378. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76379. * @return whether the trigger is handled
  76380. */
  76381. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76382. /**
  76383. * Does this action manager has pointer triggers
  76384. */
  76385. readonly hasPointerTriggers: boolean;
  76386. /**
  76387. * Does this action manager has pick triggers
  76388. */
  76389. readonly hasPickTriggers: boolean;
  76390. /**
  76391. * Registers an action to this action manager
  76392. * @param action defines the action to be registered
  76393. * @return the action amended (prepared) after registration
  76394. */
  76395. registerAction(action: IAction): Nullable<IAction>;
  76396. /**
  76397. * Unregisters an action to this action manager
  76398. * @param action defines the action to be unregistered
  76399. * @return a boolean indicating whether the action has been unregistered
  76400. */
  76401. unregisterAction(action: IAction): Boolean;
  76402. /**
  76403. * Process a specific trigger
  76404. * @param trigger defines the trigger to process
  76405. * @param evt defines the event details to be processed
  76406. */
  76407. processTrigger(trigger: number, evt?: IActionEvent): void;
  76408. /** @hidden */
  76409. _getEffectiveTarget(target: any, propertyPath: string): any;
  76410. /** @hidden */
  76411. _getProperty(propertyPath: string): string;
  76412. /**
  76413. * Serialize this manager to a JSON object
  76414. * @param name defines the property name to store this manager
  76415. * @returns a JSON representation of this manager
  76416. */
  76417. serialize(name: string): any;
  76418. /**
  76419. * Creates a new ActionManager from a JSON data
  76420. * @param parsedActions defines the JSON data to read from
  76421. * @param object defines the hosting mesh
  76422. * @param scene defines the hosting scene
  76423. */
  76424. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76425. /**
  76426. * Get a trigger name by index
  76427. * @param trigger defines the trigger index
  76428. * @returns a trigger name
  76429. */
  76430. static GetTriggerName(trigger: number): string;
  76431. }
  76432. }
  76433. declare module BABYLON {
  76434. /**
  76435. * Class representing a ray with position and direction
  76436. */
  76437. export class Ray {
  76438. /** origin point */
  76439. origin: Vector3;
  76440. /** direction */
  76441. direction: Vector3;
  76442. /** length of the ray */
  76443. length: number;
  76444. private static readonly TmpVector3;
  76445. private _tmpRay;
  76446. /**
  76447. * Creates a new ray
  76448. * @param origin origin point
  76449. * @param direction direction
  76450. * @param length length of the ray
  76451. */
  76452. constructor(
  76453. /** origin point */
  76454. origin: Vector3,
  76455. /** direction */
  76456. direction: Vector3,
  76457. /** length of the ray */
  76458. length?: number);
  76459. /**
  76460. * Checks if the ray intersects a box
  76461. * @param minimum bound of the box
  76462. * @param maximum bound of the box
  76463. * @param intersectionTreshold extra extend to be added to the box in all direction
  76464. * @returns if the box was hit
  76465. */
  76466. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76467. /**
  76468. * Checks if the ray intersects a box
  76469. * @param box the bounding box to check
  76470. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76471. * @returns if the box was hit
  76472. */
  76473. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76474. /**
  76475. * If the ray hits a sphere
  76476. * @param sphere the bounding sphere to check
  76477. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76478. * @returns true if it hits the sphere
  76479. */
  76480. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76481. /**
  76482. * If the ray hits a triange
  76483. * @param vertex0 triangle vertex
  76484. * @param vertex1 triangle vertex
  76485. * @param vertex2 triangle vertex
  76486. * @returns intersection information if hit
  76487. */
  76488. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76489. /**
  76490. * Checks if ray intersects a plane
  76491. * @param plane the plane to check
  76492. * @returns the distance away it was hit
  76493. */
  76494. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76495. /**
  76496. * Calculate the intercept of a ray on a given axis
  76497. * @param axis to check 'x' | 'y' | 'z'
  76498. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76499. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76500. */
  76501. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76502. /**
  76503. * Checks if ray intersects a mesh
  76504. * @param mesh the mesh to check
  76505. * @param fastCheck if only the bounding box should checked
  76506. * @returns picking info of the intersecton
  76507. */
  76508. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76509. /**
  76510. * Checks if ray intersects a mesh
  76511. * @param meshes the meshes to check
  76512. * @param fastCheck if only the bounding box should checked
  76513. * @param results array to store result in
  76514. * @returns Array of picking infos
  76515. */
  76516. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76517. private _comparePickingInfo;
  76518. private static smallnum;
  76519. private static rayl;
  76520. /**
  76521. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76522. * @param sega the first point of the segment to test the intersection against
  76523. * @param segb the second point of the segment to test the intersection against
  76524. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76525. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76526. */
  76527. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76528. /**
  76529. * Update the ray from viewport position
  76530. * @param x position
  76531. * @param y y position
  76532. * @param viewportWidth viewport width
  76533. * @param viewportHeight viewport height
  76534. * @param world world matrix
  76535. * @param view view matrix
  76536. * @param projection projection matrix
  76537. * @returns this ray updated
  76538. */
  76539. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76540. /**
  76541. * Creates a ray with origin and direction of 0,0,0
  76542. * @returns the new ray
  76543. */
  76544. static Zero(): Ray;
  76545. /**
  76546. * Creates a new ray from screen space and viewport
  76547. * @param x position
  76548. * @param y y position
  76549. * @param viewportWidth viewport width
  76550. * @param viewportHeight viewport height
  76551. * @param world world matrix
  76552. * @param view view matrix
  76553. * @param projection projection matrix
  76554. * @returns new ray
  76555. */
  76556. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76557. /**
  76558. * 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
  76559. * transformed to the given world matrix.
  76560. * @param origin The origin point
  76561. * @param end The end point
  76562. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76563. * @returns the new ray
  76564. */
  76565. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76566. /**
  76567. * Transforms a ray by a matrix
  76568. * @param ray ray to transform
  76569. * @param matrix matrix to apply
  76570. * @returns the resulting new ray
  76571. */
  76572. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76573. /**
  76574. * Transforms a ray by a matrix
  76575. * @param ray ray to transform
  76576. * @param matrix matrix to apply
  76577. * @param result ray to store result in
  76578. */
  76579. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76580. /**
  76581. * Unproject a ray from screen space to object space
  76582. * @param sourceX defines the screen space x coordinate to use
  76583. * @param sourceY defines the screen space y coordinate to use
  76584. * @param viewportWidth defines the current width of the viewport
  76585. * @param viewportHeight defines the current height of the viewport
  76586. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76587. * @param view defines the view matrix to use
  76588. * @param projection defines the projection matrix to use
  76589. */
  76590. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76591. }
  76592. /**
  76593. * Type used to define predicate used to select faces when a mesh intersection is detected
  76594. */
  76595. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76596. interface Scene {
  76597. /** @hidden */
  76598. _tempPickingRay: Nullable<Ray>;
  76599. /** @hidden */
  76600. _cachedRayForTransform: Ray;
  76601. /** @hidden */
  76602. _pickWithRayInverseMatrix: Matrix;
  76603. /** @hidden */
  76604. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76605. /** @hidden */
  76606. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76607. }
  76608. }
  76609. declare module BABYLON {
  76610. /**
  76611. * Groups all the scene component constants in one place to ease maintenance.
  76612. * @hidden
  76613. */
  76614. export class SceneComponentConstants {
  76615. static readonly NAME_EFFECTLAYER: string;
  76616. static readonly NAME_LAYER: string;
  76617. static readonly NAME_LENSFLARESYSTEM: string;
  76618. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76619. static readonly NAME_PARTICLESYSTEM: string;
  76620. static readonly NAME_GAMEPAD: string;
  76621. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76622. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76623. static readonly NAME_DEPTHRENDERER: string;
  76624. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76625. static readonly NAME_SPRITE: string;
  76626. static readonly NAME_OUTLINERENDERER: string;
  76627. static readonly NAME_PROCEDURALTEXTURE: string;
  76628. static readonly NAME_SHADOWGENERATOR: string;
  76629. static readonly NAME_OCTREE: string;
  76630. static readonly NAME_PHYSICSENGINE: string;
  76631. static readonly NAME_AUDIO: string;
  76632. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76633. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76634. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76635. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76636. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76637. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76638. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76639. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76640. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76641. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76642. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76643. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76644. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76645. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76646. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76647. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76648. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76649. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76650. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76651. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76652. static readonly STEP_AFTERRENDER_AUDIO: number;
  76653. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76654. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76655. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76656. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76657. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76658. static readonly STEP_POINTERMOVE_SPRITE: number;
  76659. static readonly STEP_POINTERDOWN_SPRITE: number;
  76660. static readonly STEP_POINTERUP_SPRITE: number;
  76661. }
  76662. /**
  76663. * This represents a scene component.
  76664. *
  76665. * This is used to decouple the dependency the scene is having on the different workloads like
  76666. * layers, post processes...
  76667. */
  76668. export interface ISceneComponent {
  76669. /**
  76670. * The name of the component. Each component must have a unique name.
  76671. */
  76672. name: string;
  76673. /**
  76674. * The scene the component belongs to.
  76675. */
  76676. scene: Scene;
  76677. /**
  76678. * Register the component to one instance of a scene.
  76679. */
  76680. register(): void;
  76681. /**
  76682. * Rebuilds the elements related to this component in case of
  76683. * context lost for instance.
  76684. */
  76685. rebuild(): void;
  76686. /**
  76687. * Disposes the component and the associated ressources.
  76688. */
  76689. dispose(): void;
  76690. }
  76691. /**
  76692. * This represents a SERIALIZABLE scene component.
  76693. *
  76694. * This extends Scene Component to add Serialization methods on top.
  76695. */
  76696. export interface ISceneSerializableComponent extends ISceneComponent {
  76697. /**
  76698. * Adds all the elements from the container to the scene
  76699. * @param container the container holding the elements
  76700. */
  76701. addFromContainer(container: AbstractScene): void;
  76702. /**
  76703. * Removes all the elements in the container from the scene
  76704. * @param container contains the elements to remove
  76705. * @param dispose if the removed element should be disposed (default: false)
  76706. */
  76707. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76708. /**
  76709. * Serializes the component data to the specified json object
  76710. * @param serializationObject The object to serialize to
  76711. */
  76712. serialize(serializationObject: any): void;
  76713. }
  76714. /**
  76715. * Strong typing of a Mesh related stage step action
  76716. */
  76717. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76718. /**
  76719. * Strong typing of a Evaluate Sub Mesh related stage step action
  76720. */
  76721. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76722. /**
  76723. * Strong typing of a Active Mesh related stage step action
  76724. */
  76725. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76726. /**
  76727. * Strong typing of a Camera related stage step action
  76728. */
  76729. export type CameraStageAction = (camera: Camera) => void;
  76730. /**
  76731. * Strong typing of a Camera Frame buffer related stage step action
  76732. */
  76733. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76734. /**
  76735. * Strong typing of a Render Target related stage step action
  76736. */
  76737. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76738. /**
  76739. * Strong typing of a RenderingGroup related stage step action
  76740. */
  76741. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76742. /**
  76743. * Strong typing of a Mesh Render related stage step action
  76744. */
  76745. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76746. /**
  76747. * Strong typing of a simple stage step action
  76748. */
  76749. export type SimpleStageAction = () => void;
  76750. /**
  76751. * Strong typing of a render target action.
  76752. */
  76753. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76754. /**
  76755. * Strong typing of a pointer move action.
  76756. */
  76757. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76758. /**
  76759. * Strong typing of a pointer up/down action.
  76760. */
  76761. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76762. /**
  76763. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76764. * @hidden
  76765. */
  76766. export class Stage<T extends Function> extends Array<{
  76767. index: number;
  76768. component: ISceneComponent;
  76769. action: T;
  76770. }> {
  76771. /**
  76772. * Hide ctor from the rest of the world.
  76773. * @param items The items to add.
  76774. */
  76775. private constructor();
  76776. /**
  76777. * Creates a new Stage.
  76778. * @returns A new instance of a Stage
  76779. */
  76780. static Create<T extends Function>(): Stage<T>;
  76781. /**
  76782. * Registers a step in an ordered way in the targeted stage.
  76783. * @param index Defines the position to register the step in
  76784. * @param component Defines the component attached to the step
  76785. * @param action Defines the action to launch during the step
  76786. */
  76787. registerStep(index: number, component: ISceneComponent, action: T): void;
  76788. /**
  76789. * Clears all the steps from the stage.
  76790. */
  76791. clear(): void;
  76792. }
  76793. }
  76794. declare module BABYLON {
  76795. interface Scene {
  76796. /** @hidden */
  76797. _pointerOverSprite: Nullable<Sprite>;
  76798. /** @hidden */
  76799. _pickedDownSprite: Nullable<Sprite>;
  76800. /** @hidden */
  76801. _tempSpritePickingRay: Nullable<Ray>;
  76802. /**
  76803. * All of the sprite managers added to this scene
  76804. * @see http://doc.babylonjs.com/babylon101/sprites
  76805. */
  76806. spriteManagers: Array<ISpriteManager>;
  76807. /**
  76808. * An event triggered when sprites rendering is about to start
  76809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76810. */
  76811. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76812. /**
  76813. * An event triggered when sprites rendering is done
  76814. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76815. */
  76816. onAfterSpritesRenderingObservable: Observable<Scene>;
  76817. /** @hidden */
  76818. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76819. /** Launch a ray to try to pick a sprite in the scene
  76820. * @param x position on screen
  76821. * @param y position on screen
  76822. * @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
  76823. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76824. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76825. * @returns a PickingInfo
  76826. */
  76827. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76828. /** Use the given ray to pick a sprite in the scene
  76829. * @param ray The ray (in world space) to use to pick meshes
  76830. * @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
  76831. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76832. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76833. * @returns a PickingInfo
  76834. */
  76835. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76836. /** @hidden */
  76837. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76838. /** Launch a ray to try to pick sprites in the scene
  76839. * @param x position on screen
  76840. * @param y position on screen
  76841. * @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
  76842. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76843. * @returns a PickingInfo array
  76844. */
  76845. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76846. /** Use the given ray to pick sprites in the scene
  76847. * @param ray The ray (in world space) to use to pick meshes
  76848. * @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
  76849. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76850. * @returns a PickingInfo array
  76851. */
  76852. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76853. /**
  76854. * Force the sprite under the pointer
  76855. * @param sprite defines the sprite to use
  76856. */
  76857. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  76858. /**
  76859. * Gets the sprite under the pointer
  76860. * @returns a Sprite or null if no sprite is under the pointer
  76861. */
  76862. getPointerOverSprite(): Nullable<Sprite>;
  76863. }
  76864. /**
  76865. * Defines the sprite scene component responsible to manage sprites
  76866. * in a given scene.
  76867. */
  76868. export class SpriteSceneComponent implements ISceneComponent {
  76869. /**
  76870. * The component name helpfull to identify the component in the list of scene components.
  76871. */
  76872. readonly name: string;
  76873. /**
  76874. * The scene the component belongs to.
  76875. */
  76876. scene: Scene;
  76877. /** @hidden */
  76878. private _spritePredicate;
  76879. /**
  76880. * Creates a new instance of the component for the given scene
  76881. * @param scene Defines the scene to register the component in
  76882. */
  76883. constructor(scene: Scene);
  76884. /**
  76885. * Registers the component in a given scene
  76886. */
  76887. register(): void;
  76888. /**
  76889. * Rebuilds the elements related to this component in case of
  76890. * context lost for instance.
  76891. */
  76892. rebuild(): void;
  76893. /**
  76894. * Disposes the component and the associated ressources.
  76895. */
  76896. dispose(): void;
  76897. private _pickSpriteButKeepRay;
  76898. private _pointerMove;
  76899. private _pointerDown;
  76900. private _pointerUp;
  76901. }
  76902. }
  76903. declare module BABYLON {
  76904. /** @hidden */
  76905. export var fogFragmentDeclaration: {
  76906. name: string;
  76907. shader: string;
  76908. };
  76909. }
  76910. declare module BABYLON {
  76911. /** @hidden */
  76912. export var fogFragment: {
  76913. name: string;
  76914. shader: string;
  76915. };
  76916. }
  76917. declare module BABYLON {
  76918. /** @hidden */
  76919. export var spritesPixelShader: {
  76920. name: string;
  76921. shader: string;
  76922. };
  76923. }
  76924. declare module BABYLON {
  76925. /** @hidden */
  76926. export var fogVertexDeclaration: {
  76927. name: string;
  76928. shader: string;
  76929. };
  76930. }
  76931. declare module BABYLON {
  76932. /** @hidden */
  76933. export var spritesVertexShader: {
  76934. name: string;
  76935. shader: string;
  76936. };
  76937. }
  76938. declare module BABYLON {
  76939. /**
  76940. * Defines the minimum interface to fullfil in order to be a sprite manager.
  76941. */
  76942. export interface ISpriteManager extends IDisposable {
  76943. /**
  76944. * Restricts the camera to viewing objects with the same layerMask.
  76945. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  76946. */
  76947. layerMask: number;
  76948. /**
  76949. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  76950. */
  76951. isPickable: boolean;
  76952. /**
  76953. * Specifies the rendering group id for this mesh (0 by default)
  76954. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  76955. */
  76956. renderingGroupId: number;
  76957. /**
  76958. * Defines the list of sprites managed by the manager.
  76959. */
  76960. sprites: Array<Sprite>;
  76961. /**
  76962. * Tests the intersection of a sprite with a specific ray.
  76963. * @param ray The ray we are sending to test the collision
  76964. * @param camera The camera space we are sending rays in
  76965. * @param predicate A predicate allowing excluding sprites from the list of object to test
  76966. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  76967. * @returns picking info or null.
  76968. */
  76969. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  76970. /**
  76971. * Intersects the sprites with a ray
  76972. * @param ray defines the ray to intersect with
  76973. * @param camera defines the current active camera
  76974. * @param predicate defines a predicate used to select candidate sprites
  76975. * @returns null if no hit or a PickingInfo array
  76976. */
  76977. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  76978. /**
  76979. * Renders the list of sprites on screen.
  76980. */
  76981. render(): void;
  76982. }
  76983. /**
  76984. * Class used to manage multiple sprites on the same spritesheet
  76985. * @see http://doc.babylonjs.com/babylon101/sprites
  76986. */
  76987. export class SpriteManager implements ISpriteManager {
  76988. /** defines the manager's name */
  76989. name: string;
  76990. /** Gets the list of sprites */
  76991. sprites: Sprite[];
  76992. /** Gets or sets the rendering group id (0 by default) */
  76993. renderingGroupId: number;
  76994. /** Gets or sets camera layer mask */
  76995. layerMask: number;
  76996. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  76997. fogEnabled: boolean;
  76998. /** Gets or sets a boolean indicating if the sprites are pickable */
  76999. isPickable: boolean;
  77000. /** Defines the default width of a cell in the spritesheet */
  77001. cellWidth: number;
  77002. /** Defines the default height of a cell in the spritesheet */
  77003. cellHeight: number;
  77004. /** Associative array from JSON sprite data file */
  77005. private _cellData;
  77006. /** Array of sprite names from JSON sprite data file */
  77007. private _spriteMap;
  77008. /** True when packed cell data from JSON file is ready*/
  77009. private _packedAndReady;
  77010. /**
  77011. * An event triggered when the manager is disposed.
  77012. */
  77013. onDisposeObservable: Observable<SpriteManager>;
  77014. private _onDisposeObserver;
  77015. /**
  77016. * Callback called when the manager is disposed
  77017. */
  77018. onDispose: () => void;
  77019. private _capacity;
  77020. private _fromPacked;
  77021. private _spriteTexture;
  77022. private _epsilon;
  77023. private _scene;
  77024. private _vertexData;
  77025. private _buffer;
  77026. private _vertexBuffers;
  77027. private _indexBuffer;
  77028. private _effectBase;
  77029. private _effectFog;
  77030. /**
  77031. * Gets or sets the spritesheet texture
  77032. */
  77033. texture: Texture;
  77034. /**
  77035. * Creates a new sprite manager
  77036. * @param name defines the manager's name
  77037. * @param imgUrl defines the sprite sheet url
  77038. * @param capacity defines the maximum allowed number of sprites
  77039. * @param cellSize defines the size of a sprite cell
  77040. * @param scene defines the hosting scene
  77041. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77042. * @param samplingMode defines the smapling mode to use with spritesheet
  77043. * @param fromPacked set to false; do not alter
  77044. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77045. */
  77046. constructor(
  77047. /** defines the manager's name */
  77048. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77049. private _makePacked;
  77050. private _appendSpriteVertex;
  77051. /**
  77052. * Intersects the sprites with a ray
  77053. * @param ray defines the ray to intersect with
  77054. * @param camera defines the current active camera
  77055. * @param predicate defines a predicate used to select candidate sprites
  77056. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77057. * @returns null if no hit or a PickingInfo
  77058. */
  77059. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77060. /**
  77061. * Intersects the sprites with a ray
  77062. * @param ray defines the ray to intersect with
  77063. * @param camera defines the current active camera
  77064. * @param predicate defines a predicate used to select candidate sprites
  77065. * @returns null if no hit or a PickingInfo array
  77066. */
  77067. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77068. /**
  77069. * Render all child sprites
  77070. */
  77071. render(): void;
  77072. /**
  77073. * Release associated resources
  77074. */
  77075. dispose(): void;
  77076. }
  77077. }
  77078. declare module BABYLON {
  77079. /**
  77080. * Class used to represent a sprite
  77081. * @see http://doc.babylonjs.com/babylon101/sprites
  77082. */
  77083. export class Sprite {
  77084. /** defines the name */
  77085. name: string;
  77086. /** Gets or sets the current world position */
  77087. position: Vector3;
  77088. /** Gets or sets the main color */
  77089. color: Color4;
  77090. /** Gets or sets the width */
  77091. width: number;
  77092. /** Gets or sets the height */
  77093. height: number;
  77094. /** Gets or sets rotation angle */
  77095. angle: number;
  77096. /** Gets or sets the cell index in the sprite sheet */
  77097. cellIndex: number;
  77098. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77099. cellRef: string;
  77100. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77101. invertU: number;
  77102. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77103. invertV: number;
  77104. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77105. disposeWhenFinishedAnimating: boolean;
  77106. /** Gets the list of attached animations */
  77107. animations: Animation[];
  77108. /** Gets or sets a boolean indicating if the sprite can be picked */
  77109. isPickable: boolean;
  77110. /**
  77111. * Gets or sets the associated action manager
  77112. */
  77113. actionManager: Nullable<ActionManager>;
  77114. private _animationStarted;
  77115. private _loopAnimation;
  77116. private _fromIndex;
  77117. private _toIndex;
  77118. private _delay;
  77119. private _direction;
  77120. private _manager;
  77121. private _time;
  77122. private _onAnimationEnd;
  77123. /**
  77124. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77125. */
  77126. isVisible: boolean;
  77127. /**
  77128. * Gets or sets the sprite size
  77129. */
  77130. size: number;
  77131. /**
  77132. * Creates a new Sprite
  77133. * @param name defines the name
  77134. * @param manager defines the manager
  77135. */
  77136. constructor(
  77137. /** defines the name */
  77138. name: string, manager: ISpriteManager);
  77139. /**
  77140. * Starts an animation
  77141. * @param from defines the initial key
  77142. * @param to defines the end key
  77143. * @param loop defines if the animation must loop
  77144. * @param delay defines the start delay (in ms)
  77145. * @param onAnimationEnd defines a callback to call when animation ends
  77146. */
  77147. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77148. /** Stops current animation (if any) */
  77149. stopAnimation(): void;
  77150. /** @hidden */
  77151. _animate(deltaTime: number): void;
  77152. /** Release associated resources */
  77153. dispose(): void;
  77154. }
  77155. }
  77156. declare module BABYLON {
  77157. /**
  77158. * Information about the result of picking within a scene
  77159. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77160. */
  77161. export class PickingInfo {
  77162. /** @hidden */
  77163. _pickingUnavailable: boolean;
  77164. /**
  77165. * If the pick collided with an object
  77166. */
  77167. hit: boolean;
  77168. /**
  77169. * Distance away where the pick collided
  77170. */
  77171. distance: number;
  77172. /**
  77173. * The location of pick collision
  77174. */
  77175. pickedPoint: Nullable<Vector3>;
  77176. /**
  77177. * The mesh corresponding the the pick collision
  77178. */
  77179. pickedMesh: Nullable<AbstractMesh>;
  77180. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77181. bu: number;
  77182. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77183. bv: number;
  77184. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77185. faceId: number;
  77186. /** Id of the the submesh that was picked */
  77187. subMeshId: number;
  77188. /** If a sprite was picked, this will be the sprite the pick collided with */
  77189. pickedSprite: Nullable<Sprite>;
  77190. /**
  77191. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77192. */
  77193. originMesh: Nullable<AbstractMesh>;
  77194. /**
  77195. * The ray that was used to perform the picking.
  77196. */
  77197. ray: Nullable<Ray>;
  77198. /**
  77199. * Gets the normal correspodning to the face the pick collided with
  77200. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77201. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77202. * @returns The normal correspodning to the face the pick collided with
  77203. */
  77204. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77205. /**
  77206. * Gets the texture coordinates of where the pick occured
  77207. * @returns the vector containing the coordnates of the texture
  77208. */
  77209. getTextureCoordinates(): Nullable<Vector2>;
  77210. }
  77211. }
  77212. declare module BABYLON {
  77213. /**
  77214. * Gather the list of pointer event types as constants.
  77215. */
  77216. export class PointerEventTypes {
  77217. /**
  77218. * 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.
  77219. */
  77220. static readonly POINTERDOWN: number;
  77221. /**
  77222. * The pointerup event is fired when a pointer is no longer active.
  77223. */
  77224. static readonly POINTERUP: number;
  77225. /**
  77226. * The pointermove event is fired when a pointer changes coordinates.
  77227. */
  77228. static readonly POINTERMOVE: number;
  77229. /**
  77230. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77231. */
  77232. static readonly POINTERWHEEL: number;
  77233. /**
  77234. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77235. */
  77236. static readonly POINTERPICK: number;
  77237. /**
  77238. * The pointertap event is fired when a the object has been touched and released without drag.
  77239. */
  77240. static readonly POINTERTAP: number;
  77241. /**
  77242. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77243. */
  77244. static readonly POINTERDOUBLETAP: number;
  77245. }
  77246. /**
  77247. * Base class of pointer info types.
  77248. */
  77249. export class PointerInfoBase {
  77250. /**
  77251. * Defines the type of event (PointerEventTypes)
  77252. */
  77253. type: number;
  77254. /**
  77255. * Defines the related dom event
  77256. */
  77257. event: PointerEvent | MouseWheelEvent;
  77258. /**
  77259. * Instantiates the base class of pointers info.
  77260. * @param type Defines the type of event (PointerEventTypes)
  77261. * @param event Defines the related dom event
  77262. */
  77263. constructor(
  77264. /**
  77265. * Defines the type of event (PointerEventTypes)
  77266. */
  77267. type: number,
  77268. /**
  77269. * Defines the related dom event
  77270. */
  77271. event: PointerEvent | MouseWheelEvent);
  77272. }
  77273. /**
  77274. * This class is used to store pointer related info for the onPrePointerObservable event.
  77275. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77276. */
  77277. export class PointerInfoPre extends PointerInfoBase {
  77278. /**
  77279. * Ray from a pointer if availible (eg. 6dof controller)
  77280. */
  77281. ray: Nullable<Ray>;
  77282. /**
  77283. * Defines the local position of the pointer on the canvas.
  77284. */
  77285. localPosition: Vector2;
  77286. /**
  77287. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77288. */
  77289. skipOnPointerObservable: boolean;
  77290. /**
  77291. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77292. * @param type Defines the type of event (PointerEventTypes)
  77293. * @param event Defines the related dom event
  77294. * @param localX Defines the local x coordinates of the pointer when the event occured
  77295. * @param localY Defines the local y coordinates of the pointer when the event occured
  77296. */
  77297. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77298. }
  77299. /**
  77300. * This type contains all the data related to a pointer event in Babylon.js.
  77301. * 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.
  77302. */
  77303. export class PointerInfo extends PointerInfoBase {
  77304. /**
  77305. * Defines the picking info associated to the info (if any)\
  77306. */
  77307. pickInfo: Nullable<PickingInfo>;
  77308. /**
  77309. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77310. * @param type Defines the type of event (PointerEventTypes)
  77311. * @param event Defines the related dom event
  77312. * @param pickInfo Defines the picking info associated to the info (if any)\
  77313. */
  77314. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77315. /**
  77316. * Defines the picking info associated to the info (if any)\
  77317. */
  77318. pickInfo: Nullable<PickingInfo>);
  77319. }
  77320. /**
  77321. * Data relating to a touch event on the screen.
  77322. */
  77323. export interface PointerTouch {
  77324. /**
  77325. * X coordinate of touch.
  77326. */
  77327. x: number;
  77328. /**
  77329. * Y coordinate of touch.
  77330. */
  77331. y: number;
  77332. /**
  77333. * Id of touch. Unique for each finger.
  77334. */
  77335. pointerId: number;
  77336. /**
  77337. * Event type passed from DOM.
  77338. */
  77339. type: any;
  77340. }
  77341. }
  77342. declare module BABYLON {
  77343. /**
  77344. * Manage the mouse inputs to control the movement of a free camera.
  77345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77346. */
  77347. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77348. /**
  77349. * Define if touch is enabled in the mouse input
  77350. */
  77351. touchEnabled: boolean;
  77352. /**
  77353. * Defines the camera the input is attached to.
  77354. */
  77355. camera: FreeCamera;
  77356. /**
  77357. * Defines the buttons associated with the input to handle camera move.
  77358. */
  77359. buttons: number[];
  77360. /**
  77361. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77362. */
  77363. angularSensibility: number;
  77364. private _pointerInput;
  77365. private _onMouseMove;
  77366. private _observer;
  77367. private previousPosition;
  77368. /**
  77369. * Observable for when a pointer move event occurs containing the move offset
  77370. */
  77371. onPointerMovedObservable: Observable<{
  77372. offsetX: number;
  77373. offsetY: number;
  77374. }>;
  77375. /**
  77376. * @hidden
  77377. * If the camera should be rotated automatically based on pointer movement
  77378. */
  77379. _allowCameraRotation: boolean;
  77380. /**
  77381. * Manage the mouse inputs to control the movement of a free camera.
  77382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77383. * @param touchEnabled Defines if touch is enabled or not
  77384. */
  77385. constructor(
  77386. /**
  77387. * Define if touch is enabled in the mouse input
  77388. */
  77389. touchEnabled?: boolean);
  77390. /**
  77391. * Attach the input controls to a specific dom element to get the input from.
  77392. * @param element Defines the element the controls should be listened from
  77393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77394. */
  77395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77396. /**
  77397. * Called on JS contextmenu event.
  77398. * Override this method to provide functionality.
  77399. */
  77400. protected onContextMenu(evt: PointerEvent): void;
  77401. /**
  77402. * Detach the current controls from the specified dom element.
  77403. * @param element Defines the element to stop listening the inputs from
  77404. */
  77405. detachControl(element: Nullable<HTMLElement>): void;
  77406. /**
  77407. * Gets the class name of the current intput.
  77408. * @returns the class name
  77409. */
  77410. getClassName(): string;
  77411. /**
  77412. * Get the friendly name associated with the input class.
  77413. * @returns the input friendly name
  77414. */
  77415. getSimpleName(): string;
  77416. }
  77417. }
  77418. declare module BABYLON {
  77419. /**
  77420. * Manage the touch inputs to control the movement of a free camera.
  77421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77422. */
  77423. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77424. /**
  77425. * Defines the camera the input is attached to.
  77426. */
  77427. camera: FreeCamera;
  77428. /**
  77429. * Defines the touch sensibility for rotation.
  77430. * The higher the faster.
  77431. */
  77432. touchAngularSensibility: number;
  77433. /**
  77434. * Defines the touch sensibility for move.
  77435. * The higher the faster.
  77436. */
  77437. touchMoveSensibility: number;
  77438. private _offsetX;
  77439. private _offsetY;
  77440. private _pointerPressed;
  77441. private _pointerInput;
  77442. private _observer;
  77443. private _onLostFocus;
  77444. /**
  77445. * Attach the input controls to a specific dom element to get the input from.
  77446. * @param element Defines the element the controls should be listened from
  77447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77448. */
  77449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77450. /**
  77451. * Detach the current controls from the specified dom element.
  77452. * @param element Defines the element to stop listening the inputs from
  77453. */
  77454. detachControl(element: Nullable<HTMLElement>): void;
  77455. /**
  77456. * Update the current camera state depending on the inputs that have been used this frame.
  77457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77458. */
  77459. checkInputs(): void;
  77460. /**
  77461. * Gets the class name of the current intput.
  77462. * @returns the class name
  77463. */
  77464. getClassName(): string;
  77465. /**
  77466. * Get the friendly name associated with the input class.
  77467. * @returns the input friendly name
  77468. */
  77469. getSimpleName(): string;
  77470. }
  77471. }
  77472. declare module BABYLON {
  77473. /**
  77474. * Default Inputs manager for the FreeCamera.
  77475. * It groups all the default supported inputs for ease of use.
  77476. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77477. */
  77478. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77479. /**
  77480. * @hidden
  77481. */
  77482. _mouseInput: Nullable<FreeCameraMouseInput>;
  77483. /**
  77484. * Instantiates a new FreeCameraInputsManager.
  77485. * @param camera Defines the camera the inputs belong to
  77486. */
  77487. constructor(camera: FreeCamera);
  77488. /**
  77489. * Add keyboard input support to the input manager.
  77490. * @returns the current input manager
  77491. */
  77492. addKeyboard(): FreeCameraInputsManager;
  77493. /**
  77494. * Add mouse input support to the input manager.
  77495. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77496. * @returns the current input manager
  77497. */
  77498. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77499. /**
  77500. * Removes the mouse input support from the manager
  77501. * @returns the current input manager
  77502. */
  77503. removeMouse(): FreeCameraInputsManager;
  77504. /**
  77505. * Add touch input support to the input manager.
  77506. * @returns the current input manager
  77507. */
  77508. addTouch(): FreeCameraInputsManager;
  77509. /**
  77510. * Remove all attached input methods from a camera
  77511. */
  77512. clear(): void;
  77513. }
  77514. }
  77515. declare module BABYLON {
  77516. /**
  77517. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77518. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77519. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77520. */
  77521. export class FreeCamera extends TargetCamera {
  77522. /**
  77523. * Define the collision ellipsoid of the camera.
  77524. * This is helpful to simulate a camera body like the player body around the camera
  77525. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77526. */
  77527. ellipsoid: Vector3;
  77528. /**
  77529. * Define an offset for the position of the ellipsoid around the camera.
  77530. * This can be helpful to determine the center of the body near the gravity center of the body
  77531. * instead of its head.
  77532. */
  77533. ellipsoidOffset: Vector3;
  77534. /**
  77535. * Enable or disable collisions of the camera with the rest of the scene objects.
  77536. */
  77537. checkCollisions: boolean;
  77538. /**
  77539. * Enable or disable gravity on the camera.
  77540. */
  77541. applyGravity: boolean;
  77542. /**
  77543. * Define the input manager associated to the camera.
  77544. */
  77545. inputs: FreeCameraInputsManager;
  77546. /**
  77547. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77548. * Higher values reduce sensitivity.
  77549. */
  77550. /**
  77551. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77552. * Higher values reduce sensitivity.
  77553. */
  77554. angularSensibility: number;
  77555. /**
  77556. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77557. */
  77558. keysUp: number[];
  77559. /**
  77560. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77561. */
  77562. keysDown: number[];
  77563. /**
  77564. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77565. */
  77566. keysLeft: number[];
  77567. /**
  77568. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77569. */
  77570. keysRight: number[];
  77571. /**
  77572. * Event raised when the camera collide with a mesh in the scene.
  77573. */
  77574. onCollide: (collidedMesh: AbstractMesh) => void;
  77575. private _collider;
  77576. private _needMoveForGravity;
  77577. private _oldPosition;
  77578. private _diffPosition;
  77579. private _newPosition;
  77580. /** @hidden */
  77581. _localDirection: Vector3;
  77582. /** @hidden */
  77583. _transformedDirection: Vector3;
  77584. /**
  77585. * Instantiates a Free Camera.
  77586. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77587. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77588. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77589. * @param name Define the name of the camera in the scene
  77590. * @param position Define the start position of the camera in the scene
  77591. * @param scene Define the scene the camera belongs to
  77592. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77593. */
  77594. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77595. /**
  77596. * Attached controls to the current camera.
  77597. * @param element Defines the element the controls should be listened from
  77598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77599. */
  77600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77601. /**
  77602. * Detach the current controls from the camera.
  77603. * The camera will stop reacting to inputs.
  77604. * @param element Defines the element to stop listening the inputs from
  77605. */
  77606. detachControl(element: HTMLElement): void;
  77607. private _collisionMask;
  77608. /**
  77609. * Define a collision mask to limit the list of object the camera can collide with
  77610. */
  77611. collisionMask: number;
  77612. /** @hidden */
  77613. _collideWithWorld(displacement: Vector3): void;
  77614. private _onCollisionPositionChange;
  77615. /** @hidden */
  77616. _checkInputs(): void;
  77617. /** @hidden */
  77618. _decideIfNeedsToMove(): boolean;
  77619. /** @hidden */
  77620. _updatePosition(): void;
  77621. /**
  77622. * Destroy the camera and release the current resources hold by it.
  77623. */
  77624. dispose(): void;
  77625. /**
  77626. * Gets the current object class name.
  77627. * @return the class name
  77628. */
  77629. getClassName(): string;
  77630. }
  77631. }
  77632. declare module BABYLON {
  77633. /**
  77634. * Represents a gamepad control stick position
  77635. */
  77636. export class StickValues {
  77637. /**
  77638. * The x component of the control stick
  77639. */
  77640. x: number;
  77641. /**
  77642. * The y component of the control stick
  77643. */
  77644. y: number;
  77645. /**
  77646. * Initializes the gamepad x and y control stick values
  77647. * @param x The x component of the gamepad control stick value
  77648. * @param y The y component of the gamepad control stick value
  77649. */
  77650. constructor(
  77651. /**
  77652. * The x component of the control stick
  77653. */
  77654. x: number,
  77655. /**
  77656. * The y component of the control stick
  77657. */
  77658. y: number);
  77659. }
  77660. /**
  77661. * An interface which manages callbacks for gamepad button changes
  77662. */
  77663. export interface GamepadButtonChanges {
  77664. /**
  77665. * Called when a gamepad has been changed
  77666. */
  77667. changed: boolean;
  77668. /**
  77669. * Called when a gamepad press event has been triggered
  77670. */
  77671. pressChanged: boolean;
  77672. /**
  77673. * Called when a touch event has been triggered
  77674. */
  77675. touchChanged: boolean;
  77676. /**
  77677. * Called when a value has changed
  77678. */
  77679. valueChanged: boolean;
  77680. }
  77681. /**
  77682. * Represents a gamepad
  77683. */
  77684. export class Gamepad {
  77685. /**
  77686. * The id of the gamepad
  77687. */
  77688. id: string;
  77689. /**
  77690. * The index of the gamepad
  77691. */
  77692. index: number;
  77693. /**
  77694. * The browser gamepad
  77695. */
  77696. browserGamepad: any;
  77697. /**
  77698. * Specifies what type of gamepad this represents
  77699. */
  77700. type: number;
  77701. private _leftStick;
  77702. private _rightStick;
  77703. /** @hidden */
  77704. _isConnected: boolean;
  77705. private _leftStickAxisX;
  77706. private _leftStickAxisY;
  77707. private _rightStickAxisX;
  77708. private _rightStickAxisY;
  77709. /**
  77710. * Triggered when the left control stick has been changed
  77711. */
  77712. private _onleftstickchanged;
  77713. /**
  77714. * Triggered when the right control stick has been changed
  77715. */
  77716. private _onrightstickchanged;
  77717. /**
  77718. * Represents a gamepad controller
  77719. */
  77720. static GAMEPAD: number;
  77721. /**
  77722. * Represents a generic controller
  77723. */
  77724. static GENERIC: number;
  77725. /**
  77726. * Represents an XBox controller
  77727. */
  77728. static XBOX: number;
  77729. /**
  77730. * Represents a pose-enabled controller
  77731. */
  77732. static POSE_ENABLED: number;
  77733. /**
  77734. * Represents an Dual Shock controller
  77735. */
  77736. static DUALSHOCK: number;
  77737. /**
  77738. * Specifies whether the left control stick should be Y-inverted
  77739. */
  77740. protected _invertLeftStickY: boolean;
  77741. /**
  77742. * Specifies if the gamepad has been connected
  77743. */
  77744. readonly isConnected: boolean;
  77745. /**
  77746. * Initializes the gamepad
  77747. * @param id The id of the gamepad
  77748. * @param index The index of the gamepad
  77749. * @param browserGamepad The browser gamepad
  77750. * @param leftStickX The x component of the left joystick
  77751. * @param leftStickY The y component of the left joystick
  77752. * @param rightStickX The x component of the right joystick
  77753. * @param rightStickY The y component of the right joystick
  77754. */
  77755. constructor(
  77756. /**
  77757. * The id of the gamepad
  77758. */
  77759. id: string,
  77760. /**
  77761. * The index of the gamepad
  77762. */
  77763. index: number,
  77764. /**
  77765. * The browser gamepad
  77766. */
  77767. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77768. /**
  77769. * Callback triggered when the left joystick has changed
  77770. * @param callback
  77771. */
  77772. onleftstickchanged(callback: (values: StickValues) => void): void;
  77773. /**
  77774. * Callback triggered when the right joystick has changed
  77775. * @param callback
  77776. */
  77777. onrightstickchanged(callback: (values: StickValues) => void): void;
  77778. /**
  77779. * Gets the left joystick
  77780. */
  77781. /**
  77782. * Sets the left joystick values
  77783. */
  77784. leftStick: StickValues;
  77785. /**
  77786. * Gets the right joystick
  77787. */
  77788. /**
  77789. * Sets the right joystick value
  77790. */
  77791. rightStick: StickValues;
  77792. /**
  77793. * Updates the gamepad joystick positions
  77794. */
  77795. update(): void;
  77796. /**
  77797. * Disposes the gamepad
  77798. */
  77799. dispose(): void;
  77800. }
  77801. /**
  77802. * Represents a generic gamepad
  77803. */
  77804. export class GenericPad extends Gamepad {
  77805. private _buttons;
  77806. private _onbuttondown;
  77807. private _onbuttonup;
  77808. /**
  77809. * Observable triggered when a button has been pressed
  77810. */
  77811. onButtonDownObservable: Observable<number>;
  77812. /**
  77813. * Observable triggered when a button has been released
  77814. */
  77815. onButtonUpObservable: Observable<number>;
  77816. /**
  77817. * Callback triggered when a button has been pressed
  77818. * @param callback Called when a button has been pressed
  77819. */
  77820. onbuttondown(callback: (buttonPressed: number) => void): void;
  77821. /**
  77822. * Callback triggered when a button has been released
  77823. * @param callback Called when a button has been released
  77824. */
  77825. onbuttonup(callback: (buttonReleased: number) => void): void;
  77826. /**
  77827. * Initializes the generic gamepad
  77828. * @param id The id of the generic gamepad
  77829. * @param index The index of the generic gamepad
  77830. * @param browserGamepad The browser gamepad
  77831. */
  77832. constructor(id: string, index: number, browserGamepad: any);
  77833. private _setButtonValue;
  77834. /**
  77835. * Updates the generic gamepad
  77836. */
  77837. update(): void;
  77838. /**
  77839. * Disposes the generic gamepad
  77840. */
  77841. dispose(): void;
  77842. }
  77843. }
  77844. declare module BABYLON {
  77845. interface Engine {
  77846. /**
  77847. * Creates a raw texture
  77848. * @param data defines the data to store in the texture
  77849. * @param width defines the width of the texture
  77850. * @param height defines the height of the texture
  77851. * @param format defines the format of the data
  77852. * @param generateMipMaps defines if the engine should generate the mip levels
  77853. * @param invertY defines if data must be stored with Y axis inverted
  77854. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77855. * @param compression defines the compression used (null by default)
  77856. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77857. * @returns the raw texture inside an InternalTexture
  77858. */
  77859. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77860. /**
  77861. * Update a raw texture
  77862. * @param texture defines the texture to update
  77863. * @param data defines the data to store in the texture
  77864. * @param format defines the format of the data
  77865. * @param invertY defines if data must be stored with Y axis inverted
  77866. */
  77867. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77868. /**
  77869. * Update a raw texture
  77870. * @param texture defines the texture to update
  77871. * @param data defines the data to store in the texture
  77872. * @param format defines the format of the data
  77873. * @param invertY defines if data must be stored with Y axis inverted
  77874. * @param compression defines the compression used (null by default)
  77875. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77876. */
  77877. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77878. /**
  77879. * Creates a new raw cube texture
  77880. * @param data defines the array of data to use to create each face
  77881. * @param size defines the size of the textures
  77882. * @param format defines the format of the data
  77883. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77884. * @param generateMipMaps defines if the engine should generate the mip levels
  77885. * @param invertY defines if data must be stored with Y axis inverted
  77886. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77887. * @param compression defines the compression used (null by default)
  77888. * @returns the cube texture as an InternalTexture
  77889. */
  77890. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77891. /**
  77892. * Update a raw cube texture
  77893. * @param texture defines the texture to udpdate
  77894. * @param data defines the data to store
  77895. * @param format defines the data format
  77896. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77897. * @param invertY defines if data must be stored with Y axis inverted
  77898. */
  77899. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77900. /**
  77901. * Update a raw cube texture
  77902. * @param texture defines the texture to udpdate
  77903. * @param data defines the data to store
  77904. * @param format defines the data format
  77905. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77906. * @param invertY defines if data must be stored with Y axis inverted
  77907. * @param compression defines the compression used (null by default)
  77908. */
  77909. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77910. /**
  77911. * Update a raw cube texture
  77912. * @param texture defines the texture to udpdate
  77913. * @param data defines the data to store
  77914. * @param format defines the data format
  77915. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77916. * @param invertY defines if data must be stored with Y axis inverted
  77917. * @param compression defines the compression used (null by default)
  77918. * @param level defines which level of the texture to update
  77919. */
  77920. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77921. /**
  77922. * Creates a new raw cube texture from a specified url
  77923. * @param url defines the url where the data is located
  77924. * @param scene defines the current scene
  77925. * @param size defines the size of the textures
  77926. * @param format defines the format of the data
  77927. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77928. * @param noMipmap defines if the engine should avoid generating the mip levels
  77929. * @param callback defines a callback used to extract texture data from loaded data
  77930. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77931. * @param onLoad defines a callback called when texture is loaded
  77932. * @param onError defines a callback called if there is an error
  77933. * @returns the cube texture as an InternalTexture
  77934. */
  77935. 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;
  77936. /**
  77937. * Creates a new raw cube texture from a specified url
  77938. * @param url defines the url where the data is located
  77939. * @param scene defines the current scene
  77940. * @param size defines the size of the textures
  77941. * @param format defines the format of the data
  77942. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77943. * @param noMipmap defines if the engine should avoid generating the mip levels
  77944. * @param callback defines a callback used to extract texture data from loaded data
  77945. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77946. * @param onLoad defines a callback called when texture is loaded
  77947. * @param onError defines a callback called if there is an error
  77948. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77949. * @param invertY defines if data must be stored with Y axis inverted
  77950. * @returns the cube texture as an InternalTexture
  77951. */
  77952. 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;
  77953. /**
  77954. * Creates a new raw 3D texture
  77955. * @param data defines the data used to create the texture
  77956. * @param width defines the width of the texture
  77957. * @param height defines the height of the texture
  77958. * @param depth defines the depth of the texture
  77959. * @param format defines the format of the texture
  77960. * @param generateMipMaps defines if the engine must generate mip levels
  77961. * @param invertY defines if data must be stored with Y axis inverted
  77962. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77963. * @param compression defines the compressed used (can be null)
  77964. * @param textureType defines the compressed used (can be null)
  77965. * @returns a new raw 3D texture (stored in an InternalTexture)
  77966. */
  77967. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  77968. /**
  77969. * Update a raw 3D texture
  77970. * @param texture defines the texture to update
  77971. * @param data defines the data to store
  77972. * @param format defines the data format
  77973. * @param invertY defines if data must be stored with Y axis inverted
  77974. */
  77975. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77976. /**
  77977. * Update a raw 3D texture
  77978. * @param texture defines the texture to update
  77979. * @param data defines the data to store
  77980. * @param format defines the data format
  77981. * @param invertY defines if data must be stored with Y axis inverted
  77982. * @param compression defines the used compression (can be null)
  77983. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  77984. */
  77985. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  77986. }
  77987. }
  77988. declare module BABYLON {
  77989. /**
  77990. * Raw texture can help creating a texture directly from an array of data.
  77991. * This can be super useful if you either get the data from an uncompressed source or
  77992. * if you wish to create your texture pixel by pixel.
  77993. */
  77994. export class RawTexture extends Texture {
  77995. /**
  77996. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77997. */
  77998. format: number;
  77999. private _engine;
  78000. /**
  78001. * Instantiates a new RawTexture.
  78002. * Raw texture can help creating a texture directly from an array of data.
  78003. * This can be super useful if you either get the data from an uncompressed source or
  78004. * if you wish to create your texture pixel by pixel.
  78005. * @param data define the array of data to use to create the texture
  78006. * @param width define the width of the texture
  78007. * @param height define the height of the texture
  78008. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78009. * @param scene define the scene the texture belongs to
  78010. * @param generateMipMaps define whether mip maps should be generated or not
  78011. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78012. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78013. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78014. */
  78015. constructor(data: ArrayBufferView, width: number, height: number,
  78016. /**
  78017. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78018. */
  78019. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78020. /**
  78021. * Updates the texture underlying data.
  78022. * @param data Define the new data of the texture
  78023. */
  78024. update(data: ArrayBufferView): void;
  78025. /**
  78026. * Creates a luminance texture from some data.
  78027. * @param data Define the texture data
  78028. * @param width Define the width of the texture
  78029. * @param height Define the height of the texture
  78030. * @param scene Define the scene the texture belongs to
  78031. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78032. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78033. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78034. * @returns the luminance texture
  78035. */
  78036. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78037. /**
  78038. * Creates a luminance alpha texture from some data.
  78039. * @param data Define the texture data
  78040. * @param width Define the width of the texture
  78041. * @param height Define the height of the texture
  78042. * @param scene Define the scene the texture belongs to
  78043. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78044. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78045. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78046. * @returns the luminance alpha texture
  78047. */
  78048. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78049. /**
  78050. * Creates an alpha texture from some data.
  78051. * @param data Define the texture data
  78052. * @param width Define the width of the texture
  78053. * @param height Define the height of the texture
  78054. * @param scene Define the scene the texture belongs to
  78055. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78056. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78057. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78058. * @returns the alpha texture
  78059. */
  78060. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78061. /**
  78062. * Creates a RGB texture from some data.
  78063. * @param data Define the texture data
  78064. * @param width Define the width of the texture
  78065. * @param height Define the height of the texture
  78066. * @param scene Define the scene the texture belongs to
  78067. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78068. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78069. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78070. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78071. * @returns the RGB alpha texture
  78072. */
  78073. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78074. /**
  78075. * Creates a RGBA texture from some data.
  78076. * @param data Define the texture data
  78077. * @param width Define the width of the texture
  78078. * @param height Define the height of the texture
  78079. * @param scene Define the scene the texture belongs to
  78080. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78081. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78082. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78083. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78084. * @returns the RGBA texture
  78085. */
  78086. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78087. /**
  78088. * Creates a R texture from some data.
  78089. * @param data Define the texture data
  78090. * @param width Define the width of the texture
  78091. * @param height Define the height of the texture
  78092. * @param scene Define the scene the texture belongs to
  78093. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78094. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78095. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78096. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78097. * @returns the R texture
  78098. */
  78099. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78100. }
  78101. }
  78102. declare module BABYLON {
  78103. /**
  78104. * Interface for the size containing width and height
  78105. */
  78106. export interface ISize {
  78107. /**
  78108. * Width
  78109. */
  78110. width: number;
  78111. /**
  78112. * Heighht
  78113. */
  78114. height: number;
  78115. }
  78116. /**
  78117. * Size containing widht and height
  78118. */
  78119. export class Size implements ISize {
  78120. /**
  78121. * Width
  78122. */
  78123. width: number;
  78124. /**
  78125. * Height
  78126. */
  78127. height: number;
  78128. /**
  78129. * Creates a Size object from the given width and height (floats).
  78130. * @param width width of the new size
  78131. * @param height height of the new size
  78132. */
  78133. constructor(width: number, height: number);
  78134. /**
  78135. * Returns a string with the Size width and height
  78136. * @returns a string with the Size width and height
  78137. */
  78138. toString(): string;
  78139. /**
  78140. * "Size"
  78141. * @returns the string "Size"
  78142. */
  78143. getClassName(): string;
  78144. /**
  78145. * Returns the Size hash code.
  78146. * @returns a hash code for a unique width and height
  78147. */
  78148. getHashCode(): number;
  78149. /**
  78150. * Updates the current size from the given one.
  78151. * @param src the given size
  78152. */
  78153. copyFrom(src: Size): void;
  78154. /**
  78155. * Updates in place the current Size from the given floats.
  78156. * @param width width of the new size
  78157. * @param height height of the new size
  78158. * @returns the updated Size.
  78159. */
  78160. copyFromFloats(width: number, height: number): Size;
  78161. /**
  78162. * Updates in place the current Size from the given floats.
  78163. * @param width width to set
  78164. * @param height height to set
  78165. * @returns the updated Size.
  78166. */
  78167. set(width: number, height: number): Size;
  78168. /**
  78169. * Multiplies the width and height by numbers
  78170. * @param w factor to multiple the width by
  78171. * @param h factor to multiple the height by
  78172. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78173. */
  78174. multiplyByFloats(w: number, h: number): Size;
  78175. /**
  78176. * Clones the size
  78177. * @returns a new Size copied from the given one.
  78178. */
  78179. clone(): Size;
  78180. /**
  78181. * True if the current Size and the given one width and height are strictly equal.
  78182. * @param other the other size to compare against
  78183. * @returns True if the current Size and the given one width and height are strictly equal.
  78184. */
  78185. equals(other: Size): boolean;
  78186. /**
  78187. * The surface of the Size : width * height (float).
  78188. */
  78189. readonly surface: number;
  78190. /**
  78191. * Create a new size of zero
  78192. * @returns a new Size set to (0.0, 0.0)
  78193. */
  78194. static Zero(): Size;
  78195. /**
  78196. * Sums the width and height of two sizes
  78197. * @param otherSize size to add to this size
  78198. * @returns a new Size set as the addition result of the current Size and the given one.
  78199. */
  78200. add(otherSize: Size): Size;
  78201. /**
  78202. * Subtracts the width and height of two
  78203. * @param otherSize size to subtract to this size
  78204. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78205. */
  78206. subtract(otherSize: Size): Size;
  78207. /**
  78208. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78209. * @param start starting size to lerp between
  78210. * @param end end size to lerp between
  78211. * @param amount amount to lerp between the start and end values
  78212. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78213. */
  78214. static Lerp(start: Size, end: Size, amount: number): Size;
  78215. }
  78216. }
  78217. declare module BABYLON {
  78218. /**
  78219. * Defines a runtime animation
  78220. */
  78221. export class RuntimeAnimation {
  78222. private _events;
  78223. /**
  78224. * The current frame of the runtime animation
  78225. */
  78226. private _currentFrame;
  78227. /**
  78228. * The animation used by the runtime animation
  78229. */
  78230. private _animation;
  78231. /**
  78232. * The target of the runtime animation
  78233. */
  78234. private _target;
  78235. /**
  78236. * The initiating animatable
  78237. */
  78238. private _host;
  78239. /**
  78240. * The original value of the runtime animation
  78241. */
  78242. private _originalValue;
  78243. /**
  78244. * The original blend value of the runtime animation
  78245. */
  78246. private _originalBlendValue;
  78247. /**
  78248. * The offsets cache of the runtime animation
  78249. */
  78250. private _offsetsCache;
  78251. /**
  78252. * The high limits cache of the runtime animation
  78253. */
  78254. private _highLimitsCache;
  78255. /**
  78256. * Specifies if the runtime animation has been stopped
  78257. */
  78258. private _stopped;
  78259. /**
  78260. * The blending factor of the runtime animation
  78261. */
  78262. private _blendingFactor;
  78263. /**
  78264. * The BabylonJS scene
  78265. */
  78266. private _scene;
  78267. /**
  78268. * The current value of the runtime animation
  78269. */
  78270. private _currentValue;
  78271. /** @hidden */
  78272. _animationState: _IAnimationState;
  78273. /**
  78274. * The active target of the runtime animation
  78275. */
  78276. private _activeTargets;
  78277. private _currentActiveTarget;
  78278. private _directTarget;
  78279. /**
  78280. * The target path of the runtime animation
  78281. */
  78282. private _targetPath;
  78283. /**
  78284. * The weight of the runtime animation
  78285. */
  78286. private _weight;
  78287. /**
  78288. * The ratio offset of the runtime animation
  78289. */
  78290. private _ratioOffset;
  78291. /**
  78292. * The previous delay of the runtime animation
  78293. */
  78294. private _previousDelay;
  78295. /**
  78296. * The previous ratio of the runtime animation
  78297. */
  78298. private _previousRatio;
  78299. private _enableBlending;
  78300. private _keys;
  78301. private _minFrame;
  78302. private _maxFrame;
  78303. private _minValue;
  78304. private _maxValue;
  78305. private _targetIsArray;
  78306. /**
  78307. * Gets the current frame of the runtime animation
  78308. */
  78309. readonly currentFrame: number;
  78310. /**
  78311. * Gets the weight of the runtime animation
  78312. */
  78313. readonly weight: number;
  78314. /**
  78315. * Gets the current value of the runtime animation
  78316. */
  78317. readonly currentValue: any;
  78318. /**
  78319. * Gets the target path of the runtime animation
  78320. */
  78321. readonly targetPath: string;
  78322. /**
  78323. * Gets the actual target of the runtime animation
  78324. */
  78325. readonly target: any;
  78326. /** @hidden */
  78327. _onLoop: () => void;
  78328. /**
  78329. * Create a new RuntimeAnimation object
  78330. * @param target defines the target of the animation
  78331. * @param animation defines the source animation object
  78332. * @param scene defines the hosting scene
  78333. * @param host defines the initiating Animatable
  78334. */
  78335. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78336. private _preparePath;
  78337. /**
  78338. * Gets the animation from the runtime animation
  78339. */
  78340. readonly animation: Animation;
  78341. /**
  78342. * Resets the runtime animation to the beginning
  78343. * @param restoreOriginal defines whether to restore the target property to the original value
  78344. */
  78345. reset(restoreOriginal?: boolean): void;
  78346. /**
  78347. * Specifies if the runtime animation is stopped
  78348. * @returns Boolean specifying if the runtime animation is stopped
  78349. */
  78350. isStopped(): boolean;
  78351. /**
  78352. * Disposes of the runtime animation
  78353. */
  78354. dispose(): void;
  78355. /**
  78356. * Apply the interpolated value to the target
  78357. * @param currentValue defines the value computed by the animation
  78358. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78359. */
  78360. setValue(currentValue: any, weight: number): void;
  78361. private _getOriginalValues;
  78362. private _setValue;
  78363. /**
  78364. * Gets the loop pmode of the runtime animation
  78365. * @returns Loop Mode
  78366. */
  78367. private _getCorrectLoopMode;
  78368. /**
  78369. * Move the current animation to a given frame
  78370. * @param frame defines the frame to move to
  78371. */
  78372. goToFrame(frame: number): void;
  78373. /**
  78374. * @hidden Internal use only
  78375. */
  78376. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78377. /**
  78378. * Execute the current animation
  78379. * @param delay defines the delay to add to the current frame
  78380. * @param from defines the lower bound of the animation range
  78381. * @param to defines the upper bound of the animation range
  78382. * @param loop defines if the current animation must loop
  78383. * @param speedRatio defines the current speed ratio
  78384. * @param weight defines the weight of the animation (default is -1 so no weight)
  78385. * @param onLoop optional callback called when animation loops
  78386. * @returns a boolean indicating if the animation is running
  78387. */
  78388. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78389. }
  78390. }
  78391. declare module BABYLON {
  78392. /**
  78393. * Class used to store an actual running animation
  78394. */
  78395. export class Animatable {
  78396. /** defines the target object */
  78397. target: any;
  78398. /** defines the starting frame number (default is 0) */
  78399. fromFrame: number;
  78400. /** defines the ending frame number (default is 100) */
  78401. toFrame: number;
  78402. /** defines if the animation must loop (default is false) */
  78403. loopAnimation: boolean;
  78404. /** defines a callback to call when animation ends if it is not looping */
  78405. onAnimationEnd?: (() => void) | null | undefined;
  78406. /** defines a callback to call when animation loops */
  78407. onAnimationLoop?: (() => void) | null | undefined;
  78408. private _localDelayOffset;
  78409. private _pausedDelay;
  78410. private _runtimeAnimations;
  78411. private _paused;
  78412. private _scene;
  78413. private _speedRatio;
  78414. private _weight;
  78415. private _syncRoot;
  78416. /**
  78417. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78418. * This will only apply for non looping animation (default is true)
  78419. */
  78420. disposeOnEnd: boolean;
  78421. /**
  78422. * Gets a boolean indicating if the animation has started
  78423. */
  78424. animationStarted: boolean;
  78425. /**
  78426. * Observer raised when the animation ends
  78427. */
  78428. onAnimationEndObservable: Observable<Animatable>;
  78429. /**
  78430. * Observer raised when the animation loops
  78431. */
  78432. onAnimationLoopObservable: Observable<Animatable>;
  78433. /**
  78434. * Gets the root Animatable used to synchronize and normalize animations
  78435. */
  78436. readonly syncRoot: Nullable<Animatable>;
  78437. /**
  78438. * Gets the current frame of the first RuntimeAnimation
  78439. * Used to synchronize Animatables
  78440. */
  78441. readonly masterFrame: number;
  78442. /**
  78443. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78444. */
  78445. weight: number;
  78446. /**
  78447. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78448. */
  78449. speedRatio: number;
  78450. /**
  78451. * Creates a new Animatable
  78452. * @param scene defines the hosting scene
  78453. * @param target defines the target object
  78454. * @param fromFrame defines the starting frame number (default is 0)
  78455. * @param toFrame defines the ending frame number (default is 100)
  78456. * @param loopAnimation defines if the animation must loop (default is false)
  78457. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78458. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78459. * @param animations defines a group of animation to add to the new Animatable
  78460. * @param onAnimationLoop defines a callback to call when animation loops
  78461. */
  78462. constructor(scene: Scene,
  78463. /** defines the target object */
  78464. target: any,
  78465. /** defines the starting frame number (default is 0) */
  78466. fromFrame?: number,
  78467. /** defines the ending frame number (default is 100) */
  78468. toFrame?: number,
  78469. /** defines if the animation must loop (default is false) */
  78470. loopAnimation?: boolean, speedRatio?: number,
  78471. /** defines a callback to call when animation ends if it is not looping */
  78472. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78473. /** defines a callback to call when animation loops */
  78474. onAnimationLoop?: (() => void) | null | undefined);
  78475. /**
  78476. * Synchronize and normalize current Animatable with a source Animatable
  78477. * This is useful when using animation weights and when animations are not of the same length
  78478. * @param root defines the root Animatable to synchronize with
  78479. * @returns the current Animatable
  78480. */
  78481. syncWith(root: Animatable): Animatable;
  78482. /**
  78483. * Gets the list of runtime animations
  78484. * @returns an array of RuntimeAnimation
  78485. */
  78486. getAnimations(): RuntimeAnimation[];
  78487. /**
  78488. * Adds more animations to the current animatable
  78489. * @param target defines the target of the animations
  78490. * @param animations defines the new animations to add
  78491. */
  78492. appendAnimations(target: any, animations: Animation[]): void;
  78493. /**
  78494. * Gets the source animation for a specific property
  78495. * @param property defines the propertyu to look for
  78496. * @returns null or the source animation for the given property
  78497. */
  78498. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78499. /**
  78500. * Gets the runtime animation for a specific property
  78501. * @param property defines the propertyu to look for
  78502. * @returns null or the runtime animation for the given property
  78503. */
  78504. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78505. /**
  78506. * Resets the animatable to its original state
  78507. */
  78508. reset(): void;
  78509. /**
  78510. * Allows the animatable to blend with current running animations
  78511. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78512. * @param blendingSpeed defines the blending speed to use
  78513. */
  78514. enableBlending(blendingSpeed: number): void;
  78515. /**
  78516. * Disable animation blending
  78517. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78518. */
  78519. disableBlending(): void;
  78520. /**
  78521. * Jump directly to a given frame
  78522. * @param frame defines the frame to jump to
  78523. */
  78524. goToFrame(frame: number): void;
  78525. /**
  78526. * Pause the animation
  78527. */
  78528. pause(): void;
  78529. /**
  78530. * Restart the animation
  78531. */
  78532. restart(): void;
  78533. private _raiseOnAnimationEnd;
  78534. /**
  78535. * Stop and delete the current animation
  78536. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78537. * @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)
  78538. */
  78539. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78540. /**
  78541. * Wait asynchronously for the animation to end
  78542. * @returns a promise which will be fullfilled when the animation ends
  78543. */
  78544. waitAsync(): Promise<Animatable>;
  78545. /** @hidden */
  78546. _animate(delay: number): boolean;
  78547. }
  78548. interface Scene {
  78549. /** @hidden */
  78550. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78551. /** @hidden */
  78552. _processLateAnimationBindingsForMatrices(holder: {
  78553. totalWeight: number;
  78554. animations: RuntimeAnimation[];
  78555. originalValue: Matrix;
  78556. }): any;
  78557. /** @hidden */
  78558. _processLateAnimationBindingsForQuaternions(holder: {
  78559. totalWeight: number;
  78560. animations: RuntimeAnimation[];
  78561. originalValue: Quaternion;
  78562. }, refQuaternion: Quaternion): Quaternion;
  78563. /** @hidden */
  78564. _processLateAnimationBindings(): void;
  78565. /**
  78566. * Will start the animation sequence of a given target
  78567. * @param target defines the target
  78568. * @param from defines from which frame should animation start
  78569. * @param to defines until which frame should animation run.
  78570. * @param weight defines the weight to apply to the animation (1.0 by default)
  78571. * @param loop defines if the animation loops
  78572. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78573. * @param onAnimationEnd defines the function to be executed when the animation ends
  78574. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78575. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78576. * @param onAnimationLoop defines the callback to call when an animation loops
  78577. * @returns the animatable object created for this animation
  78578. */
  78579. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78580. /**
  78581. * Will start the animation sequence of a given target
  78582. * @param target defines the target
  78583. * @param from defines from which frame should animation start
  78584. * @param to defines until which frame should animation run.
  78585. * @param loop defines if the animation loops
  78586. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78587. * @param onAnimationEnd defines the function to be executed when the animation ends
  78588. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78589. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78590. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78591. * @param onAnimationLoop defines the callback to call when an animation loops
  78592. * @returns the animatable object created for this animation
  78593. */
  78594. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78595. /**
  78596. * Will start the animation sequence of a given target and its hierarchy
  78597. * @param target defines the target
  78598. * @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.
  78599. * @param from defines from which frame should animation start
  78600. * @param to defines until which frame should animation run.
  78601. * @param loop defines if the animation loops
  78602. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78603. * @param onAnimationEnd defines the function to be executed when the animation ends
  78604. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78605. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78606. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78607. * @param onAnimationLoop defines the callback to call when an animation loops
  78608. * @returns the list of created animatables
  78609. */
  78610. 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[];
  78611. /**
  78612. * Begin a new animation on a given node
  78613. * @param target defines the target where the animation will take place
  78614. * @param animations defines the list of animations to start
  78615. * @param from defines the initial value
  78616. * @param to defines the final value
  78617. * @param loop defines if you want animation to loop (off by default)
  78618. * @param speedRatio defines the speed ratio to apply to all animations
  78619. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78620. * @param onAnimationLoop defines the callback to call when an animation loops
  78621. * @returns the list of created animatables
  78622. */
  78623. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78624. /**
  78625. * Begin a new animation on a given node and its hierarchy
  78626. * @param target defines the root node where the animation will take place
  78627. * @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.
  78628. * @param animations defines the list of animations to start
  78629. * @param from defines the initial value
  78630. * @param to defines the final value
  78631. * @param loop defines if you want animation to loop (off by default)
  78632. * @param speedRatio defines the speed ratio to apply to all animations
  78633. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78634. * @param onAnimationLoop defines the callback to call when an animation loops
  78635. * @returns the list of animatables created for all nodes
  78636. */
  78637. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78638. /**
  78639. * Gets the animatable associated with a specific target
  78640. * @param target defines the target of the animatable
  78641. * @returns the required animatable if found
  78642. */
  78643. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78644. /**
  78645. * Gets all animatables associated with a given target
  78646. * @param target defines the target to look animatables for
  78647. * @returns an array of Animatables
  78648. */
  78649. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78650. /**
  78651. * Stops and removes all animations that have been applied to the scene
  78652. */
  78653. stopAllAnimations(): void;
  78654. }
  78655. interface Bone {
  78656. /**
  78657. * Copy an animation range from another bone
  78658. * @param source defines the source bone
  78659. * @param rangeName defines the range name to copy
  78660. * @param frameOffset defines the frame offset
  78661. * @param rescaleAsRequired defines if rescaling must be applied if required
  78662. * @param skelDimensionsRatio defines the scaling ratio
  78663. * @returns true if operation was successful
  78664. */
  78665. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78666. }
  78667. }
  78668. declare module BABYLON {
  78669. /**
  78670. * Class used to override all child animations of a given target
  78671. */
  78672. export class AnimationPropertiesOverride {
  78673. /**
  78674. * Gets or sets a value indicating if animation blending must be used
  78675. */
  78676. enableBlending: boolean;
  78677. /**
  78678. * Gets or sets the blending speed to use when enableBlending is true
  78679. */
  78680. blendingSpeed: number;
  78681. /**
  78682. * Gets or sets the default loop mode to use
  78683. */
  78684. loopMode: number;
  78685. }
  78686. }
  78687. declare module BABYLON {
  78688. /**
  78689. * Class used to handle skinning animations
  78690. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78691. */
  78692. export class Skeleton implements IAnimatable {
  78693. /** defines the skeleton name */
  78694. name: string;
  78695. /** defines the skeleton Id */
  78696. id: string;
  78697. /**
  78698. * Defines the list of child bones
  78699. */
  78700. bones: Bone[];
  78701. /**
  78702. * Defines an estimate of the dimension of the skeleton at rest
  78703. */
  78704. dimensionsAtRest: Vector3;
  78705. /**
  78706. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78707. */
  78708. needInitialSkinMatrix: boolean;
  78709. /**
  78710. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78711. */
  78712. overrideMesh: Nullable<AbstractMesh>;
  78713. /**
  78714. * Gets the list of animations attached to this skeleton
  78715. */
  78716. animations: Array<Animation>;
  78717. private _scene;
  78718. private _isDirty;
  78719. private _transformMatrices;
  78720. private _transformMatrixTexture;
  78721. private _meshesWithPoseMatrix;
  78722. private _animatables;
  78723. private _identity;
  78724. private _synchronizedWithMesh;
  78725. private _ranges;
  78726. private _lastAbsoluteTransformsUpdateId;
  78727. private _canUseTextureForBones;
  78728. private _uniqueId;
  78729. /** @hidden */
  78730. _numBonesWithLinkedTransformNode: number;
  78731. /** @hidden */
  78732. _hasWaitingData: Nullable<boolean>;
  78733. /**
  78734. * Specifies if the skeleton should be serialized
  78735. */
  78736. doNotSerialize: boolean;
  78737. private _useTextureToStoreBoneMatrices;
  78738. /**
  78739. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78740. * Please note that this option is not available if the hardware does not support it
  78741. */
  78742. useTextureToStoreBoneMatrices: boolean;
  78743. private _animationPropertiesOverride;
  78744. /**
  78745. * Gets or sets the animation properties override
  78746. */
  78747. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78748. /**
  78749. * List of inspectable custom properties (used by the Inspector)
  78750. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78751. */
  78752. inspectableCustomProperties: IInspectable[];
  78753. /**
  78754. * An observable triggered before computing the skeleton's matrices
  78755. */
  78756. onBeforeComputeObservable: Observable<Skeleton>;
  78757. /**
  78758. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78759. */
  78760. readonly isUsingTextureForMatrices: boolean;
  78761. /**
  78762. * Gets the unique ID of this skeleton
  78763. */
  78764. readonly uniqueId: number;
  78765. /**
  78766. * Creates a new skeleton
  78767. * @param name defines the skeleton name
  78768. * @param id defines the skeleton Id
  78769. * @param scene defines the hosting scene
  78770. */
  78771. constructor(
  78772. /** defines the skeleton name */
  78773. name: string,
  78774. /** defines the skeleton Id */
  78775. id: string, scene: Scene);
  78776. /**
  78777. * Gets the current object class name.
  78778. * @return the class name
  78779. */
  78780. getClassName(): string;
  78781. /**
  78782. * Returns an array containing the root bones
  78783. * @returns an array containing the root bones
  78784. */
  78785. getChildren(): Array<Bone>;
  78786. /**
  78787. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78788. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78789. * @returns a Float32Array containing matrices data
  78790. */
  78791. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78792. /**
  78793. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78794. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78795. * @returns a raw texture containing the data
  78796. */
  78797. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78798. /**
  78799. * Gets the current hosting scene
  78800. * @returns a scene object
  78801. */
  78802. getScene(): Scene;
  78803. /**
  78804. * Gets a string representing the current skeleton data
  78805. * @param fullDetails defines a boolean indicating if we want a verbose version
  78806. * @returns a string representing the current skeleton data
  78807. */
  78808. toString(fullDetails?: boolean): string;
  78809. /**
  78810. * Get bone's index searching by name
  78811. * @param name defines bone's name to search for
  78812. * @return the indice of the bone. Returns -1 if not found
  78813. */
  78814. getBoneIndexByName(name: string): number;
  78815. /**
  78816. * Creater a new animation range
  78817. * @param name defines the name of the range
  78818. * @param from defines the start key
  78819. * @param to defines the end key
  78820. */
  78821. createAnimationRange(name: string, from: number, to: number): void;
  78822. /**
  78823. * Delete a specific animation range
  78824. * @param name defines the name of the range
  78825. * @param deleteFrames defines if frames must be removed as well
  78826. */
  78827. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78828. /**
  78829. * Gets a specific animation range
  78830. * @param name defines the name of the range to look for
  78831. * @returns the requested animation range or null if not found
  78832. */
  78833. getAnimationRange(name: string): Nullable<AnimationRange>;
  78834. /**
  78835. * Gets the list of all animation ranges defined on this skeleton
  78836. * @returns an array
  78837. */
  78838. getAnimationRanges(): Nullable<AnimationRange>[];
  78839. /**
  78840. * Copy animation range from a source skeleton.
  78841. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78842. * @param source defines the source skeleton
  78843. * @param name defines the name of the range to copy
  78844. * @param rescaleAsRequired defines if rescaling must be applied if required
  78845. * @returns true if operation was successful
  78846. */
  78847. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78848. /**
  78849. * Forces the skeleton to go to rest pose
  78850. */
  78851. returnToRest(): void;
  78852. private _getHighestAnimationFrame;
  78853. /**
  78854. * Begin a specific animation range
  78855. * @param name defines the name of the range to start
  78856. * @param loop defines if looping must be turned on (false by default)
  78857. * @param speedRatio defines the speed ratio to apply (1 by default)
  78858. * @param onAnimationEnd defines a callback which will be called when animation will end
  78859. * @returns a new animatable
  78860. */
  78861. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78862. /** @hidden */
  78863. _markAsDirty(): void;
  78864. /** @hidden */
  78865. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78866. /** @hidden */
  78867. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78868. private _computeTransformMatrices;
  78869. /**
  78870. * Build all resources required to render a skeleton
  78871. */
  78872. prepare(): void;
  78873. /**
  78874. * Gets the list of animatables currently running for this skeleton
  78875. * @returns an array of animatables
  78876. */
  78877. getAnimatables(): IAnimatable[];
  78878. /**
  78879. * Clone the current skeleton
  78880. * @param name defines the name of the new skeleton
  78881. * @param id defines the id of the new skeleton
  78882. * @returns the new skeleton
  78883. */
  78884. clone(name: string, id: string): Skeleton;
  78885. /**
  78886. * Enable animation blending for this skeleton
  78887. * @param blendingSpeed defines the blending speed to apply
  78888. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78889. */
  78890. enableBlending(blendingSpeed?: number): void;
  78891. /**
  78892. * Releases all resources associated with the current skeleton
  78893. */
  78894. dispose(): void;
  78895. /**
  78896. * Serialize the skeleton in a JSON object
  78897. * @returns a JSON object
  78898. */
  78899. serialize(): any;
  78900. /**
  78901. * Creates a new skeleton from serialized data
  78902. * @param parsedSkeleton defines the serialized data
  78903. * @param scene defines the hosting scene
  78904. * @returns a new skeleton
  78905. */
  78906. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78907. /**
  78908. * Compute all node absolute transforms
  78909. * @param forceUpdate defines if computation must be done even if cache is up to date
  78910. */
  78911. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78912. /**
  78913. * Gets the root pose matrix
  78914. * @returns a matrix
  78915. */
  78916. getPoseMatrix(): Nullable<Matrix>;
  78917. /**
  78918. * Sorts bones per internal index
  78919. */
  78920. sortBones(): void;
  78921. private _sortBones;
  78922. }
  78923. }
  78924. declare module BABYLON {
  78925. /**
  78926. * Class used to store bone information
  78927. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78928. */
  78929. export class Bone extends Node {
  78930. /**
  78931. * defines the bone name
  78932. */
  78933. name: string;
  78934. private static _tmpVecs;
  78935. private static _tmpQuat;
  78936. private static _tmpMats;
  78937. /**
  78938. * Gets the list of child bones
  78939. */
  78940. children: Bone[];
  78941. /** Gets the animations associated with this bone */
  78942. animations: Animation[];
  78943. /**
  78944. * Gets or sets bone length
  78945. */
  78946. length: number;
  78947. /**
  78948. * @hidden Internal only
  78949. * Set this value to map this bone to a different index in the transform matrices
  78950. * Set this value to -1 to exclude the bone from the transform matrices
  78951. */
  78952. _index: Nullable<number>;
  78953. private _skeleton;
  78954. private _localMatrix;
  78955. private _restPose;
  78956. private _baseMatrix;
  78957. private _absoluteTransform;
  78958. private _invertedAbsoluteTransform;
  78959. private _parent;
  78960. private _scalingDeterminant;
  78961. private _worldTransform;
  78962. private _localScaling;
  78963. private _localRotation;
  78964. private _localPosition;
  78965. private _needToDecompose;
  78966. private _needToCompose;
  78967. /** @hidden */
  78968. _linkedTransformNode: Nullable<TransformNode>;
  78969. /** @hidden */
  78970. _waitingTransformNodeId: Nullable<string>;
  78971. /** @hidden */
  78972. /** @hidden */
  78973. _matrix: Matrix;
  78974. /**
  78975. * Create a new bone
  78976. * @param name defines the bone name
  78977. * @param skeleton defines the parent skeleton
  78978. * @param parentBone defines the parent (can be null if the bone is the root)
  78979. * @param localMatrix defines the local matrix
  78980. * @param restPose defines the rest pose matrix
  78981. * @param baseMatrix defines the base matrix
  78982. * @param index defines index of the bone in the hiearchy
  78983. */
  78984. constructor(
  78985. /**
  78986. * defines the bone name
  78987. */
  78988. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  78989. /**
  78990. * Gets the current object class name.
  78991. * @return the class name
  78992. */
  78993. getClassName(): string;
  78994. /**
  78995. * Gets the parent skeleton
  78996. * @returns a skeleton
  78997. */
  78998. getSkeleton(): Skeleton;
  78999. /**
  79000. * Gets parent bone
  79001. * @returns a bone or null if the bone is the root of the bone hierarchy
  79002. */
  79003. getParent(): Nullable<Bone>;
  79004. /**
  79005. * Returns an array containing the root bones
  79006. * @returns an array containing the root bones
  79007. */
  79008. getChildren(): Array<Bone>;
  79009. /**
  79010. * Sets the parent bone
  79011. * @param parent defines the parent (can be null if the bone is the root)
  79012. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79013. */
  79014. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79015. /**
  79016. * Gets the local matrix
  79017. * @returns a matrix
  79018. */
  79019. getLocalMatrix(): Matrix;
  79020. /**
  79021. * Gets the base matrix (initial matrix which remains unchanged)
  79022. * @returns a matrix
  79023. */
  79024. getBaseMatrix(): Matrix;
  79025. /**
  79026. * Gets the rest pose matrix
  79027. * @returns a matrix
  79028. */
  79029. getRestPose(): Matrix;
  79030. /**
  79031. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79032. */
  79033. getWorldMatrix(): Matrix;
  79034. /**
  79035. * Sets the local matrix to rest pose matrix
  79036. */
  79037. returnToRest(): void;
  79038. /**
  79039. * Gets the inverse of the absolute transform matrix.
  79040. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79041. * @returns a matrix
  79042. */
  79043. getInvertedAbsoluteTransform(): Matrix;
  79044. /**
  79045. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79046. * @returns a matrix
  79047. */
  79048. getAbsoluteTransform(): Matrix;
  79049. /**
  79050. * Links with the given transform node.
  79051. * The local matrix of this bone is copied from the transform node every frame.
  79052. * @param transformNode defines the transform node to link to
  79053. */
  79054. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79055. /**
  79056. * Gets the node used to drive the bone's transformation
  79057. * @returns a transform node or null
  79058. */
  79059. getTransformNode(): Nullable<TransformNode>;
  79060. /** Gets or sets current position (in local space) */
  79061. position: Vector3;
  79062. /** Gets or sets current rotation (in local space) */
  79063. rotation: Vector3;
  79064. /** Gets or sets current rotation quaternion (in local space) */
  79065. rotationQuaternion: Quaternion;
  79066. /** Gets or sets current scaling (in local space) */
  79067. scaling: Vector3;
  79068. /**
  79069. * Gets the animation properties override
  79070. */
  79071. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79072. private _decompose;
  79073. private _compose;
  79074. /**
  79075. * Update the base and local matrices
  79076. * @param matrix defines the new base or local matrix
  79077. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79078. * @param updateLocalMatrix defines if the local matrix should be updated
  79079. */
  79080. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79081. /** @hidden */
  79082. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79083. /**
  79084. * Flag the bone as dirty (Forcing it to update everything)
  79085. */
  79086. markAsDirty(): void;
  79087. /** @hidden */
  79088. _markAsDirtyAndCompose(): void;
  79089. private _markAsDirtyAndDecompose;
  79090. /**
  79091. * Translate the bone in local or world space
  79092. * @param vec The amount to translate the bone
  79093. * @param space The space that the translation is in
  79094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79095. */
  79096. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79097. /**
  79098. * Set the postion of the bone in local or world space
  79099. * @param position The position to set the bone
  79100. * @param space The space that the position is in
  79101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79102. */
  79103. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79104. /**
  79105. * Set the absolute position of the bone (world space)
  79106. * @param position The position to set the bone
  79107. * @param mesh The mesh that this bone is attached to
  79108. */
  79109. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79110. /**
  79111. * Scale the bone on the x, y and z axes (in local space)
  79112. * @param x The amount to scale the bone on the x axis
  79113. * @param y The amount to scale the bone on the y axis
  79114. * @param z The amount to scale the bone on the z axis
  79115. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79116. */
  79117. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79118. /**
  79119. * Set the bone scaling in local space
  79120. * @param scale defines the scaling vector
  79121. */
  79122. setScale(scale: Vector3): void;
  79123. /**
  79124. * Gets the current scaling in local space
  79125. * @returns the current scaling vector
  79126. */
  79127. getScale(): Vector3;
  79128. /**
  79129. * Gets the current scaling in local space and stores it in a target vector
  79130. * @param result defines the target vector
  79131. */
  79132. getScaleToRef(result: Vector3): void;
  79133. /**
  79134. * Set the yaw, pitch, and roll of the bone in local or world space
  79135. * @param yaw The rotation of the bone on the y axis
  79136. * @param pitch The rotation of the bone on the x axis
  79137. * @param roll The rotation of the bone on the z axis
  79138. * @param space The space that the axes of rotation are in
  79139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79140. */
  79141. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79142. /**
  79143. * Add a rotation to the bone on an axis in local or world space
  79144. * @param axis The axis to rotate the bone on
  79145. * @param amount The amount to rotate the bone
  79146. * @param space The space that the axis is in
  79147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79148. */
  79149. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79150. /**
  79151. * Set the rotation of the bone to a particular axis angle in local or world space
  79152. * @param axis The axis to rotate the bone on
  79153. * @param angle The angle that the bone should be rotated to
  79154. * @param space The space that the axis is in
  79155. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79156. */
  79157. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79158. /**
  79159. * Set the euler rotation of the bone in local of world space
  79160. * @param rotation The euler rotation that the bone should be set to
  79161. * @param space The space that the rotation is in
  79162. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79163. */
  79164. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79165. /**
  79166. * Set the quaternion rotation of the bone in local of world space
  79167. * @param quat The quaternion rotation that the bone should be set to
  79168. * @param space The space that the rotation is in
  79169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79170. */
  79171. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79172. /**
  79173. * Set the rotation matrix of the bone in local of world space
  79174. * @param rotMat The rotation matrix that the bone should be set to
  79175. * @param space The space that the rotation is in
  79176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79177. */
  79178. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79179. private _rotateWithMatrix;
  79180. private _getNegativeRotationToRef;
  79181. /**
  79182. * Get the position of the bone in local or world space
  79183. * @param space The space that the returned position is in
  79184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79185. * @returns The position of the bone
  79186. */
  79187. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79188. /**
  79189. * Copy the position of the bone to a vector3 in local or world space
  79190. * @param space The space that the returned position is in
  79191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79192. * @param result The vector3 to copy the position to
  79193. */
  79194. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79195. /**
  79196. * Get the absolute position of the bone (world space)
  79197. * @param mesh The mesh that this bone is attached to
  79198. * @returns The absolute position of the bone
  79199. */
  79200. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79201. /**
  79202. * Copy the absolute position of the bone (world space) to the result param
  79203. * @param mesh The mesh that this bone is attached to
  79204. * @param result The vector3 to copy the absolute position to
  79205. */
  79206. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79207. /**
  79208. * Compute the absolute transforms of this bone and its children
  79209. */
  79210. computeAbsoluteTransforms(): void;
  79211. /**
  79212. * Get the world direction from an axis that is in the local space of the bone
  79213. * @param localAxis The local direction that is used to compute the world direction
  79214. * @param mesh The mesh that this bone is attached to
  79215. * @returns The world direction
  79216. */
  79217. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79218. /**
  79219. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79220. * @param localAxis The local direction that is used to compute the world direction
  79221. * @param mesh The mesh that this bone is attached to
  79222. * @param result The vector3 that the world direction will be copied to
  79223. */
  79224. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79225. /**
  79226. * Get the euler rotation of the bone in local or world space
  79227. * @param space The space that the rotation should be in
  79228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79229. * @returns The euler rotation
  79230. */
  79231. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79232. /**
  79233. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79234. * @param space The space that the rotation should be in
  79235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79236. * @param result The vector3 that the rotation should be copied to
  79237. */
  79238. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79239. /**
  79240. * Get the quaternion rotation of the bone in either local or world space
  79241. * @param space The space that the rotation should be in
  79242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79243. * @returns The quaternion rotation
  79244. */
  79245. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79246. /**
  79247. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79248. * @param space The space that the rotation should be in
  79249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79250. * @param result The quaternion that the rotation should be copied to
  79251. */
  79252. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79253. /**
  79254. * Get the rotation matrix of the bone in local or world space
  79255. * @param space The space that the rotation should be in
  79256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79257. * @returns The rotation matrix
  79258. */
  79259. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79260. /**
  79261. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79262. * @param space The space that the rotation should be in
  79263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79264. * @param result The quaternion that the rotation should be copied to
  79265. */
  79266. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79267. /**
  79268. * Get the world position of a point that is in the local space of the bone
  79269. * @param position The local position
  79270. * @param mesh The mesh that this bone is attached to
  79271. * @returns The world position
  79272. */
  79273. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79274. /**
  79275. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79276. * @param position The local position
  79277. * @param mesh The mesh that this bone is attached to
  79278. * @param result The vector3 that the world position should be copied to
  79279. */
  79280. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79281. /**
  79282. * Get the local position of a point that is in world space
  79283. * @param position The world position
  79284. * @param mesh The mesh that this bone is attached to
  79285. * @returns The local position
  79286. */
  79287. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79288. /**
  79289. * Get the local position of a point that is in world space and copy it to the result param
  79290. * @param position The world position
  79291. * @param mesh The mesh that this bone is attached to
  79292. * @param result The vector3 that the local position should be copied to
  79293. */
  79294. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79295. }
  79296. }
  79297. declare module BABYLON {
  79298. /**
  79299. * 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.
  79300. * @see https://doc.babylonjs.com/how_to/transformnode
  79301. */
  79302. export class TransformNode extends Node {
  79303. /**
  79304. * Object will not rotate to face the camera
  79305. */
  79306. static BILLBOARDMODE_NONE: number;
  79307. /**
  79308. * Object will rotate to face the camera but only on the x axis
  79309. */
  79310. static BILLBOARDMODE_X: number;
  79311. /**
  79312. * Object will rotate to face the camera but only on the y axis
  79313. */
  79314. static BILLBOARDMODE_Y: number;
  79315. /**
  79316. * Object will rotate to face the camera but only on the z axis
  79317. */
  79318. static BILLBOARDMODE_Z: number;
  79319. /**
  79320. * Object will rotate to face the camera
  79321. */
  79322. static BILLBOARDMODE_ALL: number;
  79323. /**
  79324. * Object will rotate to face the camera's position instead of orientation
  79325. */
  79326. static BILLBOARDMODE_USE_POSITION: number;
  79327. private _forward;
  79328. private _forwardInverted;
  79329. private _up;
  79330. private _right;
  79331. private _rightInverted;
  79332. private _position;
  79333. private _rotation;
  79334. private _rotationQuaternion;
  79335. protected _scaling: Vector3;
  79336. protected _isDirty: boolean;
  79337. private _transformToBoneReferal;
  79338. private _isAbsoluteSynced;
  79339. private _billboardMode;
  79340. /**
  79341. * Gets or sets the billboard mode. Default is 0.
  79342. *
  79343. * | Value | Type | Description |
  79344. * | --- | --- | --- |
  79345. * | 0 | BILLBOARDMODE_NONE | |
  79346. * | 1 | BILLBOARDMODE_X | |
  79347. * | 2 | BILLBOARDMODE_Y | |
  79348. * | 4 | BILLBOARDMODE_Z | |
  79349. * | 7 | BILLBOARDMODE_ALL | |
  79350. *
  79351. */
  79352. billboardMode: number;
  79353. private _preserveParentRotationForBillboard;
  79354. /**
  79355. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79356. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79357. */
  79358. preserveParentRotationForBillboard: boolean;
  79359. /**
  79360. * 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
  79361. */
  79362. scalingDeterminant: number;
  79363. private _infiniteDistance;
  79364. /**
  79365. * Gets or sets the distance of the object to max, often used by skybox
  79366. */
  79367. infiniteDistance: boolean;
  79368. /**
  79369. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79370. * By default the system will update normals to compensate
  79371. */
  79372. ignoreNonUniformScaling: boolean;
  79373. /**
  79374. * 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
  79375. */
  79376. reIntegrateRotationIntoRotationQuaternion: boolean;
  79377. /** @hidden */
  79378. _poseMatrix: Nullable<Matrix>;
  79379. /** @hidden */
  79380. _localMatrix: Matrix;
  79381. private _usePivotMatrix;
  79382. private _absolutePosition;
  79383. private _absoluteScaling;
  79384. private _absoluteRotationQuaternion;
  79385. private _pivotMatrix;
  79386. private _pivotMatrixInverse;
  79387. protected _postMultiplyPivotMatrix: boolean;
  79388. protected _isWorldMatrixFrozen: boolean;
  79389. /** @hidden */
  79390. _indexInSceneTransformNodesArray: number;
  79391. /**
  79392. * An event triggered after the world matrix is updated
  79393. */
  79394. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79395. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79396. /**
  79397. * Gets a string identifying the name of the class
  79398. * @returns "TransformNode" string
  79399. */
  79400. getClassName(): string;
  79401. /**
  79402. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79403. */
  79404. position: Vector3;
  79405. /**
  79406. * 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)).
  79407. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79408. */
  79409. rotation: Vector3;
  79410. /**
  79411. * 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)).
  79412. */
  79413. scaling: Vector3;
  79414. /**
  79415. * 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).
  79416. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79417. */
  79418. rotationQuaternion: Nullable<Quaternion>;
  79419. /**
  79420. * The forward direction of that transform in world space.
  79421. */
  79422. readonly forward: Vector3;
  79423. /**
  79424. * The up direction of that transform in world space.
  79425. */
  79426. readonly up: Vector3;
  79427. /**
  79428. * The right direction of that transform in world space.
  79429. */
  79430. readonly right: Vector3;
  79431. /**
  79432. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79433. * @param matrix the matrix to copy the pose from
  79434. * @returns this TransformNode.
  79435. */
  79436. updatePoseMatrix(matrix: Matrix): TransformNode;
  79437. /**
  79438. * Returns the mesh Pose matrix.
  79439. * @returns the pose matrix
  79440. */
  79441. getPoseMatrix(): Matrix;
  79442. /** @hidden */
  79443. _isSynchronized(): boolean;
  79444. /** @hidden */
  79445. _initCache(): void;
  79446. /**
  79447. * Flag the transform node as dirty (Forcing it to update everything)
  79448. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79449. * @returns this transform node
  79450. */
  79451. markAsDirty(property: string): TransformNode;
  79452. /**
  79453. * Returns the current mesh absolute position.
  79454. * Returns a Vector3.
  79455. */
  79456. readonly absolutePosition: Vector3;
  79457. /**
  79458. * Returns the current mesh absolute scaling.
  79459. * Returns a Vector3.
  79460. */
  79461. readonly absoluteScaling: Vector3;
  79462. /**
  79463. * Returns the current mesh absolute rotation.
  79464. * Returns a Quaternion.
  79465. */
  79466. readonly absoluteRotationQuaternion: Quaternion;
  79467. /**
  79468. * Sets a new matrix to apply before all other transformation
  79469. * @param matrix defines the transform matrix
  79470. * @returns the current TransformNode
  79471. */
  79472. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79473. /**
  79474. * Sets a new pivot matrix to the current node
  79475. * @param matrix defines the new pivot matrix to use
  79476. * @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
  79477. * @returns the current TransformNode
  79478. */
  79479. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79480. /**
  79481. * Returns the mesh pivot matrix.
  79482. * Default : Identity.
  79483. * @returns the matrix
  79484. */
  79485. getPivotMatrix(): Matrix;
  79486. /**
  79487. * Instantiate (when possible) or clone that node with its hierarchy
  79488. * @param newParent defines the new parent to use for the instance (or clone)
  79489. * @returns an instance (or a clone) of the current node with its hiearchy
  79490. */
  79491. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79492. /**
  79493. * Prevents the World matrix to be computed any longer
  79494. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79495. * @returns the TransformNode.
  79496. */
  79497. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79498. /**
  79499. * Allows back the World matrix computation.
  79500. * @returns the TransformNode.
  79501. */
  79502. unfreezeWorldMatrix(): this;
  79503. /**
  79504. * True if the World matrix has been frozen.
  79505. */
  79506. readonly isWorldMatrixFrozen: boolean;
  79507. /**
  79508. * Retuns the mesh absolute position in the World.
  79509. * @returns a Vector3.
  79510. */
  79511. getAbsolutePosition(): Vector3;
  79512. /**
  79513. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79514. * @param absolutePosition the absolute position to set
  79515. * @returns the TransformNode.
  79516. */
  79517. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79518. /**
  79519. * Sets the mesh position in its local space.
  79520. * @param vector3 the position to set in localspace
  79521. * @returns the TransformNode.
  79522. */
  79523. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79524. /**
  79525. * Returns the mesh position in the local space from the current World matrix values.
  79526. * @returns a new Vector3.
  79527. */
  79528. getPositionExpressedInLocalSpace(): Vector3;
  79529. /**
  79530. * Translates the mesh along the passed Vector3 in its local space.
  79531. * @param vector3 the distance to translate in localspace
  79532. * @returns the TransformNode.
  79533. */
  79534. locallyTranslate(vector3: Vector3): TransformNode;
  79535. private static _lookAtVectorCache;
  79536. /**
  79537. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79538. * @param targetPoint the position (must be in same space as current mesh) to look at
  79539. * @param yawCor optional yaw (y-axis) correction in radians
  79540. * @param pitchCor optional pitch (x-axis) correction in radians
  79541. * @param rollCor optional roll (z-axis) correction in radians
  79542. * @param space the choosen space of the target
  79543. * @returns the TransformNode.
  79544. */
  79545. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79546. /**
  79547. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79548. * This Vector3 is expressed in the World space.
  79549. * @param localAxis axis to rotate
  79550. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79551. */
  79552. getDirection(localAxis: Vector3): Vector3;
  79553. /**
  79554. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79555. * localAxis is expressed in the mesh local space.
  79556. * result is computed in the Wordl space from the mesh World matrix.
  79557. * @param localAxis axis to rotate
  79558. * @param result the resulting transformnode
  79559. * @returns this TransformNode.
  79560. */
  79561. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79562. /**
  79563. * Sets this transform node rotation to the given local axis.
  79564. * @param localAxis the axis in local space
  79565. * @param yawCor optional yaw (y-axis) correction in radians
  79566. * @param pitchCor optional pitch (x-axis) correction in radians
  79567. * @param rollCor optional roll (z-axis) correction in radians
  79568. * @returns this TransformNode
  79569. */
  79570. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79571. /**
  79572. * Sets a new pivot point to the current node
  79573. * @param point defines the new pivot point to use
  79574. * @param space defines if the point is in world or local space (local by default)
  79575. * @returns the current TransformNode
  79576. */
  79577. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79578. /**
  79579. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79580. * @returns the pivot point
  79581. */
  79582. getPivotPoint(): Vector3;
  79583. /**
  79584. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79585. * @param result the vector3 to store the result
  79586. * @returns this TransformNode.
  79587. */
  79588. getPivotPointToRef(result: Vector3): TransformNode;
  79589. /**
  79590. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79591. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79592. */
  79593. getAbsolutePivotPoint(): Vector3;
  79594. /**
  79595. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79596. * @param result vector3 to store the result
  79597. * @returns this TransformNode.
  79598. */
  79599. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79600. /**
  79601. * Defines the passed node as the parent of the current node.
  79602. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79603. * @see https://doc.babylonjs.com/how_to/parenting
  79604. * @param node the node ot set as the parent
  79605. * @returns this TransformNode.
  79606. */
  79607. setParent(node: Nullable<Node>): TransformNode;
  79608. private _nonUniformScaling;
  79609. /**
  79610. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79611. */
  79612. readonly nonUniformScaling: boolean;
  79613. /** @hidden */
  79614. _updateNonUniformScalingState(value: boolean): boolean;
  79615. /**
  79616. * Attach the current TransformNode to another TransformNode associated with a bone
  79617. * @param bone Bone affecting the TransformNode
  79618. * @param affectedTransformNode TransformNode associated with the bone
  79619. * @returns this object
  79620. */
  79621. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79622. /**
  79623. * Detach the transform node if its associated with a bone
  79624. * @returns this object
  79625. */
  79626. detachFromBone(): TransformNode;
  79627. private static _rotationAxisCache;
  79628. /**
  79629. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79630. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79631. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79632. * The passed axis is also normalized.
  79633. * @param axis the axis to rotate around
  79634. * @param amount the amount to rotate in radians
  79635. * @param space Space to rotate in (Default: local)
  79636. * @returns the TransformNode.
  79637. */
  79638. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79639. /**
  79640. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79641. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79642. * The passed axis is also normalized. .
  79643. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79644. * @param point the point to rotate around
  79645. * @param axis the axis to rotate around
  79646. * @param amount the amount to rotate in radians
  79647. * @returns the TransformNode
  79648. */
  79649. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79650. /**
  79651. * Translates the mesh along the axis vector for the passed distance in the given space.
  79652. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79653. * @param axis the axis to translate in
  79654. * @param distance the distance to translate
  79655. * @param space Space to rotate in (Default: local)
  79656. * @returns the TransformNode.
  79657. */
  79658. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79659. /**
  79660. * Adds a rotation step to the mesh current rotation.
  79661. * x, y, z are Euler angles expressed in radians.
  79662. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79663. * This means this rotation is made in the mesh local space only.
  79664. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79665. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79666. * ```javascript
  79667. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79668. * ```
  79669. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79670. * 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.
  79671. * @param x Rotation to add
  79672. * @param y Rotation to add
  79673. * @param z Rotation to add
  79674. * @returns the TransformNode.
  79675. */
  79676. addRotation(x: number, y: number, z: number): TransformNode;
  79677. /**
  79678. * @hidden
  79679. */
  79680. protected _getEffectiveParent(): Nullable<Node>;
  79681. /**
  79682. * Computes the world matrix of the node
  79683. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79684. * @returns the world matrix
  79685. */
  79686. computeWorldMatrix(force?: boolean): Matrix;
  79687. protected _afterComputeWorldMatrix(): void;
  79688. /**
  79689. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79690. * @param func callback function to add
  79691. *
  79692. * @returns the TransformNode.
  79693. */
  79694. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79695. /**
  79696. * Removes a registered callback function.
  79697. * @param func callback function to remove
  79698. * @returns the TransformNode.
  79699. */
  79700. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79701. /**
  79702. * Gets the position of the current mesh in camera space
  79703. * @param camera defines the camera to use
  79704. * @returns a position
  79705. */
  79706. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79707. /**
  79708. * Returns the distance from the mesh to the active camera
  79709. * @param camera defines the camera to use
  79710. * @returns the distance
  79711. */
  79712. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79713. /**
  79714. * Clone the current transform node
  79715. * @param name Name of the new clone
  79716. * @param newParent New parent for the clone
  79717. * @param doNotCloneChildren Do not clone children hierarchy
  79718. * @returns the new transform node
  79719. */
  79720. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79721. /**
  79722. * Serializes the objects information.
  79723. * @param currentSerializationObject defines the object to serialize in
  79724. * @returns the serialized object
  79725. */
  79726. serialize(currentSerializationObject?: any): any;
  79727. /**
  79728. * Returns a new TransformNode object parsed from the source provided.
  79729. * @param parsedTransformNode is the source.
  79730. * @param scene the scne the object belongs to
  79731. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79732. * @returns a new TransformNode object parsed from the source provided.
  79733. */
  79734. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79735. /**
  79736. * Get all child-transformNodes of this node
  79737. * @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
  79738. * @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
  79739. * @returns an array of TransformNode
  79740. */
  79741. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79742. /**
  79743. * Releases resources associated with this transform node.
  79744. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79745. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79746. */
  79747. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79748. /**
  79749. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79750. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79751. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79752. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79753. * @returns the current mesh
  79754. */
  79755. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79756. private _syncAbsoluteScalingAndRotation;
  79757. }
  79758. }
  79759. declare module BABYLON {
  79760. /**
  79761. * Defines the types of pose enabled controllers that are supported
  79762. */
  79763. export enum PoseEnabledControllerType {
  79764. /**
  79765. * HTC Vive
  79766. */
  79767. VIVE = 0,
  79768. /**
  79769. * Oculus Rift
  79770. */
  79771. OCULUS = 1,
  79772. /**
  79773. * Windows mixed reality
  79774. */
  79775. WINDOWS = 2,
  79776. /**
  79777. * Samsung gear VR
  79778. */
  79779. GEAR_VR = 3,
  79780. /**
  79781. * Google Daydream
  79782. */
  79783. DAYDREAM = 4,
  79784. /**
  79785. * Generic
  79786. */
  79787. GENERIC = 5
  79788. }
  79789. /**
  79790. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79791. */
  79792. export interface MutableGamepadButton {
  79793. /**
  79794. * Value of the button/trigger
  79795. */
  79796. value: number;
  79797. /**
  79798. * If the button/trigger is currently touched
  79799. */
  79800. touched: boolean;
  79801. /**
  79802. * If the button/trigger is currently pressed
  79803. */
  79804. pressed: boolean;
  79805. }
  79806. /**
  79807. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79808. * @hidden
  79809. */
  79810. export interface ExtendedGamepadButton extends GamepadButton {
  79811. /**
  79812. * If the button/trigger is currently pressed
  79813. */
  79814. readonly pressed: boolean;
  79815. /**
  79816. * If the button/trigger is currently touched
  79817. */
  79818. readonly touched: boolean;
  79819. /**
  79820. * Value of the button/trigger
  79821. */
  79822. readonly value: number;
  79823. }
  79824. /** @hidden */
  79825. export interface _GamePadFactory {
  79826. /**
  79827. * Returns wether or not the current gamepad can be created for this type of controller.
  79828. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79829. * @returns true if it can be created, otherwise false
  79830. */
  79831. canCreate(gamepadInfo: any): boolean;
  79832. /**
  79833. * Creates a new instance of the Gamepad.
  79834. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79835. * @returns the new gamepad instance
  79836. */
  79837. create(gamepadInfo: any): Gamepad;
  79838. }
  79839. /**
  79840. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79841. */
  79842. export class PoseEnabledControllerHelper {
  79843. /** @hidden */
  79844. static _ControllerFactories: _GamePadFactory[];
  79845. /** @hidden */
  79846. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79847. /**
  79848. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79849. * @param vrGamepad the gamepad to initialized
  79850. * @returns a vr controller of the type the gamepad identified as
  79851. */
  79852. static InitiateController(vrGamepad: any): Gamepad;
  79853. }
  79854. /**
  79855. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79856. */
  79857. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79858. /**
  79859. * If the controller is used in a webXR session
  79860. */
  79861. isXR: boolean;
  79862. private _deviceRoomPosition;
  79863. private _deviceRoomRotationQuaternion;
  79864. /**
  79865. * The device position in babylon space
  79866. */
  79867. devicePosition: Vector3;
  79868. /**
  79869. * The device rotation in babylon space
  79870. */
  79871. deviceRotationQuaternion: Quaternion;
  79872. /**
  79873. * The scale factor of the device in babylon space
  79874. */
  79875. deviceScaleFactor: number;
  79876. /**
  79877. * (Likely devicePosition should be used instead) The device position in its room space
  79878. */
  79879. position: Vector3;
  79880. /**
  79881. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79882. */
  79883. rotationQuaternion: Quaternion;
  79884. /**
  79885. * The type of controller (Eg. Windows mixed reality)
  79886. */
  79887. controllerType: PoseEnabledControllerType;
  79888. protected _calculatedPosition: Vector3;
  79889. private _calculatedRotation;
  79890. /**
  79891. * The raw pose from the device
  79892. */
  79893. rawPose: DevicePose;
  79894. private _trackPosition;
  79895. private _maxRotationDistFromHeadset;
  79896. private _draggedRoomRotation;
  79897. /**
  79898. * @hidden
  79899. */
  79900. _disableTrackPosition(fixedPosition: Vector3): void;
  79901. /**
  79902. * Internal, the mesh attached to the controller
  79903. * @hidden
  79904. */
  79905. _mesh: Nullable<AbstractMesh>;
  79906. private _poseControlledCamera;
  79907. private _leftHandSystemQuaternion;
  79908. /**
  79909. * Internal, matrix used to convert room space to babylon space
  79910. * @hidden
  79911. */
  79912. _deviceToWorld: Matrix;
  79913. /**
  79914. * Node to be used when casting a ray from the controller
  79915. * @hidden
  79916. */
  79917. _pointingPoseNode: Nullable<TransformNode>;
  79918. /**
  79919. * Name of the child mesh that can be used to cast a ray from the controller
  79920. */
  79921. static readonly POINTING_POSE: string;
  79922. /**
  79923. * Creates a new PoseEnabledController from a gamepad
  79924. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79925. */
  79926. constructor(browserGamepad: any);
  79927. private _workingMatrix;
  79928. /**
  79929. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79930. */
  79931. update(): void;
  79932. /**
  79933. * Updates only the pose device and mesh without doing any button event checking
  79934. */
  79935. protected _updatePoseAndMesh(): void;
  79936. /**
  79937. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79938. * @param poseData raw pose fromthe device
  79939. */
  79940. updateFromDevice(poseData: DevicePose): void;
  79941. /**
  79942. * @hidden
  79943. */
  79944. _meshAttachedObservable: Observable<AbstractMesh>;
  79945. /**
  79946. * Attaches a mesh to the controller
  79947. * @param mesh the mesh to be attached
  79948. */
  79949. attachToMesh(mesh: AbstractMesh): void;
  79950. /**
  79951. * Attaches the controllers mesh to a camera
  79952. * @param camera the camera the mesh should be attached to
  79953. */
  79954. attachToPoseControlledCamera(camera: TargetCamera): void;
  79955. /**
  79956. * Disposes of the controller
  79957. */
  79958. dispose(): void;
  79959. /**
  79960. * The mesh that is attached to the controller
  79961. */
  79962. readonly mesh: Nullable<AbstractMesh>;
  79963. /**
  79964. * Gets the ray of the controller in the direction the controller is pointing
  79965. * @param length the length the resulting ray should be
  79966. * @returns a ray in the direction the controller is pointing
  79967. */
  79968. getForwardRay(length?: number): Ray;
  79969. }
  79970. }
  79971. declare module BABYLON {
  79972. /**
  79973. * Defines the WebVRController object that represents controllers tracked in 3D space
  79974. */
  79975. export abstract class WebVRController extends PoseEnabledController {
  79976. /**
  79977. * Internal, the default controller model for the controller
  79978. */
  79979. protected _defaultModel: AbstractMesh;
  79980. /**
  79981. * Fired when the trigger state has changed
  79982. */
  79983. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79984. /**
  79985. * Fired when the main button state has changed
  79986. */
  79987. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79988. /**
  79989. * Fired when the secondary button state has changed
  79990. */
  79991. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79992. /**
  79993. * Fired when the pad state has changed
  79994. */
  79995. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79996. /**
  79997. * Fired when controllers stick values have changed
  79998. */
  79999. onPadValuesChangedObservable: Observable<StickValues>;
  80000. /**
  80001. * Array of button availible on the controller
  80002. */
  80003. protected _buttons: Array<MutableGamepadButton>;
  80004. private _onButtonStateChange;
  80005. /**
  80006. * Fired when a controller button's state has changed
  80007. * @param callback the callback containing the button that was modified
  80008. */
  80009. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80010. /**
  80011. * X and Y axis corresponding to the controllers joystick
  80012. */
  80013. pad: StickValues;
  80014. /**
  80015. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80016. */
  80017. hand: string;
  80018. /**
  80019. * The default controller model for the controller
  80020. */
  80021. readonly defaultModel: AbstractMesh;
  80022. /**
  80023. * Creates a new WebVRController from a gamepad
  80024. * @param vrGamepad the gamepad that the WebVRController should be created from
  80025. */
  80026. constructor(vrGamepad: any);
  80027. /**
  80028. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80029. */
  80030. update(): void;
  80031. /**
  80032. * Function to be called when a button is modified
  80033. */
  80034. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80035. /**
  80036. * Loads a mesh and attaches it to the controller
  80037. * @param scene the scene the mesh should be added to
  80038. * @param meshLoaded callback for when the mesh has been loaded
  80039. */
  80040. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80041. private _setButtonValue;
  80042. private _changes;
  80043. private _checkChanges;
  80044. /**
  80045. * Disposes of th webVRCOntroller
  80046. */
  80047. dispose(): void;
  80048. }
  80049. }
  80050. declare module BABYLON {
  80051. /**
  80052. * The HemisphericLight simulates the ambient environment light,
  80053. * so the passed direction is the light reflection direction, not the incoming direction.
  80054. */
  80055. export class HemisphericLight extends Light {
  80056. /**
  80057. * The groundColor is the light in the opposite direction to the one specified during creation.
  80058. * 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.
  80059. */
  80060. groundColor: Color3;
  80061. /**
  80062. * The light reflection direction, not the incoming direction.
  80063. */
  80064. direction: Vector3;
  80065. /**
  80066. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80067. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80068. * The HemisphericLight can't cast shadows.
  80069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80070. * @param name The friendly name of the light
  80071. * @param direction The direction of the light reflection
  80072. * @param scene The scene the light belongs to
  80073. */
  80074. constructor(name: string, direction: Vector3, scene: Scene);
  80075. protected _buildUniformLayout(): void;
  80076. /**
  80077. * Returns the string "HemisphericLight".
  80078. * @return The class name
  80079. */
  80080. getClassName(): string;
  80081. /**
  80082. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80083. * Returns the updated direction.
  80084. * @param target The target the direction should point to
  80085. * @return The computed direction
  80086. */
  80087. setDirectionToTarget(target: Vector3): Vector3;
  80088. /**
  80089. * Returns the shadow generator associated to the light.
  80090. * @returns Always null for hemispheric lights because it does not support shadows.
  80091. */
  80092. getShadowGenerator(): Nullable<IShadowGenerator>;
  80093. /**
  80094. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80095. * @param effect The effect to update
  80096. * @param lightIndex The index of the light in the effect to update
  80097. * @returns The hemispheric light
  80098. */
  80099. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80100. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80101. /**
  80102. * Computes the world matrix of the node
  80103. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80104. * @param useWasUpdatedFlag defines a reserved property
  80105. * @returns the world matrix
  80106. */
  80107. computeWorldMatrix(): Matrix;
  80108. /**
  80109. * Returns the integer 3.
  80110. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80111. */
  80112. getTypeID(): number;
  80113. /**
  80114. * Prepares the list of defines specific to the light type.
  80115. * @param defines the list of defines
  80116. * @param lightIndex defines the index of the light for the effect
  80117. */
  80118. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80119. }
  80120. }
  80121. declare module BABYLON {
  80122. /** @hidden */
  80123. export var vrMultiviewToSingleviewPixelShader: {
  80124. name: string;
  80125. shader: string;
  80126. };
  80127. }
  80128. declare module BABYLON {
  80129. /**
  80130. * Renders to multiple views with a single draw call
  80131. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80132. */
  80133. export class MultiviewRenderTarget extends RenderTargetTexture {
  80134. /**
  80135. * Creates a multiview render target
  80136. * @param scene scene used with the render target
  80137. * @param size the size of the render target (used for each view)
  80138. */
  80139. constructor(scene: Scene, size?: number | {
  80140. width: number;
  80141. height: number;
  80142. } | {
  80143. ratio: number;
  80144. });
  80145. /**
  80146. * @hidden
  80147. * @param faceIndex the face index, if its a cube texture
  80148. */
  80149. _bindFrameBuffer(faceIndex?: number): void;
  80150. /**
  80151. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80152. * @returns the view count
  80153. */
  80154. getViewCount(): number;
  80155. }
  80156. }
  80157. declare module BABYLON {
  80158. /**
  80159. * Reprasents a camera frustum
  80160. */
  80161. export class Frustum {
  80162. /**
  80163. * Gets the planes representing the frustum
  80164. * @param transform matrix to be applied to the returned planes
  80165. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80166. */
  80167. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80168. /**
  80169. * Gets the near frustum plane transformed by the transform matrix
  80170. * @param transform transformation matrix to be applied to the resulting frustum plane
  80171. * @param frustumPlane the resuling frustum plane
  80172. */
  80173. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80174. /**
  80175. * Gets the far frustum plane transformed by the transform matrix
  80176. * @param transform transformation matrix to be applied to the resulting frustum plane
  80177. * @param frustumPlane the resuling frustum plane
  80178. */
  80179. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80180. /**
  80181. * Gets the left frustum plane transformed by the transform matrix
  80182. * @param transform transformation matrix to be applied to the resulting frustum plane
  80183. * @param frustumPlane the resuling frustum plane
  80184. */
  80185. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80186. /**
  80187. * Gets the right frustum plane transformed by the transform matrix
  80188. * @param transform transformation matrix to be applied to the resulting frustum plane
  80189. * @param frustumPlane the resuling frustum plane
  80190. */
  80191. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80192. /**
  80193. * Gets the top frustum plane transformed by the transform matrix
  80194. * @param transform transformation matrix to be applied to the resulting frustum plane
  80195. * @param frustumPlane the resuling frustum plane
  80196. */
  80197. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80198. /**
  80199. * Gets the bottom frustum plane transformed by the transform matrix
  80200. * @param transform transformation matrix to be applied to the resulting frustum plane
  80201. * @param frustumPlane the resuling frustum plane
  80202. */
  80203. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80204. /**
  80205. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80206. * @param transform transformation matrix to be applied to the resulting frustum planes
  80207. * @param frustumPlanes the resuling frustum planes
  80208. */
  80209. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80210. }
  80211. }
  80212. declare module BABYLON {
  80213. interface Engine {
  80214. /**
  80215. * Creates a new multiview render target
  80216. * @param width defines the width of the texture
  80217. * @param height defines the height of the texture
  80218. * @returns the created multiview texture
  80219. */
  80220. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80221. /**
  80222. * Binds a multiview framebuffer to be drawn to
  80223. * @param multiviewTexture texture to bind
  80224. */
  80225. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80226. }
  80227. interface Camera {
  80228. /**
  80229. * @hidden
  80230. * 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)
  80231. */
  80232. _useMultiviewToSingleView: boolean;
  80233. /**
  80234. * @hidden
  80235. * 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)
  80236. */
  80237. _multiviewTexture: Nullable<RenderTargetTexture>;
  80238. /**
  80239. * @hidden
  80240. * ensures the multiview texture of the camera exists and has the specified width/height
  80241. * @param width height to set on the multiview texture
  80242. * @param height width to set on the multiview texture
  80243. */
  80244. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80245. }
  80246. interface Scene {
  80247. /** @hidden */
  80248. _transformMatrixR: Matrix;
  80249. /** @hidden */
  80250. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80251. /** @hidden */
  80252. _createMultiviewUbo(): void;
  80253. /** @hidden */
  80254. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80255. /** @hidden */
  80256. _renderMultiviewToSingleView(camera: Camera): void;
  80257. }
  80258. }
  80259. declare module BABYLON {
  80260. /**
  80261. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80262. * This will not be used for webXR as it supports displaying texture arrays directly
  80263. */
  80264. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80265. /**
  80266. * Initializes a VRMultiviewToSingleview
  80267. * @param name name of the post process
  80268. * @param camera camera to be applied to
  80269. * @param scaleFactor scaling factor to the size of the output texture
  80270. */
  80271. constructor(name: string, camera: Camera, scaleFactor: number);
  80272. }
  80273. }
  80274. declare module BABYLON {
  80275. interface Engine {
  80276. /** @hidden */
  80277. _vrDisplay: any;
  80278. /** @hidden */
  80279. _vrSupported: boolean;
  80280. /** @hidden */
  80281. _oldSize: Size;
  80282. /** @hidden */
  80283. _oldHardwareScaleFactor: number;
  80284. /** @hidden */
  80285. _vrExclusivePointerMode: boolean;
  80286. /** @hidden */
  80287. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80288. /** @hidden */
  80289. _onVRDisplayPointerRestricted: () => void;
  80290. /** @hidden */
  80291. _onVRDisplayPointerUnrestricted: () => void;
  80292. /** @hidden */
  80293. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80294. /** @hidden */
  80295. _onVrDisplayDisconnect: Nullable<() => void>;
  80296. /** @hidden */
  80297. _onVrDisplayPresentChange: Nullable<() => void>;
  80298. /**
  80299. * Observable signaled when VR display mode changes
  80300. */
  80301. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80302. /**
  80303. * Observable signaled when VR request present is complete
  80304. */
  80305. onVRRequestPresentComplete: Observable<boolean>;
  80306. /**
  80307. * Observable signaled when VR request present starts
  80308. */
  80309. onVRRequestPresentStart: Observable<Engine>;
  80310. /**
  80311. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80312. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80313. */
  80314. isInVRExclusivePointerMode: boolean;
  80315. /**
  80316. * Gets a boolean indicating if a webVR device was detected
  80317. * @returns true if a webVR device was detected
  80318. */
  80319. isVRDevicePresent(): boolean;
  80320. /**
  80321. * Gets the current webVR device
  80322. * @returns the current webVR device (or null)
  80323. */
  80324. getVRDevice(): any;
  80325. /**
  80326. * Initializes a webVR display and starts listening to display change events
  80327. * The onVRDisplayChangedObservable will be notified upon these changes
  80328. * @returns A promise containing a VRDisplay and if vr is supported
  80329. */
  80330. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80331. /** @hidden */
  80332. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80333. /**
  80334. * Call this function to switch to webVR mode
  80335. * Will do nothing if webVR is not supported or if there is no webVR device
  80336. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80337. */
  80338. enableVR(): void;
  80339. /** @hidden */
  80340. _onVRFullScreenTriggered(): void;
  80341. }
  80342. }
  80343. declare module BABYLON {
  80344. /**
  80345. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80346. * IMPORTANT!! The data is right-hand data.
  80347. * @export
  80348. * @interface DevicePose
  80349. */
  80350. export interface DevicePose {
  80351. /**
  80352. * The position of the device, values in array are [x,y,z].
  80353. */
  80354. readonly position: Nullable<Float32Array>;
  80355. /**
  80356. * The linearVelocity of the device, values in array are [x,y,z].
  80357. */
  80358. readonly linearVelocity: Nullable<Float32Array>;
  80359. /**
  80360. * The linearAcceleration of the device, values in array are [x,y,z].
  80361. */
  80362. readonly linearAcceleration: Nullable<Float32Array>;
  80363. /**
  80364. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80365. */
  80366. readonly orientation: Nullable<Float32Array>;
  80367. /**
  80368. * The angularVelocity of the device, values in array are [x,y,z].
  80369. */
  80370. readonly angularVelocity: Nullable<Float32Array>;
  80371. /**
  80372. * The angularAcceleration of the device, values in array are [x,y,z].
  80373. */
  80374. readonly angularAcceleration: Nullable<Float32Array>;
  80375. }
  80376. /**
  80377. * Interface representing a pose controlled object in Babylon.
  80378. * A pose controlled object has both regular pose values as well as pose values
  80379. * from an external device such as a VR head mounted display
  80380. */
  80381. export interface PoseControlled {
  80382. /**
  80383. * The position of the object in babylon space.
  80384. */
  80385. position: Vector3;
  80386. /**
  80387. * The rotation quaternion of the object in babylon space.
  80388. */
  80389. rotationQuaternion: Quaternion;
  80390. /**
  80391. * The position of the device in babylon space.
  80392. */
  80393. devicePosition?: Vector3;
  80394. /**
  80395. * The rotation quaternion of the device in babylon space.
  80396. */
  80397. deviceRotationQuaternion: Quaternion;
  80398. /**
  80399. * The raw pose coming from the device.
  80400. */
  80401. rawPose: Nullable<DevicePose>;
  80402. /**
  80403. * The scale of the device to be used when translating from device space to babylon space.
  80404. */
  80405. deviceScaleFactor: number;
  80406. /**
  80407. * Updates the poseControlled values based on the input device pose.
  80408. * @param poseData the pose data to update the object with
  80409. */
  80410. updateFromDevice(poseData: DevicePose): void;
  80411. }
  80412. /**
  80413. * Set of options to customize the webVRCamera
  80414. */
  80415. export interface WebVROptions {
  80416. /**
  80417. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80418. */
  80419. trackPosition?: boolean;
  80420. /**
  80421. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80422. */
  80423. positionScale?: number;
  80424. /**
  80425. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80426. */
  80427. displayName?: string;
  80428. /**
  80429. * Should the native controller meshes be initialized. (default: true)
  80430. */
  80431. controllerMeshes?: boolean;
  80432. /**
  80433. * Creating a default HemiLight only on controllers. (default: true)
  80434. */
  80435. defaultLightingOnControllers?: boolean;
  80436. /**
  80437. * If you don't want to use the default VR button of the helper. (default: false)
  80438. */
  80439. useCustomVRButton?: boolean;
  80440. /**
  80441. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80442. */
  80443. customVRButton?: HTMLButtonElement;
  80444. /**
  80445. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80446. */
  80447. rayLength?: number;
  80448. /**
  80449. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80450. */
  80451. defaultHeight?: number;
  80452. /**
  80453. * If multiview should be used if availible (default: false)
  80454. */
  80455. useMultiview?: boolean;
  80456. }
  80457. /**
  80458. * This represents a WebVR camera.
  80459. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80460. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80461. */
  80462. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80463. private webVROptions;
  80464. /**
  80465. * @hidden
  80466. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80467. */
  80468. _vrDevice: any;
  80469. /**
  80470. * The rawPose of the vrDevice.
  80471. */
  80472. rawPose: Nullable<DevicePose>;
  80473. private _onVREnabled;
  80474. private _specsVersion;
  80475. private _attached;
  80476. private _frameData;
  80477. protected _descendants: Array<Node>;
  80478. private _deviceRoomPosition;
  80479. /** @hidden */
  80480. _deviceRoomRotationQuaternion: Quaternion;
  80481. private _standingMatrix;
  80482. /**
  80483. * Represents device position in babylon space.
  80484. */
  80485. devicePosition: Vector3;
  80486. /**
  80487. * Represents device rotation in babylon space.
  80488. */
  80489. deviceRotationQuaternion: Quaternion;
  80490. /**
  80491. * The scale of the device to be used when translating from device space to babylon space.
  80492. */
  80493. deviceScaleFactor: number;
  80494. private _deviceToWorld;
  80495. private _worldToDevice;
  80496. /**
  80497. * References to the webVR controllers for the vrDevice.
  80498. */
  80499. controllers: Array<WebVRController>;
  80500. /**
  80501. * Emits an event when a controller is attached.
  80502. */
  80503. onControllersAttachedObservable: Observable<WebVRController[]>;
  80504. /**
  80505. * Emits an event when a controller's mesh has been loaded;
  80506. */
  80507. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80508. /**
  80509. * Emits an event when the HMD's pose has been updated.
  80510. */
  80511. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80512. private _poseSet;
  80513. /**
  80514. * If the rig cameras be used as parent instead of this camera.
  80515. */
  80516. rigParenting: boolean;
  80517. private _lightOnControllers;
  80518. private _defaultHeight?;
  80519. /**
  80520. * Instantiates a WebVRFreeCamera.
  80521. * @param name The name of the WebVRFreeCamera
  80522. * @param position The starting anchor position for the camera
  80523. * @param scene The scene the camera belongs to
  80524. * @param webVROptions a set of customizable options for the webVRCamera
  80525. */
  80526. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80527. /**
  80528. * Gets the device distance from the ground in meters.
  80529. * @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.
  80530. */
  80531. deviceDistanceToRoomGround(): number;
  80532. /**
  80533. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80534. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80535. */
  80536. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80537. /**
  80538. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80539. * @returns A promise with a boolean set to if the standing matrix is supported.
  80540. */
  80541. useStandingMatrixAsync(): Promise<boolean>;
  80542. /**
  80543. * Disposes the camera
  80544. */
  80545. dispose(): void;
  80546. /**
  80547. * Gets a vrController by name.
  80548. * @param name The name of the controller to retreive
  80549. * @returns the controller matching the name specified or null if not found
  80550. */
  80551. getControllerByName(name: string): Nullable<WebVRController>;
  80552. private _leftController;
  80553. /**
  80554. * The controller corresponding to the users left hand.
  80555. */
  80556. readonly leftController: Nullable<WebVRController>;
  80557. private _rightController;
  80558. /**
  80559. * The controller corresponding to the users right hand.
  80560. */
  80561. readonly rightController: Nullable<WebVRController>;
  80562. /**
  80563. * Casts a ray forward from the vrCamera's gaze.
  80564. * @param length Length of the ray (default: 100)
  80565. * @returns the ray corresponding to the gaze
  80566. */
  80567. getForwardRay(length?: number): Ray;
  80568. /**
  80569. * @hidden
  80570. * Updates the camera based on device's frame data
  80571. */
  80572. _checkInputs(): void;
  80573. /**
  80574. * Updates the poseControlled values based on the input device pose.
  80575. * @param poseData Pose coming from the device
  80576. */
  80577. updateFromDevice(poseData: DevicePose): void;
  80578. private _htmlElementAttached;
  80579. private _detachIfAttached;
  80580. /**
  80581. * WebVR's attach control will start broadcasting frames to the device.
  80582. * Note that in certain browsers (chrome for example) this function must be called
  80583. * within a user-interaction callback. Example:
  80584. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80585. *
  80586. * @param element html element to attach the vrDevice to
  80587. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80588. */
  80589. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80590. /**
  80591. * Detaches the camera from the html element and disables VR
  80592. *
  80593. * @param element html element to detach from
  80594. */
  80595. detachControl(element: HTMLElement): void;
  80596. /**
  80597. * @returns the name of this class
  80598. */
  80599. getClassName(): string;
  80600. /**
  80601. * Calls resetPose on the vrDisplay
  80602. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80603. */
  80604. resetToCurrentRotation(): void;
  80605. /**
  80606. * @hidden
  80607. * Updates the rig cameras (left and right eye)
  80608. */
  80609. _updateRigCameras(): void;
  80610. private _workingVector;
  80611. private _oneVector;
  80612. private _workingMatrix;
  80613. private updateCacheCalled;
  80614. private _correctPositionIfNotTrackPosition;
  80615. /**
  80616. * @hidden
  80617. * Updates the cached values of the camera
  80618. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80619. */
  80620. _updateCache(ignoreParentClass?: boolean): void;
  80621. /**
  80622. * @hidden
  80623. * Get current device position in babylon world
  80624. */
  80625. _computeDevicePosition(): void;
  80626. /**
  80627. * Updates the current device position and rotation in the babylon world
  80628. */
  80629. update(): void;
  80630. /**
  80631. * @hidden
  80632. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80633. * @returns an identity matrix
  80634. */
  80635. _getViewMatrix(): Matrix;
  80636. private _tmpMatrix;
  80637. /**
  80638. * This function is called by the two RIG cameras.
  80639. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80640. * @hidden
  80641. */
  80642. _getWebVRViewMatrix(): Matrix;
  80643. /** @hidden */
  80644. _getWebVRProjectionMatrix(): Matrix;
  80645. private _onGamepadConnectedObserver;
  80646. private _onGamepadDisconnectedObserver;
  80647. private _updateCacheWhenTrackingDisabledObserver;
  80648. /**
  80649. * Initializes the controllers and their meshes
  80650. */
  80651. initControllers(): void;
  80652. }
  80653. }
  80654. declare module BABYLON {
  80655. /**
  80656. * Size options for a post process
  80657. */
  80658. export type PostProcessOptions = {
  80659. width: number;
  80660. height: number;
  80661. };
  80662. /**
  80663. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80664. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80665. */
  80666. export class PostProcess {
  80667. /** Name of the PostProcess. */
  80668. name: string;
  80669. /**
  80670. * Gets or sets the unique id of the post process
  80671. */
  80672. uniqueId: number;
  80673. /**
  80674. * Width of the texture to apply the post process on
  80675. */
  80676. width: number;
  80677. /**
  80678. * Height of the texture to apply the post process on
  80679. */
  80680. height: number;
  80681. /**
  80682. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80683. * @hidden
  80684. */
  80685. _outputTexture: Nullable<InternalTexture>;
  80686. /**
  80687. * Sampling mode used by the shader
  80688. * See https://doc.babylonjs.com/classes/3.1/texture
  80689. */
  80690. renderTargetSamplingMode: number;
  80691. /**
  80692. * Clear color to use when screen clearing
  80693. */
  80694. clearColor: Color4;
  80695. /**
  80696. * If the buffer needs to be cleared before applying the post process. (default: true)
  80697. * Should be set to false if shader will overwrite all previous pixels.
  80698. */
  80699. autoClear: boolean;
  80700. /**
  80701. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80702. */
  80703. alphaMode: number;
  80704. /**
  80705. * Sets the setAlphaBlendConstants of the babylon engine
  80706. */
  80707. alphaConstants: Color4;
  80708. /**
  80709. * Animations to be used for the post processing
  80710. */
  80711. animations: Animation[];
  80712. /**
  80713. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80714. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80715. */
  80716. enablePixelPerfectMode: boolean;
  80717. /**
  80718. * Force the postprocess to be applied without taking in account viewport
  80719. */
  80720. forceFullscreenViewport: boolean;
  80721. /**
  80722. * List of inspectable custom properties (used by the Inspector)
  80723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80724. */
  80725. inspectableCustomProperties: IInspectable[];
  80726. /**
  80727. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80728. *
  80729. * | Value | Type | Description |
  80730. * | ----- | ----------------------------------- | ----------- |
  80731. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80732. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80733. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80734. *
  80735. */
  80736. scaleMode: number;
  80737. /**
  80738. * Force textures to be a power of two (default: false)
  80739. */
  80740. alwaysForcePOT: boolean;
  80741. private _samples;
  80742. /**
  80743. * Number of sample textures (default: 1)
  80744. */
  80745. samples: number;
  80746. /**
  80747. * Modify the scale of the post process to be the same as the viewport (default: false)
  80748. */
  80749. adaptScaleToCurrentViewport: boolean;
  80750. private _camera;
  80751. private _scene;
  80752. private _engine;
  80753. private _options;
  80754. private _reusable;
  80755. private _textureType;
  80756. /**
  80757. * Smart array of input and output textures for the post process.
  80758. * @hidden
  80759. */
  80760. _textures: SmartArray<InternalTexture>;
  80761. /**
  80762. * The index in _textures that corresponds to the output texture.
  80763. * @hidden
  80764. */
  80765. _currentRenderTextureInd: number;
  80766. private _effect;
  80767. private _samplers;
  80768. private _fragmentUrl;
  80769. private _vertexUrl;
  80770. private _parameters;
  80771. private _scaleRatio;
  80772. protected _indexParameters: any;
  80773. private _shareOutputWithPostProcess;
  80774. private _texelSize;
  80775. private _forcedOutputTexture;
  80776. /**
  80777. * Returns the fragment url or shader name used in the post process.
  80778. * @returns the fragment url or name in the shader store.
  80779. */
  80780. getEffectName(): string;
  80781. /**
  80782. * An event triggered when the postprocess is activated.
  80783. */
  80784. onActivateObservable: Observable<Camera>;
  80785. private _onActivateObserver;
  80786. /**
  80787. * A function that is added to the onActivateObservable
  80788. */
  80789. onActivate: Nullable<(camera: Camera) => void>;
  80790. /**
  80791. * An event triggered when the postprocess changes its size.
  80792. */
  80793. onSizeChangedObservable: Observable<PostProcess>;
  80794. private _onSizeChangedObserver;
  80795. /**
  80796. * A function that is added to the onSizeChangedObservable
  80797. */
  80798. onSizeChanged: (postProcess: PostProcess) => void;
  80799. /**
  80800. * An event triggered when the postprocess applies its effect.
  80801. */
  80802. onApplyObservable: Observable<Effect>;
  80803. private _onApplyObserver;
  80804. /**
  80805. * A function that is added to the onApplyObservable
  80806. */
  80807. onApply: (effect: Effect) => void;
  80808. /**
  80809. * An event triggered before rendering the postprocess
  80810. */
  80811. onBeforeRenderObservable: Observable<Effect>;
  80812. private _onBeforeRenderObserver;
  80813. /**
  80814. * A function that is added to the onBeforeRenderObservable
  80815. */
  80816. onBeforeRender: (effect: Effect) => void;
  80817. /**
  80818. * An event triggered after rendering the postprocess
  80819. */
  80820. onAfterRenderObservable: Observable<Effect>;
  80821. private _onAfterRenderObserver;
  80822. /**
  80823. * A function that is added to the onAfterRenderObservable
  80824. */
  80825. onAfterRender: (efect: Effect) => void;
  80826. /**
  80827. * 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
  80828. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80829. */
  80830. inputTexture: InternalTexture;
  80831. /**
  80832. * Gets the camera which post process is applied to.
  80833. * @returns The camera the post process is applied to.
  80834. */
  80835. getCamera(): Camera;
  80836. /**
  80837. * Gets the texel size of the postprocess.
  80838. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80839. */
  80840. readonly texelSize: Vector2;
  80841. /**
  80842. * Creates a new instance PostProcess
  80843. * @param name The name of the PostProcess.
  80844. * @param fragmentUrl The url of the fragment shader to be used.
  80845. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80846. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80847. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80848. * @param camera The camera to apply the render pass to.
  80849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80850. * @param engine The engine which the post process will be applied. (default: current engine)
  80851. * @param reusable If the post process can be reused on the same frame. (default: false)
  80852. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80853. * @param textureType Type of textures used when performing the post process. (default: 0)
  80854. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80855. * @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
  80856. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80857. */
  80858. constructor(
  80859. /** Name of the PostProcess. */
  80860. 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);
  80861. /**
  80862. * Gets a string idenfifying the name of the class
  80863. * @returns "PostProcess" string
  80864. */
  80865. getClassName(): string;
  80866. /**
  80867. * Gets the engine which this post process belongs to.
  80868. * @returns The engine the post process was enabled with.
  80869. */
  80870. getEngine(): Engine;
  80871. /**
  80872. * The effect that is created when initializing the post process.
  80873. * @returns The created effect corresponding the the postprocess.
  80874. */
  80875. getEffect(): Effect;
  80876. /**
  80877. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80878. * @param postProcess The post process to share the output with.
  80879. * @returns This post process.
  80880. */
  80881. shareOutputWith(postProcess: PostProcess): PostProcess;
  80882. /**
  80883. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80884. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80885. */
  80886. useOwnOutput(): void;
  80887. /**
  80888. * Updates the effect with the current post process compile time values and recompiles the shader.
  80889. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80890. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80891. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80892. * @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
  80893. * @param onCompiled Called when the shader has been compiled.
  80894. * @param onError Called if there is an error when compiling a shader.
  80895. */
  80896. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80897. /**
  80898. * The post process is reusable if it can be used multiple times within one frame.
  80899. * @returns If the post process is reusable
  80900. */
  80901. isReusable(): boolean;
  80902. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80903. markTextureDirty(): void;
  80904. /**
  80905. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80906. * 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.
  80907. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80908. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80909. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80910. * @returns The target texture that was bound to be written to.
  80911. */
  80912. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80913. /**
  80914. * If the post process is supported.
  80915. */
  80916. readonly isSupported: boolean;
  80917. /**
  80918. * The aspect ratio of the output texture.
  80919. */
  80920. readonly aspectRatio: number;
  80921. /**
  80922. * Get a value indicating if the post-process is ready to be used
  80923. * @returns true if the post-process is ready (shader is compiled)
  80924. */
  80925. isReady(): boolean;
  80926. /**
  80927. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80928. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80929. */
  80930. apply(): Nullable<Effect>;
  80931. private _disposeTextures;
  80932. /**
  80933. * Disposes the post process.
  80934. * @param camera The camera to dispose the post process on.
  80935. */
  80936. dispose(camera?: Camera): void;
  80937. }
  80938. }
  80939. declare module BABYLON {
  80940. /** @hidden */
  80941. export var kernelBlurVaryingDeclaration: {
  80942. name: string;
  80943. shader: string;
  80944. };
  80945. }
  80946. declare module BABYLON {
  80947. /** @hidden */
  80948. export var kernelBlurFragment: {
  80949. name: string;
  80950. shader: string;
  80951. };
  80952. }
  80953. declare module BABYLON {
  80954. /** @hidden */
  80955. export var kernelBlurFragment2: {
  80956. name: string;
  80957. shader: string;
  80958. };
  80959. }
  80960. declare module BABYLON {
  80961. /** @hidden */
  80962. export var kernelBlurPixelShader: {
  80963. name: string;
  80964. shader: string;
  80965. };
  80966. }
  80967. declare module BABYLON {
  80968. /** @hidden */
  80969. export var kernelBlurVertex: {
  80970. name: string;
  80971. shader: string;
  80972. };
  80973. }
  80974. declare module BABYLON {
  80975. /** @hidden */
  80976. export var kernelBlurVertexShader: {
  80977. name: string;
  80978. shader: string;
  80979. };
  80980. }
  80981. declare module BABYLON {
  80982. /**
  80983. * The Blur Post Process which blurs an image based on a kernel and direction.
  80984. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80985. */
  80986. export class BlurPostProcess extends PostProcess {
  80987. /** The direction in which to blur the image. */
  80988. direction: Vector2;
  80989. private blockCompilation;
  80990. protected _kernel: number;
  80991. protected _idealKernel: number;
  80992. protected _packedFloat: boolean;
  80993. private _staticDefines;
  80994. /**
  80995. * Sets the length in pixels of the blur sample region
  80996. */
  80997. /**
  80998. * Gets the length in pixels of the blur sample region
  80999. */
  81000. kernel: number;
  81001. /**
  81002. * Sets wether or not the blur needs to unpack/repack floats
  81003. */
  81004. /**
  81005. * Gets wether or not the blur is unpacking/repacking floats
  81006. */
  81007. packedFloat: boolean;
  81008. /**
  81009. * Creates a new instance BlurPostProcess
  81010. * @param name The name of the effect.
  81011. * @param direction The direction in which to blur the image.
  81012. * @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.
  81013. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81014. * @param camera The camera to apply the render pass to.
  81015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81016. * @param engine The engine which the post process will be applied. (default: current engine)
  81017. * @param reusable If the post process can be reused on the same frame. (default: false)
  81018. * @param textureType Type of textures used when performing the post process. (default: 0)
  81019. * @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)
  81020. */
  81021. constructor(name: string,
  81022. /** The direction in which to blur the image. */
  81023. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81024. /**
  81025. * Updates the effect with the current post process compile time values and recompiles the shader.
  81026. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81027. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81028. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81029. * @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
  81030. * @param onCompiled Called when the shader has been compiled.
  81031. * @param onError Called if there is an error when compiling a shader.
  81032. */
  81033. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81034. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81035. /**
  81036. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81037. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81038. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81039. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81040. * The gaps between physical kernels are compensated for in the weighting of the samples
  81041. * @param idealKernel Ideal blur kernel.
  81042. * @return Nearest best kernel.
  81043. */
  81044. protected _nearestBestKernel(idealKernel: number): number;
  81045. /**
  81046. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81047. * @param x The point on the Gaussian distribution to sample.
  81048. * @return the value of the Gaussian function at x.
  81049. */
  81050. protected _gaussianWeight(x: number): number;
  81051. /**
  81052. * Generates a string that can be used as a floating point number in GLSL.
  81053. * @param x Value to print.
  81054. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81055. * @return GLSL float string.
  81056. */
  81057. protected _glslFloat(x: number, decimalFigures?: number): string;
  81058. }
  81059. }
  81060. declare module BABYLON {
  81061. /**
  81062. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81063. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81064. * You can then easily use it as a reflectionTexture on a flat surface.
  81065. * In case the surface is not a plane, please consider relying on reflection probes.
  81066. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81067. */
  81068. export class MirrorTexture extends RenderTargetTexture {
  81069. private scene;
  81070. /**
  81071. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81072. * 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.
  81073. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81074. */
  81075. mirrorPlane: Plane;
  81076. /**
  81077. * Define the blur ratio used to blur the reflection if needed.
  81078. */
  81079. blurRatio: number;
  81080. /**
  81081. * Define the adaptive blur kernel used to blur the reflection if needed.
  81082. * This will autocompute the closest best match for the `blurKernel`
  81083. */
  81084. adaptiveBlurKernel: number;
  81085. /**
  81086. * Define the blur kernel used to blur the reflection if needed.
  81087. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81088. */
  81089. blurKernel: number;
  81090. /**
  81091. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81092. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81093. */
  81094. blurKernelX: number;
  81095. /**
  81096. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81097. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81098. */
  81099. blurKernelY: number;
  81100. private _autoComputeBlurKernel;
  81101. protected _onRatioRescale(): void;
  81102. private _updateGammaSpace;
  81103. private _imageProcessingConfigChangeObserver;
  81104. private _transformMatrix;
  81105. private _mirrorMatrix;
  81106. private _savedViewMatrix;
  81107. private _blurX;
  81108. private _blurY;
  81109. private _adaptiveBlurKernel;
  81110. private _blurKernelX;
  81111. private _blurKernelY;
  81112. private _blurRatio;
  81113. /**
  81114. * Instantiates a Mirror Texture.
  81115. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81116. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81117. * You can then easily use it as a reflectionTexture on a flat surface.
  81118. * In case the surface is not a plane, please consider relying on reflection probes.
  81119. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81120. * @param name
  81121. * @param size
  81122. * @param scene
  81123. * @param generateMipMaps
  81124. * @param type
  81125. * @param samplingMode
  81126. * @param generateDepthBuffer
  81127. */
  81128. constructor(name: string, size: number | {
  81129. width: number;
  81130. height: number;
  81131. } | {
  81132. ratio: number;
  81133. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81134. private _preparePostProcesses;
  81135. /**
  81136. * Clone the mirror texture.
  81137. * @returns the cloned texture
  81138. */
  81139. clone(): MirrorTexture;
  81140. /**
  81141. * Serialize the texture to a JSON representation you could use in Parse later on
  81142. * @returns the serialized JSON representation
  81143. */
  81144. serialize(): any;
  81145. /**
  81146. * Dispose the texture and release its associated resources.
  81147. */
  81148. dispose(): void;
  81149. }
  81150. }
  81151. declare module BABYLON {
  81152. /**
  81153. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81154. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81155. */
  81156. export class Texture extends BaseTexture {
  81157. /** @hidden */
  81158. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81159. /** @hidden */
  81160. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81161. /** @hidden */
  81162. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81163. /** nearest is mag = nearest and min = nearest and mip = linear */
  81164. static readonly NEAREST_SAMPLINGMODE: number;
  81165. /** nearest is mag = nearest and min = nearest and mip = linear */
  81166. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81167. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81168. static readonly BILINEAR_SAMPLINGMODE: number;
  81169. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81170. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81171. /** Trilinear is mag = linear and min = linear and mip = linear */
  81172. static readonly TRILINEAR_SAMPLINGMODE: number;
  81173. /** Trilinear is mag = linear and min = linear and mip = linear */
  81174. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81175. /** mag = nearest and min = nearest and mip = nearest */
  81176. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81177. /** mag = nearest and min = linear and mip = nearest */
  81178. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81179. /** mag = nearest and min = linear and mip = linear */
  81180. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81181. /** mag = nearest and min = linear and mip = none */
  81182. static readonly NEAREST_LINEAR: number;
  81183. /** mag = nearest and min = nearest and mip = none */
  81184. static readonly NEAREST_NEAREST: number;
  81185. /** mag = linear and min = nearest and mip = nearest */
  81186. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81187. /** mag = linear and min = nearest and mip = linear */
  81188. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81189. /** mag = linear and min = linear and mip = none */
  81190. static readonly LINEAR_LINEAR: number;
  81191. /** mag = linear and min = nearest and mip = none */
  81192. static readonly LINEAR_NEAREST: number;
  81193. /** Explicit coordinates mode */
  81194. static readonly EXPLICIT_MODE: number;
  81195. /** Spherical coordinates mode */
  81196. static readonly SPHERICAL_MODE: number;
  81197. /** Planar coordinates mode */
  81198. static readonly PLANAR_MODE: number;
  81199. /** Cubic coordinates mode */
  81200. static readonly CUBIC_MODE: number;
  81201. /** Projection coordinates mode */
  81202. static readonly PROJECTION_MODE: number;
  81203. /** Inverse Cubic coordinates mode */
  81204. static readonly SKYBOX_MODE: number;
  81205. /** Inverse Cubic coordinates mode */
  81206. static readonly INVCUBIC_MODE: number;
  81207. /** Equirectangular coordinates mode */
  81208. static readonly EQUIRECTANGULAR_MODE: number;
  81209. /** Equirectangular Fixed coordinates mode */
  81210. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81211. /** Equirectangular Fixed Mirrored coordinates mode */
  81212. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81213. /** Texture is not repeating outside of 0..1 UVs */
  81214. static readonly CLAMP_ADDRESSMODE: number;
  81215. /** Texture is repeating outside of 0..1 UVs */
  81216. static readonly WRAP_ADDRESSMODE: number;
  81217. /** Texture is repeating and mirrored */
  81218. static readonly MIRROR_ADDRESSMODE: number;
  81219. /**
  81220. * 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
  81221. */
  81222. static UseSerializedUrlIfAny: boolean;
  81223. /**
  81224. * Define the url of the texture.
  81225. */
  81226. url: Nullable<string>;
  81227. /**
  81228. * Define an offset on the texture to offset the u coordinates of the UVs
  81229. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81230. */
  81231. uOffset: number;
  81232. /**
  81233. * Define an offset on the texture to offset the v coordinates of the UVs
  81234. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81235. */
  81236. vOffset: number;
  81237. /**
  81238. * Define an offset on the texture to scale the u coordinates of the UVs
  81239. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81240. */
  81241. uScale: number;
  81242. /**
  81243. * Define an offset on the texture to scale the v coordinates of the UVs
  81244. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81245. */
  81246. vScale: number;
  81247. /**
  81248. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81249. * @see http://doc.babylonjs.com/how_to/more_materials
  81250. */
  81251. uAng: number;
  81252. /**
  81253. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81254. * @see http://doc.babylonjs.com/how_to/more_materials
  81255. */
  81256. vAng: number;
  81257. /**
  81258. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81259. * @see http://doc.babylonjs.com/how_to/more_materials
  81260. */
  81261. wAng: number;
  81262. /**
  81263. * Defines the center of rotation (U)
  81264. */
  81265. uRotationCenter: number;
  81266. /**
  81267. * Defines the center of rotation (V)
  81268. */
  81269. vRotationCenter: number;
  81270. /**
  81271. * Defines the center of rotation (W)
  81272. */
  81273. wRotationCenter: number;
  81274. /**
  81275. * Are mip maps generated for this texture or not.
  81276. */
  81277. readonly noMipmap: boolean;
  81278. /**
  81279. * List of inspectable custom properties (used by the Inspector)
  81280. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81281. */
  81282. inspectableCustomProperties: Nullable<IInspectable[]>;
  81283. private _noMipmap;
  81284. /** @hidden */
  81285. _invertY: boolean;
  81286. private _rowGenerationMatrix;
  81287. private _cachedTextureMatrix;
  81288. private _projectionModeMatrix;
  81289. private _t0;
  81290. private _t1;
  81291. private _t2;
  81292. private _cachedUOffset;
  81293. private _cachedVOffset;
  81294. private _cachedUScale;
  81295. private _cachedVScale;
  81296. private _cachedUAng;
  81297. private _cachedVAng;
  81298. private _cachedWAng;
  81299. private _cachedProjectionMatrixId;
  81300. private _cachedCoordinatesMode;
  81301. /** @hidden */
  81302. protected _initialSamplingMode: number;
  81303. /** @hidden */
  81304. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81305. private _deleteBuffer;
  81306. protected _format: Nullable<number>;
  81307. private _delayedOnLoad;
  81308. private _delayedOnError;
  81309. /**
  81310. * Observable triggered once the texture has been loaded.
  81311. */
  81312. onLoadObservable: Observable<Texture>;
  81313. protected _isBlocking: boolean;
  81314. /**
  81315. * Is the texture preventing material to render while loading.
  81316. * If false, a default texture will be used instead of the loading one during the preparation step.
  81317. */
  81318. isBlocking: boolean;
  81319. /**
  81320. * Get the current sampling mode associated with the texture.
  81321. */
  81322. readonly samplingMode: number;
  81323. /**
  81324. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81325. */
  81326. readonly invertY: boolean;
  81327. /**
  81328. * Instantiates a new texture.
  81329. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81330. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81331. * @param url define the url of the picture to load as a texture
  81332. * @param scene define the scene or engine the texture will belong to
  81333. * @param noMipmap define if the texture will require mip maps or not
  81334. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81335. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81336. * @param onLoad define a callback triggered when the texture has been loaded
  81337. * @param onError define a callback triggered when an error occurred during the loading session
  81338. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81339. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81340. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81341. */
  81342. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  81343. /**
  81344. * Update the url (and optional buffer) of this texture if url was null during construction.
  81345. * @param url the url of the texture
  81346. * @param buffer the buffer of the texture (defaults to null)
  81347. * @param onLoad callback called when the texture is loaded (defaults to null)
  81348. */
  81349. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81350. /**
  81351. * Finish the loading sequence of a texture flagged as delayed load.
  81352. * @hidden
  81353. */
  81354. delayLoad(): void;
  81355. private _prepareRowForTextureGeneration;
  81356. /**
  81357. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81358. * @returns the transform matrix of the texture.
  81359. */
  81360. getTextureMatrix(): Matrix;
  81361. /**
  81362. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81363. * @returns The reflection texture transform
  81364. */
  81365. getReflectionTextureMatrix(): Matrix;
  81366. /**
  81367. * Clones the texture.
  81368. * @returns the cloned texture
  81369. */
  81370. clone(): Texture;
  81371. /**
  81372. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81373. * @returns The JSON representation of the texture
  81374. */
  81375. serialize(): any;
  81376. /**
  81377. * Get the current class name of the texture useful for serialization or dynamic coding.
  81378. * @returns "Texture"
  81379. */
  81380. getClassName(): string;
  81381. /**
  81382. * Dispose the texture and release its associated resources.
  81383. */
  81384. dispose(): void;
  81385. /**
  81386. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81387. * @param parsedTexture Define the JSON representation of the texture
  81388. * @param scene Define the scene the parsed texture should be instantiated in
  81389. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81390. * @returns The parsed texture if successful
  81391. */
  81392. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81393. /**
  81394. * Creates a texture from its base 64 representation.
  81395. * @param data Define the base64 payload without the data: prefix
  81396. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81397. * @param scene Define the scene the texture should belong to
  81398. * @param noMipmap Forces the texture to not create mip map information if true
  81399. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81400. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81401. * @param onLoad define a callback triggered when the texture has been loaded
  81402. * @param onError define a callback triggered when an error occurred during the loading session
  81403. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81404. * @returns the created texture
  81405. */
  81406. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81407. /**
  81408. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81409. * @param data Define the base64 payload without the data: prefix
  81410. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81411. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81412. * @param scene Define the scene the texture should belong to
  81413. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81414. * @param noMipmap Forces the texture to not create mip map information if true
  81415. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81416. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81417. * @param onLoad define a callback triggered when the texture has been loaded
  81418. * @param onError define a callback triggered when an error occurred during the loading session
  81419. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81420. * @returns the created texture
  81421. */
  81422. 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;
  81423. }
  81424. }
  81425. declare module BABYLON {
  81426. /**
  81427. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81428. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81429. */
  81430. export class PostProcessManager {
  81431. private _scene;
  81432. private _indexBuffer;
  81433. private _vertexBuffers;
  81434. /**
  81435. * Creates a new instance PostProcess
  81436. * @param scene The scene that the post process is associated with.
  81437. */
  81438. constructor(scene: Scene);
  81439. private _prepareBuffers;
  81440. private _buildIndexBuffer;
  81441. /**
  81442. * Rebuilds the vertex buffers of the manager.
  81443. * @hidden
  81444. */
  81445. _rebuild(): void;
  81446. /**
  81447. * Prepares a frame to be run through a post process.
  81448. * @param sourceTexture The input texture to the post procesess. (default: null)
  81449. * @param postProcesses An array of post processes to be run. (default: null)
  81450. * @returns True if the post processes were able to be run.
  81451. * @hidden
  81452. */
  81453. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81454. /**
  81455. * Manually render a set of post processes to a texture.
  81456. * @param postProcesses An array of post processes to be run.
  81457. * @param targetTexture The target texture to render to.
  81458. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81459. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81460. * @param lodLevel defines which lod of the texture to render to
  81461. */
  81462. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81463. /**
  81464. * Finalize the result of the output of the postprocesses.
  81465. * @param doNotPresent If true the result will not be displayed to the screen.
  81466. * @param targetTexture The target texture to render to.
  81467. * @param faceIndex The index of the face to bind the target texture to.
  81468. * @param postProcesses The array of post processes to render.
  81469. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81470. * @hidden
  81471. */
  81472. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81473. /**
  81474. * Disposes of the post process manager.
  81475. */
  81476. dispose(): void;
  81477. }
  81478. }
  81479. declare module BABYLON {
  81480. /** Interface used by value gradients (color, factor, ...) */
  81481. export interface IValueGradient {
  81482. /**
  81483. * Gets or sets the gradient value (between 0 and 1)
  81484. */
  81485. gradient: number;
  81486. }
  81487. /** Class used to store color4 gradient */
  81488. export class ColorGradient implements IValueGradient {
  81489. /**
  81490. * Gets or sets the gradient value (between 0 and 1)
  81491. */
  81492. gradient: number;
  81493. /**
  81494. * Gets or sets first associated color
  81495. */
  81496. color1: Color4;
  81497. /**
  81498. * Gets or sets second associated color
  81499. */
  81500. color2?: Color4;
  81501. /**
  81502. * Will get a color picked randomly between color1 and color2.
  81503. * If color2 is undefined then color1 will be used
  81504. * @param result defines the target Color4 to store the result in
  81505. */
  81506. getColorToRef(result: Color4): void;
  81507. }
  81508. /** Class used to store color 3 gradient */
  81509. export class Color3Gradient implements IValueGradient {
  81510. /**
  81511. * Gets or sets the gradient value (between 0 and 1)
  81512. */
  81513. gradient: number;
  81514. /**
  81515. * Gets or sets the associated color
  81516. */
  81517. color: Color3;
  81518. }
  81519. /** Class used to store factor gradient */
  81520. export class FactorGradient implements IValueGradient {
  81521. /**
  81522. * Gets or sets the gradient value (between 0 and 1)
  81523. */
  81524. gradient: number;
  81525. /**
  81526. * Gets or sets first associated factor
  81527. */
  81528. factor1: number;
  81529. /**
  81530. * Gets or sets second associated factor
  81531. */
  81532. factor2?: number;
  81533. /**
  81534. * Will get a number picked randomly between factor1 and factor2.
  81535. * If factor2 is undefined then factor1 will be used
  81536. * @returns the picked number
  81537. */
  81538. getFactor(): number;
  81539. }
  81540. /**
  81541. * Helper used to simplify some generic gradient tasks
  81542. */
  81543. export class GradientHelper {
  81544. /**
  81545. * Gets the current gradient from an array of IValueGradient
  81546. * @param ratio defines the current ratio to get
  81547. * @param gradients defines the array of IValueGradient
  81548. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81549. */
  81550. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81551. }
  81552. }
  81553. declare module BABYLON {
  81554. interface AbstractScene {
  81555. /**
  81556. * The list of procedural textures added to the scene
  81557. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81558. */
  81559. proceduralTextures: Array<ProceduralTexture>;
  81560. }
  81561. /**
  81562. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81563. * in a given scene.
  81564. */
  81565. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81566. /**
  81567. * The component name helpfull to identify the component in the list of scene components.
  81568. */
  81569. readonly name: string;
  81570. /**
  81571. * The scene the component belongs to.
  81572. */
  81573. scene: Scene;
  81574. /**
  81575. * Creates a new instance of the component for the given scene
  81576. * @param scene Defines the scene to register the component in
  81577. */
  81578. constructor(scene: Scene);
  81579. /**
  81580. * Registers the component in a given scene
  81581. */
  81582. register(): void;
  81583. /**
  81584. * Rebuilds the elements related to this component in case of
  81585. * context lost for instance.
  81586. */
  81587. rebuild(): void;
  81588. /**
  81589. * Disposes the component and the associated ressources.
  81590. */
  81591. dispose(): void;
  81592. private _beforeClear;
  81593. }
  81594. }
  81595. declare module BABYLON {
  81596. interface Engine {
  81597. /**
  81598. * Creates a new render target cube texture
  81599. * @param size defines the size of the texture
  81600. * @param options defines the options used to create the texture
  81601. * @returns a new render target cube texture stored in an InternalTexture
  81602. */
  81603. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81604. }
  81605. }
  81606. declare module BABYLON {
  81607. /** @hidden */
  81608. export var proceduralVertexShader: {
  81609. name: string;
  81610. shader: string;
  81611. };
  81612. }
  81613. declare module BABYLON {
  81614. /**
  81615. * 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.
  81616. * This is the base class of any Procedural texture and contains most of the shareable code.
  81617. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81618. */
  81619. export class ProceduralTexture extends Texture {
  81620. isCube: boolean;
  81621. /**
  81622. * Define if the texture is enabled or not (disabled texture will not render)
  81623. */
  81624. isEnabled: boolean;
  81625. /**
  81626. * Define if the texture must be cleared before rendering (default is true)
  81627. */
  81628. autoClear: boolean;
  81629. /**
  81630. * Callback called when the texture is generated
  81631. */
  81632. onGenerated: () => void;
  81633. /**
  81634. * Event raised when the texture is generated
  81635. */
  81636. onGeneratedObservable: Observable<ProceduralTexture>;
  81637. /** @hidden */
  81638. _generateMipMaps: boolean;
  81639. /** @hidden **/
  81640. _effect: Effect;
  81641. /** @hidden */
  81642. _textures: {
  81643. [key: string]: Texture;
  81644. };
  81645. private _size;
  81646. private _currentRefreshId;
  81647. private _refreshRate;
  81648. private _vertexBuffers;
  81649. private _indexBuffer;
  81650. private _uniforms;
  81651. private _samplers;
  81652. private _fragment;
  81653. private _floats;
  81654. private _ints;
  81655. private _floatsArrays;
  81656. private _colors3;
  81657. private _colors4;
  81658. private _vectors2;
  81659. private _vectors3;
  81660. private _matrices;
  81661. private _fallbackTexture;
  81662. private _fallbackTextureUsed;
  81663. private _engine;
  81664. private _cachedDefines;
  81665. private _contentUpdateId;
  81666. private _contentData;
  81667. /**
  81668. * Instantiates a new procedural texture.
  81669. * 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.
  81670. * This is the base class of any Procedural texture and contains most of the shareable code.
  81671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81672. * @param name Define the name of the texture
  81673. * @param size Define the size of the texture to create
  81674. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81675. * @param scene Define the scene the texture belongs to
  81676. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81677. * @param generateMipMaps Define if the texture should creates mip maps or not
  81678. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81679. */
  81680. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81681. /**
  81682. * The effect that is created when initializing the post process.
  81683. * @returns The created effect corresponding the the postprocess.
  81684. */
  81685. getEffect(): Effect;
  81686. /**
  81687. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81688. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81689. */
  81690. getContent(): Nullable<ArrayBufferView>;
  81691. private _createIndexBuffer;
  81692. /** @hidden */
  81693. _rebuild(): void;
  81694. /**
  81695. * Resets the texture in order to recreate its associated resources.
  81696. * This can be called in case of context loss
  81697. */
  81698. reset(): void;
  81699. protected _getDefines(): string;
  81700. /**
  81701. * Is the texture ready to be used ? (rendered at least once)
  81702. * @returns true if ready, otherwise, false.
  81703. */
  81704. isReady(): boolean;
  81705. /**
  81706. * Resets the refresh counter of the texture and start bak from scratch.
  81707. * Could be useful to regenerate the texture if it is setup to render only once.
  81708. */
  81709. resetRefreshCounter(): void;
  81710. /**
  81711. * Set the fragment shader to use in order to render the texture.
  81712. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81713. */
  81714. setFragment(fragment: any): void;
  81715. /**
  81716. * Define the refresh rate of the texture or the rendering frequency.
  81717. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81718. */
  81719. refreshRate: number;
  81720. /** @hidden */
  81721. _shouldRender(): boolean;
  81722. /**
  81723. * Get the size the texture is rendering at.
  81724. * @returns the size (texture is always squared)
  81725. */
  81726. getRenderSize(): number;
  81727. /**
  81728. * Resize the texture to new value.
  81729. * @param size Define the new size the texture should have
  81730. * @param generateMipMaps Define whether the new texture should create mip maps
  81731. */
  81732. resize(size: number, generateMipMaps: boolean): void;
  81733. private _checkUniform;
  81734. /**
  81735. * Set a texture in the shader program used to render.
  81736. * @param name Define the name of the uniform samplers as defined in the shader
  81737. * @param texture Define the texture to bind to this sampler
  81738. * @return the texture itself allowing "fluent" like uniform updates
  81739. */
  81740. setTexture(name: string, texture: Texture): ProceduralTexture;
  81741. /**
  81742. * Set a float in the shader.
  81743. * @param name Define the name of the uniform as defined in the shader
  81744. * @param value Define the value to give to the uniform
  81745. * @return the texture itself allowing "fluent" like uniform updates
  81746. */
  81747. setFloat(name: string, value: number): ProceduralTexture;
  81748. /**
  81749. * Set a int in the shader.
  81750. * @param name Define the name of the uniform as defined in the shader
  81751. * @param value Define the value to give to the uniform
  81752. * @return the texture itself allowing "fluent" like uniform updates
  81753. */
  81754. setInt(name: string, value: number): ProceduralTexture;
  81755. /**
  81756. * Set an array of floats in the shader.
  81757. * @param name Define the name of the uniform as defined in the shader
  81758. * @param value Define the value to give to the uniform
  81759. * @return the texture itself allowing "fluent" like uniform updates
  81760. */
  81761. setFloats(name: string, value: number[]): ProceduralTexture;
  81762. /**
  81763. * Set a vec3 in the shader from a Color3.
  81764. * @param name Define the name of the uniform as defined in the shader
  81765. * @param value Define the value to give to the uniform
  81766. * @return the texture itself allowing "fluent" like uniform updates
  81767. */
  81768. setColor3(name: string, value: Color3): ProceduralTexture;
  81769. /**
  81770. * Set a vec4 in the shader from a Color4.
  81771. * @param name Define the name of the uniform as defined in the shader
  81772. * @param value Define the value to give to the uniform
  81773. * @return the texture itself allowing "fluent" like uniform updates
  81774. */
  81775. setColor4(name: string, value: Color4): ProceduralTexture;
  81776. /**
  81777. * Set a vec2 in the shader from a Vector2.
  81778. * @param name Define the name of the uniform as defined in the shader
  81779. * @param value Define the value to give to the uniform
  81780. * @return the texture itself allowing "fluent" like uniform updates
  81781. */
  81782. setVector2(name: string, value: Vector2): ProceduralTexture;
  81783. /**
  81784. * Set a vec3 in the shader from a Vector3.
  81785. * @param name Define the name of the uniform as defined in the shader
  81786. * @param value Define the value to give to the uniform
  81787. * @return the texture itself allowing "fluent" like uniform updates
  81788. */
  81789. setVector3(name: string, value: Vector3): ProceduralTexture;
  81790. /**
  81791. * Set a mat4 in the shader from a MAtrix.
  81792. * @param name Define the name of the uniform as defined in the shader
  81793. * @param value Define the value to give to the uniform
  81794. * @return the texture itself allowing "fluent" like uniform updates
  81795. */
  81796. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81797. /**
  81798. * Render the texture to its associated render target.
  81799. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81800. */
  81801. render(useCameraPostProcess?: boolean): void;
  81802. /**
  81803. * Clone the texture.
  81804. * @returns the cloned texture
  81805. */
  81806. clone(): ProceduralTexture;
  81807. /**
  81808. * Dispose the texture and release its asoociated resources.
  81809. */
  81810. dispose(): void;
  81811. }
  81812. }
  81813. declare module BABYLON {
  81814. /**
  81815. * This represents the base class for particle system in Babylon.
  81816. * 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.
  81817. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81818. * @example https://doc.babylonjs.com/babylon101/particles
  81819. */
  81820. export class BaseParticleSystem {
  81821. /**
  81822. * Source color is added to the destination color without alpha affecting the result
  81823. */
  81824. static BLENDMODE_ONEONE: number;
  81825. /**
  81826. * Blend current color and particle color using particle’s alpha
  81827. */
  81828. static BLENDMODE_STANDARD: number;
  81829. /**
  81830. * Add current color and particle color multiplied by particle’s alpha
  81831. */
  81832. static BLENDMODE_ADD: number;
  81833. /**
  81834. * Multiply current color with particle color
  81835. */
  81836. static BLENDMODE_MULTIPLY: number;
  81837. /**
  81838. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81839. */
  81840. static BLENDMODE_MULTIPLYADD: number;
  81841. /**
  81842. * List of animations used by the particle system.
  81843. */
  81844. animations: Animation[];
  81845. /**
  81846. * The id of the Particle system.
  81847. */
  81848. id: string;
  81849. /**
  81850. * The friendly name of the Particle system.
  81851. */
  81852. name: string;
  81853. /**
  81854. * The rendering group used by the Particle system to chose when to render.
  81855. */
  81856. renderingGroupId: number;
  81857. /**
  81858. * The emitter represents the Mesh or position we are attaching the particle system to.
  81859. */
  81860. emitter: Nullable<AbstractMesh | Vector3>;
  81861. /**
  81862. * The maximum number of particles to emit per frame
  81863. */
  81864. emitRate: number;
  81865. /**
  81866. * If you want to launch only a few particles at once, that can be done, as well.
  81867. */
  81868. manualEmitCount: number;
  81869. /**
  81870. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81871. */
  81872. updateSpeed: number;
  81873. /**
  81874. * The amount of time the particle system is running (depends of the overall update speed).
  81875. */
  81876. targetStopDuration: number;
  81877. /**
  81878. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81879. */
  81880. disposeOnStop: boolean;
  81881. /**
  81882. * Minimum power of emitting particles.
  81883. */
  81884. minEmitPower: number;
  81885. /**
  81886. * Maximum power of emitting particles.
  81887. */
  81888. maxEmitPower: number;
  81889. /**
  81890. * Minimum life time of emitting particles.
  81891. */
  81892. minLifeTime: number;
  81893. /**
  81894. * Maximum life time of emitting particles.
  81895. */
  81896. maxLifeTime: number;
  81897. /**
  81898. * Minimum Size of emitting particles.
  81899. */
  81900. minSize: number;
  81901. /**
  81902. * Maximum Size of emitting particles.
  81903. */
  81904. maxSize: number;
  81905. /**
  81906. * Minimum scale of emitting particles on X axis.
  81907. */
  81908. minScaleX: number;
  81909. /**
  81910. * Maximum scale of emitting particles on X axis.
  81911. */
  81912. maxScaleX: number;
  81913. /**
  81914. * Minimum scale of emitting particles on Y axis.
  81915. */
  81916. minScaleY: number;
  81917. /**
  81918. * Maximum scale of emitting particles on Y axis.
  81919. */
  81920. maxScaleY: number;
  81921. /**
  81922. * Gets or sets the minimal initial rotation in radians.
  81923. */
  81924. minInitialRotation: number;
  81925. /**
  81926. * Gets or sets the maximal initial rotation in radians.
  81927. */
  81928. maxInitialRotation: number;
  81929. /**
  81930. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81931. */
  81932. minAngularSpeed: number;
  81933. /**
  81934. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81935. */
  81936. maxAngularSpeed: number;
  81937. /**
  81938. * The texture used to render each particle. (this can be a spritesheet)
  81939. */
  81940. particleTexture: Nullable<Texture>;
  81941. /**
  81942. * The layer mask we are rendering the particles through.
  81943. */
  81944. layerMask: number;
  81945. /**
  81946. * This can help using your own shader to render the particle system.
  81947. * The according effect will be created
  81948. */
  81949. customShader: any;
  81950. /**
  81951. * By default particle system starts as soon as they are created. This prevents the
  81952. * automatic start to happen and let you decide when to start emitting particles.
  81953. */
  81954. preventAutoStart: boolean;
  81955. private _noiseTexture;
  81956. /**
  81957. * Gets or sets a texture used to add random noise to particle positions
  81958. */
  81959. noiseTexture: Nullable<ProceduralTexture>;
  81960. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81961. noiseStrength: Vector3;
  81962. /**
  81963. * Callback triggered when the particle animation is ending.
  81964. */
  81965. onAnimationEnd: Nullable<() => void>;
  81966. /**
  81967. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81968. */
  81969. blendMode: number;
  81970. /**
  81971. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81972. * to override the particles.
  81973. */
  81974. forceDepthWrite: boolean;
  81975. /** 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 */
  81976. preWarmCycles: number;
  81977. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81978. preWarmStepOffset: number;
  81979. /**
  81980. * 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)
  81981. */
  81982. spriteCellChangeSpeed: number;
  81983. /**
  81984. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81985. */
  81986. startSpriteCellID: number;
  81987. /**
  81988. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81989. */
  81990. endSpriteCellID: number;
  81991. /**
  81992. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81993. */
  81994. spriteCellWidth: number;
  81995. /**
  81996. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81997. */
  81998. spriteCellHeight: number;
  81999. /**
  82000. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82001. */
  82002. spriteRandomStartCell: boolean;
  82003. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82004. translationPivot: Vector2;
  82005. /** @hidden */
  82006. protected _isAnimationSheetEnabled: boolean;
  82007. /**
  82008. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82009. */
  82010. beginAnimationOnStart: boolean;
  82011. /**
  82012. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82013. */
  82014. beginAnimationFrom: number;
  82015. /**
  82016. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82017. */
  82018. beginAnimationTo: number;
  82019. /**
  82020. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82021. */
  82022. beginAnimationLoop: boolean;
  82023. /**
  82024. * Gets or sets a world offset applied to all particles
  82025. */
  82026. worldOffset: Vector3;
  82027. /**
  82028. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82029. */
  82030. isAnimationSheetEnabled: boolean;
  82031. /**
  82032. * Get hosting scene
  82033. * @returns the scene
  82034. */
  82035. getScene(): Scene;
  82036. /**
  82037. * You can use gravity if you want to give an orientation to your particles.
  82038. */
  82039. gravity: Vector3;
  82040. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82041. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82042. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82043. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82044. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82045. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82046. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82047. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82048. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82049. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82050. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82051. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82052. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82053. /**
  82054. * Defines the delay in milliseconds before starting the system (0 by default)
  82055. */
  82056. startDelay: number;
  82057. /**
  82058. * Gets the current list of drag gradients.
  82059. * You must use addDragGradient and removeDragGradient to udpate this list
  82060. * @returns the list of drag gradients
  82061. */
  82062. getDragGradients(): Nullable<Array<FactorGradient>>;
  82063. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82064. limitVelocityDamping: number;
  82065. /**
  82066. * Gets the current list of limit velocity gradients.
  82067. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82068. * @returns the list of limit velocity gradients
  82069. */
  82070. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82071. /**
  82072. * Gets the current list of color gradients.
  82073. * You must use addColorGradient and removeColorGradient to udpate this list
  82074. * @returns the list of color gradients
  82075. */
  82076. getColorGradients(): Nullable<Array<ColorGradient>>;
  82077. /**
  82078. * Gets the current list of size gradients.
  82079. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82080. * @returns the list of size gradients
  82081. */
  82082. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82083. /**
  82084. * Gets the current list of color remap gradients.
  82085. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82086. * @returns the list of color remap gradients
  82087. */
  82088. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82089. /**
  82090. * Gets the current list of alpha remap gradients.
  82091. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82092. * @returns the list of alpha remap gradients
  82093. */
  82094. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82095. /**
  82096. * Gets the current list of life time gradients.
  82097. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82098. * @returns the list of life time gradients
  82099. */
  82100. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82101. /**
  82102. * Gets the current list of angular speed gradients.
  82103. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82104. * @returns the list of angular speed gradients
  82105. */
  82106. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82107. /**
  82108. * Gets the current list of velocity gradients.
  82109. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82110. * @returns the list of velocity gradients
  82111. */
  82112. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82113. /**
  82114. * Gets the current list of start size gradients.
  82115. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82116. * @returns the list of start size gradients
  82117. */
  82118. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82119. /**
  82120. * Gets the current list of emit rate gradients.
  82121. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82122. * @returns the list of emit rate gradients
  82123. */
  82124. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82125. /**
  82126. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82127. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82128. */
  82129. direction1: Vector3;
  82130. /**
  82131. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82132. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82133. */
  82134. direction2: Vector3;
  82135. /**
  82136. * 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.
  82137. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82138. */
  82139. minEmitBox: Vector3;
  82140. /**
  82141. * 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.
  82142. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82143. */
  82144. maxEmitBox: Vector3;
  82145. /**
  82146. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82147. */
  82148. color1: Color4;
  82149. /**
  82150. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82151. */
  82152. color2: Color4;
  82153. /**
  82154. * Color the particle will have at the end of its lifetime
  82155. */
  82156. colorDead: Color4;
  82157. /**
  82158. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82159. */
  82160. textureMask: Color4;
  82161. /**
  82162. * The particle emitter type defines the emitter used by the particle system.
  82163. * It can be for example box, sphere, or cone...
  82164. */
  82165. particleEmitterType: IParticleEmitterType;
  82166. /** @hidden */
  82167. _isSubEmitter: boolean;
  82168. /**
  82169. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82170. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82171. */
  82172. billboardMode: number;
  82173. protected _isBillboardBased: boolean;
  82174. /**
  82175. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82176. */
  82177. isBillboardBased: boolean;
  82178. /**
  82179. * The scene the particle system belongs to.
  82180. */
  82181. protected _scene: Scene;
  82182. /**
  82183. * Local cache of defines for image processing.
  82184. */
  82185. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82186. /**
  82187. * Default configuration related to image processing available in the standard Material.
  82188. */
  82189. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82190. /**
  82191. * Gets the image processing configuration used either in this material.
  82192. */
  82193. /**
  82194. * Sets the Default image processing configuration used either in the this material.
  82195. *
  82196. * If sets to null, the scene one is in use.
  82197. */
  82198. imageProcessingConfiguration: ImageProcessingConfiguration;
  82199. /**
  82200. * Attaches a new image processing configuration to the Standard Material.
  82201. * @param configuration
  82202. */
  82203. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82204. /** @hidden */
  82205. protected _reset(): void;
  82206. /** @hidden */
  82207. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82208. /**
  82209. * Instantiates a particle system.
  82210. * 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.
  82211. * @param name The name of the particle system
  82212. */
  82213. constructor(name: string);
  82214. /**
  82215. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82216. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82217. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82218. * @returns the emitter
  82219. */
  82220. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82221. /**
  82222. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82223. * @param radius The radius of the hemisphere to emit from
  82224. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82225. * @returns the emitter
  82226. */
  82227. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82228. /**
  82229. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82230. * @param radius The radius of the sphere to emit from
  82231. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82232. * @returns the emitter
  82233. */
  82234. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82235. /**
  82236. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82237. * @param radius The radius of the sphere to emit from
  82238. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82239. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82240. * @returns the emitter
  82241. */
  82242. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82243. /**
  82244. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82245. * @param radius The radius of the emission cylinder
  82246. * @param height The height of the emission cylinder
  82247. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82248. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82249. * @returns the emitter
  82250. */
  82251. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82252. /**
  82253. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82254. * @param radius The radius of the cylinder to emit from
  82255. * @param height The height of the emission cylinder
  82256. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82257. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82258. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82259. * @returns the emitter
  82260. */
  82261. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82262. /**
  82263. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82264. * @param radius The radius of the cone to emit from
  82265. * @param angle The base angle of the cone
  82266. * @returns the emitter
  82267. */
  82268. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82269. /**
  82270. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82271. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82272. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82273. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82274. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82275. * @returns the emitter
  82276. */
  82277. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82278. }
  82279. }
  82280. declare module BABYLON {
  82281. /**
  82282. * Type of sub emitter
  82283. */
  82284. export enum SubEmitterType {
  82285. /**
  82286. * Attached to the particle over it's lifetime
  82287. */
  82288. ATTACHED = 0,
  82289. /**
  82290. * Created when the particle dies
  82291. */
  82292. END = 1
  82293. }
  82294. /**
  82295. * Sub emitter class used to emit particles from an existing particle
  82296. */
  82297. export class SubEmitter {
  82298. /**
  82299. * the particle system to be used by the sub emitter
  82300. */
  82301. particleSystem: ParticleSystem;
  82302. /**
  82303. * Type of the submitter (Default: END)
  82304. */
  82305. type: SubEmitterType;
  82306. /**
  82307. * 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)
  82308. * Note: This only is supported when using an emitter of type Mesh
  82309. */
  82310. inheritDirection: boolean;
  82311. /**
  82312. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82313. */
  82314. inheritedVelocityAmount: number;
  82315. /**
  82316. * Creates a sub emitter
  82317. * @param particleSystem the particle system to be used by the sub emitter
  82318. */
  82319. constructor(
  82320. /**
  82321. * the particle system to be used by the sub emitter
  82322. */
  82323. particleSystem: ParticleSystem);
  82324. /**
  82325. * Clones the sub emitter
  82326. * @returns the cloned sub emitter
  82327. */
  82328. clone(): SubEmitter;
  82329. /**
  82330. * Serialize current object to a JSON object
  82331. * @returns the serialized object
  82332. */
  82333. serialize(): any;
  82334. /** @hidden */
  82335. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82336. /**
  82337. * Creates a new SubEmitter from a serialized JSON version
  82338. * @param serializationObject defines the JSON object to read from
  82339. * @param scene defines the hosting scene
  82340. * @param rootUrl defines the rootUrl for data loading
  82341. * @returns a new SubEmitter
  82342. */
  82343. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82344. /** Release associated resources */
  82345. dispose(): void;
  82346. }
  82347. }
  82348. declare module BABYLON {
  82349. /** @hidden */
  82350. export var clipPlaneFragmentDeclaration: {
  82351. name: string;
  82352. shader: string;
  82353. };
  82354. }
  82355. declare module BABYLON {
  82356. /** @hidden */
  82357. export var imageProcessingDeclaration: {
  82358. name: string;
  82359. shader: string;
  82360. };
  82361. }
  82362. declare module BABYLON {
  82363. /** @hidden */
  82364. export var imageProcessingFunctions: {
  82365. name: string;
  82366. shader: string;
  82367. };
  82368. }
  82369. declare module BABYLON {
  82370. /** @hidden */
  82371. export var clipPlaneFragment: {
  82372. name: string;
  82373. shader: string;
  82374. };
  82375. }
  82376. declare module BABYLON {
  82377. /** @hidden */
  82378. export var particlesPixelShader: {
  82379. name: string;
  82380. shader: string;
  82381. };
  82382. }
  82383. declare module BABYLON {
  82384. /** @hidden */
  82385. export var clipPlaneVertexDeclaration: {
  82386. name: string;
  82387. shader: string;
  82388. };
  82389. }
  82390. declare module BABYLON {
  82391. /** @hidden */
  82392. export var clipPlaneVertex: {
  82393. name: string;
  82394. shader: string;
  82395. };
  82396. }
  82397. declare module BABYLON {
  82398. /** @hidden */
  82399. export var particlesVertexShader: {
  82400. name: string;
  82401. shader: string;
  82402. };
  82403. }
  82404. declare module BABYLON {
  82405. /**
  82406. * This represents a particle system in Babylon.
  82407. * 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.
  82408. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82409. * @example https://doc.babylonjs.com/babylon101/particles
  82410. */
  82411. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82412. /**
  82413. * Billboard mode will only apply to Y axis
  82414. */
  82415. static readonly BILLBOARDMODE_Y: number;
  82416. /**
  82417. * Billboard mode will apply to all axes
  82418. */
  82419. static readonly BILLBOARDMODE_ALL: number;
  82420. /**
  82421. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82422. */
  82423. static readonly BILLBOARDMODE_STRETCHED: number;
  82424. /**
  82425. * This function can be defined to provide custom update for active particles.
  82426. * This function will be called instead of regular update (age, position, color, etc.).
  82427. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82428. */
  82429. updateFunction: (particles: Particle[]) => void;
  82430. private _emitterWorldMatrix;
  82431. /**
  82432. * This function can be defined to specify initial direction for every new particle.
  82433. * It by default use the emitterType defined function
  82434. */
  82435. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82436. /**
  82437. * This function can be defined to specify initial position for every new particle.
  82438. * It by default use the emitterType defined function
  82439. */
  82440. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82441. /**
  82442. * @hidden
  82443. */
  82444. _inheritedVelocityOffset: Vector3;
  82445. /**
  82446. * An event triggered when the system is disposed
  82447. */
  82448. onDisposeObservable: Observable<ParticleSystem>;
  82449. private _onDisposeObserver;
  82450. /**
  82451. * Sets a callback that will be triggered when the system is disposed
  82452. */
  82453. onDispose: () => void;
  82454. private _particles;
  82455. private _epsilon;
  82456. private _capacity;
  82457. private _stockParticles;
  82458. private _newPartsExcess;
  82459. private _vertexData;
  82460. private _vertexBuffer;
  82461. private _vertexBuffers;
  82462. private _spriteBuffer;
  82463. private _indexBuffer;
  82464. private _effect;
  82465. private _customEffect;
  82466. private _cachedDefines;
  82467. private _scaledColorStep;
  82468. private _colorDiff;
  82469. private _scaledDirection;
  82470. private _scaledGravity;
  82471. private _currentRenderId;
  82472. private _alive;
  82473. private _useInstancing;
  82474. private _started;
  82475. private _stopped;
  82476. private _actualFrame;
  82477. private _scaledUpdateSpeed;
  82478. private _vertexBufferSize;
  82479. /** @hidden */
  82480. _currentEmitRateGradient: Nullable<FactorGradient>;
  82481. /** @hidden */
  82482. _currentEmitRate1: number;
  82483. /** @hidden */
  82484. _currentEmitRate2: number;
  82485. /** @hidden */
  82486. _currentStartSizeGradient: Nullable<FactorGradient>;
  82487. /** @hidden */
  82488. _currentStartSize1: number;
  82489. /** @hidden */
  82490. _currentStartSize2: number;
  82491. private readonly _rawTextureWidth;
  82492. private _rampGradientsTexture;
  82493. private _useRampGradients;
  82494. /** Gets or sets a boolean indicating that ramp gradients must be used
  82495. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82496. */
  82497. useRampGradients: boolean;
  82498. /**
  82499. * 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.
  82500. * 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: [])
  82501. */
  82502. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82503. private _subEmitters;
  82504. /**
  82505. * @hidden
  82506. * If the particle systems emitter should be disposed when the particle system is disposed
  82507. */
  82508. _disposeEmitterOnDispose: boolean;
  82509. /**
  82510. * The current active Sub-systems, this property is used by the root particle system only.
  82511. */
  82512. activeSubSystems: Array<ParticleSystem>;
  82513. private _rootParticleSystem;
  82514. /**
  82515. * Gets the current list of active particles
  82516. */
  82517. readonly particles: Particle[];
  82518. /**
  82519. * Returns the string "ParticleSystem"
  82520. * @returns a string containing the class name
  82521. */
  82522. getClassName(): string;
  82523. /**
  82524. * Instantiates a particle system.
  82525. * 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.
  82526. * @param name The name of the particle system
  82527. * @param capacity The max number of particles alive at the same time
  82528. * @param scene The scene the particle system belongs to
  82529. * @param customEffect a custom effect used to change the way particles are rendered by default
  82530. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82531. * @param epsilon Offset used to render the particles
  82532. */
  82533. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82534. private _addFactorGradient;
  82535. private _removeFactorGradient;
  82536. /**
  82537. * Adds a new life time gradient
  82538. * @param gradient defines the gradient to use (between 0 and 1)
  82539. * @param factor defines the life time factor to affect to the specified gradient
  82540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82541. * @returns the current particle system
  82542. */
  82543. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82544. /**
  82545. * Remove a specific life time gradient
  82546. * @param gradient defines the gradient to remove
  82547. * @returns the current particle system
  82548. */
  82549. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82550. /**
  82551. * Adds a new size gradient
  82552. * @param gradient defines the gradient to use (between 0 and 1)
  82553. * @param factor defines the size factor to affect to the specified gradient
  82554. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82555. * @returns the current particle system
  82556. */
  82557. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82558. /**
  82559. * Remove a specific size gradient
  82560. * @param gradient defines the gradient to remove
  82561. * @returns the current particle system
  82562. */
  82563. removeSizeGradient(gradient: number): IParticleSystem;
  82564. /**
  82565. * Adds a new color remap gradient
  82566. * @param gradient defines the gradient to use (between 0 and 1)
  82567. * @param min defines the color remap minimal range
  82568. * @param max defines the color remap maximal range
  82569. * @returns the current particle system
  82570. */
  82571. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82572. /**
  82573. * Remove a specific color remap gradient
  82574. * @param gradient defines the gradient to remove
  82575. * @returns the current particle system
  82576. */
  82577. removeColorRemapGradient(gradient: number): IParticleSystem;
  82578. /**
  82579. * Adds a new alpha remap gradient
  82580. * @param gradient defines the gradient to use (between 0 and 1)
  82581. * @param min defines the alpha remap minimal range
  82582. * @param max defines the alpha remap maximal range
  82583. * @returns the current particle system
  82584. */
  82585. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82586. /**
  82587. * Remove a specific alpha remap gradient
  82588. * @param gradient defines the gradient to remove
  82589. * @returns the current particle system
  82590. */
  82591. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82592. /**
  82593. * Adds a new angular speed gradient
  82594. * @param gradient defines the gradient to use (between 0 and 1)
  82595. * @param factor defines the angular speed to affect to the specified gradient
  82596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82597. * @returns the current particle system
  82598. */
  82599. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82600. /**
  82601. * Remove a specific angular speed gradient
  82602. * @param gradient defines the gradient to remove
  82603. * @returns the current particle system
  82604. */
  82605. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82606. /**
  82607. * Adds a new velocity gradient
  82608. * @param gradient defines the gradient to use (between 0 and 1)
  82609. * @param factor defines the velocity to affect to the specified gradient
  82610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82611. * @returns the current particle system
  82612. */
  82613. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82614. /**
  82615. * Remove a specific velocity gradient
  82616. * @param gradient defines the gradient to remove
  82617. * @returns the current particle system
  82618. */
  82619. removeVelocityGradient(gradient: number): IParticleSystem;
  82620. /**
  82621. * Adds a new limit velocity gradient
  82622. * @param gradient defines the gradient to use (between 0 and 1)
  82623. * @param factor defines the limit velocity value to affect to the specified gradient
  82624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82625. * @returns the current particle system
  82626. */
  82627. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82628. /**
  82629. * Remove a specific limit velocity gradient
  82630. * @param gradient defines the gradient to remove
  82631. * @returns the current particle system
  82632. */
  82633. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82634. /**
  82635. * Adds a new drag gradient
  82636. * @param gradient defines the gradient to use (between 0 and 1)
  82637. * @param factor defines the drag value to affect to the specified gradient
  82638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82639. * @returns the current particle system
  82640. */
  82641. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82642. /**
  82643. * Remove a specific drag gradient
  82644. * @param gradient defines the gradient to remove
  82645. * @returns the current particle system
  82646. */
  82647. removeDragGradient(gradient: number): IParticleSystem;
  82648. /**
  82649. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82650. * @param gradient defines the gradient to use (between 0 and 1)
  82651. * @param factor defines the emit rate value to affect to the specified gradient
  82652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82653. * @returns the current particle system
  82654. */
  82655. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82656. /**
  82657. * Remove a specific emit rate gradient
  82658. * @param gradient defines the gradient to remove
  82659. * @returns the current particle system
  82660. */
  82661. removeEmitRateGradient(gradient: number): IParticleSystem;
  82662. /**
  82663. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82664. * @param gradient defines the gradient to use (between 0 and 1)
  82665. * @param factor defines the start size value to affect to the specified gradient
  82666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82667. * @returns the current particle system
  82668. */
  82669. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82670. /**
  82671. * Remove a specific start size gradient
  82672. * @param gradient defines the gradient to remove
  82673. * @returns the current particle system
  82674. */
  82675. removeStartSizeGradient(gradient: number): IParticleSystem;
  82676. private _createRampGradientTexture;
  82677. /**
  82678. * Gets the current list of ramp gradients.
  82679. * You must use addRampGradient and removeRampGradient to udpate this list
  82680. * @returns the list of ramp gradients
  82681. */
  82682. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82683. /**
  82684. * Adds a new ramp gradient used to remap particle colors
  82685. * @param gradient defines the gradient to use (between 0 and 1)
  82686. * @param color defines the color to affect to the specified gradient
  82687. * @returns the current particle system
  82688. */
  82689. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82690. /**
  82691. * Remove a specific ramp gradient
  82692. * @param gradient defines the gradient to remove
  82693. * @returns the current particle system
  82694. */
  82695. removeRampGradient(gradient: number): ParticleSystem;
  82696. /**
  82697. * Adds a new color gradient
  82698. * @param gradient defines the gradient to use (between 0 and 1)
  82699. * @param color1 defines the color to affect to the specified gradient
  82700. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82701. * @returns this particle system
  82702. */
  82703. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82704. /**
  82705. * Remove a specific color gradient
  82706. * @param gradient defines the gradient to remove
  82707. * @returns this particle system
  82708. */
  82709. removeColorGradient(gradient: number): IParticleSystem;
  82710. private _fetchR;
  82711. protected _reset(): void;
  82712. private _resetEffect;
  82713. private _createVertexBuffers;
  82714. private _createIndexBuffer;
  82715. /**
  82716. * Gets the maximum number of particles active at the same time.
  82717. * @returns The max number of active particles.
  82718. */
  82719. getCapacity(): number;
  82720. /**
  82721. * Gets whether there are still active particles in the system.
  82722. * @returns True if it is alive, otherwise false.
  82723. */
  82724. isAlive(): boolean;
  82725. /**
  82726. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82727. * @returns True if it has been started, otherwise false.
  82728. */
  82729. isStarted(): boolean;
  82730. private _prepareSubEmitterInternalArray;
  82731. /**
  82732. * Starts the particle system and begins to emit
  82733. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82734. */
  82735. start(delay?: number): void;
  82736. /**
  82737. * Stops the particle system.
  82738. * @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.
  82739. */
  82740. stop(stopSubEmitters?: boolean): void;
  82741. /**
  82742. * Remove all active particles
  82743. */
  82744. reset(): void;
  82745. /**
  82746. * @hidden (for internal use only)
  82747. */
  82748. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82749. /**
  82750. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82751. * Its lifetime will start back at 0.
  82752. */
  82753. recycleParticle: (particle: Particle) => void;
  82754. private _stopSubEmitters;
  82755. private _createParticle;
  82756. private _removeFromRoot;
  82757. private _emitFromParticle;
  82758. private _update;
  82759. /** @hidden */
  82760. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82761. /** @hidden */
  82762. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82763. /** @hidden */
  82764. private _getEffect;
  82765. /**
  82766. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82767. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82768. */
  82769. animate(preWarmOnly?: boolean): void;
  82770. private _appendParticleVertices;
  82771. /**
  82772. * Rebuilds the particle system.
  82773. */
  82774. rebuild(): void;
  82775. /**
  82776. * Is this system ready to be used/rendered
  82777. * @return true if the system is ready
  82778. */
  82779. isReady(): boolean;
  82780. private _render;
  82781. /**
  82782. * Renders the particle system in its current state.
  82783. * @returns the current number of particles
  82784. */
  82785. render(): number;
  82786. /**
  82787. * Disposes the particle system and free the associated resources
  82788. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82789. */
  82790. dispose(disposeTexture?: boolean): void;
  82791. /**
  82792. * Clones the particle system.
  82793. * @param name The name of the cloned object
  82794. * @param newEmitter The new emitter to use
  82795. * @returns the cloned particle system
  82796. */
  82797. clone(name: string, newEmitter: any): ParticleSystem;
  82798. /**
  82799. * Serializes the particle system to a JSON object.
  82800. * @returns the JSON object
  82801. */
  82802. serialize(): any;
  82803. /** @hidden */
  82804. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82805. /** @hidden */
  82806. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82807. /**
  82808. * Parses a JSON object to create a particle system.
  82809. * @param parsedParticleSystem The JSON object to parse
  82810. * @param scene The scene to create the particle system in
  82811. * @param rootUrl The root url to use to load external dependencies like texture
  82812. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82813. * @returns the Parsed particle system
  82814. */
  82815. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82816. }
  82817. }
  82818. declare module BABYLON {
  82819. /**
  82820. * A particle represents one of the element emitted by a particle system.
  82821. * This is mainly define by its coordinates, direction, velocity and age.
  82822. */
  82823. export class Particle {
  82824. /**
  82825. * The particle system the particle belongs to.
  82826. */
  82827. particleSystem: ParticleSystem;
  82828. private static _Count;
  82829. /**
  82830. * Unique ID of the particle
  82831. */
  82832. id: number;
  82833. /**
  82834. * The world position of the particle in the scene.
  82835. */
  82836. position: Vector3;
  82837. /**
  82838. * The world direction of the particle in the scene.
  82839. */
  82840. direction: Vector3;
  82841. /**
  82842. * The color of the particle.
  82843. */
  82844. color: Color4;
  82845. /**
  82846. * The color change of the particle per step.
  82847. */
  82848. colorStep: Color4;
  82849. /**
  82850. * Defines how long will the life of the particle be.
  82851. */
  82852. lifeTime: number;
  82853. /**
  82854. * The current age of the particle.
  82855. */
  82856. age: number;
  82857. /**
  82858. * The current size of the particle.
  82859. */
  82860. size: number;
  82861. /**
  82862. * The current scale of the particle.
  82863. */
  82864. scale: Vector2;
  82865. /**
  82866. * The current angle of the particle.
  82867. */
  82868. angle: number;
  82869. /**
  82870. * Defines how fast is the angle changing.
  82871. */
  82872. angularSpeed: number;
  82873. /**
  82874. * Defines the cell index used by the particle to be rendered from a sprite.
  82875. */
  82876. cellIndex: number;
  82877. /**
  82878. * The information required to support color remapping
  82879. */
  82880. remapData: Vector4;
  82881. /** @hidden */
  82882. _randomCellOffset?: number;
  82883. /** @hidden */
  82884. _initialDirection: Nullable<Vector3>;
  82885. /** @hidden */
  82886. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82887. /** @hidden */
  82888. _initialStartSpriteCellID: number;
  82889. /** @hidden */
  82890. _initialEndSpriteCellID: number;
  82891. /** @hidden */
  82892. _currentColorGradient: Nullable<ColorGradient>;
  82893. /** @hidden */
  82894. _currentColor1: Color4;
  82895. /** @hidden */
  82896. _currentColor2: Color4;
  82897. /** @hidden */
  82898. _currentSizeGradient: Nullable<FactorGradient>;
  82899. /** @hidden */
  82900. _currentSize1: number;
  82901. /** @hidden */
  82902. _currentSize2: number;
  82903. /** @hidden */
  82904. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82905. /** @hidden */
  82906. _currentAngularSpeed1: number;
  82907. /** @hidden */
  82908. _currentAngularSpeed2: number;
  82909. /** @hidden */
  82910. _currentVelocityGradient: Nullable<FactorGradient>;
  82911. /** @hidden */
  82912. _currentVelocity1: number;
  82913. /** @hidden */
  82914. _currentVelocity2: number;
  82915. /** @hidden */
  82916. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82917. /** @hidden */
  82918. _currentLimitVelocity1: number;
  82919. /** @hidden */
  82920. _currentLimitVelocity2: number;
  82921. /** @hidden */
  82922. _currentDragGradient: Nullable<FactorGradient>;
  82923. /** @hidden */
  82924. _currentDrag1: number;
  82925. /** @hidden */
  82926. _currentDrag2: number;
  82927. /** @hidden */
  82928. _randomNoiseCoordinates1: Vector3;
  82929. /** @hidden */
  82930. _randomNoiseCoordinates2: Vector3;
  82931. /**
  82932. * Creates a new instance Particle
  82933. * @param particleSystem the particle system the particle belongs to
  82934. */
  82935. constructor(
  82936. /**
  82937. * The particle system the particle belongs to.
  82938. */
  82939. particleSystem: ParticleSystem);
  82940. private updateCellInfoFromSystem;
  82941. /**
  82942. * Defines how the sprite cell index is updated for the particle
  82943. */
  82944. updateCellIndex(): void;
  82945. /** @hidden */
  82946. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82947. /** @hidden */
  82948. _inheritParticleInfoToSubEmitters(): void;
  82949. /** @hidden */
  82950. _reset(): void;
  82951. /**
  82952. * Copy the properties of particle to another one.
  82953. * @param other the particle to copy the information to.
  82954. */
  82955. copyTo(other: Particle): void;
  82956. }
  82957. }
  82958. declare module BABYLON {
  82959. /**
  82960. * Particle emitter represents a volume emitting particles.
  82961. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82962. */
  82963. export interface IParticleEmitterType {
  82964. /**
  82965. * Called by the particle System when the direction is computed for the created particle.
  82966. * @param worldMatrix is the world matrix of the particle system
  82967. * @param directionToUpdate is the direction vector to update with the result
  82968. * @param particle is the particle we are computed the direction for
  82969. */
  82970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82971. /**
  82972. * Called by the particle System when the position is computed for the created particle.
  82973. * @param worldMatrix is the world matrix of the particle system
  82974. * @param positionToUpdate is the position vector to update with the result
  82975. * @param particle is the particle we are computed the position for
  82976. */
  82977. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82978. /**
  82979. * Clones the current emitter and returns a copy of it
  82980. * @returns the new emitter
  82981. */
  82982. clone(): IParticleEmitterType;
  82983. /**
  82984. * Called by the GPUParticleSystem to setup the update shader
  82985. * @param effect defines the update shader
  82986. */
  82987. applyToShader(effect: Effect): void;
  82988. /**
  82989. * Returns a string to use to update the GPU particles update shader
  82990. * @returns the effect defines string
  82991. */
  82992. getEffectDefines(): string;
  82993. /**
  82994. * Returns a string representing the class name
  82995. * @returns a string containing the class name
  82996. */
  82997. getClassName(): string;
  82998. /**
  82999. * Serializes the particle system to a JSON object.
  83000. * @returns the JSON object
  83001. */
  83002. serialize(): any;
  83003. /**
  83004. * Parse properties from a JSON object
  83005. * @param serializationObject defines the JSON object
  83006. */
  83007. parse(serializationObject: any): void;
  83008. }
  83009. }
  83010. declare module BABYLON {
  83011. /**
  83012. * Particle emitter emitting particles from the inside of a box.
  83013. * It emits the particles randomly between 2 given directions.
  83014. */
  83015. export class BoxParticleEmitter implements IParticleEmitterType {
  83016. /**
  83017. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83018. */
  83019. direction1: Vector3;
  83020. /**
  83021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83022. */
  83023. direction2: Vector3;
  83024. /**
  83025. * 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.
  83026. */
  83027. minEmitBox: Vector3;
  83028. /**
  83029. * 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.
  83030. */
  83031. maxEmitBox: Vector3;
  83032. /**
  83033. * Creates a new instance BoxParticleEmitter
  83034. */
  83035. constructor();
  83036. /**
  83037. * Called by the particle System when the direction is computed for the created particle.
  83038. * @param worldMatrix is the world matrix of the particle system
  83039. * @param directionToUpdate is the direction vector to update with the result
  83040. * @param particle is the particle we are computed the direction for
  83041. */
  83042. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83043. /**
  83044. * Called by the particle System when the position is computed for the created particle.
  83045. * @param worldMatrix is the world matrix of the particle system
  83046. * @param positionToUpdate is the position vector to update with the result
  83047. * @param particle is the particle we are computed the position for
  83048. */
  83049. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83050. /**
  83051. * Clones the current emitter and returns a copy of it
  83052. * @returns the new emitter
  83053. */
  83054. clone(): BoxParticleEmitter;
  83055. /**
  83056. * Called by the GPUParticleSystem to setup the update shader
  83057. * @param effect defines the update shader
  83058. */
  83059. applyToShader(effect: Effect): void;
  83060. /**
  83061. * Returns a string to use to update the GPU particles update shader
  83062. * @returns a string containng the defines string
  83063. */
  83064. getEffectDefines(): string;
  83065. /**
  83066. * Returns the string "BoxParticleEmitter"
  83067. * @returns a string containing the class name
  83068. */
  83069. getClassName(): string;
  83070. /**
  83071. * Serializes the particle system to a JSON object.
  83072. * @returns the JSON object
  83073. */
  83074. serialize(): any;
  83075. /**
  83076. * Parse properties from a JSON object
  83077. * @param serializationObject defines the JSON object
  83078. */
  83079. parse(serializationObject: any): void;
  83080. }
  83081. }
  83082. declare module BABYLON {
  83083. /**
  83084. * Particle emitter emitting particles from the inside of a cone.
  83085. * It emits the particles alongside the cone volume from the base to the particle.
  83086. * The emission direction might be randomized.
  83087. */
  83088. export class ConeParticleEmitter implements IParticleEmitterType {
  83089. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83090. directionRandomizer: number;
  83091. private _radius;
  83092. private _angle;
  83093. private _height;
  83094. /**
  83095. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83096. */
  83097. radiusRange: number;
  83098. /**
  83099. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83100. */
  83101. heightRange: number;
  83102. /**
  83103. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83104. */
  83105. emitFromSpawnPointOnly: boolean;
  83106. /**
  83107. * Gets or sets the radius of the emission cone
  83108. */
  83109. radius: number;
  83110. /**
  83111. * Gets or sets the angle of the emission cone
  83112. */
  83113. angle: number;
  83114. private _buildHeight;
  83115. /**
  83116. * Creates a new instance ConeParticleEmitter
  83117. * @param radius the radius of the emission cone (1 by default)
  83118. * @param angle the cone base angle (PI by default)
  83119. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83120. */
  83121. constructor(radius?: number, angle?: number,
  83122. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83123. directionRandomizer?: number);
  83124. /**
  83125. * Called by the particle System when the direction is computed for the created particle.
  83126. * @param worldMatrix is the world matrix of the particle system
  83127. * @param directionToUpdate is the direction vector to update with the result
  83128. * @param particle is the particle we are computed the direction for
  83129. */
  83130. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83131. /**
  83132. * Called by the particle System when the position is computed for the created particle.
  83133. * @param worldMatrix is the world matrix of the particle system
  83134. * @param positionToUpdate is the position vector to update with the result
  83135. * @param particle is the particle we are computed the position for
  83136. */
  83137. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83138. /**
  83139. * Clones the current emitter and returns a copy of it
  83140. * @returns the new emitter
  83141. */
  83142. clone(): ConeParticleEmitter;
  83143. /**
  83144. * Called by the GPUParticleSystem to setup the update shader
  83145. * @param effect defines the update shader
  83146. */
  83147. applyToShader(effect: Effect): void;
  83148. /**
  83149. * Returns a string to use to update the GPU particles update shader
  83150. * @returns a string containng the defines string
  83151. */
  83152. getEffectDefines(): string;
  83153. /**
  83154. * Returns the string "ConeParticleEmitter"
  83155. * @returns a string containing the class name
  83156. */
  83157. getClassName(): string;
  83158. /**
  83159. * Serializes the particle system to a JSON object.
  83160. * @returns the JSON object
  83161. */
  83162. serialize(): any;
  83163. /**
  83164. * Parse properties from a JSON object
  83165. * @param serializationObject defines the JSON object
  83166. */
  83167. parse(serializationObject: any): void;
  83168. }
  83169. }
  83170. declare module BABYLON {
  83171. /**
  83172. * Particle emitter emitting particles from the inside of a cylinder.
  83173. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83174. */
  83175. export class CylinderParticleEmitter implements IParticleEmitterType {
  83176. /**
  83177. * The radius of the emission cylinder.
  83178. */
  83179. radius: number;
  83180. /**
  83181. * The height of the emission cylinder.
  83182. */
  83183. height: number;
  83184. /**
  83185. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83186. */
  83187. radiusRange: number;
  83188. /**
  83189. * How much to randomize the particle direction [0-1].
  83190. */
  83191. directionRandomizer: number;
  83192. /**
  83193. * Creates a new instance CylinderParticleEmitter
  83194. * @param radius the radius of the emission cylinder (1 by default)
  83195. * @param height the height of the emission cylinder (1 by default)
  83196. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83197. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83198. */
  83199. constructor(
  83200. /**
  83201. * The radius of the emission cylinder.
  83202. */
  83203. radius?: number,
  83204. /**
  83205. * The height of the emission cylinder.
  83206. */
  83207. height?: number,
  83208. /**
  83209. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83210. */
  83211. radiusRange?: number,
  83212. /**
  83213. * How much to randomize the particle direction [0-1].
  83214. */
  83215. directionRandomizer?: number);
  83216. /**
  83217. * Called by the particle System when the direction is computed for the created particle.
  83218. * @param worldMatrix is the world matrix of the particle system
  83219. * @param directionToUpdate is the direction vector to update with the result
  83220. * @param particle is the particle we are computed the direction for
  83221. */
  83222. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83223. /**
  83224. * Called by the particle System when the position is computed for the created particle.
  83225. * @param worldMatrix is the world matrix of the particle system
  83226. * @param positionToUpdate is the position vector to update with the result
  83227. * @param particle is the particle we are computed the position for
  83228. */
  83229. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83230. /**
  83231. * Clones the current emitter and returns a copy of it
  83232. * @returns the new emitter
  83233. */
  83234. clone(): CylinderParticleEmitter;
  83235. /**
  83236. * Called by the GPUParticleSystem to setup the update shader
  83237. * @param effect defines the update shader
  83238. */
  83239. applyToShader(effect: Effect): void;
  83240. /**
  83241. * Returns a string to use to update the GPU particles update shader
  83242. * @returns a string containng the defines string
  83243. */
  83244. getEffectDefines(): string;
  83245. /**
  83246. * Returns the string "CylinderParticleEmitter"
  83247. * @returns a string containing the class name
  83248. */
  83249. getClassName(): string;
  83250. /**
  83251. * Serializes the particle system to a JSON object.
  83252. * @returns the JSON object
  83253. */
  83254. serialize(): any;
  83255. /**
  83256. * Parse properties from a JSON object
  83257. * @param serializationObject defines the JSON object
  83258. */
  83259. parse(serializationObject: any): void;
  83260. }
  83261. /**
  83262. * Particle emitter emitting particles from the inside of a cylinder.
  83263. * It emits the particles randomly between two vectors.
  83264. */
  83265. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83266. /**
  83267. * The min limit of the emission direction.
  83268. */
  83269. direction1: Vector3;
  83270. /**
  83271. * The max limit of the emission direction.
  83272. */
  83273. direction2: Vector3;
  83274. /**
  83275. * Creates a new instance CylinderDirectedParticleEmitter
  83276. * @param radius the radius of the emission cylinder (1 by default)
  83277. * @param height the height of the emission cylinder (1 by default)
  83278. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83279. * @param direction1 the min limit of the emission direction (up vector by default)
  83280. * @param direction2 the max limit of the emission direction (up vector by default)
  83281. */
  83282. constructor(radius?: number, height?: number, radiusRange?: number,
  83283. /**
  83284. * The min limit of the emission direction.
  83285. */
  83286. direction1?: Vector3,
  83287. /**
  83288. * The max limit of the emission direction.
  83289. */
  83290. direction2?: Vector3);
  83291. /**
  83292. * Called by the particle System when the direction is computed for the created particle.
  83293. * @param worldMatrix is the world matrix of the particle system
  83294. * @param directionToUpdate is the direction vector to update with the result
  83295. * @param particle is the particle we are computed the direction for
  83296. */
  83297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83298. /**
  83299. * Clones the current emitter and returns a copy of it
  83300. * @returns the new emitter
  83301. */
  83302. clone(): CylinderDirectedParticleEmitter;
  83303. /**
  83304. * Called by the GPUParticleSystem to setup the update shader
  83305. * @param effect defines the update shader
  83306. */
  83307. applyToShader(effect: Effect): void;
  83308. /**
  83309. * Returns a string to use to update the GPU particles update shader
  83310. * @returns a string containng the defines string
  83311. */
  83312. getEffectDefines(): string;
  83313. /**
  83314. * Returns the string "CylinderDirectedParticleEmitter"
  83315. * @returns a string containing the class name
  83316. */
  83317. getClassName(): string;
  83318. /**
  83319. * Serializes the particle system to a JSON object.
  83320. * @returns the JSON object
  83321. */
  83322. serialize(): any;
  83323. /**
  83324. * Parse properties from a JSON object
  83325. * @param serializationObject defines the JSON object
  83326. */
  83327. parse(serializationObject: any): void;
  83328. }
  83329. }
  83330. declare module BABYLON {
  83331. /**
  83332. * Particle emitter emitting particles from the inside of a hemisphere.
  83333. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83334. */
  83335. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83336. /**
  83337. * The radius of the emission hemisphere.
  83338. */
  83339. radius: number;
  83340. /**
  83341. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83342. */
  83343. radiusRange: number;
  83344. /**
  83345. * How much to randomize the particle direction [0-1].
  83346. */
  83347. directionRandomizer: number;
  83348. /**
  83349. * Creates a new instance HemisphericParticleEmitter
  83350. * @param radius the radius of the emission hemisphere (1 by default)
  83351. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83352. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83353. */
  83354. constructor(
  83355. /**
  83356. * The radius of the emission hemisphere.
  83357. */
  83358. radius?: number,
  83359. /**
  83360. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83361. */
  83362. radiusRange?: number,
  83363. /**
  83364. * How much to randomize the particle direction [0-1].
  83365. */
  83366. directionRandomizer?: number);
  83367. /**
  83368. * Called by the particle System when the direction is computed for the created particle.
  83369. * @param worldMatrix is the world matrix of the particle system
  83370. * @param directionToUpdate is the direction vector to update with the result
  83371. * @param particle is the particle we are computed the direction for
  83372. */
  83373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83374. /**
  83375. * Called by the particle System when the position is computed for the created particle.
  83376. * @param worldMatrix is the world matrix of the particle system
  83377. * @param positionToUpdate is the position vector to update with the result
  83378. * @param particle is the particle we are computed the position for
  83379. */
  83380. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83381. /**
  83382. * Clones the current emitter and returns a copy of it
  83383. * @returns the new emitter
  83384. */
  83385. clone(): HemisphericParticleEmitter;
  83386. /**
  83387. * Called by the GPUParticleSystem to setup the update shader
  83388. * @param effect defines the update shader
  83389. */
  83390. applyToShader(effect: Effect): void;
  83391. /**
  83392. * Returns a string to use to update the GPU particles update shader
  83393. * @returns a string containng the defines string
  83394. */
  83395. getEffectDefines(): string;
  83396. /**
  83397. * Returns the string "HemisphericParticleEmitter"
  83398. * @returns a string containing the class name
  83399. */
  83400. getClassName(): string;
  83401. /**
  83402. * Serializes the particle system to a JSON object.
  83403. * @returns the JSON object
  83404. */
  83405. serialize(): any;
  83406. /**
  83407. * Parse properties from a JSON object
  83408. * @param serializationObject defines the JSON object
  83409. */
  83410. parse(serializationObject: any): void;
  83411. }
  83412. }
  83413. declare module BABYLON {
  83414. /**
  83415. * Particle emitter emitting particles from a point.
  83416. * It emits the particles randomly between 2 given directions.
  83417. */
  83418. export class PointParticleEmitter implements IParticleEmitterType {
  83419. /**
  83420. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83421. */
  83422. direction1: Vector3;
  83423. /**
  83424. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83425. */
  83426. direction2: Vector3;
  83427. /**
  83428. * Creates a new instance PointParticleEmitter
  83429. */
  83430. constructor();
  83431. /**
  83432. * Called by the particle System when the direction is computed for the created particle.
  83433. * @param worldMatrix is the world matrix of the particle system
  83434. * @param directionToUpdate is the direction vector to update with the result
  83435. * @param particle is the particle we are computed the direction for
  83436. */
  83437. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83438. /**
  83439. * Called by the particle System when the position is computed for the created particle.
  83440. * @param worldMatrix is the world matrix of the particle system
  83441. * @param positionToUpdate is the position vector to update with the result
  83442. * @param particle is the particle we are computed the position for
  83443. */
  83444. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83445. /**
  83446. * Clones the current emitter and returns a copy of it
  83447. * @returns the new emitter
  83448. */
  83449. clone(): PointParticleEmitter;
  83450. /**
  83451. * Called by the GPUParticleSystem to setup the update shader
  83452. * @param effect defines the update shader
  83453. */
  83454. applyToShader(effect: Effect): void;
  83455. /**
  83456. * Returns a string to use to update the GPU particles update shader
  83457. * @returns a string containng the defines string
  83458. */
  83459. getEffectDefines(): string;
  83460. /**
  83461. * Returns the string "PointParticleEmitter"
  83462. * @returns a string containing the class name
  83463. */
  83464. getClassName(): string;
  83465. /**
  83466. * Serializes the particle system to a JSON object.
  83467. * @returns the JSON object
  83468. */
  83469. serialize(): any;
  83470. /**
  83471. * Parse properties from a JSON object
  83472. * @param serializationObject defines the JSON object
  83473. */
  83474. parse(serializationObject: any): void;
  83475. }
  83476. }
  83477. declare module BABYLON {
  83478. /**
  83479. * Particle emitter emitting particles from the inside of a sphere.
  83480. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83481. */
  83482. export class SphereParticleEmitter implements IParticleEmitterType {
  83483. /**
  83484. * The radius of the emission sphere.
  83485. */
  83486. radius: number;
  83487. /**
  83488. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83489. */
  83490. radiusRange: number;
  83491. /**
  83492. * How much to randomize the particle direction [0-1].
  83493. */
  83494. directionRandomizer: number;
  83495. /**
  83496. * Creates a new instance SphereParticleEmitter
  83497. * @param radius the radius of the emission sphere (1 by default)
  83498. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83499. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83500. */
  83501. constructor(
  83502. /**
  83503. * The radius of the emission sphere.
  83504. */
  83505. radius?: number,
  83506. /**
  83507. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83508. */
  83509. radiusRange?: number,
  83510. /**
  83511. * How much to randomize the particle direction [0-1].
  83512. */
  83513. directionRandomizer?: number);
  83514. /**
  83515. * Called by the particle System when the direction is computed for the created particle.
  83516. * @param worldMatrix is the world matrix of the particle system
  83517. * @param directionToUpdate is the direction vector to update with the result
  83518. * @param particle is the particle we are computed the direction for
  83519. */
  83520. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83521. /**
  83522. * Called by the particle System when the position is computed for the created particle.
  83523. * @param worldMatrix is the world matrix of the particle system
  83524. * @param positionToUpdate is the position vector to update with the result
  83525. * @param particle is the particle we are computed the position for
  83526. */
  83527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83528. /**
  83529. * Clones the current emitter and returns a copy of it
  83530. * @returns the new emitter
  83531. */
  83532. clone(): SphereParticleEmitter;
  83533. /**
  83534. * Called by the GPUParticleSystem to setup the update shader
  83535. * @param effect defines the update shader
  83536. */
  83537. applyToShader(effect: Effect): void;
  83538. /**
  83539. * Returns a string to use to update the GPU particles update shader
  83540. * @returns a string containng the defines string
  83541. */
  83542. getEffectDefines(): string;
  83543. /**
  83544. * Returns the string "SphereParticleEmitter"
  83545. * @returns a string containing the class name
  83546. */
  83547. getClassName(): string;
  83548. /**
  83549. * Serializes the particle system to a JSON object.
  83550. * @returns the JSON object
  83551. */
  83552. serialize(): any;
  83553. /**
  83554. * Parse properties from a JSON object
  83555. * @param serializationObject defines the JSON object
  83556. */
  83557. parse(serializationObject: any): void;
  83558. }
  83559. /**
  83560. * Particle emitter emitting particles from the inside of a sphere.
  83561. * It emits the particles randomly between two vectors.
  83562. */
  83563. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83564. /**
  83565. * The min limit of the emission direction.
  83566. */
  83567. direction1: Vector3;
  83568. /**
  83569. * The max limit of the emission direction.
  83570. */
  83571. direction2: Vector3;
  83572. /**
  83573. * Creates a new instance SphereDirectedParticleEmitter
  83574. * @param radius the radius of the emission sphere (1 by default)
  83575. * @param direction1 the min limit of the emission direction (up vector by default)
  83576. * @param direction2 the max limit of the emission direction (up vector by default)
  83577. */
  83578. constructor(radius?: number,
  83579. /**
  83580. * The min limit of the emission direction.
  83581. */
  83582. direction1?: Vector3,
  83583. /**
  83584. * The max limit of the emission direction.
  83585. */
  83586. direction2?: Vector3);
  83587. /**
  83588. * Called by the particle System when the direction is computed for the created particle.
  83589. * @param worldMatrix is the world matrix of the particle system
  83590. * @param directionToUpdate is the direction vector to update with the result
  83591. * @param particle is the particle we are computed the direction for
  83592. */
  83593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83594. /**
  83595. * Clones the current emitter and returns a copy of it
  83596. * @returns the new emitter
  83597. */
  83598. clone(): SphereDirectedParticleEmitter;
  83599. /**
  83600. * Called by the GPUParticleSystem to setup the update shader
  83601. * @param effect defines the update shader
  83602. */
  83603. applyToShader(effect: Effect): void;
  83604. /**
  83605. * Returns a string to use to update the GPU particles update shader
  83606. * @returns a string containng the defines string
  83607. */
  83608. getEffectDefines(): string;
  83609. /**
  83610. * Returns the string "SphereDirectedParticleEmitter"
  83611. * @returns a string containing the class name
  83612. */
  83613. getClassName(): string;
  83614. /**
  83615. * Serializes the particle system to a JSON object.
  83616. * @returns the JSON object
  83617. */
  83618. serialize(): any;
  83619. /**
  83620. * Parse properties from a JSON object
  83621. * @param serializationObject defines the JSON object
  83622. */
  83623. parse(serializationObject: any): void;
  83624. }
  83625. }
  83626. declare module BABYLON {
  83627. /**
  83628. * Interface representing a particle system in Babylon.js.
  83629. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83630. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83631. */
  83632. export interface IParticleSystem {
  83633. /**
  83634. * List of animations used by the particle system.
  83635. */
  83636. animations: Animation[];
  83637. /**
  83638. * The id of the Particle system.
  83639. */
  83640. id: string;
  83641. /**
  83642. * The name of the Particle system.
  83643. */
  83644. name: string;
  83645. /**
  83646. * The emitter represents the Mesh or position we are attaching the particle system to.
  83647. */
  83648. emitter: Nullable<AbstractMesh | Vector3>;
  83649. /**
  83650. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83651. */
  83652. isBillboardBased: boolean;
  83653. /**
  83654. * The rendering group used by the Particle system to chose when to render.
  83655. */
  83656. renderingGroupId: number;
  83657. /**
  83658. * The layer mask we are rendering the particles through.
  83659. */
  83660. layerMask: number;
  83661. /**
  83662. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83663. */
  83664. updateSpeed: number;
  83665. /**
  83666. * The amount of time the particle system is running (depends of the overall update speed).
  83667. */
  83668. targetStopDuration: number;
  83669. /**
  83670. * The texture used to render each particle. (this can be a spritesheet)
  83671. */
  83672. particleTexture: Nullable<Texture>;
  83673. /**
  83674. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83675. */
  83676. blendMode: number;
  83677. /**
  83678. * Minimum life time of emitting particles.
  83679. */
  83680. minLifeTime: number;
  83681. /**
  83682. * Maximum life time of emitting particles.
  83683. */
  83684. maxLifeTime: number;
  83685. /**
  83686. * Minimum Size of emitting particles.
  83687. */
  83688. minSize: number;
  83689. /**
  83690. * Maximum Size of emitting particles.
  83691. */
  83692. maxSize: number;
  83693. /**
  83694. * Minimum scale of emitting particles on X axis.
  83695. */
  83696. minScaleX: number;
  83697. /**
  83698. * Maximum scale of emitting particles on X axis.
  83699. */
  83700. maxScaleX: number;
  83701. /**
  83702. * Minimum scale of emitting particles on Y axis.
  83703. */
  83704. minScaleY: number;
  83705. /**
  83706. * Maximum scale of emitting particles on Y axis.
  83707. */
  83708. maxScaleY: number;
  83709. /**
  83710. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83711. */
  83712. color1: Color4;
  83713. /**
  83714. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83715. */
  83716. color2: Color4;
  83717. /**
  83718. * Color the particle will have at the end of its lifetime.
  83719. */
  83720. colorDead: Color4;
  83721. /**
  83722. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83723. */
  83724. emitRate: number;
  83725. /**
  83726. * You can use gravity if you want to give an orientation to your particles.
  83727. */
  83728. gravity: Vector3;
  83729. /**
  83730. * Minimum power of emitting particles.
  83731. */
  83732. minEmitPower: number;
  83733. /**
  83734. * Maximum power of emitting particles.
  83735. */
  83736. maxEmitPower: number;
  83737. /**
  83738. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83739. */
  83740. minAngularSpeed: number;
  83741. /**
  83742. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83743. */
  83744. maxAngularSpeed: number;
  83745. /**
  83746. * Gets or sets the minimal initial rotation in radians.
  83747. */
  83748. minInitialRotation: number;
  83749. /**
  83750. * Gets or sets the maximal initial rotation in radians.
  83751. */
  83752. maxInitialRotation: number;
  83753. /**
  83754. * The particle emitter type defines the emitter used by the particle system.
  83755. * It can be for example box, sphere, or cone...
  83756. */
  83757. particleEmitterType: Nullable<IParticleEmitterType>;
  83758. /**
  83759. * Defines the delay in milliseconds before starting the system (0 by default)
  83760. */
  83761. startDelay: number;
  83762. /**
  83763. * 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
  83764. */
  83765. preWarmCycles: number;
  83766. /**
  83767. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83768. */
  83769. preWarmStepOffset: number;
  83770. /**
  83771. * 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)
  83772. */
  83773. spriteCellChangeSpeed: number;
  83774. /**
  83775. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83776. */
  83777. startSpriteCellID: number;
  83778. /**
  83779. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83780. */
  83781. endSpriteCellID: number;
  83782. /**
  83783. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83784. */
  83785. spriteCellWidth: number;
  83786. /**
  83787. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83788. */
  83789. spriteCellHeight: number;
  83790. /**
  83791. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83792. */
  83793. spriteRandomStartCell: boolean;
  83794. /**
  83795. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83796. */
  83797. isAnimationSheetEnabled: boolean;
  83798. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83799. translationPivot: Vector2;
  83800. /**
  83801. * Gets or sets a texture used to add random noise to particle positions
  83802. */
  83803. noiseTexture: Nullable<BaseTexture>;
  83804. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83805. noiseStrength: Vector3;
  83806. /**
  83807. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83808. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83809. */
  83810. billboardMode: number;
  83811. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83812. limitVelocityDamping: number;
  83813. /**
  83814. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83815. */
  83816. beginAnimationOnStart: boolean;
  83817. /**
  83818. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83819. */
  83820. beginAnimationFrom: number;
  83821. /**
  83822. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83823. */
  83824. beginAnimationTo: number;
  83825. /**
  83826. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83827. */
  83828. beginAnimationLoop: boolean;
  83829. /**
  83830. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83831. */
  83832. disposeOnStop: boolean;
  83833. /**
  83834. * Gets the maximum number of particles active at the same time.
  83835. * @returns The max number of active particles.
  83836. */
  83837. getCapacity(): number;
  83838. /**
  83839. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83840. * @returns True if it has been started, otherwise false.
  83841. */
  83842. isStarted(): boolean;
  83843. /**
  83844. * Animates the particle system for this frame.
  83845. */
  83846. animate(): void;
  83847. /**
  83848. * Renders the particle system in its current state.
  83849. * @returns the current number of particles
  83850. */
  83851. render(): number;
  83852. /**
  83853. * Dispose the particle system and frees its associated resources.
  83854. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83855. */
  83856. dispose(disposeTexture?: boolean): void;
  83857. /**
  83858. * Clones the particle system.
  83859. * @param name The name of the cloned object
  83860. * @param newEmitter The new emitter to use
  83861. * @returns the cloned particle system
  83862. */
  83863. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83864. /**
  83865. * Serializes the particle system to a JSON object.
  83866. * @returns the JSON object
  83867. */
  83868. serialize(): any;
  83869. /**
  83870. * Rebuild the particle system
  83871. */
  83872. rebuild(): void;
  83873. /**
  83874. * Starts the particle system and begins to emit
  83875. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83876. */
  83877. start(delay?: number): void;
  83878. /**
  83879. * Stops the particle system.
  83880. */
  83881. stop(): void;
  83882. /**
  83883. * Remove all active particles
  83884. */
  83885. reset(): void;
  83886. /**
  83887. * Is this system ready to be used/rendered
  83888. * @return true if the system is ready
  83889. */
  83890. isReady(): boolean;
  83891. /**
  83892. * Adds a new color gradient
  83893. * @param gradient defines the gradient to use (between 0 and 1)
  83894. * @param color1 defines the color to affect to the specified gradient
  83895. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83896. * @returns the current particle system
  83897. */
  83898. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83899. /**
  83900. * Remove a specific color gradient
  83901. * @param gradient defines the gradient to remove
  83902. * @returns the current particle system
  83903. */
  83904. removeColorGradient(gradient: number): IParticleSystem;
  83905. /**
  83906. * Adds a new size gradient
  83907. * @param gradient defines the gradient to use (between 0 and 1)
  83908. * @param factor defines the size factor to affect to the specified gradient
  83909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83910. * @returns the current particle system
  83911. */
  83912. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83913. /**
  83914. * Remove a specific size gradient
  83915. * @param gradient defines the gradient to remove
  83916. * @returns the current particle system
  83917. */
  83918. removeSizeGradient(gradient: number): IParticleSystem;
  83919. /**
  83920. * Gets the current list of color gradients.
  83921. * You must use addColorGradient and removeColorGradient to udpate this list
  83922. * @returns the list of color gradients
  83923. */
  83924. getColorGradients(): Nullable<Array<ColorGradient>>;
  83925. /**
  83926. * Gets the current list of size gradients.
  83927. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83928. * @returns the list of size gradients
  83929. */
  83930. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83931. /**
  83932. * Gets the current list of angular speed gradients.
  83933. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83934. * @returns the list of angular speed gradients
  83935. */
  83936. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83937. /**
  83938. * Adds a new angular speed gradient
  83939. * @param gradient defines the gradient to use (between 0 and 1)
  83940. * @param factor defines the angular speed to affect to the specified gradient
  83941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83942. * @returns the current particle system
  83943. */
  83944. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83945. /**
  83946. * Remove a specific angular speed gradient
  83947. * @param gradient defines the gradient to remove
  83948. * @returns the current particle system
  83949. */
  83950. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83951. /**
  83952. * Gets the current list of velocity gradients.
  83953. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83954. * @returns the list of velocity gradients
  83955. */
  83956. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83957. /**
  83958. * Adds a new velocity gradient
  83959. * @param gradient defines the gradient to use (between 0 and 1)
  83960. * @param factor defines the velocity to affect to the specified gradient
  83961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83962. * @returns the current particle system
  83963. */
  83964. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83965. /**
  83966. * Remove a specific velocity gradient
  83967. * @param gradient defines the gradient to remove
  83968. * @returns the current particle system
  83969. */
  83970. removeVelocityGradient(gradient: number): IParticleSystem;
  83971. /**
  83972. * Gets the current list of limit velocity gradients.
  83973. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83974. * @returns the list of limit velocity gradients
  83975. */
  83976. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83977. /**
  83978. * Adds a new limit velocity gradient
  83979. * @param gradient defines the gradient to use (between 0 and 1)
  83980. * @param factor defines the limit velocity to affect to the specified gradient
  83981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83982. * @returns the current particle system
  83983. */
  83984. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83985. /**
  83986. * Remove a specific limit velocity gradient
  83987. * @param gradient defines the gradient to remove
  83988. * @returns the current particle system
  83989. */
  83990. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83991. /**
  83992. * Adds a new drag gradient
  83993. * @param gradient defines the gradient to use (between 0 and 1)
  83994. * @param factor defines the drag to affect to the specified gradient
  83995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83996. * @returns the current particle system
  83997. */
  83998. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83999. /**
  84000. * Remove a specific drag gradient
  84001. * @param gradient defines the gradient to remove
  84002. * @returns the current particle system
  84003. */
  84004. removeDragGradient(gradient: number): IParticleSystem;
  84005. /**
  84006. * Gets the current list of drag gradients.
  84007. * You must use addDragGradient and removeDragGradient to udpate this list
  84008. * @returns the list of drag gradients
  84009. */
  84010. getDragGradients(): Nullable<Array<FactorGradient>>;
  84011. /**
  84012. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84013. * @param gradient defines the gradient to use (between 0 and 1)
  84014. * @param factor defines the emit rate to affect to the specified gradient
  84015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84016. * @returns the current particle system
  84017. */
  84018. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84019. /**
  84020. * Remove a specific emit rate gradient
  84021. * @param gradient defines the gradient to remove
  84022. * @returns the current particle system
  84023. */
  84024. removeEmitRateGradient(gradient: number): IParticleSystem;
  84025. /**
  84026. * Gets the current list of emit rate gradients.
  84027. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84028. * @returns the list of emit rate gradients
  84029. */
  84030. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84031. /**
  84032. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84033. * @param gradient defines the gradient to use (between 0 and 1)
  84034. * @param factor defines the start size to affect to the specified gradient
  84035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84036. * @returns the current particle system
  84037. */
  84038. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84039. /**
  84040. * Remove a specific start size gradient
  84041. * @param gradient defines the gradient to remove
  84042. * @returns the current particle system
  84043. */
  84044. removeStartSizeGradient(gradient: number): IParticleSystem;
  84045. /**
  84046. * Gets the current list of start size gradients.
  84047. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84048. * @returns the list of start size gradients
  84049. */
  84050. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84051. /**
  84052. * Adds a new life time gradient
  84053. * @param gradient defines the gradient to use (between 0 and 1)
  84054. * @param factor defines the life time factor to affect to the specified gradient
  84055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84056. * @returns the current particle system
  84057. */
  84058. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84059. /**
  84060. * Remove a specific life time gradient
  84061. * @param gradient defines the gradient to remove
  84062. * @returns the current particle system
  84063. */
  84064. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84065. /**
  84066. * Gets the current list of life time gradients.
  84067. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84068. * @returns the list of life time gradients
  84069. */
  84070. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84071. /**
  84072. * Gets the current list of color gradients.
  84073. * You must use addColorGradient and removeColorGradient to udpate this list
  84074. * @returns the list of color gradients
  84075. */
  84076. getColorGradients(): Nullable<Array<ColorGradient>>;
  84077. /**
  84078. * Adds a new ramp gradient used to remap particle colors
  84079. * @param gradient defines the gradient to use (between 0 and 1)
  84080. * @param color defines the color to affect to the specified gradient
  84081. * @returns the current particle system
  84082. */
  84083. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84084. /**
  84085. * Gets the current list of ramp gradients.
  84086. * You must use addRampGradient and removeRampGradient to udpate this list
  84087. * @returns the list of ramp gradients
  84088. */
  84089. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84090. /** Gets or sets a boolean indicating that ramp gradients must be used
  84091. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84092. */
  84093. useRampGradients: boolean;
  84094. /**
  84095. * Adds a new color remap gradient
  84096. * @param gradient defines the gradient to use (between 0 and 1)
  84097. * @param min defines the color remap minimal range
  84098. * @param max defines the color remap maximal range
  84099. * @returns the current particle system
  84100. */
  84101. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84102. /**
  84103. * Gets the current list of color remap gradients.
  84104. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84105. * @returns the list of color remap gradients
  84106. */
  84107. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84108. /**
  84109. * Adds a new alpha remap gradient
  84110. * @param gradient defines the gradient to use (between 0 and 1)
  84111. * @param min defines the alpha remap minimal range
  84112. * @param max defines the alpha remap maximal range
  84113. * @returns the current particle system
  84114. */
  84115. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84116. /**
  84117. * Gets the current list of alpha remap gradients.
  84118. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84119. * @returns the list of alpha remap gradients
  84120. */
  84121. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84122. /**
  84123. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84124. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84125. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84126. * @returns the emitter
  84127. */
  84128. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84129. /**
  84130. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84131. * @param radius The radius of the hemisphere to emit from
  84132. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84133. * @returns the emitter
  84134. */
  84135. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84136. /**
  84137. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84138. * @param radius The radius of the sphere to emit from
  84139. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84140. * @returns the emitter
  84141. */
  84142. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84143. /**
  84144. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84145. * @param radius The radius of the sphere to emit from
  84146. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84147. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84148. * @returns the emitter
  84149. */
  84150. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84151. /**
  84152. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84153. * @param radius The radius of the emission cylinder
  84154. * @param height The height of the emission cylinder
  84155. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84156. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84157. * @returns the emitter
  84158. */
  84159. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84160. /**
  84161. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84162. * @param radius The radius of the cylinder to emit from
  84163. * @param height The height of the emission cylinder
  84164. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84165. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84166. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84167. * @returns the emitter
  84168. */
  84169. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84170. /**
  84171. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84172. * @param radius The radius of the cone to emit from
  84173. * @param angle The base angle of the cone
  84174. * @returns the emitter
  84175. */
  84176. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84177. /**
  84178. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84179. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84180. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84181. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84182. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84183. * @returns the emitter
  84184. */
  84185. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84186. /**
  84187. * Get hosting scene
  84188. * @returns the scene
  84189. */
  84190. getScene(): Scene;
  84191. }
  84192. }
  84193. declare module BABYLON {
  84194. /**
  84195. * Creates an instance based on a source mesh.
  84196. */
  84197. export class InstancedMesh extends AbstractMesh {
  84198. private _sourceMesh;
  84199. private _currentLOD;
  84200. /** @hidden */
  84201. _indexInSourceMeshInstanceArray: number;
  84202. constructor(name: string, source: Mesh);
  84203. /**
  84204. * Returns the string "InstancedMesh".
  84205. */
  84206. getClassName(): string;
  84207. /** Gets the list of lights affecting that mesh */
  84208. readonly lightSources: Light[];
  84209. _resyncLightSources(): void;
  84210. _resyncLighSource(light: Light): void;
  84211. _removeLightSource(light: Light, dispose: boolean): void;
  84212. /**
  84213. * If the source mesh receives shadows
  84214. */
  84215. readonly receiveShadows: boolean;
  84216. /**
  84217. * The material of the source mesh
  84218. */
  84219. readonly material: Nullable<Material>;
  84220. /**
  84221. * Visibility of the source mesh
  84222. */
  84223. readonly visibility: number;
  84224. /**
  84225. * Skeleton of the source mesh
  84226. */
  84227. readonly skeleton: Nullable<Skeleton>;
  84228. /**
  84229. * Rendering ground id of the source mesh
  84230. */
  84231. renderingGroupId: number;
  84232. /**
  84233. * Returns the total number of vertices (integer).
  84234. */
  84235. getTotalVertices(): number;
  84236. /**
  84237. * Returns a positive integer : the total number of indices in this mesh geometry.
  84238. * @returns the numner of indices or zero if the mesh has no geometry.
  84239. */
  84240. getTotalIndices(): number;
  84241. /**
  84242. * The source mesh of the instance
  84243. */
  84244. readonly sourceMesh: Mesh;
  84245. /**
  84246. * Is this node ready to be used/rendered
  84247. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84248. * @return {boolean} is it ready
  84249. */
  84250. isReady(completeCheck?: boolean): boolean;
  84251. /**
  84252. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84253. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84254. * @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.
  84255. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84256. */
  84257. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84258. /**
  84259. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84260. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84261. * The `data` are either a numeric array either a Float32Array.
  84262. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84263. * 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).
  84264. * Note that a new underlying VertexBuffer object is created each call.
  84265. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84266. *
  84267. * Possible `kind` values :
  84268. * - VertexBuffer.PositionKind
  84269. * - VertexBuffer.UVKind
  84270. * - VertexBuffer.UV2Kind
  84271. * - VertexBuffer.UV3Kind
  84272. * - VertexBuffer.UV4Kind
  84273. * - VertexBuffer.UV5Kind
  84274. * - VertexBuffer.UV6Kind
  84275. * - VertexBuffer.ColorKind
  84276. * - VertexBuffer.MatricesIndicesKind
  84277. * - VertexBuffer.MatricesIndicesExtraKind
  84278. * - VertexBuffer.MatricesWeightsKind
  84279. * - VertexBuffer.MatricesWeightsExtraKind
  84280. *
  84281. * Returns the Mesh.
  84282. */
  84283. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84284. /**
  84285. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84286. * If the mesh has no geometry, it is simply returned as it is.
  84287. * The `data` are either a numeric array either a Float32Array.
  84288. * No new underlying VertexBuffer object is created.
  84289. * 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.
  84290. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84291. *
  84292. * Possible `kind` values :
  84293. * - VertexBuffer.PositionKind
  84294. * - VertexBuffer.UVKind
  84295. * - VertexBuffer.UV2Kind
  84296. * - VertexBuffer.UV3Kind
  84297. * - VertexBuffer.UV4Kind
  84298. * - VertexBuffer.UV5Kind
  84299. * - VertexBuffer.UV6Kind
  84300. * - VertexBuffer.ColorKind
  84301. * - VertexBuffer.MatricesIndicesKind
  84302. * - VertexBuffer.MatricesIndicesExtraKind
  84303. * - VertexBuffer.MatricesWeightsKind
  84304. * - VertexBuffer.MatricesWeightsExtraKind
  84305. *
  84306. * Returns the Mesh.
  84307. */
  84308. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84309. /**
  84310. * Sets the mesh indices.
  84311. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84312. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84313. * This method creates a new index buffer each call.
  84314. * Returns the Mesh.
  84315. */
  84316. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84317. /**
  84318. * Boolean : True if the mesh owns the requested kind of data.
  84319. */
  84320. isVerticesDataPresent(kind: string): boolean;
  84321. /**
  84322. * Returns an array of indices (IndicesArray).
  84323. */
  84324. getIndices(): Nullable<IndicesArray>;
  84325. readonly _positions: Nullable<Vector3[]>;
  84326. /**
  84327. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84328. * This means the mesh underlying bounding box and sphere are recomputed.
  84329. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84330. * @returns the current mesh
  84331. */
  84332. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84333. /** @hidden */
  84334. _preActivate(): InstancedMesh;
  84335. /** @hidden */
  84336. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84337. /** @hidden */
  84338. _postActivate(): void;
  84339. getWorldMatrix(): Matrix;
  84340. readonly isAnInstance: boolean;
  84341. /**
  84342. * Returns the current associated LOD AbstractMesh.
  84343. */
  84344. getLOD(camera: Camera): AbstractMesh;
  84345. /** @hidden */
  84346. _syncSubMeshes(): InstancedMesh;
  84347. /** @hidden */
  84348. _generatePointsArray(): boolean;
  84349. /**
  84350. * Creates a new InstancedMesh from the current mesh.
  84351. * - name (string) : the cloned mesh name
  84352. * - newParent (optional Node) : the optional Node to parent the clone to.
  84353. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84354. *
  84355. * Returns the clone.
  84356. */
  84357. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84358. /**
  84359. * Disposes the InstancedMesh.
  84360. * Returns nothing.
  84361. */
  84362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84363. }
  84364. }
  84365. declare module BABYLON {
  84366. /**
  84367. * Defines the options associated with the creation of a shader material.
  84368. */
  84369. export interface IShaderMaterialOptions {
  84370. /**
  84371. * Does the material work in alpha blend mode
  84372. */
  84373. needAlphaBlending: boolean;
  84374. /**
  84375. * Does the material work in alpha test mode
  84376. */
  84377. needAlphaTesting: boolean;
  84378. /**
  84379. * The list of attribute names used in the shader
  84380. */
  84381. attributes: string[];
  84382. /**
  84383. * The list of unifrom names used in the shader
  84384. */
  84385. uniforms: string[];
  84386. /**
  84387. * The list of UBO names used in the shader
  84388. */
  84389. uniformBuffers: string[];
  84390. /**
  84391. * The list of sampler names used in the shader
  84392. */
  84393. samplers: string[];
  84394. /**
  84395. * The list of defines used in the shader
  84396. */
  84397. defines: string[];
  84398. }
  84399. /**
  84400. * 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.
  84401. *
  84402. * This returned material effects how the mesh will look based on the code in the shaders.
  84403. *
  84404. * @see http://doc.babylonjs.com/how_to/shader_material
  84405. */
  84406. export class ShaderMaterial extends Material {
  84407. private _shaderPath;
  84408. private _options;
  84409. private _textures;
  84410. private _textureArrays;
  84411. private _floats;
  84412. private _ints;
  84413. private _floatsArrays;
  84414. private _colors3;
  84415. private _colors3Arrays;
  84416. private _colors4;
  84417. private _colors4Arrays;
  84418. private _vectors2;
  84419. private _vectors3;
  84420. private _vectors4;
  84421. private _matrices;
  84422. private _matrices3x3;
  84423. private _matrices2x2;
  84424. private _vectors2Arrays;
  84425. private _vectors3Arrays;
  84426. private _vectors4Arrays;
  84427. private _cachedWorldViewMatrix;
  84428. private _cachedWorldViewProjectionMatrix;
  84429. private _renderId;
  84430. /**
  84431. * Instantiate a new shader material.
  84432. * 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.
  84433. * This returned material effects how the mesh will look based on the code in the shaders.
  84434. * @see http://doc.babylonjs.com/how_to/shader_material
  84435. * @param name Define the name of the material in the scene
  84436. * @param scene Define the scene the material belongs to
  84437. * @param shaderPath Defines the route to the shader code in one of three ways:
  84438. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84439. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84440. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84441. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84442. * @param options Define the options used to create the shader
  84443. */
  84444. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84445. /**
  84446. * Gets the options used to compile the shader.
  84447. * They can be modified to trigger a new compilation
  84448. */
  84449. readonly options: IShaderMaterialOptions;
  84450. /**
  84451. * Gets the current class name of the material e.g. "ShaderMaterial"
  84452. * Mainly use in serialization.
  84453. * @returns the class name
  84454. */
  84455. getClassName(): string;
  84456. /**
  84457. * Specifies if the material will require alpha blending
  84458. * @returns a boolean specifying if alpha blending is needed
  84459. */
  84460. needAlphaBlending(): boolean;
  84461. /**
  84462. * Specifies if this material should be rendered in alpha test mode
  84463. * @returns a boolean specifying if an alpha test is needed.
  84464. */
  84465. needAlphaTesting(): boolean;
  84466. private _checkUniform;
  84467. /**
  84468. * Set a texture in the shader.
  84469. * @param name Define the name of the uniform samplers as defined in the shader
  84470. * @param texture Define the texture to bind to this sampler
  84471. * @return the material itself allowing "fluent" like uniform updates
  84472. */
  84473. setTexture(name: string, texture: Texture): ShaderMaterial;
  84474. /**
  84475. * Set a texture array in the shader.
  84476. * @param name Define the name of the uniform sampler array as defined in the shader
  84477. * @param textures Define the list of textures to bind to this sampler
  84478. * @return the material itself allowing "fluent" like uniform updates
  84479. */
  84480. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84481. /**
  84482. * Set a float in the shader.
  84483. * @param name Define the name of the uniform as defined in the shader
  84484. * @param value Define the value to give to the uniform
  84485. * @return the material itself allowing "fluent" like uniform updates
  84486. */
  84487. setFloat(name: string, value: number): ShaderMaterial;
  84488. /**
  84489. * Set a int in the shader.
  84490. * @param name Define the name of the uniform as defined in the shader
  84491. * @param value Define the value to give to the uniform
  84492. * @return the material itself allowing "fluent" like uniform updates
  84493. */
  84494. setInt(name: string, value: number): ShaderMaterial;
  84495. /**
  84496. * Set an array of floats in the shader.
  84497. * @param name Define the name of the uniform as defined in the shader
  84498. * @param value Define the value to give to the uniform
  84499. * @return the material itself allowing "fluent" like uniform updates
  84500. */
  84501. setFloats(name: string, value: number[]): ShaderMaterial;
  84502. /**
  84503. * Set a vec3 in the shader from a Color3.
  84504. * @param name Define the name of the uniform as defined in the shader
  84505. * @param value Define the value to give to the uniform
  84506. * @return the material itself allowing "fluent" like uniform updates
  84507. */
  84508. setColor3(name: string, value: Color3): ShaderMaterial;
  84509. /**
  84510. * Set a vec3 array in the shader from a Color3 array.
  84511. * @param name Define the name of the uniform as defined in the shader
  84512. * @param value Define the value to give to the uniform
  84513. * @return the material itself allowing "fluent" like uniform updates
  84514. */
  84515. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84516. /**
  84517. * Set a vec4 in the shader from a Color4.
  84518. * @param name Define the name of the uniform as defined in the shader
  84519. * @param value Define the value to give to the uniform
  84520. * @return the material itself allowing "fluent" like uniform updates
  84521. */
  84522. setColor4(name: string, value: Color4): ShaderMaterial;
  84523. /**
  84524. * Set a vec4 array in the shader from a Color4 array.
  84525. * @param name Define the name of the uniform as defined in the shader
  84526. * @param value Define the value to give to the uniform
  84527. * @return the material itself allowing "fluent" like uniform updates
  84528. */
  84529. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84530. /**
  84531. * Set a vec2 in the shader from a Vector2.
  84532. * @param name Define the name of the uniform as defined in the shader
  84533. * @param value Define the value to give to the uniform
  84534. * @return the material itself allowing "fluent" like uniform updates
  84535. */
  84536. setVector2(name: string, value: Vector2): ShaderMaterial;
  84537. /**
  84538. * Set a vec3 in the shader from a Vector3.
  84539. * @param name Define the name of the uniform as defined in the shader
  84540. * @param value Define the value to give to the uniform
  84541. * @return the material itself allowing "fluent" like uniform updates
  84542. */
  84543. setVector3(name: string, value: Vector3): ShaderMaterial;
  84544. /**
  84545. * Set a vec4 in the shader from a Vector4.
  84546. * @param name Define the name of the uniform as defined in the shader
  84547. * @param value Define the value to give to the uniform
  84548. * @return the material itself allowing "fluent" like uniform updates
  84549. */
  84550. setVector4(name: string, value: Vector4): ShaderMaterial;
  84551. /**
  84552. * Set a mat4 in the shader from a Matrix.
  84553. * @param name Define the name of the uniform as defined in the shader
  84554. * @param value Define the value to give to the uniform
  84555. * @return the material itself allowing "fluent" like uniform updates
  84556. */
  84557. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84558. /**
  84559. * Set a mat3 in the shader from a Float32Array.
  84560. * @param name Define the name of the uniform as defined in the shader
  84561. * @param value Define the value to give to the uniform
  84562. * @return the material itself allowing "fluent" like uniform updates
  84563. */
  84564. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84565. /**
  84566. * Set a mat2 in the shader from a Float32Array.
  84567. * @param name Define the name of the uniform as defined in the shader
  84568. * @param value Define the value to give to the uniform
  84569. * @return the material itself allowing "fluent" like uniform updates
  84570. */
  84571. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84572. /**
  84573. * Set a vec2 array in the shader from a number array.
  84574. * @param name Define the name of the uniform as defined in the shader
  84575. * @param value Define the value to give to the uniform
  84576. * @return the material itself allowing "fluent" like uniform updates
  84577. */
  84578. setArray2(name: string, value: number[]): ShaderMaterial;
  84579. /**
  84580. * Set a vec3 array in the shader from a number array.
  84581. * @param name Define the name of the uniform as defined in the shader
  84582. * @param value Define the value to give to the uniform
  84583. * @return the material itself allowing "fluent" like uniform updates
  84584. */
  84585. setArray3(name: string, value: number[]): ShaderMaterial;
  84586. /**
  84587. * Set a vec4 array in the shader from a number array.
  84588. * @param name Define the name of the uniform as defined in the shader
  84589. * @param value Define the value to give to the uniform
  84590. * @return the material itself allowing "fluent" like uniform updates
  84591. */
  84592. setArray4(name: string, value: number[]): ShaderMaterial;
  84593. private _checkCache;
  84594. /**
  84595. * Specifies that the submesh is ready to be used
  84596. * @param mesh defines the mesh to check
  84597. * @param subMesh defines which submesh to check
  84598. * @param useInstances specifies that instances should be used
  84599. * @returns a boolean indicating that the submesh is ready or not
  84600. */
  84601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84602. /**
  84603. * Checks if the material is ready to render the requested mesh
  84604. * @param mesh Define the mesh to render
  84605. * @param useInstances Define whether or not the material is used with instances
  84606. * @returns true if ready, otherwise false
  84607. */
  84608. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84609. /**
  84610. * Binds the world matrix to the material
  84611. * @param world defines the world transformation matrix
  84612. */
  84613. bindOnlyWorldMatrix(world: Matrix): void;
  84614. /**
  84615. * Binds the material to the mesh
  84616. * @param world defines the world transformation matrix
  84617. * @param mesh defines the mesh to bind the material to
  84618. */
  84619. bind(world: Matrix, mesh?: Mesh): void;
  84620. /**
  84621. * Gets the active textures from the material
  84622. * @returns an array of textures
  84623. */
  84624. getActiveTextures(): BaseTexture[];
  84625. /**
  84626. * Specifies if the material uses a texture
  84627. * @param texture defines the texture to check against the material
  84628. * @returns a boolean specifying if the material uses the texture
  84629. */
  84630. hasTexture(texture: BaseTexture): boolean;
  84631. /**
  84632. * Makes a duplicate of the material, and gives it a new name
  84633. * @param name defines the new name for the duplicated material
  84634. * @returns the cloned material
  84635. */
  84636. clone(name: string): ShaderMaterial;
  84637. /**
  84638. * Disposes the material
  84639. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84640. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84641. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84642. */
  84643. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84644. /**
  84645. * Serializes this material in a JSON representation
  84646. * @returns the serialized material object
  84647. */
  84648. serialize(): any;
  84649. /**
  84650. * Creates a shader material from parsed shader material data
  84651. * @param source defines the JSON represnetation of the material
  84652. * @param scene defines the hosting scene
  84653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84654. * @returns a new material
  84655. */
  84656. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84657. }
  84658. }
  84659. declare module BABYLON {
  84660. /** @hidden */
  84661. export var colorPixelShader: {
  84662. name: string;
  84663. shader: string;
  84664. };
  84665. }
  84666. declare module BABYLON {
  84667. /** @hidden */
  84668. export var colorVertexShader: {
  84669. name: string;
  84670. shader: string;
  84671. };
  84672. }
  84673. declare module BABYLON {
  84674. /**
  84675. * Line mesh
  84676. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84677. */
  84678. export class LinesMesh extends Mesh {
  84679. /**
  84680. * If vertex color should be applied to the mesh
  84681. */
  84682. readonly useVertexColor?: boolean | undefined;
  84683. /**
  84684. * If vertex alpha should be applied to the mesh
  84685. */
  84686. readonly useVertexAlpha?: boolean | undefined;
  84687. /**
  84688. * Color of the line (Default: White)
  84689. */
  84690. color: Color3;
  84691. /**
  84692. * Alpha of the line (Default: 1)
  84693. */
  84694. alpha: number;
  84695. /**
  84696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84697. * This margin is expressed in world space coordinates, so its value may vary.
  84698. * Default value is 0.1
  84699. */
  84700. intersectionThreshold: number;
  84701. private _colorShader;
  84702. private color4;
  84703. /**
  84704. * Creates a new LinesMesh
  84705. * @param name defines the name
  84706. * @param scene defines the hosting scene
  84707. * @param parent defines the parent mesh if any
  84708. * @param source defines the optional source LinesMesh used to clone data from
  84709. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84710. * When false, achieved by calling a clone(), also passing False.
  84711. * This will make creation of children, recursive.
  84712. * @param useVertexColor defines if this LinesMesh supports vertex color
  84713. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84714. */
  84715. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84716. /**
  84717. * If vertex color should be applied to the mesh
  84718. */
  84719. useVertexColor?: boolean | undefined,
  84720. /**
  84721. * If vertex alpha should be applied to the mesh
  84722. */
  84723. useVertexAlpha?: boolean | undefined);
  84724. private _addClipPlaneDefine;
  84725. private _removeClipPlaneDefine;
  84726. isReady(): boolean;
  84727. /**
  84728. * Returns the string "LineMesh"
  84729. */
  84730. getClassName(): string;
  84731. /**
  84732. * @hidden
  84733. */
  84734. /**
  84735. * @hidden
  84736. */
  84737. material: Material;
  84738. /**
  84739. * @hidden
  84740. */
  84741. readonly checkCollisions: boolean;
  84742. /** @hidden */
  84743. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84744. /** @hidden */
  84745. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84746. /**
  84747. * Disposes of the line mesh
  84748. * @param doNotRecurse If children should be disposed
  84749. */
  84750. dispose(doNotRecurse?: boolean): void;
  84751. /**
  84752. * Returns a new LineMesh object cloned from the current one.
  84753. */
  84754. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84755. /**
  84756. * Creates a new InstancedLinesMesh object from the mesh model.
  84757. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84758. * @param name defines the name of the new instance
  84759. * @returns a new InstancedLinesMesh
  84760. */
  84761. createInstance(name: string): InstancedLinesMesh;
  84762. }
  84763. /**
  84764. * Creates an instance based on a source LinesMesh
  84765. */
  84766. export class InstancedLinesMesh extends InstancedMesh {
  84767. /**
  84768. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84769. * This margin is expressed in world space coordinates, so its value may vary.
  84770. * Initilized with the intersectionThreshold value of the source LinesMesh
  84771. */
  84772. intersectionThreshold: number;
  84773. constructor(name: string, source: LinesMesh);
  84774. /**
  84775. * Returns the string "InstancedLinesMesh".
  84776. */
  84777. getClassName(): string;
  84778. }
  84779. }
  84780. declare module BABYLON {
  84781. /** @hidden */
  84782. export var linePixelShader: {
  84783. name: string;
  84784. shader: string;
  84785. };
  84786. }
  84787. declare module BABYLON {
  84788. /** @hidden */
  84789. export var lineVertexShader: {
  84790. name: string;
  84791. shader: string;
  84792. };
  84793. }
  84794. declare module BABYLON {
  84795. interface AbstractMesh {
  84796. /**
  84797. * Gets the edgesRenderer associated with the mesh
  84798. */
  84799. edgesRenderer: Nullable<EdgesRenderer>;
  84800. }
  84801. interface LinesMesh {
  84802. /**
  84803. * Enables the edge rendering mode on the mesh.
  84804. * This mode makes the mesh edges visible
  84805. * @param epsilon defines the maximal distance between two angles to detect a face
  84806. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84807. * @returns the currentAbstractMesh
  84808. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84809. */
  84810. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  84811. }
  84812. interface InstancedLinesMesh {
  84813. /**
  84814. * Enables the edge rendering mode on the mesh.
  84815. * This mode makes the mesh edges visible
  84816. * @param epsilon defines the maximal distance between two angles to detect a face
  84817. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84818. * @returns the current InstancedLinesMesh
  84819. * @see https://www.babylonjs-playground.com/#19O9TU#0
  84820. */
  84821. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  84822. }
  84823. /**
  84824. * Defines the minimum contract an Edges renderer should follow.
  84825. */
  84826. export interface IEdgesRenderer extends IDisposable {
  84827. /**
  84828. * Gets or sets a boolean indicating if the edgesRenderer is active
  84829. */
  84830. isEnabled: boolean;
  84831. /**
  84832. * Renders the edges of the attached mesh,
  84833. */
  84834. render(): void;
  84835. /**
  84836. * Checks wether or not the edges renderer is ready to render.
  84837. * @return true if ready, otherwise false.
  84838. */
  84839. isReady(): boolean;
  84840. }
  84841. /**
  84842. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  84843. */
  84844. export class EdgesRenderer implements IEdgesRenderer {
  84845. /**
  84846. * Define the size of the edges with an orthographic camera
  84847. */
  84848. edgesWidthScalerForOrthographic: number;
  84849. /**
  84850. * Define the size of the edges with a perspective camera
  84851. */
  84852. edgesWidthScalerForPerspective: number;
  84853. protected _source: AbstractMesh;
  84854. protected _linesPositions: number[];
  84855. protected _linesNormals: number[];
  84856. protected _linesIndices: number[];
  84857. protected _epsilon: number;
  84858. protected _indicesCount: number;
  84859. protected _lineShader: ShaderMaterial;
  84860. protected _ib: DataBuffer;
  84861. protected _buffers: {
  84862. [key: string]: Nullable<VertexBuffer>;
  84863. };
  84864. protected _checkVerticesInsteadOfIndices: boolean;
  84865. private _meshRebuildObserver;
  84866. private _meshDisposeObserver;
  84867. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84868. isEnabled: boolean;
  84869. /**
  84870. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84871. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84872. * @param source Mesh used to create edges
  84873. * @param epsilon sum of angles in adjacency to check for edge
  84874. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84875. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84876. */
  84877. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84878. protected _prepareRessources(): void;
  84879. /** @hidden */
  84880. _rebuild(): void;
  84881. /**
  84882. * Releases the required resources for the edges renderer
  84883. */
  84884. dispose(): void;
  84885. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84886. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84887. /**
  84888. * Checks if the pair of p0 and p1 is en edge
  84889. * @param faceIndex
  84890. * @param edge
  84891. * @param faceNormals
  84892. * @param p0
  84893. * @param p1
  84894. * @private
  84895. */
  84896. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84897. /**
  84898. * push line into the position, normal and index buffer
  84899. * @protected
  84900. */
  84901. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84902. /**
  84903. * Generates lines edges from adjacencjes
  84904. * @private
  84905. */
  84906. _generateEdgesLines(): void;
  84907. /**
  84908. * Checks wether or not the edges renderer is ready to render.
  84909. * @return true if ready, otherwise false.
  84910. */
  84911. isReady(): boolean;
  84912. /**
  84913. * Renders the edges of the attached mesh,
  84914. */
  84915. render(): void;
  84916. }
  84917. /**
  84918. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84919. */
  84920. export class LineEdgesRenderer extends EdgesRenderer {
  84921. /**
  84922. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84923. * @param source LineMesh used to generate edges
  84924. * @param epsilon not important (specified angle for edge detection)
  84925. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84926. */
  84927. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84928. /**
  84929. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84930. */
  84931. _generateEdgesLines(): void;
  84932. }
  84933. }
  84934. declare module BABYLON {
  84935. /**
  84936. * This represents the object necessary to create a rendering group.
  84937. * This is exclusively used and created by the rendering manager.
  84938. * To modify the behavior, you use the available helpers in your scene or meshes.
  84939. * @hidden
  84940. */
  84941. export class RenderingGroup {
  84942. index: number;
  84943. private static _zeroVector;
  84944. private _scene;
  84945. private _opaqueSubMeshes;
  84946. private _transparentSubMeshes;
  84947. private _alphaTestSubMeshes;
  84948. private _depthOnlySubMeshes;
  84949. private _particleSystems;
  84950. private _spriteManagers;
  84951. private _opaqueSortCompareFn;
  84952. private _alphaTestSortCompareFn;
  84953. private _transparentSortCompareFn;
  84954. private _renderOpaque;
  84955. private _renderAlphaTest;
  84956. private _renderTransparent;
  84957. /** @hidden */
  84958. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84959. onBeforeTransparentRendering: () => void;
  84960. /**
  84961. * Set the opaque sort comparison function.
  84962. * If null the sub meshes will be render in the order they were created
  84963. */
  84964. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84965. /**
  84966. * Set the alpha test sort comparison function.
  84967. * If null the sub meshes will be render in the order they were created
  84968. */
  84969. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84970. /**
  84971. * Set the transparent sort comparison function.
  84972. * If null the sub meshes will be render in the order they were created
  84973. */
  84974. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84975. /**
  84976. * Creates a new rendering group.
  84977. * @param index The rendering group index
  84978. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84979. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84980. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84981. */
  84982. 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>);
  84983. /**
  84984. * Render all the sub meshes contained in the group.
  84985. * @param customRenderFunction Used to override the default render behaviour of the group.
  84986. * @returns true if rendered some submeshes.
  84987. */
  84988. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84989. /**
  84990. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84991. * @param subMeshes The submeshes to render
  84992. */
  84993. private renderOpaqueSorted;
  84994. /**
  84995. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84996. * @param subMeshes The submeshes to render
  84997. */
  84998. private renderAlphaTestSorted;
  84999. /**
  85000. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85001. * @param subMeshes The submeshes to render
  85002. */
  85003. private renderTransparentSorted;
  85004. /**
  85005. * Renders the submeshes in a specified order.
  85006. * @param subMeshes The submeshes to sort before render
  85007. * @param sortCompareFn The comparison function use to sort
  85008. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85009. * @param transparent Specifies to activate blending if true
  85010. */
  85011. private static renderSorted;
  85012. /**
  85013. * Renders the submeshes in the order they were dispatched (no sort applied).
  85014. * @param subMeshes The submeshes to render
  85015. */
  85016. private static renderUnsorted;
  85017. /**
  85018. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85019. * are rendered back to front if in the same alpha index.
  85020. *
  85021. * @param a The first submesh
  85022. * @param b The second submesh
  85023. * @returns The result of the comparison
  85024. */
  85025. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85026. /**
  85027. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85028. * are rendered back to front.
  85029. *
  85030. * @param a The first submesh
  85031. * @param b The second submesh
  85032. * @returns The result of the comparison
  85033. */
  85034. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85035. /**
  85036. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85037. * are rendered front to back (prevent overdraw).
  85038. *
  85039. * @param a The first submesh
  85040. * @param b The second submesh
  85041. * @returns The result of the comparison
  85042. */
  85043. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85044. /**
  85045. * Resets the different lists of submeshes to prepare a new frame.
  85046. */
  85047. prepare(): void;
  85048. dispose(): void;
  85049. /**
  85050. * Inserts the submesh in its correct queue depending on its material.
  85051. * @param subMesh The submesh to dispatch
  85052. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85053. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85054. */
  85055. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85056. dispatchSprites(spriteManager: ISpriteManager): void;
  85057. dispatchParticles(particleSystem: IParticleSystem): void;
  85058. private _renderParticles;
  85059. private _renderSprites;
  85060. }
  85061. }
  85062. declare module BABYLON {
  85063. /**
  85064. * Interface describing the different options available in the rendering manager
  85065. * regarding Auto Clear between groups.
  85066. */
  85067. export interface IRenderingManagerAutoClearSetup {
  85068. /**
  85069. * Defines whether or not autoclear is enable.
  85070. */
  85071. autoClear: boolean;
  85072. /**
  85073. * Defines whether or not to autoclear the depth buffer.
  85074. */
  85075. depth: boolean;
  85076. /**
  85077. * Defines whether or not to autoclear the stencil buffer.
  85078. */
  85079. stencil: boolean;
  85080. }
  85081. /**
  85082. * This class is used by the onRenderingGroupObservable
  85083. */
  85084. export class RenderingGroupInfo {
  85085. /**
  85086. * The Scene that being rendered
  85087. */
  85088. scene: Scene;
  85089. /**
  85090. * The camera currently used for the rendering pass
  85091. */
  85092. camera: Nullable<Camera>;
  85093. /**
  85094. * The ID of the renderingGroup being processed
  85095. */
  85096. renderingGroupId: number;
  85097. }
  85098. /**
  85099. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85100. * It is enable to manage the different groups as well as the different necessary sort functions.
  85101. * This should not be used directly aside of the few static configurations
  85102. */
  85103. export class RenderingManager {
  85104. /**
  85105. * The max id used for rendering groups (not included)
  85106. */
  85107. static MAX_RENDERINGGROUPS: number;
  85108. /**
  85109. * The min id used for rendering groups (included)
  85110. */
  85111. static MIN_RENDERINGGROUPS: number;
  85112. /**
  85113. * Used to globally prevent autoclearing scenes.
  85114. */
  85115. static AUTOCLEAR: boolean;
  85116. /**
  85117. * @hidden
  85118. */
  85119. _useSceneAutoClearSetup: boolean;
  85120. private _scene;
  85121. private _renderingGroups;
  85122. private _depthStencilBufferAlreadyCleaned;
  85123. private _autoClearDepthStencil;
  85124. private _customOpaqueSortCompareFn;
  85125. private _customAlphaTestSortCompareFn;
  85126. private _customTransparentSortCompareFn;
  85127. private _renderingGroupInfo;
  85128. /**
  85129. * Instantiates a new rendering group for a particular scene
  85130. * @param scene Defines the scene the groups belongs to
  85131. */
  85132. constructor(scene: Scene);
  85133. private _clearDepthStencilBuffer;
  85134. /**
  85135. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85136. * @hidden
  85137. */
  85138. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85139. /**
  85140. * Resets the different information of the group to prepare a new frame
  85141. * @hidden
  85142. */
  85143. reset(): void;
  85144. /**
  85145. * Dispose and release the group and its associated resources.
  85146. * @hidden
  85147. */
  85148. dispose(): void;
  85149. /**
  85150. * Clear the info related to rendering groups preventing retention points during dispose.
  85151. */
  85152. freeRenderingGroups(): void;
  85153. private _prepareRenderingGroup;
  85154. /**
  85155. * Add a sprite manager to the rendering manager in order to render it this frame.
  85156. * @param spriteManager Define the sprite manager to render
  85157. */
  85158. dispatchSprites(spriteManager: ISpriteManager): void;
  85159. /**
  85160. * Add a particle system to the rendering manager in order to render it this frame.
  85161. * @param particleSystem Define the particle system to render
  85162. */
  85163. dispatchParticles(particleSystem: IParticleSystem): void;
  85164. /**
  85165. * Add a submesh to the manager in order to render it this frame
  85166. * @param subMesh The submesh to dispatch
  85167. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85168. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85169. */
  85170. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85171. /**
  85172. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85173. * This allowed control for front to back rendering or reversly depending of the special needs.
  85174. *
  85175. * @param renderingGroupId The rendering group id corresponding to its index
  85176. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85177. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85178. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85179. */
  85180. 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;
  85181. /**
  85182. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85183. *
  85184. * @param renderingGroupId The rendering group id corresponding to its index
  85185. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85186. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85187. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85188. */
  85189. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85190. /**
  85191. * Gets the current auto clear configuration for one rendering group of the rendering
  85192. * manager.
  85193. * @param index the rendering group index to get the information for
  85194. * @returns The auto clear setup for the requested rendering group
  85195. */
  85196. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85197. }
  85198. }
  85199. declare module BABYLON {
  85200. /**
  85201. * This Helps creating a texture that will be created from a camera in your scene.
  85202. * It is basically a dynamic texture that could be used to create special effects for instance.
  85203. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85204. */
  85205. export class RenderTargetTexture extends Texture {
  85206. isCube: boolean;
  85207. /**
  85208. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85209. */
  85210. static readonly REFRESHRATE_RENDER_ONCE: number;
  85211. /**
  85212. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85213. */
  85214. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85215. /**
  85216. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85217. * the central point of your effect and can save a lot of performances.
  85218. */
  85219. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85220. /**
  85221. * Use this predicate to dynamically define the list of mesh you want to render.
  85222. * If set, the renderList property will be overwritten.
  85223. */
  85224. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85225. private _renderList;
  85226. /**
  85227. * Use this list to define the list of mesh you want to render.
  85228. */
  85229. renderList: Nullable<Array<AbstractMesh>>;
  85230. private _hookArray;
  85231. /**
  85232. * Define if particles should be rendered in your texture.
  85233. */
  85234. renderParticles: boolean;
  85235. /**
  85236. * Define if sprites should be rendered in your texture.
  85237. */
  85238. renderSprites: boolean;
  85239. /**
  85240. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85241. */
  85242. coordinatesMode: number;
  85243. /**
  85244. * Define the camera used to render the texture.
  85245. */
  85246. activeCamera: Nullable<Camera>;
  85247. /**
  85248. * Override the render function of the texture with your own one.
  85249. */
  85250. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85251. /**
  85252. * Define if camera post processes should be use while rendering the texture.
  85253. */
  85254. useCameraPostProcesses: boolean;
  85255. /**
  85256. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85257. */
  85258. ignoreCameraViewport: boolean;
  85259. private _postProcessManager;
  85260. private _postProcesses;
  85261. private _resizeObserver;
  85262. /**
  85263. * An event triggered when the texture is unbind.
  85264. */
  85265. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85266. /**
  85267. * An event triggered when the texture is unbind.
  85268. */
  85269. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85270. private _onAfterUnbindObserver;
  85271. /**
  85272. * Set a after unbind callback in the texture.
  85273. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85274. */
  85275. onAfterUnbind: () => void;
  85276. /**
  85277. * An event triggered before rendering the texture
  85278. */
  85279. onBeforeRenderObservable: Observable<number>;
  85280. private _onBeforeRenderObserver;
  85281. /**
  85282. * Set a before render callback in the texture.
  85283. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85284. */
  85285. onBeforeRender: (faceIndex: number) => void;
  85286. /**
  85287. * An event triggered after rendering the texture
  85288. */
  85289. onAfterRenderObservable: Observable<number>;
  85290. private _onAfterRenderObserver;
  85291. /**
  85292. * Set a after render callback in the texture.
  85293. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85294. */
  85295. onAfterRender: (faceIndex: number) => void;
  85296. /**
  85297. * An event triggered after the texture clear
  85298. */
  85299. onClearObservable: Observable<Engine>;
  85300. private _onClearObserver;
  85301. /**
  85302. * Set a clear callback in the texture.
  85303. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85304. */
  85305. onClear: (Engine: Engine) => void;
  85306. /**
  85307. * An event triggered when the texture is resized.
  85308. */
  85309. onResizeObservable: Observable<RenderTargetTexture>;
  85310. /**
  85311. * Define the clear color of the Render Target if it should be different from the scene.
  85312. */
  85313. clearColor: Color4;
  85314. protected _size: number | {
  85315. width: number;
  85316. height: number;
  85317. };
  85318. protected _initialSizeParameter: number | {
  85319. width: number;
  85320. height: number;
  85321. } | {
  85322. ratio: number;
  85323. };
  85324. protected _sizeRatio: Nullable<number>;
  85325. /** @hidden */
  85326. _generateMipMaps: boolean;
  85327. protected _renderingManager: RenderingManager;
  85328. /** @hidden */
  85329. _waitingRenderList: string[];
  85330. protected _doNotChangeAspectRatio: boolean;
  85331. protected _currentRefreshId: number;
  85332. protected _refreshRate: number;
  85333. protected _textureMatrix: Matrix;
  85334. protected _samples: number;
  85335. protected _renderTargetOptions: RenderTargetCreationOptions;
  85336. /**
  85337. * Gets render target creation options that were used.
  85338. */
  85339. readonly renderTargetOptions: RenderTargetCreationOptions;
  85340. protected _engine: Engine;
  85341. protected _onRatioRescale(): void;
  85342. /**
  85343. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85344. * It must define where the camera used to render the texture is set
  85345. */
  85346. boundingBoxPosition: Vector3;
  85347. private _boundingBoxSize;
  85348. /**
  85349. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85350. * When defined, the cubemap will switch to local mode
  85351. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85352. * @example https://www.babylonjs-playground.com/#RNASML
  85353. */
  85354. boundingBoxSize: Vector3;
  85355. /**
  85356. * In case the RTT has been created with a depth texture, get the associated
  85357. * depth texture.
  85358. * Otherwise, return null.
  85359. */
  85360. depthStencilTexture: Nullable<InternalTexture>;
  85361. /**
  85362. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85363. * or used a shadow, depth texture...
  85364. * @param name The friendly name of the texture
  85365. * @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)
  85366. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85367. * @param generateMipMaps True if mip maps need to be generated after render.
  85368. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85369. * @param type The type of the buffer in the RTT (int, half float, float...)
  85370. * @param isCube True if a cube texture needs to be created
  85371. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85372. * @param generateDepthBuffer True to generate a depth buffer
  85373. * @param generateStencilBuffer True to generate a stencil buffer
  85374. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85375. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85376. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85377. */
  85378. constructor(name: string, size: number | {
  85379. width: number;
  85380. height: number;
  85381. } | {
  85382. ratio: number;
  85383. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85384. /**
  85385. * Creates a depth stencil texture.
  85386. * This is only available in WebGL 2 or with the depth texture extension available.
  85387. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85388. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85389. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85390. */
  85391. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85392. private _processSizeParameter;
  85393. /**
  85394. * Define the number of samples to use in case of MSAA.
  85395. * It defaults to one meaning no MSAA has been enabled.
  85396. */
  85397. samples: number;
  85398. /**
  85399. * Resets the refresh counter of the texture and start bak from scratch.
  85400. * Could be useful to regenerate the texture if it is setup to render only once.
  85401. */
  85402. resetRefreshCounter(): void;
  85403. /**
  85404. * Define the refresh rate of the texture or the rendering frequency.
  85405. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85406. */
  85407. refreshRate: number;
  85408. /**
  85409. * Adds a post process to the render target rendering passes.
  85410. * @param postProcess define the post process to add
  85411. */
  85412. addPostProcess(postProcess: PostProcess): void;
  85413. /**
  85414. * Clear all the post processes attached to the render target
  85415. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85416. */
  85417. clearPostProcesses(dispose?: boolean): void;
  85418. /**
  85419. * Remove one of the post process from the list of attached post processes to the texture
  85420. * @param postProcess define the post process to remove from the list
  85421. */
  85422. removePostProcess(postProcess: PostProcess): void;
  85423. /** @hidden */
  85424. _shouldRender(): boolean;
  85425. /**
  85426. * Gets the actual render size of the texture.
  85427. * @returns the width of the render size
  85428. */
  85429. getRenderSize(): number;
  85430. /**
  85431. * Gets the actual render width of the texture.
  85432. * @returns the width of the render size
  85433. */
  85434. getRenderWidth(): number;
  85435. /**
  85436. * Gets the actual render height of the texture.
  85437. * @returns the height of the render size
  85438. */
  85439. getRenderHeight(): number;
  85440. /**
  85441. * Get if the texture can be rescaled or not.
  85442. */
  85443. readonly canRescale: boolean;
  85444. /**
  85445. * Resize the texture using a ratio.
  85446. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85447. */
  85448. scale(ratio: number): void;
  85449. /**
  85450. * Get the texture reflection matrix used to rotate/transform the reflection.
  85451. * @returns the reflection matrix
  85452. */
  85453. getReflectionTextureMatrix(): Matrix;
  85454. /**
  85455. * Resize the texture to a new desired size.
  85456. * Be carrefull as it will recreate all the data in the new texture.
  85457. * @param size Define the new size. It can be:
  85458. * - a number for squared texture,
  85459. * - an object containing { width: number, height: number }
  85460. * - or an object containing a ratio { ratio: number }
  85461. */
  85462. resize(size: number | {
  85463. width: number;
  85464. height: number;
  85465. } | {
  85466. ratio: number;
  85467. }): void;
  85468. /**
  85469. * Renders all the objects from the render list into the texture.
  85470. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85471. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85472. */
  85473. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85474. private _bestReflectionRenderTargetDimension;
  85475. /**
  85476. * @hidden
  85477. * @param faceIndex face index to bind to if this is a cubetexture
  85478. */
  85479. _bindFrameBuffer(faceIndex?: number): void;
  85480. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85481. private renderToTarget;
  85482. /**
  85483. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85484. * This allowed control for front to back rendering or reversly depending of the special needs.
  85485. *
  85486. * @param renderingGroupId The rendering group id corresponding to its index
  85487. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85488. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85489. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85490. */
  85491. 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;
  85492. /**
  85493. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85494. *
  85495. * @param renderingGroupId The rendering group id corresponding to its index
  85496. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85497. */
  85498. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85499. /**
  85500. * Clones the texture.
  85501. * @returns the cloned texture
  85502. */
  85503. clone(): RenderTargetTexture;
  85504. /**
  85505. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85506. * @returns The JSON representation of the texture
  85507. */
  85508. serialize(): any;
  85509. /**
  85510. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85511. */
  85512. disposeFramebufferObjects(): void;
  85513. /**
  85514. * Dispose the texture and release its associated resources.
  85515. */
  85516. dispose(): void;
  85517. /** @hidden */
  85518. _rebuild(): void;
  85519. /**
  85520. * Clear the info related to rendering groups preventing retention point in material dispose.
  85521. */
  85522. freeRenderingGroups(): void;
  85523. /**
  85524. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85525. * @returns the view count
  85526. */
  85527. getViewCount(): number;
  85528. }
  85529. }
  85530. declare module BABYLON {
  85531. /**
  85532. * Base class for the main features of a material in Babylon.js
  85533. */
  85534. export class Material implements IAnimatable {
  85535. /**
  85536. * Returns the triangle fill mode
  85537. */
  85538. static readonly TriangleFillMode: number;
  85539. /**
  85540. * Returns the wireframe mode
  85541. */
  85542. static readonly WireFrameFillMode: number;
  85543. /**
  85544. * Returns the point fill mode
  85545. */
  85546. static readonly PointFillMode: number;
  85547. /**
  85548. * Returns the point list draw mode
  85549. */
  85550. static readonly PointListDrawMode: number;
  85551. /**
  85552. * Returns the line list draw mode
  85553. */
  85554. static readonly LineListDrawMode: number;
  85555. /**
  85556. * Returns the line loop draw mode
  85557. */
  85558. static readonly LineLoopDrawMode: number;
  85559. /**
  85560. * Returns the line strip draw mode
  85561. */
  85562. static readonly LineStripDrawMode: number;
  85563. /**
  85564. * Returns the triangle strip draw mode
  85565. */
  85566. static readonly TriangleStripDrawMode: number;
  85567. /**
  85568. * Returns the triangle fan draw mode
  85569. */
  85570. static readonly TriangleFanDrawMode: number;
  85571. /**
  85572. * Stores the clock-wise side orientation
  85573. */
  85574. static readonly ClockWiseSideOrientation: number;
  85575. /**
  85576. * Stores the counter clock-wise side orientation
  85577. */
  85578. static readonly CounterClockWiseSideOrientation: number;
  85579. /**
  85580. * The dirty texture flag value
  85581. */
  85582. static readonly TextureDirtyFlag: number;
  85583. /**
  85584. * The dirty light flag value
  85585. */
  85586. static readonly LightDirtyFlag: number;
  85587. /**
  85588. * The dirty fresnel flag value
  85589. */
  85590. static readonly FresnelDirtyFlag: number;
  85591. /**
  85592. * The dirty attribute flag value
  85593. */
  85594. static readonly AttributesDirtyFlag: number;
  85595. /**
  85596. * The dirty misc flag value
  85597. */
  85598. static readonly MiscDirtyFlag: number;
  85599. /**
  85600. * The all dirty flag value
  85601. */
  85602. static readonly AllDirtyFlag: number;
  85603. /**
  85604. * The ID of the material
  85605. */
  85606. id: string;
  85607. /**
  85608. * Gets or sets the unique id of the material
  85609. */
  85610. uniqueId: number;
  85611. /**
  85612. * The name of the material
  85613. */
  85614. name: string;
  85615. /**
  85616. * Gets or sets user defined metadata
  85617. */
  85618. metadata: any;
  85619. /**
  85620. * For internal use only. Please do not use.
  85621. */
  85622. reservedDataStore: any;
  85623. /**
  85624. * Specifies if the ready state should be checked on each call
  85625. */
  85626. checkReadyOnEveryCall: boolean;
  85627. /**
  85628. * Specifies if the ready state should be checked once
  85629. */
  85630. checkReadyOnlyOnce: boolean;
  85631. /**
  85632. * The state of the material
  85633. */
  85634. state: string;
  85635. /**
  85636. * The alpha value of the material
  85637. */
  85638. protected _alpha: number;
  85639. /**
  85640. * List of inspectable custom properties (used by the Inspector)
  85641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85642. */
  85643. inspectableCustomProperties: IInspectable[];
  85644. /**
  85645. * Sets the alpha value of the material
  85646. */
  85647. /**
  85648. * Gets the alpha value of the material
  85649. */
  85650. alpha: number;
  85651. /**
  85652. * Specifies if back face culling is enabled
  85653. */
  85654. protected _backFaceCulling: boolean;
  85655. /**
  85656. * Sets the back-face culling state
  85657. */
  85658. /**
  85659. * Gets the back-face culling state
  85660. */
  85661. backFaceCulling: boolean;
  85662. /**
  85663. * Stores the value for side orientation
  85664. */
  85665. sideOrientation: number;
  85666. /**
  85667. * Callback triggered when the material is compiled
  85668. */
  85669. onCompiled: Nullable<(effect: Effect) => void>;
  85670. /**
  85671. * Callback triggered when an error occurs
  85672. */
  85673. onError: Nullable<(effect: Effect, errors: string) => void>;
  85674. /**
  85675. * Callback triggered to get the render target textures
  85676. */
  85677. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85678. /**
  85679. * Gets a boolean indicating that current material needs to register RTT
  85680. */
  85681. readonly hasRenderTargetTextures: boolean;
  85682. /**
  85683. * Specifies if the material should be serialized
  85684. */
  85685. doNotSerialize: boolean;
  85686. /**
  85687. * @hidden
  85688. */
  85689. _storeEffectOnSubMeshes: boolean;
  85690. /**
  85691. * Stores the animations for the material
  85692. */
  85693. animations: Nullable<Array<Animation>>;
  85694. /**
  85695. * An event triggered when the material is disposed
  85696. */
  85697. onDisposeObservable: Observable<Material>;
  85698. /**
  85699. * An observer which watches for dispose events
  85700. */
  85701. private _onDisposeObserver;
  85702. private _onUnBindObservable;
  85703. /**
  85704. * Called during a dispose event
  85705. */
  85706. onDispose: () => void;
  85707. private _onBindObservable;
  85708. /**
  85709. * An event triggered when the material is bound
  85710. */
  85711. readonly onBindObservable: Observable<AbstractMesh>;
  85712. /**
  85713. * An observer which watches for bind events
  85714. */
  85715. private _onBindObserver;
  85716. /**
  85717. * Called during a bind event
  85718. */
  85719. onBind: (Mesh: AbstractMesh) => void;
  85720. /**
  85721. * An event triggered when the material is unbound
  85722. */
  85723. readonly onUnBindObservable: Observable<Material>;
  85724. /**
  85725. * Stores the value of the alpha mode
  85726. */
  85727. private _alphaMode;
  85728. /**
  85729. * Sets the value of the alpha mode.
  85730. *
  85731. * | Value | Type | Description |
  85732. * | --- | --- | --- |
  85733. * | 0 | ALPHA_DISABLE | |
  85734. * | 1 | ALPHA_ADD | |
  85735. * | 2 | ALPHA_COMBINE | |
  85736. * | 3 | ALPHA_SUBTRACT | |
  85737. * | 4 | ALPHA_MULTIPLY | |
  85738. * | 5 | ALPHA_MAXIMIZED | |
  85739. * | 6 | ALPHA_ONEONE | |
  85740. * | 7 | ALPHA_PREMULTIPLIED | |
  85741. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85742. * | 9 | ALPHA_INTERPOLATE | |
  85743. * | 10 | ALPHA_SCREENMODE | |
  85744. *
  85745. */
  85746. /**
  85747. * Gets the value of the alpha mode
  85748. */
  85749. alphaMode: number;
  85750. /**
  85751. * Stores the state of the need depth pre-pass value
  85752. */
  85753. private _needDepthPrePass;
  85754. /**
  85755. * Sets the need depth pre-pass value
  85756. */
  85757. /**
  85758. * Gets the depth pre-pass value
  85759. */
  85760. needDepthPrePass: boolean;
  85761. /**
  85762. * Specifies if depth writing should be disabled
  85763. */
  85764. disableDepthWrite: boolean;
  85765. /**
  85766. * Specifies if depth writing should be forced
  85767. */
  85768. forceDepthWrite: boolean;
  85769. /**
  85770. * Specifies if there should be a separate pass for culling
  85771. */
  85772. separateCullingPass: boolean;
  85773. /**
  85774. * Stores the state specifing if fog should be enabled
  85775. */
  85776. private _fogEnabled;
  85777. /**
  85778. * Sets the state for enabling fog
  85779. */
  85780. /**
  85781. * Gets the value of the fog enabled state
  85782. */
  85783. fogEnabled: boolean;
  85784. /**
  85785. * Stores the size of points
  85786. */
  85787. pointSize: number;
  85788. /**
  85789. * Stores the z offset value
  85790. */
  85791. zOffset: number;
  85792. /**
  85793. * Gets a value specifying if wireframe mode is enabled
  85794. */
  85795. /**
  85796. * Sets the state of wireframe mode
  85797. */
  85798. wireframe: boolean;
  85799. /**
  85800. * Gets the value specifying if point clouds are enabled
  85801. */
  85802. /**
  85803. * Sets the state of point cloud mode
  85804. */
  85805. pointsCloud: boolean;
  85806. /**
  85807. * Gets the material fill mode
  85808. */
  85809. /**
  85810. * Sets the material fill mode
  85811. */
  85812. fillMode: number;
  85813. /**
  85814. * @hidden
  85815. * Stores the effects for the material
  85816. */
  85817. _effect: Nullable<Effect>;
  85818. /**
  85819. * @hidden
  85820. * Specifies if the material was previously ready
  85821. */
  85822. _wasPreviouslyReady: boolean;
  85823. /**
  85824. * Specifies if uniform buffers should be used
  85825. */
  85826. private _useUBO;
  85827. /**
  85828. * Stores a reference to the scene
  85829. */
  85830. private _scene;
  85831. /**
  85832. * Stores the fill mode state
  85833. */
  85834. private _fillMode;
  85835. /**
  85836. * Specifies if the depth write state should be cached
  85837. */
  85838. private _cachedDepthWriteState;
  85839. /**
  85840. * Stores the uniform buffer
  85841. */
  85842. protected _uniformBuffer: UniformBuffer;
  85843. /** @hidden */
  85844. _indexInSceneMaterialArray: number;
  85845. /** @hidden */
  85846. meshMap: Nullable<{
  85847. [id: string]: AbstractMesh | undefined;
  85848. }>;
  85849. /**
  85850. * Creates a material instance
  85851. * @param name defines the name of the material
  85852. * @param scene defines the scene to reference
  85853. * @param doNotAdd specifies if the material should be added to the scene
  85854. */
  85855. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  85856. /**
  85857. * Returns a string representation of the current material
  85858. * @param fullDetails defines a boolean indicating which levels of logging is desired
  85859. * @returns a string with material information
  85860. */
  85861. toString(fullDetails?: boolean): string;
  85862. /**
  85863. * Gets the class name of the material
  85864. * @returns a string with the class name of the material
  85865. */
  85866. getClassName(): string;
  85867. /**
  85868. * Specifies if updates for the material been locked
  85869. */
  85870. readonly isFrozen: boolean;
  85871. /**
  85872. * Locks updates for the material
  85873. */
  85874. freeze(): void;
  85875. /**
  85876. * Unlocks updates for the material
  85877. */
  85878. unfreeze(): void;
  85879. /**
  85880. * Specifies if the material is ready to be used
  85881. * @param mesh defines the mesh to check
  85882. * @param useInstances specifies if instances should be used
  85883. * @returns a boolean indicating if the material is ready to be used
  85884. */
  85885. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85886. /**
  85887. * Specifies that the submesh is ready to be used
  85888. * @param mesh defines the mesh to check
  85889. * @param subMesh defines which submesh to check
  85890. * @param useInstances specifies that instances should be used
  85891. * @returns a boolean indicating that the submesh is ready or not
  85892. */
  85893. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85894. /**
  85895. * Returns the material effect
  85896. * @returns the effect associated with the material
  85897. */
  85898. getEffect(): Nullable<Effect>;
  85899. /**
  85900. * Returns the current scene
  85901. * @returns a Scene
  85902. */
  85903. getScene(): Scene;
  85904. /**
  85905. * Specifies if the material will require alpha blending
  85906. * @returns a boolean specifying if alpha blending is needed
  85907. */
  85908. needAlphaBlending(): boolean;
  85909. /**
  85910. * Specifies if the mesh will require alpha blending
  85911. * @param mesh defines the mesh to check
  85912. * @returns a boolean specifying if alpha blending is needed for the mesh
  85913. */
  85914. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85915. /**
  85916. * Specifies if this material should be rendered in alpha test mode
  85917. * @returns a boolean specifying if an alpha test is needed.
  85918. */
  85919. needAlphaTesting(): boolean;
  85920. /**
  85921. * Gets the texture used for the alpha test
  85922. * @returns the texture to use for alpha testing
  85923. */
  85924. getAlphaTestTexture(): Nullable<BaseTexture>;
  85925. /**
  85926. * Marks the material to indicate that it needs to be re-calculated
  85927. */
  85928. markDirty(): void;
  85929. /** @hidden */
  85930. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85931. /**
  85932. * Binds the material to the mesh
  85933. * @param world defines the world transformation matrix
  85934. * @param mesh defines the mesh to bind the material to
  85935. */
  85936. bind(world: Matrix, mesh?: Mesh): void;
  85937. /**
  85938. * Binds the submesh to the material
  85939. * @param world defines the world transformation matrix
  85940. * @param mesh defines the mesh containing the submesh
  85941. * @param subMesh defines the submesh to bind the material to
  85942. */
  85943. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85944. /**
  85945. * Binds the world matrix to the material
  85946. * @param world defines the world transformation matrix
  85947. */
  85948. bindOnlyWorldMatrix(world: Matrix): void;
  85949. /**
  85950. * Binds the scene's uniform buffer to the effect.
  85951. * @param effect defines the effect to bind to the scene uniform buffer
  85952. * @param sceneUbo defines the uniform buffer storing scene data
  85953. */
  85954. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85955. /**
  85956. * Binds the view matrix to the effect
  85957. * @param effect defines the effect to bind the view matrix to
  85958. */
  85959. bindView(effect: Effect): void;
  85960. /**
  85961. * Binds the view projection matrix to the effect
  85962. * @param effect defines the effect to bind the view projection matrix to
  85963. */
  85964. bindViewProjection(effect: Effect): void;
  85965. /**
  85966. * Specifies if material alpha testing should be turned on for the mesh
  85967. * @param mesh defines the mesh to check
  85968. */
  85969. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85970. /**
  85971. * Processes to execute after binding the material to a mesh
  85972. * @param mesh defines the rendered mesh
  85973. */
  85974. protected _afterBind(mesh?: Mesh): void;
  85975. /**
  85976. * Unbinds the material from the mesh
  85977. */
  85978. unbind(): void;
  85979. /**
  85980. * Gets the active textures from the material
  85981. * @returns an array of textures
  85982. */
  85983. getActiveTextures(): BaseTexture[];
  85984. /**
  85985. * Specifies if the material uses a texture
  85986. * @param texture defines the texture to check against the material
  85987. * @returns a boolean specifying if the material uses the texture
  85988. */
  85989. hasTexture(texture: BaseTexture): boolean;
  85990. /**
  85991. * Makes a duplicate of the material, and gives it a new name
  85992. * @param name defines the new name for the duplicated material
  85993. * @returns the cloned material
  85994. */
  85995. clone(name: string): Nullable<Material>;
  85996. /**
  85997. * Gets the meshes bound to the material
  85998. * @returns an array of meshes bound to the material
  85999. */
  86000. getBindedMeshes(): AbstractMesh[];
  86001. /**
  86002. * Force shader compilation
  86003. * @param mesh defines the mesh associated with this material
  86004. * @param onCompiled defines a function to execute once the material is compiled
  86005. * @param options defines the options to configure the compilation
  86006. */
  86007. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86008. clipPlane: boolean;
  86009. }>): void;
  86010. /**
  86011. * Force shader compilation
  86012. * @param mesh defines the mesh that will use this material
  86013. * @param options defines additional options for compiling the shaders
  86014. * @returns a promise that resolves when the compilation completes
  86015. */
  86016. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86017. clipPlane: boolean;
  86018. }>): Promise<void>;
  86019. private static readonly _AllDirtyCallBack;
  86020. private static readonly _ImageProcessingDirtyCallBack;
  86021. private static readonly _TextureDirtyCallBack;
  86022. private static readonly _FresnelDirtyCallBack;
  86023. private static readonly _MiscDirtyCallBack;
  86024. private static readonly _LightsDirtyCallBack;
  86025. private static readonly _AttributeDirtyCallBack;
  86026. private static _FresnelAndMiscDirtyCallBack;
  86027. private static _TextureAndMiscDirtyCallBack;
  86028. private static readonly _DirtyCallbackArray;
  86029. private static readonly _RunDirtyCallBacks;
  86030. /**
  86031. * Marks a define in the material to indicate that it needs to be re-computed
  86032. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86033. */
  86034. markAsDirty(flag: number): void;
  86035. /**
  86036. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86037. * @param func defines a function which checks material defines against the submeshes
  86038. */
  86039. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86040. /**
  86041. * Indicates that we need to re-calculated for all submeshes
  86042. */
  86043. protected _markAllSubMeshesAsAllDirty(): void;
  86044. /**
  86045. * Indicates that image processing needs to be re-calculated for all submeshes
  86046. */
  86047. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86048. /**
  86049. * Indicates that textures need to be re-calculated for all submeshes
  86050. */
  86051. protected _markAllSubMeshesAsTexturesDirty(): void;
  86052. /**
  86053. * Indicates that fresnel needs to be re-calculated for all submeshes
  86054. */
  86055. protected _markAllSubMeshesAsFresnelDirty(): void;
  86056. /**
  86057. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86058. */
  86059. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86060. /**
  86061. * Indicates that lights need to be re-calculated for all submeshes
  86062. */
  86063. protected _markAllSubMeshesAsLightsDirty(): void;
  86064. /**
  86065. * Indicates that attributes need to be re-calculated for all submeshes
  86066. */
  86067. protected _markAllSubMeshesAsAttributesDirty(): void;
  86068. /**
  86069. * Indicates that misc needs to be re-calculated for all submeshes
  86070. */
  86071. protected _markAllSubMeshesAsMiscDirty(): void;
  86072. /**
  86073. * Indicates that textures and misc need to be re-calculated for all submeshes
  86074. */
  86075. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86076. /**
  86077. * Disposes the material
  86078. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86079. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86080. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86081. */
  86082. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86083. /** @hidden */
  86084. private releaseVertexArrayObject;
  86085. /**
  86086. * Serializes this material
  86087. * @returns the serialized material object
  86088. */
  86089. serialize(): any;
  86090. /**
  86091. * Creates a material from parsed material data
  86092. * @param parsedMaterial defines parsed material data
  86093. * @param scene defines the hosting scene
  86094. * @param rootUrl defines the root URL to use to load textures
  86095. * @returns a new material
  86096. */
  86097. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86098. }
  86099. }
  86100. declare module BABYLON {
  86101. /**
  86102. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86103. * separate meshes. This can be use to improve performances.
  86104. * @see http://doc.babylonjs.com/how_to/multi_materials
  86105. */
  86106. export class MultiMaterial extends Material {
  86107. private _subMaterials;
  86108. /**
  86109. * Gets or Sets the list of Materials used within the multi material.
  86110. * They need to be ordered according to the submeshes order in the associated mesh
  86111. */
  86112. subMaterials: Nullable<Material>[];
  86113. /**
  86114. * Function used to align with Node.getChildren()
  86115. * @returns the list of Materials used within the multi material
  86116. */
  86117. getChildren(): Nullable<Material>[];
  86118. /**
  86119. * Instantiates a new Multi Material
  86120. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86121. * separate meshes. This can be use to improve performances.
  86122. * @see http://doc.babylonjs.com/how_to/multi_materials
  86123. * @param name Define the name in the scene
  86124. * @param scene Define the scene the material belongs to
  86125. */
  86126. constructor(name: string, scene: Scene);
  86127. private _hookArray;
  86128. /**
  86129. * Get one of the submaterial by its index in the submaterials array
  86130. * @param index The index to look the sub material at
  86131. * @returns The Material if the index has been defined
  86132. */
  86133. getSubMaterial(index: number): Nullable<Material>;
  86134. /**
  86135. * Get the list of active textures for the whole sub materials list.
  86136. * @returns All the textures that will be used during the rendering
  86137. */
  86138. getActiveTextures(): BaseTexture[];
  86139. /**
  86140. * Gets the current class name of the material e.g. "MultiMaterial"
  86141. * Mainly use in serialization.
  86142. * @returns the class name
  86143. */
  86144. getClassName(): string;
  86145. /**
  86146. * Checks if the material is ready to render the requested sub mesh
  86147. * @param mesh Define the mesh the submesh belongs to
  86148. * @param subMesh Define the sub mesh to look readyness for
  86149. * @param useInstances Define whether or not the material is used with instances
  86150. * @returns true if ready, otherwise false
  86151. */
  86152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86153. /**
  86154. * Clones the current material and its related sub materials
  86155. * @param name Define the name of the newly cloned material
  86156. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86157. * @returns the cloned material
  86158. */
  86159. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86160. /**
  86161. * Serializes the materials into a JSON representation.
  86162. * @returns the JSON representation
  86163. */
  86164. serialize(): any;
  86165. /**
  86166. * Dispose the material and release its associated resources
  86167. * @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)
  86168. * @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)
  86169. * @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)
  86170. */
  86171. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86172. /**
  86173. * Creates a MultiMaterial from parsed MultiMaterial data.
  86174. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86175. * @param scene defines the hosting scene
  86176. * @returns a new MultiMaterial
  86177. */
  86178. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86179. }
  86180. }
  86181. declare module BABYLON {
  86182. /**
  86183. * Base class for submeshes
  86184. */
  86185. export class BaseSubMesh {
  86186. /** @hidden */
  86187. _materialDefines: Nullable<MaterialDefines>;
  86188. /** @hidden */
  86189. _materialEffect: Nullable<Effect>;
  86190. /**
  86191. * Gets associated effect
  86192. */
  86193. readonly effect: Nullable<Effect>;
  86194. /**
  86195. * Sets associated effect (effect used to render this submesh)
  86196. * @param effect defines the effect to associate with
  86197. * @param defines defines the set of defines used to compile this effect
  86198. */
  86199. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86200. }
  86201. /**
  86202. * Defines a subdivision inside a mesh
  86203. */
  86204. export class SubMesh extends BaseSubMesh implements ICullable {
  86205. /** the material index to use */
  86206. materialIndex: number;
  86207. /** vertex index start */
  86208. verticesStart: number;
  86209. /** vertices count */
  86210. verticesCount: number;
  86211. /** index start */
  86212. indexStart: number;
  86213. /** indices count */
  86214. indexCount: number;
  86215. /** @hidden */
  86216. _linesIndexCount: number;
  86217. private _mesh;
  86218. private _renderingMesh;
  86219. private _boundingInfo;
  86220. private _linesIndexBuffer;
  86221. /** @hidden */
  86222. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86223. /** @hidden */
  86224. _trianglePlanes: Plane[];
  86225. /** @hidden */
  86226. _lastColliderTransformMatrix: Nullable<Matrix>;
  86227. /** @hidden */
  86228. _renderId: number;
  86229. /** @hidden */
  86230. _alphaIndex: number;
  86231. /** @hidden */
  86232. _distanceToCamera: number;
  86233. /** @hidden */
  86234. _id: number;
  86235. private _currentMaterial;
  86236. /**
  86237. * Add a new submesh to a mesh
  86238. * @param materialIndex defines the material index to use
  86239. * @param verticesStart defines vertex index start
  86240. * @param verticesCount defines vertices count
  86241. * @param indexStart defines index start
  86242. * @param indexCount defines indices count
  86243. * @param mesh defines the parent mesh
  86244. * @param renderingMesh defines an optional rendering mesh
  86245. * @param createBoundingBox defines if bounding box should be created for this submesh
  86246. * @returns the new submesh
  86247. */
  86248. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86249. /**
  86250. * Creates a new submesh
  86251. * @param materialIndex defines the material index to use
  86252. * @param verticesStart defines vertex index start
  86253. * @param verticesCount defines vertices count
  86254. * @param indexStart defines index start
  86255. * @param indexCount defines indices count
  86256. * @param mesh defines the parent mesh
  86257. * @param renderingMesh defines an optional rendering mesh
  86258. * @param createBoundingBox defines if bounding box should be created for this submesh
  86259. */
  86260. constructor(
  86261. /** the material index to use */
  86262. materialIndex: number,
  86263. /** vertex index start */
  86264. verticesStart: number,
  86265. /** vertices count */
  86266. verticesCount: number,
  86267. /** index start */
  86268. indexStart: number,
  86269. /** indices count */
  86270. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86271. /**
  86272. * Returns true if this submesh covers the entire parent mesh
  86273. * @ignorenaming
  86274. */
  86275. readonly IsGlobal: boolean;
  86276. /**
  86277. * Returns the submesh BoudingInfo object
  86278. * @returns current bounding info (or mesh's one if the submesh is global)
  86279. */
  86280. getBoundingInfo(): BoundingInfo;
  86281. /**
  86282. * Sets the submesh BoundingInfo
  86283. * @param boundingInfo defines the new bounding info to use
  86284. * @returns the SubMesh
  86285. */
  86286. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86287. /**
  86288. * Returns the mesh of the current submesh
  86289. * @return the parent mesh
  86290. */
  86291. getMesh(): AbstractMesh;
  86292. /**
  86293. * Returns the rendering mesh of the submesh
  86294. * @returns the rendering mesh (could be different from parent mesh)
  86295. */
  86296. getRenderingMesh(): Mesh;
  86297. /**
  86298. * Returns the submesh material
  86299. * @returns null or the current material
  86300. */
  86301. getMaterial(): Nullable<Material>;
  86302. /**
  86303. * Sets a new updated BoundingInfo object to the submesh
  86304. * @param data defines an optional position array to use to determine the bounding info
  86305. * @returns the SubMesh
  86306. */
  86307. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86308. /** @hidden */
  86309. _checkCollision(collider: Collider): boolean;
  86310. /**
  86311. * Updates the submesh BoundingInfo
  86312. * @param world defines the world matrix to use to update the bounding info
  86313. * @returns the submesh
  86314. */
  86315. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86316. /**
  86317. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86318. * @param frustumPlanes defines the frustum planes
  86319. * @returns true if the submesh is intersecting with the frustum
  86320. */
  86321. isInFrustum(frustumPlanes: Plane[]): boolean;
  86322. /**
  86323. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86324. * @param frustumPlanes defines the frustum planes
  86325. * @returns true if the submesh is inside the frustum
  86326. */
  86327. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86328. /**
  86329. * Renders the submesh
  86330. * @param enableAlphaMode defines if alpha needs to be used
  86331. * @returns the submesh
  86332. */
  86333. render(enableAlphaMode: boolean): SubMesh;
  86334. /**
  86335. * @hidden
  86336. */
  86337. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86338. /**
  86339. * Checks if the submesh intersects with a ray
  86340. * @param ray defines the ray to test
  86341. * @returns true is the passed ray intersects the submesh bounding box
  86342. */
  86343. canIntersects(ray: Ray): boolean;
  86344. /**
  86345. * Intersects current submesh with a ray
  86346. * @param ray defines the ray to test
  86347. * @param positions defines mesh's positions array
  86348. * @param indices defines mesh's indices array
  86349. * @param fastCheck defines if only bounding info should be used
  86350. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86351. * @returns intersection info or null if no intersection
  86352. */
  86353. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86354. /** @hidden */
  86355. private _intersectLines;
  86356. /** @hidden */
  86357. private _intersectUnIndexedLines;
  86358. /** @hidden */
  86359. private _intersectTriangles;
  86360. /** @hidden */
  86361. private _intersectUnIndexedTriangles;
  86362. /** @hidden */
  86363. _rebuild(): void;
  86364. /**
  86365. * Creates a new submesh from the passed mesh
  86366. * @param newMesh defines the new hosting mesh
  86367. * @param newRenderingMesh defines an optional rendering mesh
  86368. * @returns the new submesh
  86369. */
  86370. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86371. /**
  86372. * Release associated resources
  86373. */
  86374. dispose(): void;
  86375. /**
  86376. * Gets the class name
  86377. * @returns the string "SubMesh".
  86378. */
  86379. getClassName(): string;
  86380. /**
  86381. * Creates a new submesh from indices data
  86382. * @param materialIndex the index of the main mesh material
  86383. * @param startIndex the index where to start the copy in the mesh indices array
  86384. * @param indexCount the number of indices to copy then from the startIndex
  86385. * @param mesh the main mesh to create the submesh from
  86386. * @param renderingMesh the optional rendering mesh
  86387. * @returns a new submesh
  86388. */
  86389. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86390. }
  86391. }
  86392. declare module BABYLON {
  86393. /**
  86394. * Class used to represent data loading progression
  86395. */
  86396. export class SceneLoaderFlags {
  86397. private static _ForceFullSceneLoadingForIncremental;
  86398. private static _ShowLoadingScreen;
  86399. private static _CleanBoneMatrixWeights;
  86400. private static _loggingLevel;
  86401. /**
  86402. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86403. */
  86404. static ForceFullSceneLoadingForIncremental: boolean;
  86405. /**
  86406. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86407. */
  86408. static ShowLoadingScreen: boolean;
  86409. /**
  86410. * Defines the current logging level (while loading the scene)
  86411. * @ignorenaming
  86412. */
  86413. static loggingLevel: number;
  86414. /**
  86415. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86416. */
  86417. static CleanBoneMatrixWeights: boolean;
  86418. }
  86419. }
  86420. declare module BABYLON {
  86421. /**
  86422. * Class used to store geometry data (vertex buffers + index buffer)
  86423. */
  86424. export class Geometry implements IGetSetVerticesData {
  86425. /**
  86426. * Gets or sets the ID of the geometry
  86427. */
  86428. id: string;
  86429. /**
  86430. * Gets or sets the unique ID of the geometry
  86431. */
  86432. uniqueId: number;
  86433. /**
  86434. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86435. */
  86436. delayLoadState: number;
  86437. /**
  86438. * Gets the file containing the data to load when running in delay load state
  86439. */
  86440. delayLoadingFile: Nullable<string>;
  86441. /**
  86442. * Callback called when the geometry is updated
  86443. */
  86444. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86445. private _scene;
  86446. private _engine;
  86447. private _meshes;
  86448. private _totalVertices;
  86449. /** @hidden */
  86450. _indices: IndicesArray;
  86451. /** @hidden */
  86452. _vertexBuffers: {
  86453. [key: string]: VertexBuffer;
  86454. };
  86455. private _isDisposed;
  86456. private _extend;
  86457. private _boundingBias;
  86458. /** @hidden */
  86459. _delayInfo: Array<string>;
  86460. private _indexBuffer;
  86461. private _indexBufferIsUpdatable;
  86462. /** @hidden */
  86463. _boundingInfo: Nullable<BoundingInfo>;
  86464. /** @hidden */
  86465. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86466. /** @hidden */
  86467. _softwareSkinningFrameId: number;
  86468. private _vertexArrayObjects;
  86469. private _updatable;
  86470. /** @hidden */
  86471. _positions: Nullable<Vector3[]>;
  86472. /**
  86473. * 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
  86474. */
  86475. /**
  86476. * 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
  86477. */
  86478. boundingBias: Vector2;
  86479. /**
  86480. * Static function used to attach a new empty geometry to a mesh
  86481. * @param mesh defines the mesh to attach the geometry to
  86482. * @returns the new Geometry
  86483. */
  86484. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86485. /**
  86486. * Creates a new geometry
  86487. * @param id defines the unique ID
  86488. * @param scene defines the hosting scene
  86489. * @param vertexData defines the VertexData used to get geometry data
  86490. * @param updatable defines if geometry must be updatable (false by default)
  86491. * @param mesh defines the mesh that will be associated with the geometry
  86492. */
  86493. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86494. /**
  86495. * Gets the current extend of the geometry
  86496. */
  86497. readonly extend: {
  86498. minimum: Vector3;
  86499. maximum: Vector3;
  86500. };
  86501. /**
  86502. * Gets the hosting scene
  86503. * @returns the hosting Scene
  86504. */
  86505. getScene(): Scene;
  86506. /**
  86507. * Gets the hosting engine
  86508. * @returns the hosting Engine
  86509. */
  86510. getEngine(): Engine;
  86511. /**
  86512. * Defines if the geometry is ready to use
  86513. * @returns true if the geometry is ready to be used
  86514. */
  86515. isReady(): boolean;
  86516. /**
  86517. * Gets a value indicating that the geometry should not be serialized
  86518. */
  86519. readonly doNotSerialize: boolean;
  86520. /** @hidden */
  86521. _rebuild(): void;
  86522. /**
  86523. * Affects all geometry data in one call
  86524. * @param vertexData defines the geometry data
  86525. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86526. */
  86527. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86528. /**
  86529. * Set specific vertex data
  86530. * @param kind defines the data kind (Position, normal, etc...)
  86531. * @param data defines the vertex data to use
  86532. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86533. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86534. */
  86535. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86536. /**
  86537. * Removes a specific vertex data
  86538. * @param kind defines the data kind (Position, normal, etc...)
  86539. */
  86540. removeVerticesData(kind: string): void;
  86541. /**
  86542. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86543. * @param buffer defines the vertex buffer to use
  86544. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86545. */
  86546. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86547. /**
  86548. * Update a specific vertex buffer
  86549. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86550. * It will do nothing if the buffer is not updatable
  86551. * @param kind defines the data kind (Position, normal, etc...)
  86552. * @param data defines the data to use
  86553. * @param offset defines the offset in the target buffer where to store the data
  86554. * @param useBytes set to true if the offset is in bytes
  86555. */
  86556. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86557. /**
  86558. * Update a specific vertex buffer
  86559. * This function will create a new buffer if the current one is not updatable
  86560. * @param kind defines the data kind (Position, normal, etc...)
  86561. * @param data defines the data to use
  86562. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86563. */
  86564. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86565. private _updateBoundingInfo;
  86566. /** @hidden */
  86567. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86568. /**
  86569. * Gets total number of vertices
  86570. * @returns the total number of vertices
  86571. */
  86572. getTotalVertices(): number;
  86573. /**
  86574. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86575. * @param kind defines the data kind (Position, normal, etc...)
  86576. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86578. * @returns a float array containing vertex data
  86579. */
  86580. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86581. /**
  86582. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86583. * @param kind defines the data kind (Position, normal, etc...)
  86584. * @returns true if the vertex buffer with the specified kind is updatable
  86585. */
  86586. isVertexBufferUpdatable(kind: string): boolean;
  86587. /**
  86588. * Gets a specific vertex buffer
  86589. * @param kind defines the data kind (Position, normal, etc...)
  86590. * @returns a VertexBuffer
  86591. */
  86592. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86593. /**
  86594. * Returns all vertex buffers
  86595. * @return an object holding all vertex buffers indexed by kind
  86596. */
  86597. getVertexBuffers(): Nullable<{
  86598. [key: string]: VertexBuffer;
  86599. }>;
  86600. /**
  86601. * Gets a boolean indicating if specific vertex buffer is present
  86602. * @param kind defines the data kind (Position, normal, etc...)
  86603. * @returns true if data is present
  86604. */
  86605. isVerticesDataPresent(kind: string): boolean;
  86606. /**
  86607. * Gets a list of all attached data kinds (Position, normal, etc...)
  86608. * @returns a list of string containing all kinds
  86609. */
  86610. getVerticesDataKinds(): string[];
  86611. /**
  86612. * Update index buffer
  86613. * @param indices defines the indices to store in the index buffer
  86614. * @param offset defines the offset in the target buffer where to store the data
  86615. * @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)
  86616. */
  86617. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86618. /**
  86619. * Creates a new index buffer
  86620. * @param indices defines the indices to store in the index buffer
  86621. * @param totalVertices defines the total number of vertices (could be null)
  86622. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86623. */
  86624. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86625. /**
  86626. * Return the total number of indices
  86627. * @returns the total number of indices
  86628. */
  86629. getTotalIndices(): number;
  86630. /**
  86631. * Gets the index buffer array
  86632. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86633. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86634. * @returns the index buffer array
  86635. */
  86636. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86637. /**
  86638. * Gets the index buffer
  86639. * @return the index buffer
  86640. */
  86641. getIndexBuffer(): Nullable<DataBuffer>;
  86642. /** @hidden */
  86643. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86644. /**
  86645. * Release the associated resources for a specific mesh
  86646. * @param mesh defines the source mesh
  86647. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86648. */
  86649. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86650. /**
  86651. * Apply current geometry to a given mesh
  86652. * @param mesh defines the mesh to apply geometry to
  86653. */
  86654. applyToMesh(mesh: Mesh): void;
  86655. private _updateExtend;
  86656. private _applyToMesh;
  86657. private notifyUpdate;
  86658. /**
  86659. * Load the geometry if it was flagged as delay loaded
  86660. * @param scene defines the hosting scene
  86661. * @param onLoaded defines a callback called when the geometry is loaded
  86662. */
  86663. load(scene: Scene, onLoaded?: () => void): void;
  86664. private _queueLoad;
  86665. /**
  86666. * Invert the geometry to move from a right handed system to a left handed one.
  86667. */
  86668. toLeftHanded(): void;
  86669. /** @hidden */
  86670. _resetPointsArrayCache(): void;
  86671. /** @hidden */
  86672. _generatePointsArray(): boolean;
  86673. /**
  86674. * Gets a value indicating if the geometry is disposed
  86675. * @returns true if the geometry was disposed
  86676. */
  86677. isDisposed(): boolean;
  86678. private _disposeVertexArrayObjects;
  86679. /**
  86680. * Free all associated resources
  86681. */
  86682. dispose(): void;
  86683. /**
  86684. * Clone the current geometry into a new geometry
  86685. * @param id defines the unique ID of the new geometry
  86686. * @returns a new geometry object
  86687. */
  86688. copy(id: string): Geometry;
  86689. /**
  86690. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86691. * @return a JSON representation of the current geometry data (without the vertices data)
  86692. */
  86693. serialize(): any;
  86694. private toNumberArray;
  86695. /**
  86696. * Serialize all vertices data into a JSON oject
  86697. * @returns a JSON representation of the current geometry data
  86698. */
  86699. serializeVerticeData(): any;
  86700. /**
  86701. * Extracts a clone of a mesh geometry
  86702. * @param mesh defines the source mesh
  86703. * @param id defines the unique ID of the new geometry object
  86704. * @returns the new geometry object
  86705. */
  86706. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86707. /**
  86708. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86709. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86710. * Be aware Math.random() could cause collisions, but:
  86711. * "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"
  86712. * @returns a string containing a new GUID
  86713. */
  86714. static RandomId(): string;
  86715. /** @hidden */
  86716. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86717. private static _CleanMatricesWeights;
  86718. /**
  86719. * Create a new geometry from persisted data (Using .babylon file format)
  86720. * @param parsedVertexData defines the persisted data
  86721. * @param scene defines the hosting scene
  86722. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86723. * @returns the new geometry object
  86724. */
  86725. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86726. }
  86727. }
  86728. declare module BABYLON {
  86729. /**
  86730. * Define an interface for all classes that will get and set the data on vertices
  86731. */
  86732. export interface IGetSetVerticesData {
  86733. /**
  86734. * Gets a boolean indicating if specific vertex data is present
  86735. * @param kind defines the vertex data kind to use
  86736. * @returns true is data kind is present
  86737. */
  86738. isVerticesDataPresent(kind: string): boolean;
  86739. /**
  86740. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86741. * @param kind defines the data kind (Position, normal, etc...)
  86742. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86743. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86744. * @returns a float array containing vertex data
  86745. */
  86746. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86747. /**
  86748. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86749. * @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.
  86750. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86751. * @returns the indices array or an empty array if the mesh has no geometry
  86752. */
  86753. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86754. /**
  86755. * Set specific vertex data
  86756. * @param kind defines the data kind (Position, normal, etc...)
  86757. * @param data defines the vertex data to use
  86758. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86759. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86760. */
  86761. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86762. /**
  86763. * Update a specific associated vertex buffer
  86764. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86765. * - VertexBuffer.PositionKind
  86766. * - VertexBuffer.UVKind
  86767. * - VertexBuffer.UV2Kind
  86768. * - VertexBuffer.UV3Kind
  86769. * - VertexBuffer.UV4Kind
  86770. * - VertexBuffer.UV5Kind
  86771. * - VertexBuffer.UV6Kind
  86772. * - VertexBuffer.ColorKind
  86773. * - VertexBuffer.MatricesIndicesKind
  86774. * - VertexBuffer.MatricesIndicesExtraKind
  86775. * - VertexBuffer.MatricesWeightsKind
  86776. * - VertexBuffer.MatricesWeightsExtraKind
  86777. * @param data defines the data source
  86778. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86779. * @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)
  86780. */
  86781. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86782. /**
  86783. * Creates a new index buffer
  86784. * @param indices defines the indices to store in the index buffer
  86785. * @param totalVertices defines the total number of vertices (could be null)
  86786. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86787. */
  86788. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86789. }
  86790. /**
  86791. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86792. */
  86793. export class VertexData {
  86794. /**
  86795. * Mesh side orientation : usually the external or front surface
  86796. */
  86797. static readonly FRONTSIDE: number;
  86798. /**
  86799. * Mesh side orientation : usually the internal or back surface
  86800. */
  86801. static readonly BACKSIDE: number;
  86802. /**
  86803. * Mesh side orientation : both internal and external or front and back surfaces
  86804. */
  86805. static readonly DOUBLESIDE: number;
  86806. /**
  86807. * Mesh side orientation : by default, `FRONTSIDE`
  86808. */
  86809. static readonly DEFAULTSIDE: number;
  86810. /**
  86811. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  86812. */
  86813. positions: Nullable<FloatArray>;
  86814. /**
  86815. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  86816. */
  86817. normals: Nullable<FloatArray>;
  86818. /**
  86819. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  86820. */
  86821. tangents: Nullable<FloatArray>;
  86822. /**
  86823. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86824. */
  86825. uvs: Nullable<FloatArray>;
  86826. /**
  86827. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86828. */
  86829. uvs2: Nullable<FloatArray>;
  86830. /**
  86831. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86832. */
  86833. uvs3: Nullable<FloatArray>;
  86834. /**
  86835. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86836. */
  86837. uvs4: Nullable<FloatArray>;
  86838. /**
  86839. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86840. */
  86841. uvs5: Nullable<FloatArray>;
  86842. /**
  86843. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  86844. */
  86845. uvs6: Nullable<FloatArray>;
  86846. /**
  86847. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  86848. */
  86849. colors: Nullable<FloatArray>;
  86850. /**
  86851. * 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).
  86852. */
  86853. matricesIndices: Nullable<FloatArray>;
  86854. /**
  86855. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  86856. */
  86857. matricesWeights: Nullable<FloatArray>;
  86858. /**
  86859. * An array extending the number of possible indices
  86860. */
  86861. matricesIndicesExtra: Nullable<FloatArray>;
  86862. /**
  86863. * An array extending the number of possible weights when the number of indices is extended
  86864. */
  86865. matricesWeightsExtra: Nullable<FloatArray>;
  86866. /**
  86867. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  86868. */
  86869. indices: Nullable<IndicesArray>;
  86870. /**
  86871. * Uses the passed data array to set the set the values for the specified kind of data
  86872. * @param data a linear array of floating numbers
  86873. * @param kind the type of data that is being set, eg positions, colors etc
  86874. */
  86875. set(data: FloatArray, kind: string): void;
  86876. /**
  86877. * Associates the vertexData to the passed Mesh.
  86878. * Sets it as updatable or not (default `false`)
  86879. * @param mesh the mesh the vertexData is applied to
  86880. * @param updatable when used and having the value true allows new data to update the vertexData
  86881. * @returns the VertexData
  86882. */
  86883. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  86884. /**
  86885. * Associates the vertexData to the passed Geometry.
  86886. * Sets it as updatable or not (default `false`)
  86887. * @param geometry the geometry the vertexData is applied to
  86888. * @param updatable when used and having the value true allows new data to update the vertexData
  86889. * @returns VertexData
  86890. */
  86891. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  86892. /**
  86893. * Updates the associated mesh
  86894. * @param mesh the mesh to be updated
  86895. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86896. * @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
  86897. * @returns VertexData
  86898. */
  86899. updateMesh(mesh: Mesh): VertexData;
  86900. /**
  86901. * Updates the associated geometry
  86902. * @param geometry the geometry to be updated
  86903. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  86904. * @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
  86905. * @returns VertexData.
  86906. */
  86907. updateGeometry(geometry: Geometry): VertexData;
  86908. private _applyTo;
  86909. private _update;
  86910. /**
  86911. * Transforms each position and each normal of the vertexData according to the passed Matrix
  86912. * @param matrix the transforming matrix
  86913. * @returns the VertexData
  86914. */
  86915. transform(matrix: Matrix): VertexData;
  86916. /**
  86917. * Merges the passed VertexData into the current one
  86918. * @param other the VertexData to be merged into the current one
  86919. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  86920. * @returns the modified VertexData
  86921. */
  86922. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  86923. private _mergeElement;
  86924. private _validate;
  86925. /**
  86926. * Serializes the VertexData
  86927. * @returns a serialized object
  86928. */
  86929. serialize(): any;
  86930. /**
  86931. * Extracts the vertexData from a mesh
  86932. * @param mesh the mesh from which to extract the VertexData
  86933. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  86934. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86935. * @returns the object VertexData associated to the passed mesh
  86936. */
  86937. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86938. /**
  86939. * Extracts the vertexData from the geometry
  86940. * @param geometry the geometry from which to extract the VertexData
  86941. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  86942. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  86943. * @returns the object VertexData associated to the passed mesh
  86944. */
  86945. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  86946. private static _ExtractFrom;
  86947. /**
  86948. * Creates the VertexData for a Ribbon
  86949. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  86950. * * pathArray array of paths, each of which an array of successive Vector3
  86951. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  86952. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  86953. * * 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
  86954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86955. * * 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)
  86956. * * 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)
  86957. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  86958. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  86959. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  86960. * @returns the VertexData of the ribbon
  86961. */
  86962. static CreateRibbon(options: {
  86963. pathArray: Vector3[][];
  86964. closeArray?: boolean;
  86965. closePath?: boolean;
  86966. offset?: number;
  86967. sideOrientation?: number;
  86968. frontUVs?: Vector4;
  86969. backUVs?: Vector4;
  86970. invertUV?: boolean;
  86971. uvs?: Vector2[];
  86972. colors?: Color4[];
  86973. }): VertexData;
  86974. /**
  86975. * Creates the VertexData for a box
  86976. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86977. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86978. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86979. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86980. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86981. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86982. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86984. * * 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)
  86985. * * 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)
  86986. * @returns the VertexData of the box
  86987. */
  86988. static CreateBox(options: {
  86989. size?: number;
  86990. width?: number;
  86991. height?: number;
  86992. depth?: number;
  86993. faceUV?: Vector4[];
  86994. faceColors?: Color4[];
  86995. sideOrientation?: number;
  86996. frontUVs?: Vector4;
  86997. backUVs?: Vector4;
  86998. }): VertexData;
  86999. /**
  87000. * Creates the VertexData for a tiled box
  87001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87002. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87003. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87004. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87005. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87006. * @returns the VertexData of the box
  87007. */
  87008. static CreateTiledBox(options: {
  87009. pattern?: number;
  87010. width?: number;
  87011. height?: number;
  87012. depth?: number;
  87013. tileSize?: number;
  87014. tileWidth?: number;
  87015. tileHeight?: number;
  87016. alignHorizontal?: number;
  87017. alignVertical?: number;
  87018. faceUV?: Vector4[];
  87019. faceColors?: Color4[];
  87020. sideOrientation?: number;
  87021. }): VertexData;
  87022. /**
  87023. * Creates the VertexData for a tiled plane
  87024. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87025. * * pattern a limited pattern arrangement depending on the number
  87026. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87027. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87028. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87030. * * 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)
  87031. * * 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)
  87032. * @returns the VertexData of the tiled plane
  87033. */
  87034. static CreateTiledPlane(options: {
  87035. pattern?: number;
  87036. tileSize?: number;
  87037. tileWidth?: number;
  87038. tileHeight?: number;
  87039. size?: number;
  87040. width?: number;
  87041. height?: number;
  87042. alignHorizontal?: number;
  87043. alignVertical?: number;
  87044. sideOrientation?: number;
  87045. frontUVs?: Vector4;
  87046. backUVs?: Vector4;
  87047. }): VertexData;
  87048. /**
  87049. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87051. * * segments sets the number of horizontal strips optional, default 32
  87052. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87053. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87054. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87055. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87056. * * 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
  87057. * * 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
  87058. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87059. * * 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)
  87060. * * 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)
  87061. * @returns the VertexData of the ellipsoid
  87062. */
  87063. static CreateSphere(options: {
  87064. segments?: number;
  87065. diameter?: number;
  87066. diameterX?: number;
  87067. diameterY?: number;
  87068. diameterZ?: number;
  87069. arc?: number;
  87070. slice?: number;
  87071. sideOrientation?: number;
  87072. frontUVs?: Vector4;
  87073. backUVs?: Vector4;
  87074. }): VertexData;
  87075. /**
  87076. * Creates the VertexData for a cylinder, cone or prism
  87077. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87078. * * height sets the height (y direction) of the cylinder, optional, default 2
  87079. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87080. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87081. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87082. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87083. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87084. * * 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
  87085. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87086. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87087. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87088. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87089. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87090. * * 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)
  87091. * * 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)
  87092. * @returns the VertexData of the cylinder, cone or prism
  87093. */
  87094. static CreateCylinder(options: {
  87095. height?: number;
  87096. diameterTop?: number;
  87097. diameterBottom?: number;
  87098. diameter?: number;
  87099. tessellation?: number;
  87100. subdivisions?: number;
  87101. arc?: number;
  87102. faceColors?: Color4[];
  87103. faceUV?: Vector4[];
  87104. hasRings?: boolean;
  87105. enclose?: boolean;
  87106. sideOrientation?: number;
  87107. frontUVs?: Vector4;
  87108. backUVs?: Vector4;
  87109. }): VertexData;
  87110. /**
  87111. * Creates the VertexData for a torus
  87112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87113. * * diameter the diameter of the torus, optional default 1
  87114. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87115. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87117. * * 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)
  87118. * * 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)
  87119. * @returns the VertexData of the torus
  87120. */
  87121. static CreateTorus(options: {
  87122. diameter?: number;
  87123. thickness?: number;
  87124. tessellation?: number;
  87125. sideOrientation?: number;
  87126. frontUVs?: Vector4;
  87127. backUVs?: Vector4;
  87128. }): VertexData;
  87129. /**
  87130. * Creates the VertexData of the LineSystem
  87131. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87132. * - lines an array of lines, each line being an array of successive Vector3
  87133. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87134. * @returns the VertexData of the LineSystem
  87135. */
  87136. static CreateLineSystem(options: {
  87137. lines: Vector3[][];
  87138. colors?: Nullable<Color4[][]>;
  87139. }): VertexData;
  87140. /**
  87141. * Create the VertexData for a DashedLines
  87142. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87143. * - points an array successive Vector3
  87144. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87145. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87146. * - dashNb the intended total number of dashes, optional, default 200
  87147. * @returns the VertexData for the DashedLines
  87148. */
  87149. static CreateDashedLines(options: {
  87150. points: Vector3[];
  87151. dashSize?: number;
  87152. gapSize?: number;
  87153. dashNb?: number;
  87154. }): VertexData;
  87155. /**
  87156. * Creates the VertexData for a Ground
  87157. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87158. * - width the width (x direction) of the ground, optional, default 1
  87159. * - height the height (z direction) of the ground, optional, default 1
  87160. * - subdivisions the number of subdivisions per side, optional, default 1
  87161. * @returns the VertexData of the Ground
  87162. */
  87163. static CreateGround(options: {
  87164. width?: number;
  87165. height?: number;
  87166. subdivisions?: number;
  87167. subdivisionsX?: number;
  87168. subdivisionsY?: number;
  87169. }): VertexData;
  87170. /**
  87171. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87172. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87173. * * xmin the ground minimum X coordinate, optional, default -1
  87174. * * zmin the ground minimum Z coordinate, optional, default -1
  87175. * * xmax the ground maximum X coordinate, optional, default 1
  87176. * * zmax the ground maximum Z coordinate, optional, default 1
  87177. * * 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}
  87178. * * 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}
  87179. * @returns the VertexData of the TiledGround
  87180. */
  87181. static CreateTiledGround(options: {
  87182. xmin: number;
  87183. zmin: number;
  87184. xmax: number;
  87185. zmax: number;
  87186. subdivisions?: {
  87187. w: number;
  87188. h: number;
  87189. };
  87190. precision?: {
  87191. w: number;
  87192. h: number;
  87193. };
  87194. }): VertexData;
  87195. /**
  87196. * Creates the VertexData of the Ground designed from a heightmap
  87197. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87198. * * width the width (x direction) of the ground
  87199. * * height the height (z direction) of the ground
  87200. * * subdivisions the number of subdivisions per side
  87201. * * minHeight the minimum altitude on the ground, optional, default 0
  87202. * * maxHeight the maximum altitude on the ground, optional default 1
  87203. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87204. * * buffer the array holding the image color data
  87205. * * bufferWidth the width of image
  87206. * * bufferHeight the height of image
  87207. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87208. * @returns the VertexData of the Ground designed from a heightmap
  87209. */
  87210. static CreateGroundFromHeightMap(options: {
  87211. width: number;
  87212. height: number;
  87213. subdivisions: number;
  87214. minHeight: number;
  87215. maxHeight: number;
  87216. colorFilter: Color3;
  87217. buffer: Uint8Array;
  87218. bufferWidth: number;
  87219. bufferHeight: number;
  87220. alphaFilter: number;
  87221. }): VertexData;
  87222. /**
  87223. * Creates the VertexData for a Plane
  87224. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87225. * * size sets the width and height of the plane to the value of size, optional default 1
  87226. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87227. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87229. * * 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)
  87230. * * 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)
  87231. * @returns the VertexData of the box
  87232. */
  87233. static CreatePlane(options: {
  87234. size?: number;
  87235. width?: number;
  87236. height?: number;
  87237. sideOrientation?: number;
  87238. frontUVs?: Vector4;
  87239. backUVs?: Vector4;
  87240. }): VertexData;
  87241. /**
  87242. * Creates the VertexData of the Disc or regular Polygon
  87243. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87244. * * radius the radius of the disc, optional default 0.5
  87245. * * tessellation the number of polygon sides, optional, default 64
  87246. * * 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
  87247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87248. * * 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)
  87249. * * 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)
  87250. * @returns the VertexData of the box
  87251. */
  87252. static CreateDisc(options: {
  87253. radius?: number;
  87254. tessellation?: number;
  87255. arc?: number;
  87256. sideOrientation?: number;
  87257. frontUVs?: Vector4;
  87258. backUVs?: Vector4;
  87259. }): VertexData;
  87260. /**
  87261. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87262. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87263. * @param polygon a mesh built from polygonTriangulation.build()
  87264. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87265. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87266. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87267. * @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)
  87268. * @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)
  87269. * @returns the VertexData of the Polygon
  87270. */
  87271. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87272. /**
  87273. * Creates the VertexData of the IcoSphere
  87274. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87275. * * radius the radius of the IcoSphere, optional default 1
  87276. * * radiusX allows stretching in the x direction, optional, default radius
  87277. * * radiusY allows stretching in the y direction, optional, default radius
  87278. * * radiusZ allows stretching in the z direction, optional, default radius
  87279. * * flat when true creates a flat shaded mesh, optional, default true
  87280. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87281. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87282. * * 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)
  87283. * * 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)
  87284. * @returns the VertexData of the IcoSphere
  87285. */
  87286. static CreateIcoSphere(options: {
  87287. radius?: number;
  87288. radiusX?: number;
  87289. radiusY?: number;
  87290. radiusZ?: number;
  87291. flat?: boolean;
  87292. subdivisions?: number;
  87293. sideOrientation?: number;
  87294. frontUVs?: Vector4;
  87295. backUVs?: Vector4;
  87296. }): VertexData;
  87297. /**
  87298. * Creates the VertexData for a Polyhedron
  87299. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87300. * * type provided types are:
  87301. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87302. * * 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)
  87303. * * size the size of the IcoSphere, optional default 1
  87304. * * sizeX allows stretching in the x direction, optional, default size
  87305. * * sizeY allows stretching in the y direction, optional, default size
  87306. * * sizeZ allows stretching in the z direction, optional, default size
  87307. * * 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
  87308. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87309. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87310. * * flat when true creates a flat shaded mesh, optional, default true
  87311. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87312. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87313. * * 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)
  87314. * * 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)
  87315. * @returns the VertexData of the Polyhedron
  87316. */
  87317. static CreatePolyhedron(options: {
  87318. type?: number;
  87319. size?: number;
  87320. sizeX?: number;
  87321. sizeY?: number;
  87322. sizeZ?: number;
  87323. custom?: any;
  87324. faceUV?: Vector4[];
  87325. faceColors?: Color4[];
  87326. flat?: boolean;
  87327. sideOrientation?: number;
  87328. frontUVs?: Vector4;
  87329. backUVs?: Vector4;
  87330. }): VertexData;
  87331. /**
  87332. * Creates the VertexData for a TorusKnot
  87333. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87334. * * radius the radius of the torus knot, optional, default 2
  87335. * * tube the thickness of the tube, optional, default 0.5
  87336. * * radialSegments the number of sides on each tube segments, optional, default 32
  87337. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87338. * * p the number of windings around the z axis, optional, default 2
  87339. * * q the number of windings around the x axis, optional, default 3
  87340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87341. * * 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)
  87342. * * 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)
  87343. * @returns the VertexData of the Torus Knot
  87344. */
  87345. static CreateTorusKnot(options: {
  87346. radius?: number;
  87347. tube?: number;
  87348. radialSegments?: number;
  87349. tubularSegments?: number;
  87350. p?: number;
  87351. q?: number;
  87352. sideOrientation?: number;
  87353. frontUVs?: Vector4;
  87354. backUVs?: Vector4;
  87355. }): VertexData;
  87356. /**
  87357. * Compute normals for given positions and indices
  87358. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87359. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87360. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87361. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87362. * * facetNormals : optional array of facet normals (vector3)
  87363. * * facetPositions : optional array of facet positions (vector3)
  87364. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87365. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87366. * * bInfo : optional bounding info, required for facetPartitioning computation
  87367. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87368. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87369. * * useRightHandedSystem: optional boolean to for right handed system computation
  87370. * * depthSort : optional boolean to enable the facet depth sort computation
  87371. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87372. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87373. */
  87374. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87375. facetNormals?: any;
  87376. facetPositions?: any;
  87377. facetPartitioning?: any;
  87378. ratio?: number;
  87379. bInfo?: any;
  87380. bbSize?: Vector3;
  87381. subDiv?: any;
  87382. useRightHandedSystem?: boolean;
  87383. depthSort?: boolean;
  87384. distanceTo?: Vector3;
  87385. depthSortedFacets?: any;
  87386. }): void;
  87387. /** @hidden */
  87388. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87389. /**
  87390. * Applies VertexData created from the imported parameters to the geometry
  87391. * @param parsedVertexData the parsed data from an imported file
  87392. * @param geometry the geometry to apply the VertexData to
  87393. */
  87394. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87395. }
  87396. }
  87397. declare module BABYLON {
  87398. /**
  87399. * Defines a target to use with MorphTargetManager
  87400. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87401. */
  87402. export class MorphTarget implements IAnimatable {
  87403. /** defines the name of the target */
  87404. name: string;
  87405. /**
  87406. * Gets or sets the list of animations
  87407. */
  87408. animations: Animation[];
  87409. private _scene;
  87410. private _positions;
  87411. private _normals;
  87412. private _tangents;
  87413. private _uvs;
  87414. private _influence;
  87415. /**
  87416. * Observable raised when the influence changes
  87417. */
  87418. onInfluenceChanged: Observable<boolean>;
  87419. /** @hidden */
  87420. _onDataLayoutChanged: Observable<void>;
  87421. /**
  87422. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87423. */
  87424. influence: number;
  87425. /**
  87426. * Gets or sets the id of the morph Target
  87427. */
  87428. id: string;
  87429. private _animationPropertiesOverride;
  87430. /**
  87431. * Gets or sets the animation properties override
  87432. */
  87433. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87434. /**
  87435. * Creates a new MorphTarget
  87436. * @param name defines the name of the target
  87437. * @param influence defines the influence to use
  87438. * @param scene defines the scene the morphtarget belongs to
  87439. */
  87440. constructor(
  87441. /** defines the name of the target */
  87442. name: string, influence?: number, scene?: Nullable<Scene>);
  87443. /**
  87444. * Gets a boolean defining if the target contains position data
  87445. */
  87446. readonly hasPositions: boolean;
  87447. /**
  87448. * Gets a boolean defining if the target contains normal data
  87449. */
  87450. readonly hasNormals: boolean;
  87451. /**
  87452. * Gets a boolean defining if the target contains tangent data
  87453. */
  87454. readonly hasTangents: boolean;
  87455. /**
  87456. * Gets a boolean defining if the target contains texture coordinates data
  87457. */
  87458. readonly hasUVs: boolean;
  87459. /**
  87460. * Affects position data to this target
  87461. * @param data defines the position data to use
  87462. */
  87463. setPositions(data: Nullable<FloatArray>): void;
  87464. /**
  87465. * Gets the position data stored in this target
  87466. * @returns a FloatArray containing the position data (or null if not present)
  87467. */
  87468. getPositions(): Nullable<FloatArray>;
  87469. /**
  87470. * Affects normal data to this target
  87471. * @param data defines the normal data to use
  87472. */
  87473. setNormals(data: Nullable<FloatArray>): void;
  87474. /**
  87475. * Gets the normal data stored in this target
  87476. * @returns a FloatArray containing the normal data (or null if not present)
  87477. */
  87478. getNormals(): Nullable<FloatArray>;
  87479. /**
  87480. * Affects tangent data to this target
  87481. * @param data defines the tangent data to use
  87482. */
  87483. setTangents(data: Nullable<FloatArray>): void;
  87484. /**
  87485. * Gets the tangent data stored in this target
  87486. * @returns a FloatArray containing the tangent data (or null if not present)
  87487. */
  87488. getTangents(): Nullable<FloatArray>;
  87489. /**
  87490. * Affects texture coordinates data to this target
  87491. * @param data defines the texture coordinates data to use
  87492. */
  87493. setUVs(data: Nullable<FloatArray>): void;
  87494. /**
  87495. * Gets the texture coordinates data stored in this target
  87496. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87497. */
  87498. getUVs(): Nullable<FloatArray>;
  87499. /**
  87500. * Serializes the current target into a Serialization object
  87501. * @returns the serialized object
  87502. */
  87503. serialize(): any;
  87504. /**
  87505. * Returns the string "MorphTarget"
  87506. * @returns "MorphTarget"
  87507. */
  87508. getClassName(): string;
  87509. /**
  87510. * Creates a new target from serialized data
  87511. * @param serializationObject defines the serialized data to use
  87512. * @returns a new MorphTarget
  87513. */
  87514. static Parse(serializationObject: any): MorphTarget;
  87515. /**
  87516. * Creates a MorphTarget from mesh data
  87517. * @param mesh defines the source mesh
  87518. * @param name defines the name to use for the new target
  87519. * @param influence defines the influence to attach to the target
  87520. * @returns a new MorphTarget
  87521. */
  87522. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87523. }
  87524. }
  87525. declare module BABYLON {
  87526. /**
  87527. * This class is used to deform meshes using morphing between different targets
  87528. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87529. */
  87530. export class MorphTargetManager {
  87531. private _targets;
  87532. private _targetInfluenceChangedObservers;
  87533. private _targetDataLayoutChangedObservers;
  87534. private _activeTargets;
  87535. private _scene;
  87536. private _influences;
  87537. private _supportsNormals;
  87538. private _supportsTangents;
  87539. private _supportsUVs;
  87540. private _vertexCount;
  87541. private _uniqueId;
  87542. private _tempInfluences;
  87543. /**
  87544. * Gets or sets a boolean indicating if normals must be morphed
  87545. */
  87546. enableNormalMorphing: boolean;
  87547. /**
  87548. * Gets or sets a boolean indicating if tangents must be morphed
  87549. */
  87550. enableTangentMorphing: boolean;
  87551. /**
  87552. * Gets or sets a boolean indicating if UV must be morphed
  87553. */
  87554. enableUVMorphing: boolean;
  87555. /**
  87556. * Creates a new MorphTargetManager
  87557. * @param scene defines the current scene
  87558. */
  87559. constructor(scene?: Nullable<Scene>);
  87560. /**
  87561. * Gets the unique ID of this manager
  87562. */
  87563. readonly uniqueId: number;
  87564. /**
  87565. * Gets the number of vertices handled by this manager
  87566. */
  87567. readonly vertexCount: number;
  87568. /**
  87569. * Gets a boolean indicating if this manager supports morphing of normals
  87570. */
  87571. readonly supportsNormals: boolean;
  87572. /**
  87573. * Gets a boolean indicating if this manager supports morphing of tangents
  87574. */
  87575. readonly supportsTangents: boolean;
  87576. /**
  87577. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87578. */
  87579. readonly supportsUVs: boolean;
  87580. /**
  87581. * Gets the number of targets stored in this manager
  87582. */
  87583. readonly numTargets: number;
  87584. /**
  87585. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87586. */
  87587. readonly numInfluencers: number;
  87588. /**
  87589. * Gets the list of influences (one per target)
  87590. */
  87591. readonly influences: Float32Array;
  87592. /**
  87593. * Gets the active target at specified index. An active target is a target with an influence > 0
  87594. * @param index defines the index to check
  87595. * @returns the requested target
  87596. */
  87597. getActiveTarget(index: number): MorphTarget;
  87598. /**
  87599. * Gets the target at specified index
  87600. * @param index defines the index to check
  87601. * @returns the requested target
  87602. */
  87603. getTarget(index: number): MorphTarget;
  87604. /**
  87605. * Add a new target to this manager
  87606. * @param target defines the target to add
  87607. */
  87608. addTarget(target: MorphTarget): void;
  87609. /**
  87610. * Removes a target from the manager
  87611. * @param target defines the target to remove
  87612. */
  87613. removeTarget(target: MorphTarget): void;
  87614. /**
  87615. * Serializes the current manager into a Serialization object
  87616. * @returns the serialized object
  87617. */
  87618. serialize(): any;
  87619. private _syncActiveTargets;
  87620. /**
  87621. * Syncrhonize the targets with all the meshes using this morph target manager
  87622. */
  87623. synchronize(): void;
  87624. /**
  87625. * Creates a new MorphTargetManager from serialized data
  87626. * @param serializationObject defines the serialized data
  87627. * @param scene defines the hosting scene
  87628. * @returns the new MorphTargetManager
  87629. */
  87630. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87631. }
  87632. }
  87633. declare module BABYLON {
  87634. /**
  87635. * Class used to represent a specific level of detail of a mesh
  87636. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87637. */
  87638. export class MeshLODLevel {
  87639. /** Defines the distance where this level should start being displayed */
  87640. distance: number;
  87641. /** Defines the mesh to use to render this level */
  87642. mesh: Nullable<Mesh>;
  87643. /**
  87644. * Creates a new LOD level
  87645. * @param distance defines the distance where this level should star being displayed
  87646. * @param mesh defines the mesh to use to render this level
  87647. */
  87648. constructor(
  87649. /** Defines the distance where this level should start being displayed */
  87650. distance: number,
  87651. /** Defines the mesh to use to render this level */
  87652. mesh: Nullable<Mesh>);
  87653. }
  87654. }
  87655. declare module BABYLON {
  87656. /**
  87657. * Mesh representing the gorund
  87658. */
  87659. export class GroundMesh extends Mesh {
  87660. /** If octree should be generated */
  87661. generateOctree: boolean;
  87662. private _heightQuads;
  87663. /** @hidden */
  87664. _subdivisionsX: number;
  87665. /** @hidden */
  87666. _subdivisionsY: number;
  87667. /** @hidden */
  87668. _width: number;
  87669. /** @hidden */
  87670. _height: number;
  87671. /** @hidden */
  87672. _minX: number;
  87673. /** @hidden */
  87674. _maxX: number;
  87675. /** @hidden */
  87676. _minZ: number;
  87677. /** @hidden */
  87678. _maxZ: number;
  87679. constructor(name: string, scene: Scene);
  87680. /**
  87681. * "GroundMesh"
  87682. * @returns "GroundMesh"
  87683. */
  87684. getClassName(): string;
  87685. /**
  87686. * The minimum of x and y subdivisions
  87687. */
  87688. readonly subdivisions: number;
  87689. /**
  87690. * X subdivisions
  87691. */
  87692. readonly subdivisionsX: number;
  87693. /**
  87694. * Y subdivisions
  87695. */
  87696. readonly subdivisionsY: number;
  87697. /**
  87698. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87699. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87700. * @param chunksCount the number of subdivisions for x and y
  87701. * @param octreeBlocksSize (Default: 32)
  87702. */
  87703. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87704. /**
  87705. * Returns a height (y) value in the Worl system :
  87706. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87707. * @param x x coordinate
  87708. * @param z z coordinate
  87709. * @returns the ground y position if (x, z) are outside the ground surface.
  87710. */
  87711. getHeightAtCoordinates(x: number, z: number): number;
  87712. /**
  87713. * Returns a normalized vector (Vector3) orthogonal to the ground
  87714. * at the ground coordinates (x, z) expressed in the World system.
  87715. * @param x x coordinate
  87716. * @param z z coordinate
  87717. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87718. */
  87719. getNormalAtCoordinates(x: number, z: number): Vector3;
  87720. /**
  87721. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87722. * at the ground coordinates (x, z) expressed in the World system.
  87723. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87724. * @param x x coordinate
  87725. * @param z z coordinate
  87726. * @param ref vector to store the result
  87727. * @returns the GroundMesh.
  87728. */
  87729. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87730. /**
  87731. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87732. * if the ground has been updated.
  87733. * This can be used in the render loop.
  87734. * @returns the GroundMesh.
  87735. */
  87736. updateCoordinateHeights(): GroundMesh;
  87737. private _getFacetAt;
  87738. private _initHeightQuads;
  87739. private _computeHeightQuads;
  87740. /**
  87741. * Serializes this ground mesh
  87742. * @param serializationObject object to write serialization to
  87743. */
  87744. serialize(serializationObject: any): void;
  87745. /**
  87746. * Parses a serialized ground mesh
  87747. * @param parsedMesh the serialized mesh
  87748. * @param scene the scene to create the ground mesh in
  87749. * @returns the created ground mesh
  87750. */
  87751. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87752. }
  87753. }
  87754. declare module BABYLON {
  87755. /**
  87756. * Interface for Physics-Joint data
  87757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87758. */
  87759. export interface PhysicsJointData {
  87760. /**
  87761. * The main pivot of the joint
  87762. */
  87763. mainPivot?: Vector3;
  87764. /**
  87765. * The connected pivot of the joint
  87766. */
  87767. connectedPivot?: Vector3;
  87768. /**
  87769. * The main axis of the joint
  87770. */
  87771. mainAxis?: Vector3;
  87772. /**
  87773. * The connected axis of the joint
  87774. */
  87775. connectedAxis?: Vector3;
  87776. /**
  87777. * The collision of the joint
  87778. */
  87779. collision?: boolean;
  87780. /**
  87781. * Native Oimo/Cannon/Energy data
  87782. */
  87783. nativeParams?: any;
  87784. }
  87785. /**
  87786. * This is a holder class for the physics joint created by the physics plugin
  87787. * It holds a set of functions to control the underlying joint
  87788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87789. */
  87790. export class PhysicsJoint {
  87791. /**
  87792. * The type of the physics joint
  87793. */
  87794. type: number;
  87795. /**
  87796. * The data for the physics joint
  87797. */
  87798. jointData: PhysicsJointData;
  87799. private _physicsJoint;
  87800. protected _physicsPlugin: IPhysicsEnginePlugin;
  87801. /**
  87802. * Initializes the physics joint
  87803. * @param type The type of the physics joint
  87804. * @param jointData The data for the physics joint
  87805. */
  87806. constructor(
  87807. /**
  87808. * The type of the physics joint
  87809. */
  87810. type: number,
  87811. /**
  87812. * The data for the physics joint
  87813. */
  87814. jointData: PhysicsJointData);
  87815. /**
  87816. * Gets the physics joint
  87817. */
  87818. /**
  87819. * Sets the physics joint
  87820. */
  87821. physicsJoint: any;
  87822. /**
  87823. * Sets the physics plugin
  87824. */
  87825. physicsPlugin: IPhysicsEnginePlugin;
  87826. /**
  87827. * Execute a function that is physics-plugin specific.
  87828. * @param {Function} func the function that will be executed.
  87829. * It accepts two parameters: the physics world and the physics joint
  87830. */
  87831. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  87832. /**
  87833. * Distance-Joint type
  87834. */
  87835. static DistanceJoint: number;
  87836. /**
  87837. * Hinge-Joint type
  87838. */
  87839. static HingeJoint: number;
  87840. /**
  87841. * Ball-and-Socket joint type
  87842. */
  87843. static BallAndSocketJoint: number;
  87844. /**
  87845. * Wheel-Joint type
  87846. */
  87847. static WheelJoint: number;
  87848. /**
  87849. * Slider-Joint type
  87850. */
  87851. static SliderJoint: number;
  87852. /**
  87853. * Prismatic-Joint type
  87854. */
  87855. static PrismaticJoint: number;
  87856. /**
  87857. * Universal-Joint type
  87858. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  87859. */
  87860. static UniversalJoint: number;
  87861. /**
  87862. * Hinge-Joint 2 type
  87863. */
  87864. static Hinge2Joint: number;
  87865. /**
  87866. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  87867. */
  87868. static PointToPointJoint: number;
  87869. /**
  87870. * Spring-Joint type
  87871. */
  87872. static SpringJoint: number;
  87873. /**
  87874. * Lock-Joint type
  87875. */
  87876. static LockJoint: number;
  87877. }
  87878. /**
  87879. * A class representing a physics distance joint
  87880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87881. */
  87882. export class DistanceJoint extends PhysicsJoint {
  87883. /**
  87884. *
  87885. * @param jointData The data for the Distance-Joint
  87886. */
  87887. constructor(jointData: DistanceJointData);
  87888. /**
  87889. * Update the predefined distance.
  87890. * @param maxDistance The maximum preferred distance
  87891. * @param minDistance The minimum preferred distance
  87892. */
  87893. updateDistance(maxDistance: number, minDistance?: number): void;
  87894. }
  87895. /**
  87896. * Represents a Motor-Enabled Joint
  87897. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87898. */
  87899. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  87900. /**
  87901. * Initializes the Motor-Enabled Joint
  87902. * @param type The type of the joint
  87903. * @param jointData The physica joint data for the joint
  87904. */
  87905. constructor(type: number, jointData: PhysicsJointData);
  87906. /**
  87907. * Set the motor values.
  87908. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87909. * @param force the force to apply
  87910. * @param maxForce max force for this motor.
  87911. */
  87912. setMotor(force?: number, maxForce?: number): void;
  87913. /**
  87914. * Set the motor's limits.
  87915. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87916. * @param upperLimit The upper limit of the motor
  87917. * @param lowerLimit The lower limit of the motor
  87918. */
  87919. setLimit(upperLimit: number, lowerLimit?: number): void;
  87920. }
  87921. /**
  87922. * This class represents a single physics Hinge-Joint
  87923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87924. */
  87925. export class HingeJoint extends MotorEnabledJoint {
  87926. /**
  87927. * Initializes the Hinge-Joint
  87928. * @param jointData The joint data for the Hinge-Joint
  87929. */
  87930. constructor(jointData: PhysicsJointData);
  87931. /**
  87932. * Set the motor values.
  87933. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87934. * @param {number} force the force to apply
  87935. * @param {number} maxForce max force for this motor.
  87936. */
  87937. setMotor(force?: number, maxForce?: number): void;
  87938. /**
  87939. * Set the motor's limits.
  87940. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87941. * @param upperLimit The upper limit of the motor
  87942. * @param lowerLimit The lower limit of the motor
  87943. */
  87944. setLimit(upperLimit: number, lowerLimit?: number): void;
  87945. }
  87946. /**
  87947. * This class represents a dual hinge physics joint (same as wheel joint)
  87948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87949. */
  87950. export class Hinge2Joint extends MotorEnabledJoint {
  87951. /**
  87952. * Initializes the Hinge2-Joint
  87953. * @param jointData The joint data for the Hinge2-Joint
  87954. */
  87955. constructor(jointData: PhysicsJointData);
  87956. /**
  87957. * Set the motor values.
  87958. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87959. * @param {number} targetSpeed the speed the motor is to reach
  87960. * @param {number} maxForce max force for this motor.
  87961. * @param {motorIndex} the motor's index, 0 or 1.
  87962. */
  87963. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  87964. /**
  87965. * Set the motor limits.
  87966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  87967. * @param {number} upperLimit the upper limit
  87968. * @param {number} lowerLimit lower limit
  87969. * @param {motorIndex} the motor's index, 0 or 1.
  87970. */
  87971. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87972. }
  87973. /**
  87974. * Interface for a motor enabled joint
  87975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87976. */
  87977. export interface IMotorEnabledJoint {
  87978. /**
  87979. * Physics joint
  87980. */
  87981. physicsJoint: any;
  87982. /**
  87983. * Sets the motor of the motor-enabled joint
  87984. * @param force The force of the motor
  87985. * @param maxForce The maximum force of the motor
  87986. * @param motorIndex The index of the motor
  87987. */
  87988. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  87989. /**
  87990. * Sets the limit of the motor
  87991. * @param upperLimit The upper limit of the motor
  87992. * @param lowerLimit The lower limit of the motor
  87993. * @param motorIndex The index of the motor
  87994. */
  87995. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  87996. }
  87997. /**
  87998. * Joint data for a Distance-Joint
  87999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88000. */
  88001. export interface DistanceJointData extends PhysicsJointData {
  88002. /**
  88003. * Max distance the 2 joint objects can be apart
  88004. */
  88005. maxDistance: number;
  88006. }
  88007. /**
  88008. * Joint data from a spring joint
  88009. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88010. */
  88011. export interface SpringJointData extends PhysicsJointData {
  88012. /**
  88013. * Length of the spring
  88014. */
  88015. length: number;
  88016. /**
  88017. * Stiffness of the spring
  88018. */
  88019. stiffness: number;
  88020. /**
  88021. * Damping of the spring
  88022. */
  88023. damping: number;
  88024. /** this callback will be called when applying the force to the impostors. */
  88025. forceApplicationCallback: () => void;
  88026. }
  88027. }
  88028. declare module BABYLON {
  88029. /**
  88030. * Holds the data for the raycast result
  88031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88032. */
  88033. export class PhysicsRaycastResult {
  88034. private _hasHit;
  88035. private _hitDistance;
  88036. private _hitNormalWorld;
  88037. private _hitPointWorld;
  88038. private _rayFromWorld;
  88039. private _rayToWorld;
  88040. /**
  88041. * Gets if there was a hit
  88042. */
  88043. readonly hasHit: boolean;
  88044. /**
  88045. * Gets the distance from the hit
  88046. */
  88047. readonly hitDistance: number;
  88048. /**
  88049. * Gets the hit normal/direction in the world
  88050. */
  88051. readonly hitNormalWorld: Vector3;
  88052. /**
  88053. * Gets the hit point in the world
  88054. */
  88055. readonly hitPointWorld: Vector3;
  88056. /**
  88057. * Gets the ray "start point" of the ray in the world
  88058. */
  88059. readonly rayFromWorld: Vector3;
  88060. /**
  88061. * Gets the ray "end point" of the ray in the world
  88062. */
  88063. readonly rayToWorld: Vector3;
  88064. /**
  88065. * Sets the hit data (normal & point in world space)
  88066. * @param hitNormalWorld defines the normal in world space
  88067. * @param hitPointWorld defines the point in world space
  88068. */
  88069. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88070. /**
  88071. * Sets the distance from the start point to the hit point
  88072. * @param distance
  88073. */
  88074. setHitDistance(distance: number): void;
  88075. /**
  88076. * Calculates the distance manually
  88077. */
  88078. calculateHitDistance(): void;
  88079. /**
  88080. * Resets all the values to default
  88081. * @param from The from point on world space
  88082. * @param to The to point on world space
  88083. */
  88084. reset(from?: Vector3, to?: Vector3): void;
  88085. }
  88086. /**
  88087. * Interface for the size containing width and height
  88088. */
  88089. interface IXYZ {
  88090. /**
  88091. * X
  88092. */
  88093. x: number;
  88094. /**
  88095. * Y
  88096. */
  88097. y: number;
  88098. /**
  88099. * Z
  88100. */
  88101. z: number;
  88102. }
  88103. }
  88104. declare module BABYLON {
  88105. /**
  88106. * Interface used to describe a physics joint
  88107. */
  88108. export interface PhysicsImpostorJoint {
  88109. /** Defines the main impostor to which the joint is linked */
  88110. mainImpostor: PhysicsImpostor;
  88111. /** Defines the impostor that is connected to the main impostor using this joint */
  88112. connectedImpostor: PhysicsImpostor;
  88113. /** Defines the joint itself */
  88114. joint: PhysicsJoint;
  88115. }
  88116. /** @hidden */
  88117. export interface IPhysicsEnginePlugin {
  88118. world: any;
  88119. name: string;
  88120. setGravity(gravity: Vector3): void;
  88121. setTimeStep(timeStep: number): void;
  88122. getTimeStep(): number;
  88123. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88124. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88125. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88126. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88127. removePhysicsBody(impostor: PhysicsImpostor): void;
  88128. generateJoint(joint: PhysicsImpostorJoint): void;
  88129. removeJoint(joint: PhysicsImpostorJoint): void;
  88130. isSupported(): boolean;
  88131. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88132. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88133. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88134. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88135. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88136. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88137. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88138. getBodyMass(impostor: PhysicsImpostor): number;
  88139. getBodyFriction(impostor: PhysicsImpostor): number;
  88140. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88141. getBodyRestitution(impostor: PhysicsImpostor): number;
  88142. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88143. getBodyPressure?(impostor: PhysicsImpostor): number;
  88144. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88145. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88146. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88147. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88148. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88149. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88150. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88151. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88152. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88153. sleepBody(impostor: PhysicsImpostor): void;
  88154. wakeUpBody(impostor: PhysicsImpostor): void;
  88155. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88156. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88157. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88158. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88159. getRadius(impostor: PhysicsImpostor): number;
  88160. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88161. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88162. dispose(): void;
  88163. }
  88164. /**
  88165. * Interface used to define a physics engine
  88166. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88167. */
  88168. export interface IPhysicsEngine {
  88169. /**
  88170. * Gets the gravity vector used by the simulation
  88171. */
  88172. gravity: Vector3;
  88173. /**
  88174. * Sets the gravity vector used by the simulation
  88175. * @param gravity defines the gravity vector to use
  88176. */
  88177. setGravity(gravity: Vector3): void;
  88178. /**
  88179. * Set the time step of the physics engine.
  88180. * Default is 1/60.
  88181. * To slow it down, enter 1/600 for example.
  88182. * To speed it up, 1/30
  88183. * @param newTimeStep the new timestep to apply to this world.
  88184. */
  88185. setTimeStep(newTimeStep: number): void;
  88186. /**
  88187. * Get the time step of the physics engine.
  88188. * @returns the current time step
  88189. */
  88190. getTimeStep(): number;
  88191. /**
  88192. * Release all resources
  88193. */
  88194. dispose(): void;
  88195. /**
  88196. * Gets the name of the current physics plugin
  88197. * @returns the name of the plugin
  88198. */
  88199. getPhysicsPluginName(): string;
  88200. /**
  88201. * Adding a new impostor for the impostor tracking.
  88202. * This will be done by the impostor itself.
  88203. * @param impostor the impostor to add
  88204. */
  88205. addImpostor(impostor: PhysicsImpostor): void;
  88206. /**
  88207. * Remove an impostor from the engine.
  88208. * This impostor and its mesh will not longer be updated by the physics engine.
  88209. * @param impostor the impostor to remove
  88210. */
  88211. removeImpostor(impostor: PhysicsImpostor): void;
  88212. /**
  88213. * Add a joint to the physics engine
  88214. * @param mainImpostor defines the main impostor to which the joint is added.
  88215. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88216. * @param joint defines the joint that will connect both impostors.
  88217. */
  88218. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88219. /**
  88220. * Removes a joint from the simulation
  88221. * @param mainImpostor defines the impostor used with the joint
  88222. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88223. * @param joint defines the joint to remove
  88224. */
  88225. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88226. /**
  88227. * Gets the current plugin used to run the simulation
  88228. * @returns current plugin
  88229. */
  88230. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88231. /**
  88232. * Gets the list of physic impostors
  88233. * @returns an array of PhysicsImpostor
  88234. */
  88235. getImpostors(): Array<PhysicsImpostor>;
  88236. /**
  88237. * Gets the impostor for a physics enabled object
  88238. * @param object defines the object impersonated by the impostor
  88239. * @returns the PhysicsImpostor or null if not found
  88240. */
  88241. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88242. /**
  88243. * Gets the impostor for a physics body object
  88244. * @param body defines physics body used by the impostor
  88245. * @returns the PhysicsImpostor or null if not found
  88246. */
  88247. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88248. /**
  88249. * Does a raycast in the physics world
  88250. * @param from when should the ray start?
  88251. * @param to when should the ray end?
  88252. * @returns PhysicsRaycastResult
  88253. */
  88254. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88255. /**
  88256. * Called by the scene. No need to call it.
  88257. * @param delta defines the timespam between frames
  88258. */
  88259. _step(delta: number): void;
  88260. }
  88261. }
  88262. declare module BABYLON {
  88263. /**
  88264. * The interface for the physics imposter parameters
  88265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88266. */
  88267. export interface PhysicsImpostorParameters {
  88268. /**
  88269. * The mass of the physics imposter
  88270. */
  88271. mass: number;
  88272. /**
  88273. * The friction of the physics imposter
  88274. */
  88275. friction?: number;
  88276. /**
  88277. * The coefficient of restitution of the physics imposter
  88278. */
  88279. restitution?: number;
  88280. /**
  88281. * The native options of the physics imposter
  88282. */
  88283. nativeOptions?: any;
  88284. /**
  88285. * Specifies if the parent should be ignored
  88286. */
  88287. ignoreParent?: boolean;
  88288. /**
  88289. * Specifies if bi-directional transformations should be disabled
  88290. */
  88291. disableBidirectionalTransformation?: boolean;
  88292. /**
  88293. * The pressure inside the physics imposter, soft object only
  88294. */
  88295. pressure?: number;
  88296. /**
  88297. * The stiffness the physics imposter, soft object only
  88298. */
  88299. stiffness?: number;
  88300. /**
  88301. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88302. */
  88303. velocityIterations?: number;
  88304. /**
  88305. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88306. */
  88307. positionIterations?: number;
  88308. /**
  88309. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88310. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88311. * Add to fix multiple points
  88312. */
  88313. fixedPoints?: number;
  88314. /**
  88315. * The collision margin around a soft object
  88316. */
  88317. margin?: number;
  88318. /**
  88319. * The collision margin around a soft object
  88320. */
  88321. damping?: number;
  88322. /**
  88323. * The path for a rope based on an extrusion
  88324. */
  88325. path?: any;
  88326. /**
  88327. * The shape of an extrusion used for a rope based on an extrusion
  88328. */
  88329. shape?: any;
  88330. }
  88331. /**
  88332. * Interface for a physics-enabled object
  88333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88334. */
  88335. export interface IPhysicsEnabledObject {
  88336. /**
  88337. * The position of the physics-enabled object
  88338. */
  88339. position: Vector3;
  88340. /**
  88341. * The rotation of the physics-enabled object
  88342. */
  88343. rotationQuaternion: Nullable<Quaternion>;
  88344. /**
  88345. * The scale of the physics-enabled object
  88346. */
  88347. scaling: Vector3;
  88348. /**
  88349. * The rotation of the physics-enabled object
  88350. */
  88351. rotation?: Vector3;
  88352. /**
  88353. * The parent of the physics-enabled object
  88354. */
  88355. parent?: any;
  88356. /**
  88357. * The bounding info of the physics-enabled object
  88358. * @returns The bounding info of the physics-enabled object
  88359. */
  88360. getBoundingInfo(): BoundingInfo;
  88361. /**
  88362. * Computes the world matrix
  88363. * @param force Specifies if the world matrix should be computed by force
  88364. * @returns A world matrix
  88365. */
  88366. computeWorldMatrix(force: boolean): Matrix;
  88367. /**
  88368. * Gets the world matrix
  88369. * @returns A world matrix
  88370. */
  88371. getWorldMatrix?(): Matrix;
  88372. /**
  88373. * Gets the child meshes
  88374. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88375. * @returns An array of abstract meshes
  88376. */
  88377. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88378. /**
  88379. * Gets the vertex data
  88380. * @param kind The type of vertex data
  88381. * @returns A nullable array of numbers, or a float32 array
  88382. */
  88383. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88384. /**
  88385. * Gets the indices from the mesh
  88386. * @returns A nullable array of index arrays
  88387. */
  88388. getIndices?(): Nullable<IndicesArray>;
  88389. /**
  88390. * Gets the scene from the mesh
  88391. * @returns the indices array or null
  88392. */
  88393. getScene?(): Scene;
  88394. /**
  88395. * Gets the absolute position from the mesh
  88396. * @returns the absolute position
  88397. */
  88398. getAbsolutePosition(): Vector3;
  88399. /**
  88400. * Gets the absolute pivot point from the mesh
  88401. * @returns the absolute pivot point
  88402. */
  88403. getAbsolutePivotPoint(): Vector3;
  88404. /**
  88405. * Rotates the mesh
  88406. * @param axis The axis of rotation
  88407. * @param amount The amount of rotation
  88408. * @param space The space of the rotation
  88409. * @returns The rotation transform node
  88410. */
  88411. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88412. /**
  88413. * Translates the mesh
  88414. * @param axis The axis of translation
  88415. * @param distance The distance of translation
  88416. * @param space The space of the translation
  88417. * @returns The transform node
  88418. */
  88419. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88420. /**
  88421. * Sets the absolute position of the mesh
  88422. * @param absolutePosition The absolute position of the mesh
  88423. * @returns The transform node
  88424. */
  88425. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88426. /**
  88427. * Gets the class name of the mesh
  88428. * @returns The class name
  88429. */
  88430. getClassName(): string;
  88431. }
  88432. /**
  88433. * Represents a physics imposter
  88434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88435. */
  88436. export class PhysicsImpostor {
  88437. /**
  88438. * The physics-enabled object used as the physics imposter
  88439. */
  88440. object: IPhysicsEnabledObject;
  88441. /**
  88442. * The type of the physics imposter
  88443. */
  88444. type: number;
  88445. private _options;
  88446. private _scene?;
  88447. /**
  88448. * The default object size of the imposter
  88449. */
  88450. static DEFAULT_OBJECT_SIZE: Vector3;
  88451. /**
  88452. * The identity quaternion of the imposter
  88453. */
  88454. static IDENTITY_QUATERNION: Quaternion;
  88455. /** @hidden */
  88456. _pluginData: any;
  88457. private _physicsEngine;
  88458. private _physicsBody;
  88459. private _bodyUpdateRequired;
  88460. private _onBeforePhysicsStepCallbacks;
  88461. private _onAfterPhysicsStepCallbacks;
  88462. /** @hidden */
  88463. _onPhysicsCollideCallbacks: Array<{
  88464. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88465. otherImpostors: Array<PhysicsImpostor>;
  88466. }>;
  88467. private _deltaPosition;
  88468. private _deltaRotation;
  88469. private _deltaRotationConjugated;
  88470. /** @hidden */
  88471. _isFromLine: boolean;
  88472. private _parent;
  88473. private _isDisposed;
  88474. private static _tmpVecs;
  88475. private static _tmpQuat;
  88476. /**
  88477. * Specifies if the physics imposter is disposed
  88478. */
  88479. readonly isDisposed: boolean;
  88480. /**
  88481. * Gets the mass of the physics imposter
  88482. */
  88483. mass: number;
  88484. /**
  88485. * Gets the coefficient of friction
  88486. */
  88487. /**
  88488. * Sets the coefficient of friction
  88489. */
  88490. friction: number;
  88491. /**
  88492. * Gets the coefficient of restitution
  88493. */
  88494. /**
  88495. * Sets the coefficient of restitution
  88496. */
  88497. restitution: number;
  88498. /**
  88499. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88500. */
  88501. /**
  88502. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88503. */
  88504. pressure: number;
  88505. /**
  88506. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88507. */
  88508. /**
  88509. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88510. */
  88511. stiffness: number;
  88512. /**
  88513. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88514. */
  88515. /**
  88516. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88517. */
  88518. velocityIterations: number;
  88519. /**
  88520. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88521. */
  88522. /**
  88523. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88524. */
  88525. positionIterations: number;
  88526. /**
  88527. * The unique id of the physics imposter
  88528. * set by the physics engine when adding this impostor to the array
  88529. */
  88530. uniqueId: number;
  88531. /**
  88532. * @hidden
  88533. */
  88534. soft: boolean;
  88535. /**
  88536. * @hidden
  88537. */
  88538. segments: number;
  88539. private _joints;
  88540. /**
  88541. * Initializes the physics imposter
  88542. * @param object The physics-enabled object used as the physics imposter
  88543. * @param type The type of the physics imposter
  88544. * @param _options The options for the physics imposter
  88545. * @param _scene The Babylon scene
  88546. */
  88547. constructor(
  88548. /**
  88549. * The physics-enabled object used as the physics imposter
  88550. */
  88551. object: IPhysicsEnabledObject,
  88552. /**
  88553. * The type of the physics imposter
  88554. */
  88555. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88556. /**
  88557. * This function will completly initialize this impostor.
  88558. * It will create a new body - but only if this mesh has no parent.
  88559. * If it has, this impostor will not be used other than to define the impostor
  88560. * of the child mesh.
  88561. * @hidden
  88562. */
  88563. _init(): void;
  88564. private _getPhysicsParent;
  88565. /**
  88566. * Should a new body be generated.
  88567. * @returns boolean specifying if body initialization is required
  88568. */
  88569. isBodyInitRequired(): boolean;
  88570. /**
  88571. * Sets the updated scaling
  88572. * @param updated Specifies if the scaling is updated
  88573. */
  88574. setScalingUpdated(): void;
  88575. /**
  88576. * Force a regeneration of this or the parent's impostor's body.
  88577. * Use under cautious - This will remove all joints already implemented.
  88578. */
  88579. forceUpdate(): void;
  88580. /**
  88581. * Gets the body that holds this impostor. Either its own, or its parent.
  88582. */
  88583. /**
  88584. * Set the physics body. Used mainly by the physics engine/plugin
  88585. */
  88586. physicsBody: any;
  88587. /**
  88588. * Get the parent of the physics imposter
  88589. * @returns Physics imposter or null
  88590. */
  88591. /**
  88592. * Sets the parent of the physics imposter
  88593. */
  88594. parent: Nullable<PhysicsImpostor>;
  88595. /**
  88596. * Resets the update flags
  88597. */
  88598. resetUpdateFlags(): void;
  88599. /**
  88600. * Gets the object extend size
  88601. * @returns the object extend size
  88602. */
  88603. getObjectExtendSize(): Vector3;
  88604. /**
  88605. * Gets the object center
  88606. * @returns The object center
  88607. */
  88608. getObjectCenter(): Vector3;
  88609. /**
  88610. * Get a specific parametes from the options parameter
  88611. * @param paramName The object parameter name
  88612. * @returns The object parameter
  88613. */
  88614. getParam(paramName: string): any;
  88615. /**
  88616. * Sets a specific parameter in the options given to the physics plugin
  88617. * @param paramName The parameter name
  88618. * @param value The value of the parameter
  88619. */
  88620. setParam(paramName: string, value: number): void;
  88621. /**
  88622. * Specifically change the body's mass option. Won't recreate the physics body object
  88623. * @param mass The mass of the physics imposter
  88624. */
  88625. setMass(mass: number): void;
  88626. /**
  88627. * Gets the linear velocity
  88628. * @returns linear velocity or null
  88629. */
  88630. getLinearVelocity(): Nullable<Vector3>;
  88631. /**
  88632. * Sets the linear velocity
  88633. * @param velocity linear velocity or null
  88634. */
  88635. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88636. /**
  88637. * Gets the angular velocity
  88638. * @returns angular velocity or null
  88639. */
  88640. getAngularVelocity(): Nullable<Vector3>;
  88641. /**
  88642. * Sets the angular velocity
  88643. * @param velocity The velocity or null
  88644. */
  88645. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88646. /**
  88647. * Execute a function with the physics plugin native code
  88648. * Provide a function the will have two variables - the world object and the physics body object
  88649. * @param func The function to execute with the physics plugin native code
  88650. */
  88651. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88652. /**
  88653. * Register a function that will be executed before the physics world is stepping forward
  88654. * @param func The function to execute before the physics world is stepped forward
  88655. */
  88656. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88657. /**
  88658. * Unregister a function that will be executed before the physics world is stepping forward
  88659. * @param func The function to execute before the physics world is stepped forward
  88660. */
  88661. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88662. /**
  88663. * Register a function that will be executed after the physics step
  88664. * @param func The function to execute after physics step
  88665. */
  88666. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88667. /**
  88668. * Unregisters a function that will be executed after the physics step
  88669. * @param func The function to execute after physics step
  88670. */
  88671. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88672. /**
  88673. * register a function that will be executed when this impostor collides against a different body
  88674. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88675. * @param func Callback that is executed on collision
  88676. */
  88677. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88678. /**
  88679. * Unregisters the physics imposter on contact
  88680. * @param collideAgainst The physics object to collide against
  88681. * @param func Callback to execute on collision
  88682. */
  88683. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88684. private _tmpQuat;
  88685. private _tmpQuat2;
  88686. /**
  88687. * Get the parent rotation
  88688. * @returns The parent rotation
  88689. */
  88690. getParentsRotation(): Quaternion;
  88691. /**
  88692. * this function is executed by the physics engine.
  88693. */
  88694. beforeStep: () => void;
  88695. /**
  88696. * this function is executed by the physics engine
  88697. */
  88698. afterStep: () => void;
  88699. /**
  88700. * Legacy collision detection event support
  88701. */
  88702. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88703. /**
  88704. * event and body object due to cannon's event-based architecture.
  88705. */
  88706. onCollide: (e: {
  88707. body: any;
  88708. }) => void;
  88709. /**
  88710. * Apply a force
  88711. * @param force The force to apply
  88712. * @param contactPoint The contact point for the force
  88713. * @returns The physics imposter
  88714. */
  88715. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88716. /**
  88717. * Apply an impulse
  88718. * @param force The impulse force
  88719. * @param contactPoint The contact point for the impulse force
  88720. * @returns The physics imposter
  88721. */
  88722. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88723. /**
  88724. * A help function to create a joint
  88725. * @param otherImpostor A physics imposter used to create a joint
  88726. * @param jointType The type of joint
  88727. * @param jointData The data for the joint
  88728. * @returns The physics imposter
  88729. */
  88730. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88731. /**
  88732. * Add a joint to this impostor with a different impostor
  88733. * @param otherImpostor A physics imposter used to add a joint
  88734. * @param joint The joint to add
  88735. * @returns The physics imposter
  88736. */
  88737. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88738. /**
  88739. * Add an anchor to a cloth impostor
  88740. * @param otherImpostor rigid impostor to anchor to
  88741. * @param width ratio across width from 0 to 1
  88742. * @param height ratio up height from 0 to 1
  88743. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88744. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88745. * @returns impostor the soft imposter
  88746. */
  88747. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88748. /**
  88749. * Add a hook to a rope impostor
  88750. * @param otherImpostor rigid impostor to anchor to
  88751. * @param length ratio across rope from 0 to 1
  88752. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88753. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88754. * @returns impostor the rope imposter
  88755. */
  88756. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88757. /**
  88758. * Will keep this body still, in a sleep mode.
  88759. * @returns the physics imposter
  88760. */
  88761. sleep(): PhysicsImpostor;
  88762. /**
  88763. * Wake the body up.
  88764. * @returns The physics imposter
  88765. */
  88766. wakeUp(): PhysicsImpostor;
  88767. /**
  88768. * Clones the physics imposter
  88769. * @param newObject The physics imposter clones to this physics-enabled object
  88770. * @returns A nullable physics imposter
  88771. */
  88772. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88773. /**
  88774. * Disposes the physics imposter
  88775. */
  88776. dispose(): void;
  88777. /**
  88778. * Sets the delta position
  88779. * @param position The delta position amount
  88780. */
  88781. setDeltaPosition(position: Vector3): void;
  88782. /**
  88783. * Sets the delta rotation
  88784. * @param rotation The delta rotation amount
  88785. */
  88786. setDeltaRotation(rotation: Quaternion): void;
  88787. /**
  88788. * Gets the box size of the physics imposter and stores the result in the input parameter
  88789. * @param result Stores the box size
  88790. * @returns The physics imposter
  88791. */
  88792. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88793. /**
  88794. * Gets the radius of the physics imposter
  88795. * @returns Radius of the physics imposter
  88796. */
  88797. getRadius(): number;
  88798. /**
  88799. * Sync a bone with this impostor
  88800. * @param bone The bone to sync to the impostor.
  88801. * @param boneMesh The mesh that the bone is influencing.
  88802. * @param jointPivot The pivot of the joint / bone in local space.
  88803. * @param distToJoint Optional distance from the impostor to the joint.
  88804. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88805. */
  88806. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88807. /**
  88808. * Sync impostor to a bone
  88809. * @param bone The bone that the impostor will be synced to.
  88810. * @param boneMesh The mesh that the bone is influencing.
  88811. * @param jointPivot The pivot of the joint / bone in local space.
  88812. * @param distToJoint Optional distance from the impostor to the joint.
  88813. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88814. * @param boneAxis Optional vector3 axis the bone is aligned with
  88815. */
  88816. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  88817. /**
  88818. * No-Imposter type
  88819. */
  88820. static NoImpostor: number;
  88821. /**
  88822. * Sphere-Imposter type
  88823. */
  88824. static SphereImpostor: number;
  88825. /**
  88826. * Box-Imposter type
  88827. */
  88828. static BoxImpostor: number;
  88829. /**
  88830. * Plane-Imposter type
  88831. */
  88832. static PlaneImpostor: number;
  88833. /**
  88834. * Mesh-imposter type
  88835. */
  88836. static MeshImpostor: number;
  88837. /**
  88838. * Capsule-Impostor type (Ammo.js plugin only)
  88839. */
  88840. static CapsuleImpostor: number;
  88841. /**
  88842. * Cylinder-Imposter type
  88843. */
  88844. static CylinderImpostor: number;
  88845. /**
  88846. * Particle-Imposter type
  88847. */
  88848. static ParticleImpostor: number;
  88849. /**
  88850. * Heightmap-Imposter type
  88851. */
  88852. static HeightmapImpostor: number;
  88853. /**
  88854. * ConvexHull-Impostor type (Ammo.js plugin only)
  88855. */
  88856. static ConvexHullImpostor: number;
  88857. /**
  88858. * Rope-Imposter type
  88859. */
  88860. static RopeImpostor: number;
  88861. /**
  88862. * Cloth-Imposter type
  88863. */
  88864. static ClothImpostor: number;
  88865. /**
  88866. * Softbody-Imposter type
  88867. */
  88868. static SoftbodyImpostor: number;
  88869. }
  88870. }
  88871. declare module BABYLON {
  88872. /**
  88873. * @hidden
  88874. **/
  88875. export class _CreationDataStorage {
  88876. closePath?: boolean;
  88877. closeArray?: boolean;
  88878. idx: number[];
  88879. dashSize: number;
  88880. gapSize: number;
  88881. path3D: Path3D;
  88882. pathArray: Vector3[][];
  88883. arc: number;
  88884. radius: number;
  88885. cap: number;
  88886. tessellation: number;
  88887. }
  88888. /**
  88889. * @hidden
  88890. **/
  88891. class _InstanceDataStorage {
  88892. visibleInstances: any;
  88893. batchCache: _InstancesBatch;
  88894. instancesBufferSize: number;
  88895. instancesBuffer: Nullable<Buffer>;
  88896. instancesData: Float32Array;
  88897. overridenInstanceCount: number;
  88898. isFrozen: boolean;
  88899. previousBatch: Nullable<_InstancesBatch>;
  88900. hardwareInstancedRendering: boolean;
  88901. sideOrientation: number;
  88902. }
  88903. /**
  88904. * @hidden
  88905. **/
  88906. export class _InstancesBatch {
  88907. mustReturn: boolean;
  88908. visibleInstances: Nullable<InstancedMesh[]>[];
  88909. renderSelf: boolean[];
  88910. hardwareInstancedRendering: boolean[];
  88911. }
  88912. /**
  88913. * Class used to represent renderable models
  88914. */
  88915. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  88916. /**
  88917. * Mesh side orientation : usually the external or front surface
  88918. */
  88919. static readonly FRONTSIDE: number;
  88920. /**
  88921. * Mesh side orientation : usually the internal or back surface
  88922. */
  88923. static readonly BACKSIDE: number;
  88924. /**
  88925. * Mesh side orientation : both internal and external or front and back surfaces
  88926. */
  88927. static readonly DOUBLESIDE: number;
  88928. /**
  88929. * Mesh side orientation : by default, `FRONTSIDE`
  88930. */
  88931. static readonly DEFAULTSIDE: number;
  88932. /**
  88933. * Mesh cap setting : no cap
  88934. */
  88935. static readonly NO_CAP: number;
  88936. /**
  88937. * Mesh cap setting : one cap at the beginning of the mesh
  88938. */
  88939. static readonly CAP_START: number;
  88940. /**
  88941. * Mesh cap setting : one cap at the end of the mesh
  88942. */
  88943. static readonly CAP_END: number;
  88944. /**
  88945. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  88946. */
  88947. static readonly CAP_ALL: number;
  88948. /**
  88949. * Mesh pattern setting : no flip or rotate
  88950. */
  88951. static readonly NO_FLIP: number;
  88952. /**
  88953. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  88954. */
  88955. static readonly FLIP_TILE: number;
  88956. /**
  88957. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  88958. */
  88959. static readonly ROTATE_TILE: number;
  88960. /**
  88961. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  88962. */
  88963. static readonly FLIP_ROW: number;
  88964. /**
  88965. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  88966. */
  88967. static readonly ROTATE_ROW: number;
  88968. /**
  88969. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  88970. */
  88971. static readonly FLIP_N_ROTATE_TILE: number;
  88972. /**
  88973. * Mesh pattern setting : rotate pattern and rotate
  88974. */
  88975. static readonly FLIP_N_ROTATE_ROW: number;
  88976. /**
  88977. * Mesh tile positioning : part tiles same on left/right or top/bottom
  88978. */
  88979. static readonly CENTER: number;
  88980. /**
  88981. * Mesh tile positioning : part tiles on left
  88982. */
  88983. static readonly LEFT: number;
  88984. /**
  88985. * Mesh tile positioning : part tiles on right
  88986. */
  88987. static readonly RIGHT: number;
  88988. /**
  88989. * Mesh tile positioning : part tiles on top
  88990. */
  88991. static readonly TOP: number;
  88992. /**
  88993. * Mesh tile positioning : part tiles on bottom
  88994. */
  88995. static readonly BOTTOM: number;
  88996. /**
  88997. * Gets the default side orientation.
  88998. * @param orientation the orientation to value to attempt to get
  88999. * @returns the default orientation
  89000. * @hidden
  89001. */
  89002. static _GetDefaultSideOrientation(orientation?: number): number;
  89003. private _internalMeshDataInfo;
  89004. /**
  89005. * An event triggered before rendering the mesh
  89006. */
  89007. readonly onBeforeRenderObservable: Observable<Mesh>;
  89008. /**
  89009. * An event triggered before binding the mesh
  89010. */
  89011. readonly onBeforeBindObservable: Observable<Mesh>;
  89012. /**
  89013. * An event triggered after rendering the mesh
  89014. */
  89015. readonly onAfterRenderObservable: Observable<Mesh>;
  89016. /**
  89017. * An event triggered before drawing the mesh
  89018. */
  89019. readonly onBeforeDrawObservable: Observable<Mesh>;
  89020. private _onBeforeDrawObserver;
  89021. /**
  89022. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89023. */
  89024. onBeforeDraw: () => void;
  89025. readonly hasInstances: boolean;
  89026. /**
  89027. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89028. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89029. */
  89030. delayLoadState: number;
  89031. /**
  89032. * Gets the list of instances created from this mesh
  89033. * it is not supposed to be modified manually.
  89034. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89035. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89036. */
  89037. instances: InstancedMesh[];
  89038. /**
  89039. * Gets the file containing delay loading data for this mesh
  89040. */
  89041. delayLoadingFile: string;
  89042. /** @hidden */
  89043. _binaryInfo: any;
  89044. /**
  89045. * User defined function used to change how LOD level selection is done
  89046. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89047. */
  89048. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89049. /**
  89050. * Gets or sets the morph target manager
  89051. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89052. */
  89053. morphTargetManager: Nullable<MorphTargetManager>;
  89054. /** @hidden */
  89055. _creationDataStorage: Nullable<_CreationDataStorage>;
  89056. /** @hidden */
  89057. _geometry: Nullable<Geometry>;
  89058. /** @hidden */
  89059. _delayInfo: Array<string>;
  89060. /** @hidden */
  89061. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89062. /** @hidden */
  89063. _instanceDataStorage: _InstanceDataStorage;
  89064. private _effectiveMaterial;
  89065. /** @hidden */
  89066. _shouldGenerateFlatShading: boolean;
  89067. /** @hidden */
  89068. _originalBuilderSideOrientation: number;
  89069. /**
  89070. * Use this property to change the original side orientation defined at construction time
  89071. */
  89072. overrideMaterialSideOrientation: Nullable<number>;
  89073. /**
  89074. * Gets the source mesh (the one used to clone this one from)
  89075. */
  89076. readonly source: Nullable<Mesh>;
  89077. /**
  89078. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89079. */
  89080. isUnIndexed: boolean;
  89081. /**
  89082. * @constructor
  89083. * @param name The value used by scene.getMeshByName() to do a lookup.
  89084. * @param scene The scene to add this mesh to.
  89085. * @param parent The parent of this mesh, if it has one
  89086. * @param source An optional Mesh from which geometry is shared, cloned.
  89087. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89088. * When false, achieved by calling a clone(), also passing False.
  89089. * This will make creation of children, recursive.
  89090. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89091. */
  89092. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89093. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89094. /**
  89095. * Gets the class name
  89096. * @returns the string "Mesh".
  89097. */
  89098. getClassName(): string;
  89099. /** @hidden */
  89100. readonly _isMesh: boolean;
  89101. /**
  89102. * Returns a description of this mesh
  89103. * @param fullDetails define if full details about this mesh must be used
  89104. * @returns a descriptive string representing this mesh
  89105. */
  89106. toString(fullDetails?: boolean): string;
  89107. /** @hidden */
  89108. _unBindEffect(): void;
  89109. /**
  89110. * Gets a boolean indicating if this mesh has LOD
  89111. */
  89112. readonly hasLODLevels: boolean;
  89113. /**
  89114. * Gets the list of MeshLODLevel associated with the current mesh
  89115. * @returns an array of MeshLODLevel
  89116. */
  89117. getLODLevels(): MeshLODLevel[];
  89118. private _sortLODLevels;
  89119. /**
  89120. * Add a mesh as LOD level triggered at the given distance.
  89121. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89122. * @param distance The distance from the center of the object to show this level
  89123. * @param mesh The mesh to be added as LOD level (can be null)
  89124. * @return This mesh (for chaining)
  89125. */
  89126. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89127. /**
  89128. * Returns the LOD level mesh at the passed distance or null if not found.
  89129. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89130. * @param distance The distance from the center of the object to show this level
  89131. * @returns a Mesh or `null`
  89132. */
  89133. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89134. /**
  89135. * Remove a mesh from the LOD array
  89136. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89137. * @param mesh defines the mesh to be removed
  89138. * @return This mesh (for chaining)
  89139. */
  89140. removeLODLevel(mesh: Mesh): Mesh;
  89141. /**
  89142. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89143. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89144. * @param camera defines the camera to use to compute distance
  89145. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89146. * @return This mesh (for chaining)
  89147. */
  89148. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89149. /**
  89150. * Gets the mesh internal Geometry object
  89151. */
  89152. readonly geometry: Nullable<Geometry>;
  89153. /**
  89154. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89155. * @returns the total number of vertices
  89156. */
  89157. getTotalVertices(): number;
  89158. /**
  89159. * Returns the content of an associated vertex buffer
  89160. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89161. * - VertexBuffer.PositionKind
  89162. * - VertexBuffer.UVKind
  89163. * - VertexBuffer.UV2Kind
  89164. * - VertexBuffer.UV3Kind
  89165. * - VertexBuffer.UV4Kind
  89166. * - VertexBuffer.UV5Kind
  89167. * - VertexBuffer.UV6Kind
  89168. * - VertexBuffer.ColorKind
  89169. * - VertexBuffer.MatricesIndicesKind
  89170. * - VertexBuffer.MatricesIndicesExtraKind
  89171. * - VertexBuffer.MatricesWeightsKind
  89172. * - VertexBuffer.MatricesWeightsExtraKind
  89173. * @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
  89174. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89175. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89176. */
  89177. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89178. /**
  89179. * Returns the mesh VertexBuffer object from the requested `kind`
  89180. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89181. * - VertexBuffer.PositionKind
  89182. * - VertexBuffer.NormalKind
  89183. * - VertexBuffer.UVKind
  89184. * - VertexBuffer.UV2Kind
  89185. * - VertexBuffer.UV3Kind
  89186. * - VertexBuffer.UV4Kind
  89187. * - VertexBuffer.UV5Kind
  89188. * - VertexBuffer.UV6Kind
  89189. * - VertexBuffer.ColorKind
  89190. * - VertexBuffer.MatricesIndicesKind
  89191. * - VertexBuffer.MatricesIndicesExtraKind
  89192. * - VertexBuffer.MatricesWeightsKind
  89193. * - VertexBuffer.MatricesWeightsExtraKind
  89194. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89195. */
  89196. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89197. /**
  89198. * Tests if a specific vertex buffer is associated with this mesh
  89199. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89200. * - VertexBuffer.PositionKind
  89201. * - VertexBuffer.NormalKind
  89202. * - VertexBuffer.UVKind
  89203. * - VertexBuffer.UV2Kind
  89204. * - VertexBuffer.UV3Kind
  89205. * - VertexBuffer.UV4Kind
  89206. * - VertexBuffer.UV5Kind
  89207. * - VertexBuffer.UV6Kind
  89208. * - VertexBuffer.ColorKind
  89209. * - VertexBuffer.MatricesIndicesKind
  89210. * - VertexBuffer.MatricesIndicesExtraKind
  89211. * - VertexBuffer.MatricesWeightsKind
  89212. * - VertexBuffer.MatricesWeightsExtraKind
  89213. * @returns a boolean
  89214. */
  89215. isVerticesDataPresent(kind: string): boolean;
  89216. /**
  89217. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89218. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89219. * - VertexBuffer.PositionKind
  89220. * - VertexBuffer.UVKind
  89221. * - VertexBuffer.UV2Kind
  89222. * - VertexBuffer.UV3Kind
  89223. * - VertexBuffer.UV4Kind
  89224. * - VertexBuffer.UV5Kind
  89225. * - VertexBuffer.UV6Kind
  89226. * - VertexBuffer.ColorKind
  89227. * - VertexBuffer.MatricesIndicesKind
  89228. * - VertexBuffer.MatricesIndicesExtraKind
  89229. * - VertexBuffer.MatricesWeightsKind
  89230. * - VertexBuffer.MatricesWeightsExtraKind
  89231. * @returns a boolean
  89232. */
  89233. isVertexBufferUpdatable(kind: string): boolean;
  89234. /**
  89235. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89236. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89237. * - VertexBuffer.PositionKind
  89238. * - VertexBuffer.NormalKind
  89239. * - VertexBuffer.UVKind
  89240. * - VertexBuffer.UV2Kind
  89241. * - VertexBuffer.UV3Kind
  89242. * - VertexBuffer.UV4Kind
  89243. * - VertexBuffer.UV5Kind
  89244. * - VertexBuffer.UV6Kind
  89245. * - VertexBuffer.ColorKind
  89246. * - VertexBuffer.MatricesIndicesKind
  89247. * - VertexBuffer.MatricesIndicesExtraKind
  89248. * - VertexBuffer.MatricesWeightsKind
  89249. * - VertexBuffer.MatricesWeightsExtraKind
  89250. * @returns an array of strings
  89251. */
  89252. getVerticesDataKinds(): string[];
  89253. /**
  89254. * Returns a positive integer : the total number of indices in this mesh geometry.
  89255. * @returns the numner of indices or zero if the mesh has no geometry.
  89256. */
  89257. getTotalIndices(): number;
  89258. /**
  89259. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89260. * @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.
  89261. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89262. * @returns the indices array or an empty array if the mesh has no geometry
  89263. */
  89264. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89265. readonly isBlocked: boolean;
  89266. /**
  89267. * Determine if the current mesh is ready to be rendered
  89268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89269. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89270. * @returns true if all associated assets are ready (material, textures, shaders)
  89271. */
  89272. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89273. /**
  89274. * 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.
  89275. */
  89276. readonly areNormalsFrozen: boolean;
  89277. /**
  89278. * 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.
  89279. * @returns the current mesh
  89280. */
  89281. freezeNormals(): Mesh;
  89282. /**
  89283. * 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
  89284. * @returns the current mesh
  89285. */
  89286. unfreezeNormals(): Mesh;
  89287. /**
  89288. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89289. */
  89290. overridenInstanceCount: number;
  89291. /** @hidden */
  89292. _preActivate(): Mesh;
  89293. /** @hidden */
  89294. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89295. /** @hidden */
  89296. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89297. /**
  89298. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89299. * This means the mesh underlying bounding box and sphere are recomputed.
  89300. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89301. * @returns the current mesh
  89302. */
  89303. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89304. /** @hidden */
  89305. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89306. /**
  89307. * This function will subdivide the mesh into multiple submeshes
  89308. * @param count defines the expected number of submeshes
  89309. */
  89310. subdivide(count: number): void;
  89311. /**
  89312. * Copy a FloatArray into a specific associated vertex buffer
  89313. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89314. * - VertexBuffer.PositionKind
  89315. * - VertexBuffer.UVKind
  89316. * - VertexBuffer.UV2Kind
  89317. * - VertexBuffer.UV3Kind
  89318. * - VertexBuffer.UV4Kind
  89319. * - VertexBuffer.UV5Kind
  89320. * - VertexBuffer.UV6Kind
  89321. * - VertexBuffer.ColorKind
  89322. * - VertexBuffer.MatricesIndicesKind
  89323. * - VertexBuffer.MatricesIndicesExtraKind
  89324. * - VertexBuffer.MatricesWeightsKind
  89325. * - VertexBuffer.MatricesWeightsExtraKind
  89326. * @param data defines the data source
  89327. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89328. * @param stride defines the data stride size (can be null)
  89329. * @returns the current mesh
  89330. */
  89331. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89332. /**
  89333. * Flags an associated vertex buffer as updatable
  89334. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89335. * - VertexBuffer.PositionKind
  89336. * - VertexBuffer.UVKind
  89337. * - VertexBuffer.UV2Kind
  89338. * - VertexBuffer.UV3Kind
  89339. * - VertexBuffer.UV4Kind
  89340. * - VertexBuffer.UV5Kind
  89341. * - VertexBuffer.UV6Kind
  89342. * - VertexBuffer.ColorKind
  89343. * - VertexBuffer.MatricesIndicesKind
  89344. * - VertexBuffer.MatricesIndicesExtraKind
  89345. * - VertexBuffer.MatricesWeightsKind
  89346. * - VertexBuffer.MatricesWeightsExtraKind
  89347. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89348. */
  89349. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89350. /**
  89351. * Sets the mesh global Vertex Buffer
  89352. * @param buffer defines the buffer to use
  89353. * @returns the current mesh
  89354. */
  89355. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89356. /**
  89357. * Update a specific associated vertex buffer
  89358. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89359. * - VertexBuffer.PositionKind
  89360. * - VertexBuffer.UVKind
  89361. * - VertexBuffer.UV2Kind
  89362. * - VertexBuffer.UV3Kind
  89363. * - VertexBuffer.UV4Kind
  89364. * - VertexBuffer.UV5Kind
  89365. * - VertexBuffer.UV6Kind
  89366. * - VertexBuffer.ColorKind
  89367. * - VertexBuffer.MatricesIndicesKind
  89368. * - VertexBuffer.MatricesIndicesExtraKind
  89369. * - VertexBuffer.MatricesWeightsKind
  89370. * - VertexBuffer.MatricesWeightsExtraKind
  89371. * @param data defines the data source
  89372. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89373. * @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)
  89374. * @returns the current mesh
  89375. */
  89376. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89377. /**
  89378. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89379. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89380. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89381. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89382. * @returns the current mesh
  89383. */
  89384. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89385. /**
  89386. * Creates a un-shared specific occurence of the geometry for the mesh.
  89387. * @returns the current mesh
  89388. */
  89389. makeGeometryUnique(): Mesh;
  89390. /**
  89391. * Set the index buffer of this mesh
  89392. * @param indices defines the source data
  89393. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89394. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89395. * @returns the current mesh
  89396. */
  89397. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89398. /**
  89399. * Update the current index buffer
  89400. * @param indices defines the source data
  89401. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89402. * @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)
  89403. * @returns the current mesh
  89404. */
  89405. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89406. /**
  89407. * Invert the geometry to move from a right handed system to a left handed one.
  89408. * @returns the current mesh
  89409. */
  89410. toLeftHanded(): Mesh;
  89411. /** @hidden */
  89412. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89413. /** @hidden */
  89414. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89415. /**
  89416. * Registers for this mesh a javascript function called just before the rendering process
  89417. * @param func defines the function to call before rendering this mesh
  89418. * @returns the current mesh
  89419. */
  89420. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89421. /**
  89422. * Disposes a previously registered javascript function called before the rendering
  89423. * @param func defines the function to remove
  89424. * @returns the current mesh
  89425. */
  89426. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89427. /**
  89428. * Registers for this mesh a javascript function called just after the rendering is complete
  89429. * @param func defines the function to call after rendering this mesh
  89430. * @returns the current mesh
  89431. */
  89432. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89433. /**
  89434. * Disposes a previously registered javascript function called after the rendering.
  89435. * @param func defines the function to remove
  89436. * @returns the current mesh
  89437. */
  89438. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89439. /** @hidden */
  89440. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89441. /** @hidden */
  89442. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89443. /** @hidden */
  89444. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89445. /** @hidden */
  89446. _rebuild(): void;
  89447. /** @hidden */
  89448. _freeze(): void;
  89449. /** @hidden */
  89450. _unFreeze(): void;
  89451. /**
  89452. * 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
  89453. * @param subMesh defines the subMesh to render
  89454. * @param enableAlphaMode defines if alpha mode can be changed
  89455. * @returns the current mesh
  89456. */
  89457. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89458. private _onBeforeDraw;
  89459. /**
  89460. * Renormalize the mesh and patch it up if there are no weights
  89461. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89462. * However in the case of zero weights then we set just a single influence to 1.
  89463. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89464. */
  89465. cleanMatrixWeights(): void;
  89466. private normalizeSkinFourWeights;
  89467. private normalizeSkinWeightsAndExtra;
  89468. /**
  89469. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89470. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89471. * the user know there was an issue with importing the mesh
  89472. * @returns a validation object with skinned, valid and report string
  89473. */
  89474. validateSkinning(): {
  89475. skinned: boolean;
  89476. valid: boolean;
  89477. report: string;
  89478. };
  89479. /** @hidden */
  89480. _checkDelayState(): Mesh;
  89481. private _queueLoad;
  89482. /**
  89483. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89484. * A mesh is in the frustum if its bounding box intersects the frustum
  89485. * @param frustumPlanes defines the frustum to test
  89486. * @returns true if the mesh is in the frustum planes
  89487. */
  89488. isInFrustum(frustumPlanes: Plane[]): boolean;
  89489. /**
  89490. * Sets the mesh material by the material or multiMaterial `id` property
  89491. * @param id is a string identifying the material or the multiMaterial
  89492. * @returns the current mesh
  89493. */
  89494. setMaterialByID(id: string): Mesh;
  89495. /**
  89496. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89497. * @returns an array of IAnimatable
  89498. */
  89499. getAnimatables(): IAnimatable[];
  89500. /**
  89501. * Modifies the mesh geometry according to the passed transformation matrix.
  89502. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89503. * The mesh normals are modified using the same transformation.
  89504. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89505. * @param transform defines the transform matrix to use
  89506. * @see http://doc.babylonjs.com/resources/baking_transformations
  89507. * @returns the current mesh
  89508. */
  89509. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89510. /**
  89511. * Modifies the mesh geometry according to its own current World Matrix.
  89512. * The mesh World Matrix is then reset.
  89513. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89514. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89515. * @see http://doc.babylonjs.com/resources/baking_transformations
  89516. * @returns the current mesh
  89517. */
  89518. bakeCurrentTransformIntoVertices(): Mesh;
  89519. /** @hidden */
  89520. readonly _positions: Nullable<Vector3[]>;
  89521. /** @hidden */
  89522. _resetPointsArrayCache(): Mesh;
  89523. /** @hidden */
  89524. _generatePointsArray(): boolean;
  89525. /**
  89526. * Returns a new Mesh object generated from the current mesh properties.
  89527. * This method must not get confused with createInstance()
  89528. * @param name is a string, the name given to the new mesh
  89529. * @param newParent can be any Node object (default `null`)
  89530. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89531. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89532. * @returns a new mesh
  89533. */
  89534. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89535. /**
  89536. * Releases resources associated with this mesh.
  89537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89539. */
  89540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89541. /**
  89542. * Modifies the mesh geometry according to a displacement map.
  89543. * 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.
  89544. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89545. * @param url is a string, the URL from the image file is to be downloaded.
  89546. * @param minHeight is the lower limit of the displacement.
  89547. * @param maxHeight is the upper limit of the displacement.
  89548. * @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.
  89549. * @param uvOffset is an optional vector2 used to offset UV.
  89550. * @param uvScale is an optional vector2 used to scale UV.
  89551. * @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.
  89552. * @returns the Mesh.
  89553. */
  89554. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89555. /**
  89556. * Modifies the mesh geometry according to a displacementMap buffer.
  89557. * 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.
  89558. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89559. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89560. * @param heightMapWidth is the width of the buffer image.
  89561. * @param heightMapHeight is the height of the buffer image.
  89562. * @param minHeight is the lower limit of the displacement.
  89563. * @param maxHeight is the upper limit of the displacement.
  89564. * @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.
  89565. * @param uvOffset is an optional vector2 used to offset UV.
  89566. * @param uvScale is an optional vector2 used to scale UV.
  89567. * @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.
  89568. * @returns the Mesh.
  89569. */
  89570. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89571. /**
  89572. * Modify the mesh to get a flat shading rendering.
  89573. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89574. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89575. * @returns current mesh
  89576. */
  89577. convertToFlatShadedMesh(): Mesh;
  89578. /**
  89579. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89580. * In other words, more vertices, no more indices and a single bigger VBO.
  89581. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89582. * @returns current mesh
  89583. */
  89584. convertToUnIndexedMesh(): Mesh;
  89585. /**
  89586. * Inverses facet orientations.
  89587. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89588. * @param flipNormals will also inverts the normals
  89589. * @returns current mesh
  89590. */
  89591. flipFaces(flipNormals?: boolean): Mesh;
  89592. /**
  89593. * Increase the number of facets and hence vertices in a mesh
  89594. * Vertex normals are interpolated from existing vertex normals
  89595. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89596. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89597. */
  89598. increaseVertices(numberPerEdge: number): void;
  89599. /**
  89600. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89601. * This will undo any application of covertToFlatShadedMesh
  89602. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89603. */
  89604. forceSharedVertices(): void;
  89605. /** @hidden */
  89606. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89607. /** @hidden */
  89608. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89609. /**
  89610. * Creates a new InstancedMesh object from the mesh model.
  89611. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89612. * @param name defines the name of the new instance
  89613. * @returns a new InstancedMesh
  89614. */
  89615. createInstance(name: string): InstancedMesh;
  89616. /**
  89617. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89618. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89619. * @returns the current mesh
  89620. */
  89621. synchronizeInstances(): Mesh;
  89622. /**
  89623. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89624. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89625. * This should be used together with the simplification to avoid disappearing triangles.
  89626. * @param successCallback an optional success callback to be called after the optimization finished.
  89627. * @returns the current mesh
  89628. */
  89629. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89630. /**
  89631. * Serialize current mesh
  89632. * @param serializationObject defines the object which will receive the serialization data
  89633. */
  89634. serialize(serializationObject: any): void;
  89635. /** @hidden */
  89636. _syncGeometryWithMorphTargetManager(): void;
  89637. /** @hidden */
  89638. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89639. /**
  89640. * Returns a new Mesh object parsed from the source provided.
  89641. * @param parsedMesh is the source
  89642. * @param scene defines the hosting scene
  89643. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89644. * @returns a new Mesh
  89645. */
  89646. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89647. /**
  89648. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89649. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89650. * @param name defines the name of the mesh to create
  89651. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89652. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89653. * @param closePath creates a seam between the first and the last points of each path of the path array
  89654. * @param offset is taken in account only if the `pathArray` is containing a single path
  89655. * @param scene defines the hosting scene
  89656. * @param updatable defines if the mesh must be flagged as updatable
  89657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89658. * @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)
  89659. * @returns a new Mesh
  89660. */
  89661. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89662. /**
  89663. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89664. * @param name defines the name of the mesh to create
  89665. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89666. * @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
  89667. * @param scene defines the hosting scene
  89668. * @param updatable defines if the mesh must be flagged as updatable
  89669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89670. * @returns a new Mesh
  89671. */
  89672. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89673. /**
  89674. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89675. * @param name defines the name of the mesh to create
  89676. * @param size sets the size (float) of each box side (default 1)
  89677. * @param scene defines the hosting scene
  89678. * @param updatable defines if the mesh must be flagged as updatable
  89679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89680. * @returns a new Mesh
  89681. */
  89682. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89683. /**
  89684. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89685. * @param name defines the name of the mesh to create
  89686. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89687. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89688. * @param scene defines the hosting scene
  89689. * @param updatable defines if the mesh must be flagged as updatable
  89690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89691. * @returns a new Mesh
  89692. */
  89693. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89694. /**
  89695. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89696. * @param name defines the name of the mesh to create
  89697. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89698. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89699. * @param scene defines the hosting scene
  89700. * @returns a new Mesh
  89701. */
  89702. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89703. /**
  89704. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89705. * @param name defines the name of the mesh to create
  89706. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89707. * @param diameterTop set the top cap diameter (floats, default 1)
  89708. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89709. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89710. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89711. * @param scene defines the hosting scene
  89712. * @param updatable defines if the mesh must be flagged as updatable
  89713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89714. * @returns a new Mesh
  89715. */
  89716. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89717. /**
  89718. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89719. * @param name defines the name of the mesh to create
  89720. * @param diameter sets the diameter size (float) of the torus (default 1)
  89721. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89722. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89723. * @param scene defines the hosting scene
  89724. * @param updatable defines if the mesh must be flagged as updatable
  89725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89726. * @returns a new Mesh
  89727. */
  89728. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89729. /**
  89730. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89731. * @param name defines the name of the mesh to create
  89732. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89733. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89734. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89735. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89736. * @param p the number of windings on X axis (positive integers, default 2)
  89737. * @param q the number of windings on Y axis (positive integers, default 3)
  89738. * @param scene defines the hosting scene
  89739. * @param updatable defines if the mesh must be flagged as updatable
  89740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89741. * @returns a new Mesh
  89742. */
  89743. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89744. /**
  89745. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89746. * @param name defines the name of the mesh to create
  89747. * @param points is an array successive Vector3
  89748. * @param scene defines the hosting scene
  89749. * @param updatable defines if the mesh must be flagged as updatable
  89750. * @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).
  89751. * @returns a new Mesh
  89752. */
  89753. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89754. /**
  89755. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89756. * @param name defines the name of the mesh to create
  89757. * @param points is an array successive Vector3
  89758. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89759. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89760. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89761. * @param scene defines the hosting scene
  89762. * @param updatable defines if the mesh must be flagged as updatable
  89763. * @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)
  89764. * @returns a new Mesh
  89765. */
  89766. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89767. /**
  89768. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89769. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89770. * 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.
  89771. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89772. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89773. * Remember you can only change the shape positions, not their number when updating a polygon.
  89774. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89775. * @param name defines the name of the mesh to create
  89776. * @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
  89777. * @param scene defines the hosting scene
  89778. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89779. * @param updatable defines if the mesh must be flagged as updatable
  89780. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89781. * @param earcutInjection can be used to inject your own earcut reference
  89782. * @returns a new Mesh
  89783. */
  89784. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89785. /**
  89786. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89787. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89788. * @param name defines the name of the mesh to create
  89789. * @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
  89790. * @param depth defines the height of extrusion
  89791. * @param scene defines the hosting scene
  89792. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89793. * @param updatable defines if the mesh must be flagged as updatable
  89794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89795. * @param earcutInjection can be used to inject your own earcut reference
  89796. * @returns a new Mesh
  89797. */
  89798. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89799. /**
  89800. * Creates an extruded shape mesh.
  89801. * 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
  89802. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89803. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89804. * @param name defines the name of the mesh to create
  89805. * @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
  89806. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89807. * @param scale is the value to scale the shape
  89808. * @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
  89809. * @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
  89810. * @param scene defines the hosting scene
  89811. * @param updatable defines if the mesh must be flagged as updatable
  89812. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89813. * @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)
  89814. * @returns a new Mesh
  89815. */
  89816. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89817. /**
  89818. * Creates an custom extruded shape mesh.
  89819. * The custom extrusion is a parametric shape.
  89820. * It has no predefined shape. Its final shape will depend on the input parameters.
  89821. * Please consider using the same method from the MeshBuilder class instead
  89822. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89823. * @param name defines the name of the mesh to create
  89824. * @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
  89825. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89826. * @param scaleFunction is a custom Javascript function called on each path point
  89827. * @param rotationFunction is a custom Javascript function called on each path point
  89828. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  89829. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  89830. * @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
  89831. * @param scene defines the hosting scene
  89832. * @param updatable defines if the mesh must be flagged as updatable
  89833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89834. * @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)
  89835. * @returns a new Mesh
  89836. */
  89837. 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;
  89838. /**
  89839. * Creates lathe mesh.
  89840. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  89841. * Please consider using the same method from the MeshBuilder class instead
  89842. * @param name defines the name of the mesh to create
  89843. * @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
  89844. * @param radius is the radius value of the lathe
  89845. * @param tessellation is the side number of the lathe.
  89846. * @param scene defines the hosting scene
  89847. * @param updatable defines if the mesh must be flagged as updatable
  89848. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89849. * @returns a new Mesh
  89850. */
  89851. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89852. /**
  89853. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  89854. * @param name defines the name of the mesh to create
  89855. * @param size sets the size (float) of both sides of the plane at once (default 1)
  89856. * @param scene defines the hosting scene
  89857. * @param updatable defines if the mesh must be flagged as updatable
  89858. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89859. * @returns a new Mesh
  89860. */
  89861. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89862. /**
  89863. * Creates a ground mesh.
  89864. * Please consider using the same method from the MeshBuilder class instead
  89865. * @param name defines the name of the mesh to create
  89866. * @param width set the width of the ground
  89867. * @param height set the height of the ground
  89868. * @param subdivisions sets the number of subdivisions per side
  89869. * @param scene defines the hosting scene
  89870. * @param updatable defines if the mesh must be flagged as updatable
  89871. * @returns a new Mesh
  89872. */
  89873. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  89874. /**
  89875. * Creates a tiled ground mesh.
  89876. * Please consider using the same method from the MeshBuilder class instead
  89877. * @param name defines the name of the mesh to create
  89878. * @param xmin set the ground minimum X coordinate
  89879. * @param zmin set the ground minimum Y coordinate
  89880. * @param xmax set the ground maximum X coordinate
  89881. * @param zmax set the ground maximum Z coordinate
  89882. * @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
  89883. * @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
  89884. * @param scene defines the hosting scene
  89885. * @param updatable defines if the mesh must be flagged as updatable
  89886. * @returns a new Mesh
  89887. */
  89888. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  89889. w: number;
  89890. h: number;
  89891. }, precision: {
  89892. w: number;
  89893. h: number;
  89894. }, scene: Scene, updatable?: boolean): Mesh;
  89895. /**
  89896. * Creates a ground mesh from a height map.
  89897. * Please consider using the same method from the MeshBuilder class instead
  89898. * @see http://doc.babylonjs.com/babylon101/height_map
  89899. * @param name defines the name of the mesh to create
  89900. * @param url sets the URL of the height map image resource
  89901. * @param width set the ground width size
  89902. * @param height set the ground height size
  89903. * @param subdivisions sets the number of subdivision per side
  89904. * @param minHeight is the minimum altitude on the ground
  89905. * @param maxHeight is the maximum altitude on the ground
  89906. * @param scene defines the hosting scene
  89907. * @param updatable defines if the mesh must be flagged as updatable
  89908. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  89909. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  89910. * @returns a new Mesh
  89911. */
  89912. 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;
  89913. /**
  89914. * Creates a tube mesh.
  89915. * The tube is a parametric shape.
  89916. * It has no predefined shape. Its final shape will depend on the input parameters.
  89917. * Please consider using the same method from the MeshBuilder class instead
  89918. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89919. * @param name defines the name of the mesh to create
  89920. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  89921. * @param radius sets the tube radius size
  89922. * @param tessellation is the number of sides on the tubular surface
  89923. * @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
  89924. * @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
  89925. * @param scene defines the hosting scene
  89926. * @param updatable defines if the mesh must be flagged as updatable
  89927. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89928. * @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)
  89929. * @returns a new Mesh
  89930. */
  89931. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  89932. (i: number, distance: number): number;
  89933. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89934. /**
  89935. * Creates a polyhedron mesh.
  89936. * Please consider using the same method from the MeshBuilder class instead.
  89937. * * 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
  89938. * * The parameter `size` (positive float, default 1) sets the polygon size
  89939. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89940. * * 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`
  89941. * * 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
  89942. * * 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)`)
  89943. * * 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
  89944. * * 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
  89945. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89946. * * 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
  89947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89948. * @param name defines the name of the mesh to create
  89949. * @param options defines the options used to create the mesh
  89950. * @param scene defines the hosting scene
  89951. * @returns a new Mesh
  89952. */
  89953. static CreatePolyhedron(name: string, options: {
  89954. type?: number;
  89955. size?: number;
  89956. sizeX?: number;
  89957. sizeY?: number;
  89958. sizeZ?: number;
  89959. custom?: any;
  89960. faceUV?: Vector4[];
  89961. faceColors?: Color4[];
  89962. updatable?: boolean;
  89963. sideOrientation?: number;
  89964. }, scene: Scene): Mesh;
  89965. /**
  89966. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  89967. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  89968. * * 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`)
  89969. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  89970. * * 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
  89971. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89972. * * 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
  89973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89974. * @param name defines the name of the mesh
  89975. * @param options defines the options used to create the mesh
  89976. * @param scene defines the hosting scene
  89977. * @returns a new Mesh
  89978. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  89979. */
  89980. static CreateIcoSphere(name: string, options: {
  89981. radius?: number;
  89982. flat?: boolean;
  89983. subdivisions?: number;
  89984. sideOrientation?: number;
  89985. updatable?: boolean;
  89986. }, scene: Scene): Mesh;
  89987. /**
  89988. * Creates a decal mesh.
  89989. * Please consider using the same method from the MeshBuilder class instead.
  89990. * A decal is a mesh usually applied as a model onto the surface of another mesh
  89991. * @param name defines the name of the mesh
  89992. * @param sourceMesh defines the mesh receiving the decal
  89993. * @param position sets the position of the decal in world coordinates
  89994. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  89995. * @param size sets the decal scaling
  89996. * @param angle sets the angle to rotate the decal
  89997. * @returns a new Mesh
  89998. */
  89999. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90000. /**
  90001. * Prepare internal position array for software CPU skinning
  90002. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90003. */
  90004. setPositionsForCPUSkinning(): Float32Array;
  90005. /**
  90006. * Prepare internal normal array for software CPU skinning
  90007. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90008. */
  90009. setNormalsForCPUSkinning(): Float32Array;
  90010. /**
  90011. * Updates the vertex buffer by applying transformation from the bones
  90012. * @param skeleton defines the skeleton to apply to current mesh
  90013. * @returns the current mesh
  90014. */
  90015. applySkeleton(skeleton: Skeleton): Mesh;
  90016. /**
  90017. * 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
  90018. * @param meshes defines the list of meshes to scan
  90019. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90020. */
  90021. static MinMax(meshes: AbstractMesh[]): {
  90022. min: Vector3;
  90023. max: Vector3;
  90024. };
  90025. /**
  90026. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90027. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90028. * @returns a vector3
  90029. */
  90030. static Center(meshesOrMinMaxVector: {
  90031. min: Vector3;
  90032. max: Vector3;
  90033. } | AbstractMesh[]): Vector3;
  90034. /**
  90035. * Merge the array of meshes into a single mesh for performance reasons.
  90036. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90037. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90038. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90039. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90040. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90041. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90042. * @returns a new mesh
  90043. */
  90044. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90045. /** @hidden */
  90046. addInstance(instance: InstancedMesh): void;
  90047. /** @hidden */
  90048. removeInstance(instance: InstancedMesh): void;
  90049. }
  90050. }
  90051. declare module BABYLON {
  90052. /**
  90053. * This is the base class of all the camera used in the application.
  90054. * @see http://doc.babylonjs.com/features/cameras
  90055. */
  90056. export class Camera extends Node {
  90057. /** @hidden */
  90058. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90059. /**
  90060. * This is the default projection mode used by the cameras.
  90061. * It helps recreating a feeling of perspective and better appreciate depth.
  90062. * This is the best way to simulate real life cameras.
  90063. */
  90064. static readonly PERSPECTIVE_CAMERA: number;
  90065. /**
  90066. * This helps creating camera with an orthographic mode.
  90067. * 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.
  90068. */
  90069. static readonly ORTHOGRAPHIC_CAMERA: number;
  90070. /**
  90071. * This is the default FOV mode for perspective cameras.
  90072. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90073. */
  90074. static readonly FOVMODE_VERTICAL_FIXED: number;
  90075. /**
  90076. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90077. */
  90078. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90079. /**
  90080. * This specifies ther is no need for a camera rig.
  90081. * Basically only one eye is rendered corresponding to the camera.
  90082. */
  90083. static readonly RIG_MODE_NONE: number;
  90084. /**
  90085. * Simulates a camera Rig with one blue eye and one red eye.
  90086. * This can be use with 3d blue and red glasses.
  90087. */
  90088. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90089. /**
  90090. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90091. */
  90092. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90093. /**
  90094. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90095. */
  90096. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90097. /**
  90098. * Defines that both eyes of the camera will be rendered over under each other.
  90099. */
  90100. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90101. /**
  90102. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90103. */
  90104. static readonly RIG_MODE_VR: number;
  90105. /**
  90106. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90107. */
  90108. static readonly RIG_MODE_WEBVR: number;
  90109. /**
  90110. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90111. */
  90112. static readonly RIG_MODE_CUSTOM: number;
  90113. /**
  90114. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90115. */
  90116. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90117. /**
  90118. * Define the input manager associated with the camera.
  90119. */
  90120. inputs: CameraInputsManager<Camera>;
  90121. /** @hidden */
  90122. _position: Vector3;
  90123. /**
  90124. * Define the current local position of the camera in the scene
  90125. */
  90126. position: Vector3;
  90127. /**
  90128. * The vector the camera should consider as up.
  90129. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90130. */
  90131. upVector: Vector3;
  90132. /**
  90133. * Define the current limit on the left side for an orthographic camera
  90134. * In scene unit
  90135. */
  90136. orthoLeft: Nullable<number>;
  90137. /**
  90138. * Define the current limit on the right side for an orthographic camera
  90139. * In scene unit
  90140. */
  90141. orthoRight: Nullable<number>;
  90142. /**
  90143. * Define the current limit on the bottom side for an orthographic camera
  90144. * In scene unit
  90145. */
  90146. orthoBottom: Nullable<number>;
  90147. /**
  90148. * Define the current limit on the top side for an orthographic camera
  90149. * In scene unit
  90150. */
  90151. orthoTop: Nullable<number>;
  90152. /**
  90153. * Field Of View is set in Radians. (default is 0.8)
  90154. */
  90155. fov: number;
  90156. /**
  90157. * Define the minimum distance the camera can see from.
  90158. * This is important to note that the depth buffer are not infinite and the closer it starts
  90159. * the more your scene might encounter depth fighting issue.
  90160. */
  90161. minZ: number;
  90162. /**
  90163. * Define the maximum distance the camera can see to.
  90164. * This is important to note that the depth buffer are not infinite and the further it end
  90165. * the more your scene might encounter depth fighting issue.
  90166. */
  90167. maxZ: number;
  90168. /**
  90169. * Define the default inertia of the camera.
  90170. * This helps giving a smooth feeling to the camera movement.
  90171. */
  90172. inertia: number;
  90173. /**
  90174. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90175. */
  90176. mode: number;
  90177. /**
  90178. * Define wether the camera is intermediate.
  90179. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90180. */
  90181. isIntermediate: boolean;
  90182. /**
  90183. * Define the viewport of the camera.
  90184. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90185. */
  90186. viewport: Viewport;
  90187. /**
  90188. * Restricts the camera to viewing objects with the same layerMask.
  90189. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90190. */
  90191. layerMask: number;
  90192. /**
  90193. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90194. */
  90195. fovMode: number;
  90196. /**
  90197. * Rig mode of the camera.
  90198. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90199. * This is normally controlled byt the camera themselves as internal use.
  90200. */
  90201. cameraRigMode: number;
  90202. /**
  90203. * Defines the distance between both "eyes" in case of a RIG
  90204. */
  90205. interaxialDistance: number;
  90206. /**
  90207. * Defines if stereoscopic rendering is done side by side or over under.
  90208. */
  90209. isStereoscopicSideBySide: boolean;
  90210. /**
  90211. * 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
  90212. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90213. * else in the scene. (Eg. security camera)
  90214. *
  90215. * 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)
  90216. */
  90217. customRenderTargets: RenderTargetTexture[];
  90218. /**
  90219. * When set, the camera will render to this render target instead of the default canvas
  90220. *
  90221. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90222. */
  90223. outputRenderTarget: Nullable<RenderTargetTexture>;
  90224. /**
  90225. * Observable triggered when the camera view matrix has changed.
  90226. */
  90227. onViewMatrixChangedObservable: Observable<Camera>;
  90228. /**
  90229. * Observable triggered when the camera Projection matrix has changed.
  90230. */
  90231. onProjectionMatrixChangedObservable: Observable<Camera>;
  90232. /**
  90233. * Observable triggered when the inputs have been processed.
  90234. */
  90235. onAfterCheckInputsObservable: Observable<Camera>;
  90236. /**
  90237. * Observable triggered when reset has been called and applied to the camera.
  90238. */
  90239. onRestoreStateObservable: Observable<Camera>;
  90240. /** @hidden */
  90241. _cameraRigParams: any;
  90242. /** @hidden */
  90243. _rigCameras: Camera[];
  90244. /** @hidden */
  90245. _rigPostProcess: Nullable<PostProcess>;
  90246. protected _webvrViewMatrix: Matrix;
  90247. /** @hidden */
  90248. _skipRendering: boolean;
  90249. /** @hidden */
  90250. _projectionMatrix: Matrix;
  90251. /** @hidden */
  90252. _postProcesses: Nullable<PostProcess>[];
  90253. /** @hidden */
  90254. _activeMeshes: SmartArray<AbstractMesh>;
  90255. protected _globalPosition: Vector3;
  90256. /** @hidden */
  90257. _computedViewMatrix: Matrix;
  90258. private _doNotComputeProjectionMatrix;
  90259. private _transformMatrix;
  90260. private _frustumPlanes;
  90261. private _refreshFrustumPlanes;
  90262. private _storedFov;
  90263. private _stateStored;
  90264. /**
  90265. * Instantiates a new camera object.
  90266. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90267. * @see http://doc.babylonjs.com/features/cameras
  90268. * @param name Defines the name of the camera in the scene
  90269. * @param position Defines the position of the camera
  90270. * @param scene Defines the scene the camera belongs too
  90271. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90272. */
  90273. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90274. /**
  90275. * Store current camera state (fov, position, etc..)
  90276. * @returns the camera
  90277. */
  90278. storeState(): Camera;
  90279. /**
  90280. * Restores the camera state values if it has been stored. You must call storeState() first
  90281. */
  90282. protected _restoreStateValues(): boolean;
  90283. /**
  90284. * Restored camera state. You must call storeState() first.
  90285. * @returns true if restored and false otherwise
  90286. */
  90287. restoreState(): boolean;
  90288. /**
  90289. * Gets the class name of the camera.
  90290. * @returns the class name
  90291. */
  90292. getClassName(): string;
  90293. /** @hidden */
  90294. readonly _isCamera: boolean;
  90295. /**
  90296. * Gets a string representation of the camera useful for debug purpose.
  90297. * @param fullDetails Defines that a more verboe level of logging is required
  90298. * @returns the string representation
  90299. */
  90300. toString(fullDetails?: boolean): string;
  90301. /**
  90302. * Gets the current world space position of the camera.
  90303. */
  90304. readonly globalPosition: Vector3;
  90305. /**
  90306. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90307. * @returns the active meshe list
  90308. */
  90309. getActiveMeshes(): SmartArray<AbstractMesh>;
  90310. /**
  90311. * Check wether a mesh is part of the current active mesh list of the camera
  90312. * @param mesh Defines the mesh to check
  90313. * @returns true if active, false otherwise
  90314. */
  90315. isActiveMesh(mesh: Mesh): boolean;
  90316. /**
  90317. * Is this camera ready to be used/rendered
  90318. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90319. * @return true if the camera is ready
  90320. */
  90321. isReady(completeCheck?: boolean): boolean;
  90322. /** @hidden */
  90323. _initCache(): void;
  90324. /** @hidden */
  90325. _updateCache(ignoreParentClass?: boolean): void;
  90326. /** @hidden */
  90327. _isSynchronized(): boolean;
  90328. /** @hidden */
  90329. _isSynchronizedViewMatrix(): boolean;
  90330. /** @hidden */
  90331. _isSynchronizedProjectionMatrix(): boolean;
  90332. /**
  90333. * Attach the input controls to a specific dom element to get the input from.
  90334. * @param element Defines the element the controls should be listened from
  90335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90336. */
  90337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90338. /**
  90339. * Detach the current controls from the specified dom element.
  90340. * @param element Defines the element to stop listening the inputs from
  90341. */
  90342. detachControl(element: HTMLElement): void;
  90343. /**
  90344. * Update the camera state according to the different inputs gathered during the frame.
  90345. */
  90346. update(): void;
  90347. /** @hidden */
  90348. _checkInputs(): void;
  90349. /** @hidden */
  90350. readonly rigCameras: Camera[];
  90351. /**
  90352. * Gets the post process used by the rig cameras
  90353. */
  90354. readonly rigPostProcess: Nullable<PostProcess>;
  90355. /**
  90356. * Internal, gets the first post proces.
  90357. * @returns the first post process to be run on this camera.
  90358. */
  90359. _getFirstPostProcess(): Nullable<PostProcess>;
  90360. private _cascadePostProcessesToRigCams;
  90361. /**
  90362. * Attach a post process to the camera.
  90363. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90364. * @param postProcess The post process to attach to the camera
  90365. * @param insertAt The position of the post process in case several of them are in use in the scene
  90366. * @returns the position the post process has been inserted at
  90367. */
  90368. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90369. /**
  90370. * Detach a post process to the camera.
  90371. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90372. * @param postProcess The post process to detach from the camera
  90373. */
  90374. detachPostProcess(postProcess: PostProcess): void;
  90375. /**
  90376. * Gets the current world matrix of the camera
  90377. */
  90378. getWorldMatrix(): Matrix;
  90379. /** @hidden */
  90380. _getViewMatrix(): Matrix;
  90381. /**
  90382. * Gets the current view matrix of the camera.
  90383. * @param force forces the camera to recompute the matrix without looking at the cached state
  90384. * @returns the view matrix
  90385. */
  90386. getViewMatrix(force?: boolean): Matrix;
  90387. /**
  90388. * Freeze the projection matrix.
  90389. * It will prevent the cache check of the camera projection compute and can speed up perf
  90390. * if no parameter of the camera are meant to change
  90391. * @param projection Defines manually a projection if necessary
  90392. */
  90393. freezeProjectionMatrix(projection?: Matrix): void;
  90394. /**
  90395. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90396. */
  90397. unfreezeProjectionMatrix(): void;
  90398. /**
  90399. * Gets the current projection matrix of the camera.
  90400. * @param force forces the camera to recompute the matrix without looking at the cached state
  90401. * @returns the projection matrix
  90402. */
  90403. getProjectionMatrix(force?: boolean): Matrix;
  90404. /**
  90405. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90406. * @returns a Matrix
  90407. */
  90408. getTransformationMatrix(): Matrix;
  90409. private _updateFrustumPlanes;
  90410. /**
  90411. * Checks if a cullable object (mesh...) is in the camera frustum
  90412. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90413. * @param target The object to check
  90414. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90415. * @returns true if the object is in frustum otherwise false
  90416. */
  90417. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90418. /**
  90419. * Checks if a cullable object (mesh...) is in the camera frustum
  90420. * Unlike isInFrustum this cheks the full bounding box
  90421. * @param target The object to check
  90422. * @returns true if the object is in frustum otherwise false
  90423. */
  90424. isCompletelyInFrustum(target: ICullable): boolean;
  90425. /**
  90426. * Gets a ray in the forward direction from the camera.
  90427. * @param length Defines the length of the ray to create
  90428. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90429. * @param origin Defines the start point of the ray which defaults to the camera position
  90430. * @returns the forward ray
  90431. */
  90432. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90433. /**
  90434. * Releases resources associated with this node.
  90435. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90436. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90437. */
  90438. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90439. /** @hidden */
  90440. _isLeftCamera: boolean;
  90441. /**
  90442. * Gets the left camera of a rig setup in case of Rigged Camera
  90443. */
  90444. readonly isLeftCamera: boolean;
  90445. /** @hidden */
  90446. _isRightCamera: boolean;
  90447. /**
  90448. * Gets the right camera of a rig setup in case of Rigged Camera
  90449. */
  90450. readonly isRightCamera: boolean;
  90451. /**
  90452. * Gets the left camera of a rig setup in case of Rigged Camera
  90453. */
  90454. readonly leftCamera: Nullable<FreeCamera>;
  90455. /**
  90456. * Gets the right camera of a rig setup in case of Rigged Camera
  90457. */
  90458. readonly rightCamera: Nullable<FreeCamera>;
  90459. /**
  90460. * Gets the left camera target of a rig setup in case of Rigged Camera
  90461. * @returns the target position
  90462. */
  90463. getLeftTarget(): Nullable<Vector3>;
  90464. /**
  90465. * Gets the right camera target of a rig setup in case of Rigged Camera
  90466. * @returns the target position
  90467. */
  90468. getRightTarget(): Nullable<Vector3>;
  90469. /**
  90470. * @hidden
  90471. */
  90472. setCameraRigMode(mode: number, rigParams: any): void;
  90473. /** @hidden */
  90474. static _setStereoscopicRigMode(camera: Camera): void;
  90475. /** @hidden */
  90476. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90477. /** @hidden */
  90478. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90479. /** @hidden */
  90480. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90481. /** @hidden */
  90482. _getVRProjectionMatrix(): Matrix;
  90483. protected _updateCameraRotationMatrix(): void;
  90484. protected _updateWebVRCameraRotationMatrix(): void;
  90485. /**
  90486. * This function MUST be overwritten by the different WebVR cameras available.
  90487. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90488. * @hidden
  90489. */
  90490. _getWebVRProjectionMatrix(): Matrix;
  90491. /**
  90492. * This function MUST be overwritten by the different WebVR cameras available.
  90493. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90494. * @hidden
  90495. */
  90496. _getWebVRViewMatrix(): Matrix;
  90497. /** @hidden */
  90498. setCameraRigParameter(name: string, value: any): void;
  90499. /**
  90500. * needs to be overridden by children so sub has required properties to be copied
  90501. * @hidden
  90502. */
  90503. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90504. /**
  90505. * May need to be overridden by children
  90506. * @hidden
  90507. */
  90508. _updateRigCameras(): void;
  90509. /** @hidden */
  90510. _setupInputs(): void;
  90511. /**
  90512. * Serialiaze the camera setup to a json represention
  90513. * @returns the JSON representation
  90514. */
  90515. serialize(): any;
  90516. /**
  90517. * Clones the current camera.
  90518. * @param name The cloned camera name
  90519. * @returns the cloned camera
  90520. */
  90521. clone(name: string): Camera;
  90522. /**
  90523. * Gets the direction of the camera relative to a given local axis.
  90524. * @param localAxis Defines the reference axis to provide a relative direction.
  90525. * @return the direction
  90526. */
  90527. getDirection(localAxis: Vector3): Vector3;
  90528. /**
  90529. * Returns the current camera absolute rotation
  90530. */
  90531. readonly absoluteRotation: Quaternion;
  90532. /**
  90533. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90534. * @param localAxis Defines the reference axis to provide a relative direction.
  90535. * @param result Defines the vector to store the result in
  90536. */
  90537. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90538. /**
  90539. * Gets a camera constructor for a given camera type
  90540. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90541. * @param name The name of the camera the result will be able to instantiate
  90542. * @param scene The scene the result will construct the camera in
  90543. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90544. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90545. * @returns a factory method to construc the camera
  90546. */
  90547. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90548. /**
  90549. * Compute the world matrix of the camera.
  90550. * @returns the camera workd matrix
  90551. */
  90552. computeWorldMatrix(): Matrix;
  90553. /**
  90554. * Parse a JSON and creates the camera from the parsed information
  90555. * @param parsedCamera The JSON to parse
  90556. * @param scene The scene to instantiate the camera in
  90557. * @returns the newly constructed camera
  90558. */
  90559. static Parse(parsedCamera: any, scene: Scene): Camera;
  90560. }
  90561. }
  90562. declare module BABYLON {
  90563. /**
  90564. * Class containing static functions to help procedurally build meshes
  90565. */
  90566. export class DiscBuilder {
  90567. /**
  90568. * Creates a plane polygonal mesh. By default, this is a disc
  90569. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90570. * * 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
  90571. * * 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
  90572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90573. * * 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
  90574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90575. * @param name defines the name of the mesh
  90576. * @param options defines the options used to create the mesh
  90577. * @param scene defines the hosting scene
  90578. * @returns the plane polygonal mesh
  90579. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90580. */
  90581. static CreateDisc(name: string, options: {
  90582. radius?: number;
  90583. tessellation?: number;
  90584. arc?: number;
  90585. updatable?: boolean;
  90586. sideOrientation?: number;
  90587. frontUVs?: Vector4;
  90588. backUVs?: Vector4;
  90589. }, scene?: Nullable<Scene>): Mesh;
  90590. }
  90591. }
  90592. declare module BABYLON {
  90593. /**
  90594. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90595. *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.
  90596. * The SPS is also a particle system. It provides some methods to manage the particles.
  90597. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90598. *
  90599. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90600. */
  90601. export class SolidParticleSystem implements IDisposable {
  90602. /**
  90603. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90604. * Example : var p = SPS.particles[i];
  90605. */
  90606. particles: SolidParticle[];
  90607. /**
  90608. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90609. */
  90610. nbParticles: number;
  90611. /**
  90612. * If the particles must ever face the camera (default false). Useful for planar particles.
  90613. */
  90614. billboard: boolean;
  90615. /**
  90616. * Recompute normals when adding a shape
  90617. */
  90618. recomputeNormals: boolean;
  90619. /**
  90620. * This a counter ofr your own usage. It's not set by any SPS functions.
  90621. */
  90622. counter: number;
  90623. /**
  90624. * The SPS name. This name is also given to the underlying mesh.
  90625. */
  90626. name: string;
  90627. /**
  90628. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90629. */
  90630. mesh: Mesh;
  90631. /**
  90632. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90633. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90634. */
  90635. vars: any;
  90636. /**
  90637. * This array is populated when the SPS is set as 'pickable'.
  90638. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90639. * Each element of this array is an object `{idx: int, faceId: int}`.
  90640. * `idx` is the picked particle index in the `SPS.particles` array
  90641. * `faceId` is the picked face index counted within this particle.
  90642. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90643. */
  90644. pickedParticles: {
  90645. idx: number;
  90646. faceId: number;
  90647. }[];
  90648. /**
  90649. * This array is populated when `enableDepthSort` is set to true.
  90650. * Each element of this array is an instance of the class DepthSortedParticle.
  90651. */
  90652. depthSortedParticles: DepthSortedParticle[];
  90653. /**
  90654. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90655. * @hidden
  90656. */
  90657. _bSphereOnly: boolean;
  90658. /**
  90659. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90660. * @hidden
  90661. */
  90662. _bSphereRadiusFactor: number;
  90663. private _scene;
  90664. private _positions;
  90665. private _indices;
  90666. private _normals;
  90667. private _colors;
  90668. private _uvs;
  90669. private _indices32;
  90670. private _positions32;
  90671. private _normals32;
  90672. private _fixedNormal32;
  90673. private _colors32;
  90674. private _uvs32;
  90675. private _index;
  90676. private _updatable;
  90677. private _pickable;
  90678. private _isVisibilityBoxLocked;
  90679. private _alwaysVisible;
  90680. private _depthSort;
  90681. private _shapeCounter;
  90682. private _copy;
  90683. private _color;
  90684. private _computeParticleColor;
  90685. private _computeParticleTexture;
  90686. private _computeParticleRotation;
  90687. private _computeParticleVertex;
  90688. private _computeBoundingBox;
  90689. private _depthSortParticles;
  90690. private _camera;
  90691. private _mustUnrotateFixedNormals;
  90692. private _particlesIntersect;
  90693. private _needs32Bits;
  90694. /**
  90695. * Creates a SPS (Solid Particle System) object.
  90696. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90697. * @param scene (Scene) is the scene in which the SPS is added.
  90698. * @param options defines the options of the sps e.g.
  90699. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90700. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90701. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90702. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90703. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90704. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90705. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90706. */
  90707. constructor(name: string, scene: Scene, options?: {
  90708. updatable?: boolean;
  90709. isPickable?: boolean;
  90710. enableDepthSort?: boolean;
  90711. particleIntersection?: boolean;
  90712. boundingSphereOnly?: boolean;
  90713. bSphereRadiusFactor?: number;
  90714. });
  90715. /**
  90716. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90717. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90718. * @returns the created mesh
  90719. */
  90720. buildMesh(): Mesh;
  90721. /**
  90722. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90723. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90724. * Thus the particles generated from `digest()` have their property `position` set yet.
  90725. * @param mesh ( Mesh ) is the mesh to be digested
  90726. * @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
  90727. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90728. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90729. * @returns the current SPS
  90730. */
  90731. digest(mesh: Mesh, options?: {
  90732. facetNb?: number;
  90733. number?: number;
  90734. delta?: number;
  90735. }): SolidParticleSystem;
  90736. private _unrotateFixedNormals;
  90737. private _resetCopy;
  90738. private _meshBuilder;
  90739. private _posToShape;
  90740. private _uvsToShapeUV;
  90741. private _addParticle;
  90742. /**
  90743. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90744. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90745. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90746. * @param nb (positive integer) the number of particles to be created from this model
  90747. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90748. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90749. * @returns the number of shapes in the system
  90750. */
  90751. addShape(mesh: Mesh, nb: number, options?: {
  90752. positionFunction?: any;
  90753. vertexFunction?: any;
  90754. }): number;
  90755. private _rebuildParticle;
  90756. /**
  90757. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90758. * @returns the SPS.
  90759. */
  90760. rebuildMesh(): SolidParticleSystem;
  90761. /**
  90762. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90763. * This method calls `updateParticle()` for each particle of the SPS.
  90764. * For an animated SPS, it is usually called within the render loop.
  90765. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90766. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90767. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90768. * @returns the SPS.
  90769. */
  90770. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90771. /**
  90772. * Disposes the SPS.
  90773. */
  90774. dispose(): void;
  90775. /**
  90776. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90777. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90778. * @returns the SPS.
  90779. */
  90780. refreshVisibleSize(): SolidParticleSystem;
  90781. /**
  90782. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90783. * @param size the size (float) of the visibility box
  90784. * note : this doesn't lock the SPS mesh bounding box.
  90785. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90786. */
  90787. setVisibilityBox(size: number): void;
  90788. /**
  90789. * Gets whether the SPS as always visible or not
  90790. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90791. */
  90792. /**
  90793. * Sets the SPS as always visible or not
  90794. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90795. */
  90796. isAlwaysVisible: boolean;
  90797. /**
  90798. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90799. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90800. */
  90801. /**
  90802. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90803. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90804. */
  90805. isVisibilityBoxLocked: boolean;
  90806. /**
  90807. * Tells to `setParticles()` to compute the particle rotations or not.
  90808. * Default value : true. The SPS is faster when it's set to false.
  90809. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90810. */
  90811. /**
  90812. * Gets if `setParticles()` computes the particle rotations or not.
  90813. * Default value : true. The SPS is faster when it's set to false.
  90814. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  90815. */
  90816. computeParticleRotation: boolean;
  90817. /**
  90818. * Tells to `setParticles()` to compute the particle colors or not.
  90819. * Default value : true. The SPS is faster when it's set to false.
  90820. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90821. */
  90822. /**
  90823. * Gets if `setParticles()` computes the particle colors or not.
  90824. * Default value : true. The SPS is faster when it's set to false.
  90825. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  90826. */
  90827. computeParticleColor: boolean;
  90828. /**
  90829. * Gets if `setParticles()` computes the particle textures or not.
  90830. * Default value : true. The SPS is faster when it's set to false.
  90831. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  90832. */
  90833. computeParticleTexture: boolean;
  90834. /**
  90835. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  90836. * Default value : false. The SPS is faster when it's set to false.
  90837. * Note : the particle custom vertex positions aren't stored values.
  90838. */
  90839. /**
  90840. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  90841. * Default value : false. The SPS is faster when it's set to false.
  90842. * Note : the particle custom vertex positions aren't stored values.
  90843. */
  90844. computeParticleVertex: boolean;
  90845. /**
  90846. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  90847. */
  90848. /**
  90849. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  90850. */
  90851. computeBoundingBox: boolean;
  90852. /**
  90853. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  90854. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90855. * Default : `true`
  90856. */
  90857. /**
  90858. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  90859. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  90860. * Default : `true`
  90861. */
  90862. depthSortParticles: boolean;
  90863. /**
  90864. * This function does nothing. It may be overwritten to set all the particle first values.
  90865. * The SPS doesn't call this function, you may have to call it by your own.
  90866. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90867. */
  90868. initParticles(): void;
  90869. /**
  90870. * This function does nothing. It may be overwritten to recycle a particle.
  90871. * The SPS doesn't call this function, you may have to call it by your own.
  90872. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90873. * @param particle The particle to recycle
  90874. * @returns the recycled particle
  90875. */
  90876. recycleParticle(particle: SolidParticle): SolidParticle;
  90877. /**
  90878. * Updates a particle : this function should be overwritten by the user.
  90879. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  90880. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  90881. * @example : just set a particle position or velocity and recycle conditions
  90882. * @param particle The particle to update
  90883. * @returns the updated particle
  90884. */
  90885. updateParticle(particle: SolidParticle): SolidParticle;
  90886. /**
  90887. * Updates a vertex of a particle : it can be overwritten by the user.
  90888. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  90889. * @param particle the current particle
  90890. * @param vertex the current index of the current particle
  90891. * @param pt the index of the current vertex in the particle shape
  90892. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  90893. * @example : just set a vertex particle position
  90894. * @returns the updated vertex
  90895. */
  90896. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  90897. /**
  90898. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  90899. * This does nothing and may be overwritten by the user.
  90900. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90901. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90902. * @param update the boolean update value actually passed to setParticles()
  90903. */
  90904. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90905. /**
  90906. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  90907. * This will be passed three parameters.
  90908. * This does nothing and may be overwritten by the user.
  90909. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90910. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  90911. * @param update the boolean update value actually passed to setParticles()
  90912. */
  90913. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  90914. }
  90915. }
  90916. declare module BABYLON {
  90917. /**
  90918. * Represents one particle of a solid particle system.
  90919. */
  90920. export class SolidParticle {
  90921. /**
  90922. * particle global index
  90923. */
  90924. idx: number;
  90925. /**
  90926. * The color of the particle
  90927. */
  90928. color: Nullable<Color4>;
  90929. /**
  90930. * The world space position of the particle.
  90931. */
  90932. position: Vector3;
  90933. /**
  90934. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  90935. */
  90936. rotation: Vector3;
  90937. /**
  90938. * The world space rotation quaternion of the particle.
  90939. */
  90940. rotationQuaternion: Nullable<Quaternion>;
  90941. /**
  90942. * The scaling of the particle.
  90943. */
  90944. scaling: Vector3;
  90945. /**
  90946. * The uvs of the particle.
  90947. */
  90948. uvs: Vector4;
  90949. /**
  90950. * The current speed of the particle.
  90951. */
  90952. velocity: Vector3;
  90953. /**
  90954. * The pivot point in the particle local space.
  90955. */
  90956. pivot: Vector3;
  90957. /**
  90958. * Must the particle be translated from its pivot point in its local space ?
  90959. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  90960. * Default : false
  90961. */
  90962. translateFromPivot: boolean;
  90963. /**
  90964. * Is the particle active or not ?
  90965. */
  90966. alive: boolean;
  90967. /**
  90968. * Is the particle visible or not ?
  90969. */
  90970. isVisible: boolean;
  90971. /**
  90972. * Index of this particle in the global "positions" array (Internal use)
  90973. * @hidden
  90974. */
  90975. _pos: number;
  90976. /**
  90977. * @hidden Index of this particle in the global "indices" array (Internal use)
  90978. */
  90979. _ind: number;
  90980. /**
  90981. * @hidden ModelShape of this particle (Internal use)
  90982. */
  90983. _model: ModelShape;
  90984. /**
  90985. * ModelShape id of this particle
  90986. */
  90987. shapeId: number;
  90988. /**
  90989. * Index of the particle in its shape id
  90990. */
  90991. idxInShape: number;
  90992. /**
  90993. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  90994. */
  90995. _modelBoundingInfo: BoundingInfo;
  90996. /**
  90997. * @hidden Particle BoundingInfo object (Internal use)
  90998. */
  90999. _boundingInfo: BoundingInfo;
  91000. /**
  91001. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91002. */
  91003. _sps: SolidParticleSystem;
  91004. /**
  91005. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91006. */
  91007. _stillInvisible: boolean;
  91008. /**
  91009. * @hidden Last computed particle rotation matrix
  91010. */
  91011. _rotationMatrix: number[];
  91012. /**
  91013. * Parent particle Id, if any.
  91014. * Default null.
  91015. */
  91016. parentId: Nullable<number>;
  91017. /**
  91018. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91019. * The possible values are :
  91020. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91021. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91022. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91023. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91024. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91025. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91026. * */
  91027. cullingStrategy: number;
  91028. /**
  91029. * @hidden Internal global position in the SPS.
  91030. */
  91031. _globalPosition: Vector3;
  91032. /**
  91033. * Creates a Solid Particle object.
  91034. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91035. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91036. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91037. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91038. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91039. * @param shapeId (integer) is the model shape identifier in the SPS.
  91040. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91041. * @param sps defines the sps it is associated to
  91042. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91043. */
  91044. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91045. /**
  91046. * Legacy support, changed scale to scaling
  91047. */
  91048. /**
  91049. * Legacy support, changed scale to scaling
  91050. */
  91051. scale: Vector3;
  91052. /**
  91053. * Legacy support, changed quaternion to rotationQuaternion
  91054. */
  91055. /**
  91056. * Legacy support, changed quaternion to rotationQuaternion
  91057. */
  91058. quaternion: Nullable<Quaternion>;
  91059. /**
  91060. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91061. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91062. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91063. * @returns true if it intersects
  91064. */
  91065. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91066. /**
  91067. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91068. * A particle is in the frustum if its bounding box intersects the frustum
  91069. * @param frustumPlanes defines the frustum to test
  91070. * @returns true if the particle is in the frustum planes
  91071. */
  91072. isInFrustum(frustumPlanes: Plane[]): boolean;
  91073. /**
  91074. * get the rotation matrix of the particle
  91075. * @hidden
  91076. */
  91077. getRotationMatrix(m: Matrix): void;
  91078. }
  91079. /**
  91080. * Represents the shape of the model used by one particle of a solid particle system.
  91081. * SPS internal tool, don't use it manually.
  91082. */
  91083. export class ModelShape {
  91084. /**
  91085. * The shape id
  91086. * @hidden
  91087. */
  91088. shapeID: number;
  91089. /**
  91090. * flat array of model positions (internal use)
  91091. * @hidden
  91092. */
  91093. _shape: Vector3[];
  91094. /**
  91095. * flat array of model UVs (internal use)
  91096. * @hidden
  91097. */
  91098. _shapeUV: number[];
  91099. /**
  91100. * length of the shape in the model indices array (internal use)
  91101. * @hidden
  91102. */
  91103. _indicesLength: number;
  91104. /**
  91105. * Custom position function (internal use)
  91106. * @hidden
  91107. */
  91108. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91109. /**
  91110. * Custom vertex function (internal use)
  91111. * @hidden
  91112. */
  91113. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91114. /**
  91115. * 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.
  91116. * SPS internal tool, don't use it manually.
  91117. * @hidden
  91118. */
  91119. 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>);
  91120. }
  91121. /**
  91122. * Represents a Depth Sorted Particle in the solid particle system.
  91123. */
  91124. export class DepthSortedParticle {
  91125. /**
  91126. * Index of the particle in the "indices" array
  91127. */
  91128. ind: number;
  91129. /**
  91130. * Length of the particle shape in the "indices" array
  91131. */
  91132. indicesLength: number;
  91133. /**
  91134. * Squared distance from the particle to the camera
  91135. */
  91136. sqDistance: number;
  91137. }
  91138. }
  91139. declare module BABYLON {
  91140. /**
  91141. * @hidden
  91142. */
  91143. export class _MeshCollisionData {
  91144. _checkCollisions: boolean;
  91145. _collisionMask: number;
  91146. _collisionGroup: number;
  91147. _collider: Nullable<Collider>;
  91148. _oldPositionForCollisions: Vector3;
  91149. _diffPositionForCollisions: Vector3;
  91150. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91151. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91152. }
  91153. }
  91154. declare module BABYLON {
  91155. /** @hidden */
  91156. class _FacetDataStorage {
  91157. facetPositions: Vector3[];
  91158. facetNormals: Vector3[];
  91159. facetPartitioning: number[][];
  91160. facetNb: number;
  91161. partitioningSubdivisions: number;
  91162. partitioningBBoxRatio: number;
  91163. facetDataEnabled: boolean;
  91164. facetParameters: any;
  91165. bbSize: Vector3;
  91166. subDiv: {
  91167. max: number;
  91168. X: number;
  91169. Y: number;
  91170. Z: number;
  91171. };
  91172. facetDepthSort: boolean;
  91173. facetDepthSortEnabled: boolean;
  91174. depthSortedIndices: IndicesArray;
  91175. depthSortedFacets: {
  91176. ind: number;
  91177. sqDistance: number;
  91178. }[];
  91179. facetDepthSortFunction: (f1: {
  91180. ind: number;
  91181. sqDistance: number;
  91182. }, f2: {
  91183. ind: number;
  91184. sqDistance: number;
  91185. }) => number;
  91186. facetDepthSortFrom: Vector3;
  91187. facetDepthSortOrigin: Vector3;
  91188. invertedMatrix: Matrix;
  91189. }
  91190. /**
  91191. * @hidden
  91192. **/
  91193. class _InternalAbstractMeshDataInfo {
  91194. _hasVertexAlpha: boolean;
  91195. _useVertexColors: boolean;
  91196. _numBoneInfluencers: number;
  91197. _applyFog: boolean;
  91198. _receiveShadows: boolean;
  91199. _facetData: _FacetDataStorage;
  91200. _visibility: number;
  91201. _skeleton: Nullable<Skeleton>;
  91202. _layerMask: number;
  91203. _computeBonesUsingShaders: boolean;
  91204. _isActive: boolean;
  91205. _onlyForInstances: boolean;
  91206. _isActiveIntermediate: boolean;
  91207. _onlyForInstancesIntermediate: boolean;
  91208. }
  91209. /**
  91210. * Class used to store all common mesh properties
  91211. */
  91212. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91213. /** No occlusion */
  91214. static OCCLUSION_TYPE_NONE: number;
  91215. /** Occlusion set to optimisitic */
  91216. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91217. /** Occlusion set to strict */
  91218. static OCCLUSION_TYPE_STRICT: number;
  91219. /** Use an accurante occlusion algorithm */
  91220. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91221. /** Use a conservative occlusion algorithm */
  91222. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91223. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91224. * Test order :
  91225. * Is the bounding sphere outside the frustum ?
  91226. * If not, are the bounding box vertices outside the frustum ?
  91227. * It not, then the cullable object is in the frustum.
  91228. */
  91229. static readonly CULLINGSTRATEGY_STANDARD: number;
  91230. /** Culling strategy : Bounding Sphere Only.
  91231. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91232. * It's also less accurate than the standard because some not visible objects can still be selected.
  91233. * Test : is the bounding sphere outside the frustum ?
  91234. * If not, then the cullable object is in the frustum.
  91235. */
  91236. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91237. /** Culling strategy : Optimistic Inclusion.
  91238. * This in an inclusion test first, then the standard exclusion test.
  91239. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91240. * 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.
  91241. * Anyway, it's as accurate as the standard strategy.
  91242. * Test :
  91243. * Is the cullable object bounding sphere center in the frustum ?
  91244. * If not, apply the default culling strategy.
  91245. */
  91246. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91247. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91248. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91249. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91250. * 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.
  91251. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91252. * Test :
  91253. * Is the cullable object bounding sphere center in the frustum ?
  91254. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91255. */
  91256. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91257. /**
  91258. * No billboard
  91259. */
  91260. static readonly BILLBOARDMODE_NONE: number;
  91261. /** Billboard on X axis */
  91262. static readonly BILLBOARDMODE_X: number;
  91263. /** Billboard on Y axis */
  91264. static readonly BILLBOARDMODE_Y: number;
  91265. /** Billboard on Z axis */
  91266. static readonly BILLBOARDMODE_Z: number;
  91267. /** Billboard on all axes */
  91268. static readonly BILLBOARDMODE_ALL: number;
  91269. /** Billboard on using position instead of orientation */
  91270. static readonly BILLBOARDMODE_USE_POSITION: number;
  91271. /** @hidden */
  91272. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91273. /**
  91274. * The culling strategy to use to check whether the mesh must be rendered or not.
  91275. * This value can be changed at any time and will be used on the next render mesh selection.
  91276. * The possible values are :
  91277. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91278. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91279. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91280. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91281. * Please read each static variable documentation to get details about the culling process.
  91282. * */
  91283. cullingStrategy: number;
  91284. /**
  91285. * Gets the number of facets in the mesh
  91286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91287. */
  91288. readonly facetNb: number;
  91289. /**
  91290. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91292. */
  91293. partitioningSubdivisions: number;
  91294. /**
  91295. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91296. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91298. */
  91299. partitioningBBoxRatio: number;
  91300. /**
  91301. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91302. * Works only for updatable meshes.
  91303. * Doesn't work with multi-materials
  91304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91305. */
  91306. mustDepthSortFacets: boolean;
  91307. /**
  91308. * The location (Vector3) where the facet depth sort must be computed from.
  91309. * By default, the active camera position.
  91310. * Used only when facet depth sort is enabled
  91311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91312. */
  91313. facetDepthSortFrom: Vector3;
  91314. /**
  91315. * gets a boolean indicating if facetData is enabled
  91316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91317. */
  91318. readonly isFacetDataEnabled: boolean;
  91319. /** @hidden */
  91320. _updateNonUniformScalingState(value: boolean): boolean;
  91321. /**
  91322. * An event triggered when this mesh collides with another one
  91323. */
  91324. onCollideObservable: Observable<AbstractMesh>;
  91325. /** Set a function to call when this mesh collides with another one */
  91326. onCollide: () => void;
  91327. /**
  91328. * An event triggered when the collision's position changes
  91329. */
  91330. onCollisionPositionChangeObservable: Observable<Vector3>;
  91331. /** Set a function to call when the collision's position changes */
  91332. onCollisionPositionChange: () => void;
  91333. /**
  91334. * An event triggered when material is changed
  91335. */
  91336. onMaterialChangedObservable: Observable<AbstractMesh>;
  91337. /**
  91338. * Gets or sets the orientation for POV movement & rotation
  91339. */
  91340. definedFacingForward: boolean;
  91341. /** @hidden */
  91342. _occlusionQuery: Nullable<WebGLQuery>;
  91343. /** @hidden */
  91344. _renderingGroup: Nullable<RenderingGroup>;
  91345. /**
  91346. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91347. */
  91348. /**
  91349. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91350. */
  91351. visibility: number;
  91352. /** Gets or sets the alpha index used to sort transparent meshes
  91353. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91354. */
  91355. alphaIndex: number;
  91356. /**
  91357. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91358. */
  91359. isVisible: boolean;
  91360. /**
  91361. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91362. */
  91363. isPickable: boolean;
  91364. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91365. showSubMeshesBoundingBox: boolean;
  91366. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91367. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91368. */
  91369. isBlocker: boolean;
  91370. /**
  91371. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91372. */
  91373. enablePointerMoveEvents: boolean;
  91374. /**
  91375. * Specifies the rendering group id for this mesh (0 by default)
  91376. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91377. */
  91378. renderingGroupId: number;
  91379. private _material;
  91380. /** Gets or sets current material */
  91381. material: Nullable<Material>;
  91382. /**
  91383. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91384. * @see http://doc.babylonjs.com/babylon101/shadows
  91385. */
  91386. receiveShadows: boolean;
  91387. /** Defines color to use when rendering outline */
  91388. outlineColor: Color3;
  91389. /** Define width to use when rendering outline */
  91390. outlineWidth: number;
  91391. /** Defines color to use when rendering overlay */
  91392. overlayColor: Color3;
  91393. /** Defines alpha to use when rendering overlay */
  91394. overlayAlpha: number;
  91395. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91396. hasVertexAlpha: boolean;
  91397. /** 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) */
  91398. useVertexColors: boolean;
  91399. /**
  91400. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91401. */
  91402. computeBonesUsingShaders: boolean;
  91403. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91404. numBoneInfluencers: number;
  91405. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91406. applyFog: boolean;
  91407. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91408. useOctreeForRenderingSelection: boolean;
  91409. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91410. useOctreeForPicking: boolean;
  91411. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91412. useOctreeForCollisions: boolean;
  91413. /**
  91414. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91415. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91416. */
  91417. layerMask: number;
  91418. /**
  91419. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91420. */
  91421. alwaysSelectAsActiveMesh: boolean;
  91422. /**
  91423. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91424. */
  91425. doNotSyncBoundingInfo: boolean;
  91426. /**
  91427. * Gets or sets the current action manager
  91428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91429. */
  91430. actionManager: Nullable<AbstractActionManager>;
  91431. private _meshCollisionData;
  91432. /**
  91433. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91434. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91435. */
  91436. ellipsoid: Vector3;
  91437. /**
  91438. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91439. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91440. */
  91441. ellipsoidOffset: Vector3;
  91442. /**
  91443. * Gets or sets a collision mask used to mask collisions (default is -1).
  91444. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91445. */
  91446. collisionMask: number;
  91447. /**
  91448. * Gets or sets the current collision group mask (-1 by default).
  91449. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91450. */
  91451. collisionGroup: number;
  91452. /**
  91453. * Defines edge width used when edgesRenderer is enabled
  91454. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91455. */
  91456. edgesWidth: number;
  91457. /**
  91458. * Defines edge color used when edgesRenderer is enabled
  91459. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91460. */
  91461. edgesColor: Color4;
  91462. /** @hidden */
  91463. _edgesRenderer: Nullable<IEdgesRenderer>;
  91464. /** @hidden */
  91465. _masterMesh: Nullable<AbstractMesh>;
  91466. /** @hidden */
  91467. _boundingInfo: Nullable<BoundingInfo>;
  91468. /** @hidden */
  91469. _renderId: number;
  91470. /**
  91471. * Gets or sets the list of subMeshes
  91472. * @see http://doc.babylonjs.com/how_to/multi_materials
  91473. */
  91474. subMeshes: SubMesh[];
  91475. /** @hidden */
  91476. _intersectionsInProgress: AbstractMesh[];
  91477. /** @hidden */
  91478. _unIndexed: boolean;
  91479. /** @hidden */
  91480. _lightSources: Light[];
  91481. /** Gets the list of lights affecting that mesh */
  91482. readonly lightSources: Light[];
  91483. /** @hidden */
  91484. readonly _positions: Nullable<Vector3[]>;
  91485. /** @hidden */
  91486. _waitingData: {
  91487. lods: Nullable<any>;
  91488. actions: Nullable<any>;
  91489. freezeWorldMatrix: Nullable<boolean>;
  91490. };
  91491. /** @hidden */
  91492. _bonesTransformMatrices: Nullable<Float32Array>;
  91493. /** @hidden */
  91494. _transformMatrixTexture: Nullable<RawTexture>;
  91495. /**
  91496. * Gets or sets a skeleton to apply skining transformations
  91497. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91498. */
  91499. skeleton: Nullable<Skeleton>;
  91500. /**
  91501. * An event triggered when the mesh is rebuilt.
  91502. */
  91503. onRebuildObservable: Observable<AbstractMesh>;
  91504. /**
  91505. * Creates a new AbstractMesh
  91506. * @param name defines the name of the mesh
  91507. * @param scene defines the hosting scene
  91508. */
  91509. constructor(name: string, scene?: Nullable<Scene>);
  91510. /**
  91511. * Returns the string "AbstractMesh"
  91512. * @returns "AbstractMesh"
  91513. */
  91514. getClassName(): string;
  91515. /**
  91516. * Gets a string representation of the current mesh
  91517. * @param fullDetails defines a boolean indicating if full details must be included
  91518. * @returns a string representation of the current mesh
  91519. */
  91520. toString(fullDetails?: boolean): string;
  91521. /**
  91522. * @hidden
  91523. */
  91524. protected _getEffectiveParent(): Nullable<Node>;
  91525. /** @hidden */
  91526. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91527. /** @hidden */
  91528. _rebuild(): void;
  91529. /** @hidden */
  91530. _resyncLightSources(): void;
  91531. /** @hidden */
  91532. _resyncLighSource(light: Light): void;
  91533. /** @hidden */
  91534. _unBindEffect(): void;
  91535. /** @hidden */
  91536. _removeLightSource(light: Light, dispose: boolean): void;
  91537. private _markSubMeshesAsDirty;
  91538. /** @hidden */
  91539. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91540. /** @hidden */
  91541. _markSubMeshesAsAttributesDirty(): void;
  91542. /** @hidden */
  91543. _markSubMeshesAsMiscDirty(): void;
  91544. /**
  91545. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91546. */
  91547. scaling: Vector3;
  91548. /**
  91549. * Returns true if the mesh is blocked. Implemented by child classes
  91550. */
  91551. readonly isBlocked: boolean;
  91552. /**
  91553. * Returns the mesh itself by default. Implemented by child classes
  91554. * @param camera defines the camera to use to pick the right LOD level
  91555. * @returns the currentAbstractMesh
  91556. */
  91557. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91558. /**
  91559. * Returns 0 by default. Implemented by child classes
  91560. * @returns an integer
  91561. */
  91562. getTotalVertices(): number;
  91563. /**
  91564. * Returns a positive integer : the total number of indices in this mesh geometry.
  91565. * @returns the numner of indices or zero if the mesh has no geometry.
  91566. */
  91567. getTotalIndices(): number;
  91568. /**
  91569. * Returns null by default. Implemented by child classes
  91570. * @returns null
  91571. */
  91572. getIndices(): Nullable<IndicesArray>;
  91573. /**
  91574. * Returns the array of the requested vertex data kind. Implemented by child classes
  91575. * @param kind defines the vertex data kind to use
  91576. * @returns null
  91577. */
  91578. getVerticesData(kind: string): Nullable<FloatArray>;
  91579. /**
  91580. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91581. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91582. * Note that a new underlying VertexBuffer object is created each call.
  91583. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91584. * @param kind defines vertex data kind:
  91585. * * VertexBuffer.PositionKind
  91586. * * VertexBuffer.UVKind
  91587. * * VertexBuffer.UV2Kind
  91588. * * VertexBuffer.UV3Kind
  91589. * * VertexBuffer.UV4Kind
  91590. * * VertexBuffer.UV5Kind
  91591. * * VertexBuffer.UV6Kind
  91592. * * VertexBuffer.ColorKind
  91593. * * VertexBuffer.MatricesIndicesKind
  91594. * * VertexBuffer.MatricesIndicesExtraKind
  91595. * * VertexBuffer.MatricesWeightsKind
  91596. * * VertexBuffer.MatricesWeightsExtraKind
  91597. * @param data defines the data source
  91598. * @param updatable defines if the data must be flagged as updatable (or static)
  91599. * @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
  91600. * @returns the current mesh
  91601. */
  91602. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91603. /**
  91604. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91605. * If the mesh has no geometry, it is simply returned as it is.
  91606. * @param kind defines vertex data kind:
  91607. * * VertexBuffer.PositionKind
  91608. * * VertexBuffer.UVKind
  91609. * * VertexBuffer.UV2Kind
  91610. * * VertexBuffer.UV3Kind
  91611. * * VertexBuffer.UV4Kind
  91612. * * VertexBuffer.UV5Kind
  91613. * * VertexBuffer.UV6Kind
  91614. * * VertexBuffer.ColorKind
  91615. * * VertexBuffer.MatricesIndicesKind
  91616. * * VertexBuffer.MatricesIndicesExtraKind
  91617. * * VertexBuffer.MatricesWeightsKind
  91618. * * VertexBuffer.MatricesWeightsExtraKind
  91619. * @param data defines the data source
  91620. * @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
  91621. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91622. * @returns the current mesh
  91623. */
  91624. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91625. /**
  91626. * Sets the mesh indices,
  91627. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91628. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91629. * @param totalVertices Defines the total number of vertices
  91630. * @returns the current mesh
  91631. */
  91632. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91633. /**
  91634. * Gets a boolean indicating if specific vertex data is present
  91635. * @param kind defines the vertex data kind to use
  91636. * @returns true is data kind is present
  91637. */
  91638. isVerticesDataPresent(kind: string): boolean;
  91639. /**
  91640. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91641. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91642. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91643. * @returns a BoundingInfo
  91644. */
  91645. getBoundingInfo(): BoundingInfo;
  91646. /**
  91647. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91648. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91649. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91650. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91651. * @returns the current mesh
  91652. */
  91653. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91654. /**
  91655. * Overwrite the current bounding info
  91656. * @param boundingInfo defines the new bounding info
  91657. * @returns the current mesh
  91658. */
  91659. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91660. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91661. readonly useBones: boolean;
  91662. /** @hidden */
  91663. _preActivate(): void;
  91664. /** @hidden */
  91665. _preActivateForIntermediateRendering(renderId: number): void;
  91666. /** @hidden */
  91667. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91668. /** @hidden */
  91669. _postActivate(): void;
  91670. /** @hidden */
  91671. _freeze(): void;
  91672. /** @hidden */
  91673. _unFreeze(): void;
  91674. /**
  91675. * Gets the current world matrix
  91676. * @returns a Matrix
  91677. */
  91678. getWorldMatrix(): Matrix;
  91679. /** @hidden */
  91680. _getWorldMatrixDeterminant(): number;
  91681. /**
  91682. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91683. */
  91684. readonly isAnInstance: boolean;
  91685. /**
  91686. * Gets a boolean indicating if this mesh has instances
  91687. */
  91688. readonly hasInstances: boolean;
  91689. /**
  91690. * Perform relative position change from the point of view of behind the front of the mesh.
  91691. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91692. * Supports definition of mesh facing forward or backward
  91693. * @param amountRight defines the distance on the right axis
  91694. * @param amountUp defines the distance on the up axis
  91695. * @param amountForward defines the distance on the forward axis
  91696. * @returns the current mesh
  91697. */
  91698. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91699. /**
  91700. * Calculate relative position change from the point of view of behind the front of the mesh.
  91701. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91702. * Supports definition of mesh facing forward or backward
  91703. * @param amountRight defines the distance on the right axis
  91704. * @param amountUp defines the distance on the up axis
  91705. * @param amountForward defines the distance on the forward axis
  91706. * @returns the new displacement vector
  91707. */
  91708. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91709. /**
  91710. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91711. * Supports definition of mesh facing forward or backward
  91712. * @param flipBack defines the flip
  91713. * @param twirlClockwise defines the twirl
  91714. * @param tiltRight defines the tilt
  91715. * @returns the current mesh
  91716. */
  91717. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91718. /**
  91719. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91720. * Supports definition of mesh facing forward or backward.
  91721. * @param flipBack defines the flip
  91722. * @param twirlClockwise defines the twirl
  91723. * @param tiltRight defines the tilt
  91724. * @returns the new rotation vector
  91725. */
  91726. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91727. /**
  91728. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91729. * This means the mesh underlying bounding box and sphere are recomputed.
  91730. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91731. * @returns the current mesh
  91732. */
  91733. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91734. /** @hidden */
  91735. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91736. /** @hidden */
  91737. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91738. /** @hidden */
  91739. _updateBoundingInfo(): AbstractMesh;
  91740. /** @hidden */
  91741. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91742. /** @hidden */
  91743. protected _afterComputeWorldMatrix(): void;
  91744. /** @hidden */
  91745. readonly _effectiveMesh: AbstractMesh;
  91746. /**
  91747. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91748. * A mesh is in the frustum if its bounding box intersects the frustum
  91749. * @param frustumPlanes defines the frustum to test
  91750. * @returns true if the mesh is in the frustum planes
  91751. */
  91752. isInFrustum(frustumPlanes: Plane[]): boolean;
  91753. /**
  91754. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91755. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91756. * @param frustumPlanes defines the frustum to test
  91757. * @returns true if the mesh is completely in the frustum planes
  91758. */
  91759. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91760. /**
  91761. * True if the mesh intersects another mesh or a SolidParticle object
  91762. * @param mesh defines a target mesh or SolidParticle to test
  91763. * @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)
  91764. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91765. * @returns true if there is an intersection
  91766. */
  91767. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91768. /**
  91769. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91770. * @param point defines the point to test
  91771. * @returns true if there is an intersection
  91772. */
  91773. intersectsPoint(point: Vector3): boolean;
  91774. /**
  91775. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91777. */
  91778. checkCollisions: boolean;
  91779. /**
  91780. * Gets Collider object used to compute collisions (not physics)
  91781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91782. */
  91783. readonly collider: Nullable<Collider>;
  91784. /**
  91785. * Move the mesh using collision engine
  91786. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91787. * @param displacement defines the requested displacement vector
  91788. * @returns the current mesh
  91789. */
  91790. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91791. private _onCollisionPositionChange;
  91792. /** @hidden */
  91793. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91794. /** @hidden */
  91795. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91796. /** @hidden */
  91797. _checkCollision(collider: Collider): AbstractMesh;
  91798. /** @hidden */
  91799. _generatePointsArray(): boolean;
  91800. /**
  91801. * Checks if the passed Ray intersects with the mesh
  91802. * @param ray defines the ray to use
  91803. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91804. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91805. * @returns the picking info
  91806. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91807. */
  91808. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  91809. /**
  91810. * Clones the current mesh
  91811. * @param name defines the mesh name
  91812. * @param newParent defines the new mesh parent
  91813. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  91814. * @returns the new mesh
  91815. */
  91816. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91817. /**
  91818. * Disposes all the submeshes of the current meshnp
  91819. * @returns the current mesh
  91820. */
  91821. releaseSubMeshes(): AbstractMesh;
  91822. /**
  91823. * Releases resources associated with this abstract mesh.
  91824. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91825. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91826. */
  91827. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91828. /**
  91829. * Adds the passed mesh as a child to the current mesh
  91830. * @param mesh defines the child mesh
  91831. * @returns the current mesh
  91832. */
  91833. addChild(mesh: AbstractMesh): AbstractMesh;
  91834. /**
  91835. * Removes the passed mesh from the current mesh children list
  91836. * @param mesh defines the child mesh
  91837. * @returns the current mesh
  91838. */
  91839. removeChild(mesh: AbstractMesh): AbstractMesh;
  91840. /** @hidden */
  91841. private _initFacetData;
  91842. /**
  91843. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  91844. * This method can be called within the render loop.
  91845. * 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
  91846. * @returns the current mesh
  91847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91848. */
  91849. updateFacetData(): AbstractMesh;
  91850. /**
  91851. * Returns the facetLocalNormals array.
  91852. * The normals are expressed in the mesh local spac
  91853. * @returns an array of Vector3
  91854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91855. */
  91856. getFacetLocalNormals(): Vector3[];
  91857. /**
  91858. * Returns the facetLocalPositions array.
  91859. * The facet positions are expressed in the mesh local space
  91860. * @returns an array of Vector3
  91861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91862. */
  91863. getFacetLocalPositions(): Vector3[];
  91864. /**
  91865. * Returns the facetLocalPartioning array
  91866. * @returns an array of array of numbers
  91867. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91868. */
  91869. getFacetLocalPartitioning(): number[][];
  91870. /**
  91871. * Returns the i-th facet position in the world system.
  91872. * This method allocates a new Vector3 per call
  91873. * @param i defines the facet index
  91874. * @returns a new Vector3
  91875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91876. */
  91877. getFacetPosition(i: number): Vector3;
  91878. /**
  91879. * Sets the reference Vector3 with the i-th facet position in the world system
  91880. * @param i defines the facet index
  91881. * @param ref defines the target vector
  91882. * @returns the current mesh
  91883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91884. */
  91885. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  91886. /**
  91887. * Returns the i-th facet normal in the world system.
  91888. * This method allocates a new Vector3 per call
  91889. * @param i defines the facet index
  91890. * @returns a new Vector3
  91891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91892. */
  91893. getFacetNormal(i: number): Vector3;
  91894. /**
  91895. * Sets the reference Vector3 with the i-th facet normal in the world system
  91896. * @param i defines the facet index
  91897. * @param ref defines the target vector
  91898. * @returns the current mesh
  91899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91900. */
  91901. getFacetNormalToRef(i: number, ref: Vector3): this;
  91902. /**
  91903. * 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)
  91904. * @param x defines x coordinate
  91905. * @param y defines y coordinate
  91906. * @param z defines z coordinate
  91907. * @returns the array of facet indexes
  91908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91909. */
  91910. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  91911. /**
  91912. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  91913. * @param projected sets as the (x,y,z) world projection on the facet
  91914. * @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
  91915. * @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
  91916. * @param x defines x coordinate
  91917. * @param y defines y coordinate
  91918. * @param z defines z coordinate
  91919. * @returns the face index if found (or null instead)
  91920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91921. */
  91922. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91923. /**
  91924. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  91925. * @param projected sets as the (x,y,z) local projection on the facet
  91926. * @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
  91927. * @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
  91928. * @param x defines x coordinate
  91929. * @param y defines y coordinate
  91930. * @param z defines z coordinate
  91931. * @returns the face index if found (or null instead)
  91932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91933. */
  91934. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  91935. /**
  91936. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  91937. * @returns the parameters
  91938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91939. */
  91940. getFacetDataParameters(): any;
  91941. /**
  91942. * Disables the feature FacetData and frees the related memory
  91943. * @returns the current mesh
  91944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  91945. */
  91946. disableFacetData(): AbstractMesh;
  91947. /**
  91948. * Updates the AbstractMesh indices array
  91949. * @param indices defines the data source
  91950. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91951. * @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)
  91952. * @returns the current mesh
  91953. */
  91954. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91955. /**
  91956. * Creates new normals data for the mesh
  91957. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  91958. * @returns the current mesh
  91959. */
  91960. createNormals(updatable: boolean): AbstractMesh;
  91961. /**
  91962. * Align the mesh with a normal
  91963. * @param normal defines the normal to use
  91964. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  91965. * @returns the current mesh
  91966. */
  91967. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  91968. /** @hidden */
  91969. _checkOcclusionQuery(): boolean;
  91970. /**
  91971. * Disables the mesh edge rendering mode
  91972. * @returns the currentAbstractMesh
  91973. */
  91974. disableEdgesRendering(): AbstractMesh;
  91975. /**
  91976. * Enables the edge rendering mode on the mesh.
  91977. * This mode makes the mesh edges visible
  91978. * @param epsilon defines the maximal distance between two angles to detect a face
  91979. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91980. * @returns the currentAbstractMesh
  91981. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91982. */
  91983. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91984. }
  91985. }
  91986. declare module BABYLON {
  91987. /**
  91988. * Interface used to define ActionEvent
  91989. */
  91990. export interface IActionEvent {
  91991. /** The mesh or sprite that triggered the action */
  91992. source: any;
  91993. /** The X mouse cursor position at the time of the event */
  91994. pointerX: number;
  91995. /** The Y mouse cursor position at the time of the event */
  91996. pointerY: number;
  91997. /** The mesh that is currently pointed at (can be null) */
  91998. meshUnderPointer: Nullable<AbstractMesh>;
  91999. /** the original (browser) event that triggered the ActionEvent */
  92000. sourceEvent?: any;
  92001. /** additional data for the event */
  92002. additionalData?: any;
  92003. }
  92004. /**
  92005. * ActionEvent is the event being sent when an action is triggered.
  92006. */
  92007. export class ActionEvent implements IActionEvent {
  92008. /** The mesh or sprite that triggered the action */
  92009. source: any;
  92010. /** The X mouse cursor position at the time of the event */
  92011. pointerX: number;
  92012. /** The Y mouse cursor position at the time of the event */
  92013. pointerY: number;
  92014. /** The mesh that is currently pointed at (can be null) */
  92015. meshUnderPointer: Nullable<AbstractMesh>;
  92016. /** the original (browser) event that triggered the ActionEvent */
  92017. sourceEvent?: any;
  92018. /** additional data for the event */
  92019. additionalData?: any;
  92020. /**
  92021. * Creates a new ActionEvent
  92022. * @param source The mesh or sprite that triggered the action
  92023. * @param pointerX The X mouse cursor position at the time of the event
  92024. * @param pointerY The Y mouse cursor position at the time of the event
  92025. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92026. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92027. * @param additionalData additional data for the event
  92028. */
  92029. constructor(
  92030. /** The mesh or sprite that triggered the action */
  92031. source: any,
  92032. /** The X mouse cursor position at the time of the event */
  92033. pointerX: number,
  92034. /** The Y mouse cursor position at the time of the event */
  92035. pointerY: number,
  92036. /** The mesh that is currently pointed at (can be null) */
  92037. meshUnderPointer: Nullable<AbstractMesh>,
  92038. /** the original (browser) event that triggered the ActionEvent */
  92039. sourceEvent?: any,
  92040. /** additional data for the event */
  92041. additionalData?: any);
  92042. /**
  92043. * Helper function to auto-create an ActionEvent from a source mesh.
  92044. * @param source The source mesh that triggered the event
  92045. * @param evt The original (browser) event
  92046. * @param additionalData additional data for the event
  92047. * @returns the new ActionEvent
  92048. */
  92049. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92050. /**
  92051. * Helper function to auto-create an ActionEvent from a source sprite
  92052. * @param source The source sprite that triggered the event
  92053. * @param scene Scene associated with the sprite
  92054. * @param evt The original (browser) event
  92055. * @param additionalData additional data for the event
  92056. * @returns the new ActionEvent
  92057. */
  92058. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92059. /**
  92060. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92061. * @param scene the scene where the event occurred
  92062. * @param evt The original (browser) event
  92063. * @returns the new ActionEvent
  92064. */
  92065. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92066. /**
  92067. * Helper function to auto-create an ActionEvent from a primitive
  92068. * @param prim defines the target primitive
  92069. * @param pointerPos defines the pointer position
  92070. * @param evt The original (browser) event
  92071. * @param additionalData additional data for the event
  92072. * @returns the new ActionEvent
  92073. */
  92074. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92075. }
  92076. }
  92077. declare module BABYLON {
  92078. /**
  92079. * Abstract class used to decouple action Manager from scene and meshes.
  92080. * Do not instantiate.
  92081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92082. */
  92083. export abstract class AbstractActionManager implements IDisposable {
  92084. /** Gets the list of active triggers */
  92085. static Triggers: {
  92086. [key: string]: number;
  92087. };
  92088. /** Gets the cursor to use when hovering items */
  92089. hoverCursor: string;
  92090. /** Gets the list of actions */
  92091. actions: IAction[];
  92092. /**
  92093. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92094. */
  92095. isRecursive: boolean;
  92096. /**
  92097. * Releases all associated resources
  92098. */
  92099. abstract dispose(): void;
  92100. /**
  92101. * Does this action manager has pointer triggers
  92102. */
  92103. abstract readonly hasPointerTriggers: boolean;
  92104. /**
  92105. * Does this action manager has pick triggers
  92106. */
  92107. abstract readonly hasPickTriggers: boolean;
  92108. /**
  92109. * Process a specific trigger
  92110. * @param trigger defines the trigger to process
  92111. * @param evt defines the event details to be processed
  92112. */
  92113. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92114. /**
  92115. * Does this action manager handles actions of any of the given triggers
  92116. * @param triggers defines the triggers to be tested
  92117. * @return a boolean indicating whether one (or more) of the triggers is handled
  92118. */
  92119. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92120. /**
  92121. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92122. * speed.
  92123. * @param triggerA defines the trigger to be tested
  92124. * @param triggerB defines the trigger to be tested
  92125. * @return a boolean indicating whether one (or more) of the triggers is handled
  92126. */
  92127. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92128. /**
  92129. * Does this action manager handles actions of a given trigger
  92130. * @param trigger defines the trigger to be tested
  92131. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92132. * @return whether the trigger is handled
  92133. */
  92134. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92135. /**
  92136. * Serialize this manager to a JSON object
  92137. * @param name defines the property name to store this manager
  92138. * @returns a JSON representation of this manager
  92139. */
  92140. abstract serialize(name: string): any;
  92141. /**
  92142. * Registers an action to this action manager
  92143. * @param action defines the action to be registered
  92144. * @return the action amended (prepared) after registration
  92145. */
  92146. abstract registerAction(action: IAction): Nullable<IAction>;
  92147. /**
  92148. * Unregisters an action to this action manager
  92149. * @param action defines the action to be unregistered
  92150. * @return a boolean indicating whether the action has been unregistered
  92151. */
  92152. abstract unregisterAction(action: IAction): Boolean;
  92153. /**
  92154. * Does exist one action manager with at least one trigger
  92155. **/
  92156. static readonly HasTriggers: boolean;
  92157. /**
  92158. * Does exist one action manager with at least one pick trigger
  92159. **/
  92160. static readonly HasPickTriggers: boolean;
  92161. /**
  92162. * Does exist one action manager that handles actions of a given trigger
  92163. * @param trigger defines the trigger to be tested
  92164. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92165. **/
  92166. static HasSpecificTrigger(trigger: number): boolean;
  92167. }
  92168. }
  92169. declare module BABYLON {
  92170. /**
  92171. * Defines how a node can be built from a string name.
  92172. */
  92173. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92174. /**
  92175. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92176. */
  92177. export class Node implements IBehaviorAware<Node> {
  92178. /** @hidden */
  92179. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92180. private static _NodeConstructors;
  92181. /**
  92182. * Add a new node constructor
  92183. * @param type defines the type name of the node to construct
  92184. * @param constructorFunc defines the constructor function
  92185. */
  92186. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92187. /**
  92188. * Returns a node constructor based on type name
  92189. * @param type defines the type name
  92190. * @param name defines the new node name
  92191. * @param scene defines the hosting scene
  92192. * @param options defines optional options to transmit to constructors
  92193. * @returns the new constructor or null
  92194. */
  92195. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92196. /**
  92197. * Gets or sets the name of the node
  92198. */
  92199. name: string;
  92200. /**
  92201. * Gets or sets the id of the node
  92202. */
  92203. id: string;
  92204. /**
  92205. * Gets or sets the unique id of the node
  92206. */
  92207. uniqueId: number;
  92208. /**
  92209. * Gets or sets a string used to store user defined state for the node
  92210. */
  92211. state: string;
  92212. /**
  92213. * Gets or sets an object used to store user defined information for the node
  92214. */
  92215. metadata: any;
  92216. /**
  92217. * For internal use only. Please do not use.
  92218. */
  92219. reservedDataStore: any;
  92220. /**
  92221. * List of inspectable custom properties (used by the Inspector)
  92222. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92223. */
  92224. inspectableCustomProperties: IInspectable[];
  92225. /**
  92226. * Gets or sets a boolean used to define if the node must be serialized
  92227. */
  92228. doNotSerialize: boolean;
  92229. /** @hidden */
  92230. _isDisposed: boolean;
  92231. /**
  92232. * Gets a list of Animations associated with the node
  92233. */
  92234. animations: Animation[];
  92235. protected _ranges: {
  92236. [name: string]: Nullable<AnimationRange>;
  92237. };
  92238. /**
  92239. * Callback raised when the node is ready to be used
  92240. */
  92241. onReady: Nullable<(node: Node) => void>;
  92242. private _isEnabled;
  92243. private _isParentEnabled;
  92244. private _isReady;
  92245. /** @hidden */
  92246. _currentRenderId: number;
  92247. private _parentUpdateId;
  92248. /** @hidden */
  92249. _childUpdateId: number;
  92250. /** @hidden */
  92251. _waitingParentId: Nullable<string>;
  92252. /** @hidden */
  92253. _scene: Scene;
  92254. /** @hidden */
  92255. _cache: any;
  92256. private _parentNode;
  92257. private _children;
  92258. /** @hidden */
  92259. _worldMatrix: Matrix;
  92260. /** @hidden */
  92261. _worldMatrixDeterminant: number;
  92262. /** @hidden */
  92263. _worldMatrixDeterminantIsDirty: boolean;
  92264. /** @hidden */
  92265. private _sceneRootNodesIndex;
  92266. /**
  92267. * Gets a boolean indicating if the node has been disposed
  92268. * @returns true if the node was disposed
  92269. */
  92270. isDisposed(): boolean;
  92271. /**
  92272. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92273. * @see https://doc.babylonjs.com/how_to/parenting
  92274. */
  92275. parent: Nullable<Node>;
  92276. private addToSceneRootNodes;
  92277. private removeFromSceneRootNodes;
  92278. private _animationPropertiesOverride;
  92279. /**
  92280. * Gets or sets the animation properties override
  92281. */
  92282. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92283. /**
  92284. * Gets a string idenfifying the name of the class
  92285. * @returns "Node" string
  92286. */
  92287. getClassName(): string;
  92288. /** @hidden */
  92289. readonly _isNode: boolean;
  92290. /**
  92291. * An event triggered when the mesh is disposed
  92292. */
  92293. onDisposeObservable: Observable<Node>;
  92294. private _onDisposeObserver;
  92295. /**
  92296. * Sets a callback that will be raised when the node will be disposed
  92297. */
  92298. onDispose: () => void;
  92299. /**
  92300. * Creates a new Node
  92301. * @param name the name and id to be given to this node
  92302. * @param scene the scene this node will be added to
  92303. * @param addToRootNodes the node will be added to scene.rootNodes
  92304. */
  92305. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92306. /**
  92307. * Gets the scene of the node
  92308. * @returns a scene
  92309. */
  92310. getScene(): Scene;
  92311. /**
  92312. * Gets the engine of the node
  92313. * @returns a Engine
  92314. */
  92315. getEngine(): Engine;
  92316. private _behaviors;
  92317. /**
  92318. * Attach a behavior to the node
  92319. * @see http://doc.babylonjs.com/features/behaviour
  92320. * @param behavior defines the behavior to attach
  92321. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92322. * @returns the current Node
  92323. */
  92324. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92325. /**
  92326. * Remove an attached behavior
  92327. * @see http://doc.babylonjs.com/features/behaviour
  92328. * @param behavior defines the behavior to attach
  92329. * @returns the current Node
  92330. */
  92331. removeBehavior(behavior: Behavior<Node>): Node;
  92332. /**
  92333. * Gets the list of attached behaviors
  92334. * @see http://doc.babylonjs.com/features/behaviour
  92335. */
  92336. readonly behaviors: Behavior<Node>[];
  92337. /**
  92338. * Gets an attached behavior by name
  92339. * @param name defines the name of the behavior to look for
  92340. * @see http://doc.babylonjs.com/features/behaviour
  92341. * @returns null if behavior was not found else the requested behavior
  92342. */
  92343. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92344. /**
  92345. * Returns the latest update of the World matrix
  92346. * @returns a Matrix
  92347. */
  92348. getWorldMatrix(): Matrix;
  92349. /** @hidden */
  92350. _getWorldMatrixDeterminant(): number;
  92351. /**
  92352. * Returns directly the latest state of the mesh World matrix.
  92353. * A Matrix is returned.
  92354. */
  92355. readonly worldMatrixFromCache: Matrix;
  92356. /** @hidden */
  92357. _initCache(): void;
  92358. /** @hidden */
  92359. updateCache(force?: boolean): void;
  92360. /** @hidden */
  92361. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92362. /** @hidden */
  92363. _updateCache(ignoreParentClass?: boolean): void;
  92364. /** @hidden */
  92365. _isSynchronized(): boolean;
  92366. /** @hidden */
  92367. _markSyncedWithParent(): void;
  92368. /** @hidden */
  92369. isSynchronizedWithParent(): boolean;
  92370. /** @hidden */
  92371. isSynchronized(): boolean;
  92372. /**
  92373. * Is this node ready to be used/rendered
  92374. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92375. * @return true if the node is ready
  92376. */
  92377. isReady(completeCheck?: boolean): boolean;
  92378. /**
  92379. * Is this node enabled?
  92380. * 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
  92381. * @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
  92382. * @return whether this node (and its parent) is enabled
  92383. */
  92384. isEnabled(checkAncestors?: boolean): boolean;
  92385. /** @hidden */
  92386. protected _syncParentEnabledState(): void;
  92387. /**
  92388. * Set the enabled state of this node
  92389. * @param value defines the new enabled state
  92390. */
  92391. setEnabled(value: boolean): void;
  92392. /**
  92393. * Is this node a descendant of the given node?
  92394. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92395. * @param ancestor defines the parent node to inspect
  92396. * @returns a boolean indicating if this node is a descendant of the given node
  92397. */
  92398. isDescendantOf(ancestor: Node): boolean;
  92399. /** @hidden */
  92400. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92401. /**
  92402. * Will return all nodes that have this node as ascendant
  92403. * @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
  92404. * @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
  92405. * @return all children nodes of all types
  92406. */
  92407. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92408. /**
  92409. * Get all child-meshes of this node
  92410. * @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)
  92411. * @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
  92412. * @returns an array of AbstractMesh
  92413. */
  92414. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92415. /**
  92416. * Get all direct children of this node
  92417. * @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
  92418. * @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)
  92419. * @returns an array of Node
  92420. */
  92421. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92422. /** @hidden */
  92423. _setReady(state: boolean): void;
  92424. /**
  92425. * Get an animation by name
  92426. * @param name defines the name of the animation to look for
  92427. * @returns null if not found else the requested animation
  92428. */
  92429. getAnimationByName(name: string): Nullable<Animation>;
  92430. /**
  92431. * Creates an animation range for this node
  92432. * @param name defines the name of the range
  92433. * @param from defines the starting key
  92434. * @param to defines the end key
  92435. */
  92436. createAnimationRange(name: string, from: number, to: number): void;
  92437. /**
  92438. * Delete a specific animation range
  92439. * @param name defines the name of the range to delete
  92440. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92441. */
  92442. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92443. /**
  92444. * Get an animation range by name
  92445. * @param name defines the name of the animation range to look for
  92446. * @returns null if not found else the requested animation range
  92447. */
  92448. getAnimationRange(name: string): Nullable<AnimationRange>;
  92449. /**
  92450. * Gets the list of all animation ranges defined on this node
  92451. * @returns an array
  92452. */
  92453. getAnimationRanges(): Nullable<AnimationRange>[];
  92454. /**
  92455. * Will start the animation sequence
  92456. * @param name defines the range frames for animation sequence
  92457. * @param loop defines if the animation should loop (false by default)
  92458. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92459. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92460. * @returns the object created for this animation. If range does not exist, it will return null
  92461. */
  92462. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92463. /**
  92464. * Serialize animation ranges into a JSON compatible object
  92465. * @returns serialization object
  92466. */
  92467. serializeAnimationRanges(): any;
  92468. /**
  92469. * Computes the world matrix of the node
  92470. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92471. * @returns the world matrix
  92472. */
  92473. computeWorldMatrix(force?: boolean): Matrix;
  92474. /**
  92475. * Releases resources associated with this node.
  92476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92478. */
  92479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92480. /**
  92481. * Parse animation range data from a serialization object and store them into a given node
  92482. * @param node defines where to store the animation ranges
  92483. * @param parsedNode defines the serialization object to read data from
  92484. * @param scene defines the hosting scene
  92485. */
  92486. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92487. /**
  92488. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92489. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92490. * @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
  92491. * @returns the new bounding vectors
  92492. */
  92493. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92494. min: Vector3;
  92495. max: Vector3;
  92496. };
  92497. }
  92498. }
  92499. declare module BABYLON {
  92500. /**
  92501. * @hidden
  92502. */
  92503. export class _IAnimationState {
  92504. key: number;
  92505. repeatCount: number;
  92506. workValue?: any;
  92507. loopMode?: number;
  92508. offsetValue?: any;
  92509. highLimitValue?: any;
  92510. }
  92511. /**
  92512. * Class used to store any kind of animation
  92513. */
  92514. export class Animation {
  92515. /**Name of the animation */
  92516. name: string;
  92517. /**Property to animate */
  92518. targetProperty: string;
  92519. /**The frames per second of the animation */
  92520. framePerSecond: number;
  92521. /**The data type of the animation */
  92522. dataType: number;
  92523. /**The loop mode of the animation */
  92524. loopMode?: number | undefined;
  92525. /**Specifies if blending should be enabled */
  92526. enableBlending?: boolean | undefined;
  92527. /**
  92528. * Use matrix interpolation instead of using direct key value when animating matrices
  92529. */
  92530. static AllowMatricesInterpolation: boolean;
  92531. /**
  92532. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92533. */
  92534. static AllowMatrixDecomposeForInterpolation: boolean;
  92535. /**
  92536. * Stores the key frames of the animation
  92537. */
  92538. private _keys;
  92539. /**
  92540. * Stores the easing function of the animation
  92541. */
  92542. private _easingFunction;
  92543. /**
  92544. * @hidden Internal use only
  92545. */
  92546. _runtimeAnimations: RuntimeAnimation[];
  92547. /**
  92548. * The set of event that will be linked to this animation
  92549. */
  92550. private _events;
  92551. /**
  92552. * Stores an array of target property paths
  92553. */
  92554. targetPropertyPath: string[];
  92555. /**
  92556. * Stores the blending speed of the animation
  92557. */
  92558. blendingSpeed: number;
  92559. /**
  92560. * Stores the animation ranges for the animation
  92561. */
  92562. private _ranges;
  92563. /**
  92564. * @hidden Internal use
  92565. */
  92566. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92567. /**
  92568. * Sets up an animation
  92569. * @param property The property to animate
  92570. * @param animationType The animation type to apply
  92571. * @param framePerSecond The frames per second of the animation
  92572. * @param easingFunction The easing function used in the animation
  92573. * @returns The created animation
  92574. */
  92575. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92576. /**
  92577. * Create and start an animation on a node
  92578. * @param name defines the name of the global animation that will be run on all nodes
  92579. * @param node defines the root node where the animation will take place
  92580. * @param targetProperty defines property to animate
  92581. * @param framePerSecond defines the number of frame per second yo use
  92582. * @param totalFrame defines the number of frames in total
  92583. * @param from defines the initial value
  92584. * @param to defines the final value
  92585. * @param loopMode defines which loop mode you want to use (off by default)
  92586. * @param easingFunction defines the easing function to use (linear by default)
  92587. * @param onAnimationEnd defines the callback to call when animation end
  92588. * @returns the animatable created for this animation
  92589. */
  92590. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92591. /**
  92592. * Create and start an animation on a node and its descendants
  92593. * @param name defines the name of the global animation that will be run on all nodes
  92594. * @param node defines the root node where the animation will take place
  92595. * @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
  92596. * @param targetProperty defines property to animate
  92597. * @param framePerSecond defines the number of frame per second to use
  92598. * @param totalFrame defines the number of frames in total
  92599. * @param from defines the initial value
  92600. * @param to defines the final value
  92601. * @param loopMode defines which loop mode you want to use (off by default)
  92602. * @param easingFunction defines the easing function to use (linear by default)
  92603. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92604. * @returns the list of animatables created for all nodes
  92605. * @example https://www.babylonjs-playground.com/#MH0VLI
  92606. */
  92607. 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[]>;
  92608. /**
  92609. * Creates a new animation, merges it with the existing animations and starts it
  92610. * @param name Name of the animation
  92611. * @param node Node which contains the scene that begins the animations
  92612. * @param targetProperty Specifies which property to animate
  92613. * @param framePerSecond The frames per second of the animation
  92614. * @param totalFrame The total number of frames
  92615. * @param from The frame at the beginning of the animation
  92616. * @param to The frame at the end of the animation
  92617. * @param loopMode Specifies the loop mode of the animation
  92618. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92619. * @param onAnimationEnd Callback to run once the animation is complete
  92620. * @returns Nullable animation
  92621. */
  92622. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92623. /**
  92624. * Transition property of an host to the target Value
  92625. * @param property The property to transition
  92626. * @param targetValue The target Value of the property
  92627. * @param host The object where the property to animate belongs
  92628. * @param scene Scene used to run the animation
  92629. * @param frameRate Framerate (in frame/s) to use
  92630. * @param transition The transition type we want to use
  92631. * @param duration The duration of the animation, in milliseconds
  92632. * @param onAnimationEnd Callback trigger at the end of the animation
  92633. * @returns Nullable animation
  92634. */
  92635. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92636. /**
  92637. * Return the array of runtime animations currently using this animation
  92638. */
  92639. readonly runtimeAnimations: RuntimeAnimation[];
  92640. /**
  92641. * Specifies if any of the runtime animations are currently running
  92642. */
  92643. readonly hasRunningRuntimeAnimations: boolean;
  92644. /**
  92645. * Initializes the animation
  92646. * @param name Name of the animation
  92647. * @param targetProperty Property to animate
  92648. * @param framePerSecond The frames per second of the animation
  92649. * @param dataType The data type of the animation
  92650. * @param loopMode The loop mode of the animation
  92651. * @param enableBlending Specifies if blending should be enabled
  92652. */
  92653. constructor(
  92654. /**Name of the animation */
  92655. name: string,
  92656. /**Property to animate */
  92657. targetProperty: string,
  92658. /**The frames per second of the animation */
  92659. framePerSecond: number,
  92660. /**The data type of the animation */
  92661. dataType: number,
  92662. /**The loop mode of the animation */
  92663. loopMode?: number | undefined,
  92664. /**Specifies if blending should be enabled */
  92665. enableBlending?: boolean | undefined);
  92666. /**
  92667. * Converts the animation to a string
  92668. * @param fullDetails support for multiple levels of logging within scene loading
  92669. * @returns String form of the animation
  92670. */
  92671. toString(fullDetails?: boolean): string;
  92672. /**
  92673. * Add an event to this animation
  92674. * @param event Event to add
  92675. */
  92676. addEvent(event: AnimationEvent): void;
  92677. /**
  92678. * Remove all events found at the given frame
  92679. * @param frame The frame to remove events from
  92680. */
  92681. removeEvents(frame: number): void;
  92682. /**
  92683. * Retrieves all the events from the animation
  92684. * @returns Events from the animation
  92685. */
  92686. getEvents(): AnimationEvent[];
  92687. /**
  92688. * Creates an animation range
  92689. * @param name Name of the animation range
  92690. * @param from Starting frame of the animation range
  92691. * @param to Ending frame of the animation
  92692. */
  92693. createRange(name: string, from: number, to: number): void;
  92694. /**
  92695. * Deletes an animation range by name
  92696. * @param name Name of the animation range to delete
  92697. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92698. */
  92699. deleteRange(name: string, deleteFrames?: boolean): void;
  92700. /**
  92701. * Gets the animation range by name, or null if not defined
  92702. * @param name Name of the animation range
  92703. * @returns Nullable animation range
  92704. */
  92705. getRange(name: string): Nullable<AnimationRange>;
  92706. /**
  92707. * Gets the key frames from the animation
  92708. * @returns The key frames of the animation
  92709. */
  92710. getKeys(): Array<IAnimationKey>;
  92711. /**
  92712. * Gets the highest frame rate of the animation
  92713. * @returns Highest frame rate of the animation
  92714. */
  92715. getHighestFrame(): number;
  92716. /**
  92717. * Gets the easing function of the animation
  92718. * @returns Easing function of the animation
  92719. */
  92720. getEasingFunction(): IEasingFunction;
  92721. /**
  92722. * Sets the easing function of the animation
  92723. * @param easingFunction A custom mathematical formula for animation
  92724. */
  92725. setEasingFunction(easingFunction: EasingFunction): void;
  92726. /**
  92727. * Interpolates a scalar linearly
  92728. * @param startValue Start value of the animation curve
  92729. * @param endValue End value of the animation curve
  92730. * @param gradient Scalar amount to interpolate
  92731. * @returns Interpolated scalar value
  92732. */
  92733. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92734. /**
  92735. * Interpolates a scalar cubically
  92736. * @param startValue Start value of the animation curve
  92737. * @param outTangent End tangent of the animation
  92738. * @param endValue End value of the animation curve
  92739. * @param inTangent Start tangent of the animation curve
  92740. * @param gradient Scalar amount to interpolate
  92741. * @returns Interpolated scalar value
  92742. */
  92743. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92744. /**
  92745. * Interpolates a quaternion using a spherical linear interpolation
  92746. * @param startValue Start value of the animation curve
  92747. * @param endValue End value of the animation curve
  92748. * @param gradient Scalar amount to interpolate
  92749. * @returns Interpolated quaternion value
  92750. */
  92751. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92752. /**
  92753. * Interpolates a quaternion cubically
  92754. * @param startValue Start value of the animation curve
  92755. * @param outTangent End tangent of the animation curve
  92756. * @param endValue End value of the animation curve
  92757. * @param inTangent Start tangent of the animation curve
  92758. * @param gradient Scalar amount to interpolate
  92759. * @returns Interpolated quaternion value
  92760. */
  92761. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92762. /**
  92763. * Interpolates a Vector3 linearl
  92764. * @param startValue Start value of the animation curve
  92765. * @param endValue End value of the animation curve
  92766. * @param gradient Scalar amount to interpolate
  92767. * @returns Interpolated scalar value
  92768. */
  92769. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92770. /**
  92771. * Interpolates a Vector3 cubically
  92772. * @param startValue Start value of the animation curve
  92773. * @param outTangent End tangent of the animation
  92774. * @param endValue End value of the animation curve
  92775. * @param inTangent Start tangent of the animation curve
  92776. * @param gradient Scalar amount to interpolate
  92777. * @returns InterpolatedVector3 value
  92778. */
  92779. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92780. /**
  92781. * Interpolates a Vector2 linearly
  92782. * @param startValue Start value of the animation curve
  92783. * @param endValue End value of the animation curve
  92784. * @param gradient Scalar amount to interpolate
  92785. * @returns Interpolated Vector2 value
  92786. */
  92787. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92788. /**
  92789. * Interpolates a Vector2 cubically
  92790. * @param startValue Start value of the animation curve
  92791. * @param outTangent End tangent of the animation
  92792. * @param endValue End value of the animation curve
  92793. * @param inTangent Start tangent of the animation curve
  92794. * @param gradient Scalar amount to interpolate
  92795. * @returns Interpolated Vector2 value
  92796. */
  92797. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92798. /**
  92799. * Interpolates a size linearly
  92800. * @param startValue Start value of the animation curve
  92801. * @param endValue End value of the animation curve
  92802. * @param gradient Scalar amount to interpolate
  92803. * @returns Interpolated Size value
  92804. */
  92805. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92806. /**
  92807. * Interpolates a Color3 linearly
  92808. * @param startValue Start value of the animation curve
  92809. * @param endValue End value of the animation curve
  92810. * @param gradient Scalar amount to interpolate
  92811. * @returns Interpolated Color3 value
  92812. */
  92813. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  92814. /**
  92815. * @hidden Internal use only
  92816. */
  92817. _getKeyValue(value: any): any;
  92818. /**
  92819. * @hidden Internal use only
  92820. */
  92821. _interpolate(currentFrame: number, state: _IAnimationState): any;
  92822. /**
  92823. * Defines the function to use to interpolate matrices
  92824. * @param startValue defines the start matrix
  92825. * @param endValue defines the end matrix
  92826. * @param gradient defines the gradient between both matrices
  92827. * @param result defines an optional target matrix where to store the interpolation
  92828. * @returns the interpolated matrix
  92829. */
  92830. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  92831. /**
  92832. * Makes a copy of the animation
  92833. * @returns Cloned animation
  92834. */
  92835. clone(): Animation;
  92836. /**
  92837. * Sets the key frames of the animation
  92838. * @param values The animation key frames to set
  92839. */
  92840. setKeys(values: Array<IAnimationKey>): void;
  92841. /**
  92842. * Serializes the animation to an object
  92843. * @returns Serialized object
  92844. */
  92845. serialize(): any;
  92846. /**
  92847. * Float animation type
  92848. */
  92849. private static _ANIMATIONTYPE_FLOAT;
  92850. /**
  92851. * Vector3 animation type
  92852. */
  92853. private static _ANIMATIONTYPE_VECTOR3;
  92854. /**
  92855. * Quaternion animation type
  92856. */
  92857. private static _ANIMATIONTYPE_QUATERNION;
  92858. /**
  92859. * Matrix animation type
  92860. */
  92861. private static _ANIMATIONTYPE_MATRIX;
  92862. /**
  92863. * Color3 animation type
  92864. */
  92865. private static _ANIMATIONTYPE_COLOR3;
  92866. /**
  92867. * Vector2 animation type
  92868. */
  92869. private static _ANIMATIONTYPE_VECTOR2;
  92870. /**
  92871. * Size animation type
  92872. */
  92873. private static _ANIMATIONTYPE_SIZE;
  92874. /**
  92875. * Relative Loop Mode
  92876. */
  92877. private static _ANIMATIONLOOPMODE_RELATIVE;
  92878. /**
  92879. * Cycle Loop Mode
  92880. */
  92881. private static _ANIMATIONLOOPMODE_CYCLE;
  92882. /**
  92883. * Constant Loop Mode
  92884. */
  92885. private static _ANIMATIONLOOPMODE_CONSTANT;
  92886. /**
  92887. * Get the float animation type
  92888. */
  92889. static readonly ANIMATIONTYPE_FLOAT: number;
  92890. /**
  92891. * Get the Vector3 animation type
  92892. */
  92893. static readonly ANIMATIONTYPE_VECTOR3: number;
  92894. /**
  92895. * Get the Vector2 animation type
  92896. */
  92897. static readonly ANIMATIONTYPE_VECTOR2: number;
  92898. /**
  92899. * Get the Size animation type
  92900. */
  92901. static readonly ANIMATIONTYPE_SIZE: number;
  92902. /**
  92903. * Get the Quaternion animation type
  92904. */
  92905. static readonly ANIMATIONTYPE_QUATERNION: number;
  92906. /**
  92907. * Get the Matrix animation type
  92908. */
  92909. static readonly ANIMATIONTYPE_MATRIX: number;
  92910. /**
  92911. * Get the Color3 animation type
  92912. */
  92913. static readonly ANIMATIONTYPE_COLOR3: number;
  92914. /**
  92915. * Get the Relative Loop Mode
  92916. */
  92917. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  92918. /**
  92919. * Get the Cycle Loop Mode
  92920. */
  92921. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  92922. /**
  92923. * Get the Constant Loop Mode
  92924. */
  92925. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  92926. /** @hidden */
  92927. static _UniversalLerp(left: any, right: any, amount: number): any;
  92928. /**
  92929. * Parses an animation object and creates an animation
  92930. * @param parsedAnimation Parsed animation object
  92931. * @returns Animation object
  92932. */
  92933. static Parse(parsedAnimation: any): Animation;
  92934. /**
  92935. * Appends the serialized animations from the source animations
  92936. * @param source Source containing the animations
  92937. * @param destination Target to store the animations
  92938. */
  92939. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92940. }
  92941. }
  92942. declare module BABYLON {
  92943. /**
  92944. * Interface containing an array of animations
  92945. */
  92946. export interface IAnimatable {
  92947. /**
  92948. * Array of animations
  92949. */
  92950. animations: Nullable<Array<Animation>>;
  92951. }
  92952. }
  92953. declare module BABYLON {
  92954. /**
  92955. * This represents all the required information to add a fresnel effect on a material:
  92956. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92957. */
  92958. export class FresnelParameters {
  92959. private _isEnabled;
  92960. /**
  92961. * Define if the fresnel effect is enable or not.
  92962. */
  92963. isEnabled: boolean;
  92964. /**
  92965. * Define the color used on edges (grazing angle)
  92966. */
  92967. leftColor: Color3;
  92968. /**
  92969. * Define the color used on center
  92970. */
  92971. rightColor: Color3;
  92972. /**
  92973. * Define bias applied to computed fresnel term
  92974. */
  92975. bias: number;
  92976. /**
  92977. * Defined the power exponent applied to fresnel term
  92978. */
  92979. power: number;
  92980. /**
  92981. * Clones the current fresnel and its valuues
  92982. * @returns a clone fresnel configuration
  92983. */
  92984. clone(): FresnelParameters;
  92985. /**
  92986. * Serializes the current fresnel parameters to a JSON representation.
  92987. * @return the JSON serialization
  92988. */
  92989. serialize(): any;
  92990. /**
  92991. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92992. * @param parsedFresnelParameters Define the JSON representation
  92993. * @returns the parsed parameters
  92994. */
  92995. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92996. }
  92997. }
  92998. declare module BABYLON {
  92999. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93000. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93001. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93002. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93003. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93004. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93005. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93006. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93007. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93008. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93009. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93010. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93011. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93012. /**
  93013. * Decorator used to define property that can be serialized as reference to a camera
  93014. * @param sourceName defines the name of the property to decorate
  93015. */
  93016. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93017. /**
  93018. * Class used to help serialization objects
  93019. */
  93020. export class SerializationHelper {
  93021. /** @hidden */
  93022. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93023. /** @hidden */
  93024. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93025. /** @hidden */
  93026. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93027. /** @hidden */
  93028. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93029. /**
  93030. * Appends the serialized animations from the source animations
  93031. * @param source Source containing the animations
  93032. * @param destination Target to store the animations
  93033. */
  93034. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93035. /**
  93036. * Static function used to serialized a specific entity
  93037. * @param entity defines the entity to serialize
  93038. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93039. * @returns a JSON compatible object representing the serialization of the entity
  93040. */
  93041. static Serialize<T>(entity: T, serializationObject?: any): any;
  93042. /**
  93043. * Creates a new entity from a serialization data object
  93044. * @param creationFunction defines a function used to instanciated the new entity
  93045. * @param source defines the source serialization data
  93046. * @param scene defines the hosting scene
  93047. * @param rootUrl defines the root url for resources
  93048. * @returns a new entity
  93049. */
  93050. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93051. /**
  93052. * Clones an object
  93053. * @param creationFunction defines the function used to instanciate the new object
  93054. * @param source defines the source object
  93055. * @returns the cloned object
  93056. */
  93057. static Clone<T>(creationFunction: () => T, source: T): T;
  93058. /**
  93059. * Instanciates a new object based on a source one (some data will be shared between both object)
  93060. * @param creationFunction defines the function used to instanciate the new object
  93061. * @param source defines the source object
  93062. * @returns the new object
  93063. */
  93064. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93065. }
  93066. }
  93067. declare module BABYLON {
  93068. /**
  93069. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93070. */
  93071. export interface CubeMapInfo {
  93072. /**
  93073. * The pixel array for the front face.
  93074. * This is stored in format, left to right, up to down format.
  93075. */
  93076. front: Nullable<ArrayBufferView>;
  93077. /**
  93078. * The pixel array for the back face.
  93079. * This is stored in format, left to right, up to down format.
  93080. */
  93081. back: Nullable<ArrayBufferView>;
  93082. /**
  93083. * The pixel array for the left face.
  93084. * This is stored in format, left to right, up to down format.
  93085. */
  93086. left: Nullable<ArrayBufferView>;
  93087. /**
  93088. * The pixel array for the right face.
  93089. * This is stored in format, left to right, up to down format.
  93090. */
  93091. right: Nullable<ArrayBufferView>;
  93092. /**
  93093. * The pixel array for the up face.
  93094. * This is stored in format, left to right, up to down format.
  93095. */
  93096. up: Nullable<ArrayBufferView>;
  93097. /**
  93098. * The pixel array for the down face.
  93099. * This is stored in format, left to right, up to down format.
  93100. */
  93101. down: Nullable<ArrayBufferView>;
  93102. /**
  93103. * The size of the cubemap stored.
  93104. *
  93105. * Each faces will be size * size pixels.
  93106. */
  93107. size: number;
  93108. /**
  93109. * The format of the texture.
  93110. *
  93111. * RGBA, RGB.
  93112. */
  93113. format: number;
  93114. /**
  93115. * The type of the texture data.
  93116. *
  93117. * UNSIGNED_INT, FLOAT.
  93118. */
  93119. type: number;
  93120. /**
  93121. * Specifies whether the texture is in gamma space.
  93122. */
  93123. gammaSpace: boolean;
  93124. }
  93125. /**
  93126. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93127. */
  93128. export class PanoramaToCubeMapTools {
  93129. private static FACE_FRONT;
  93130. private static FACE_BACK;
  93131. private static FACE_RIGHT;
  93132. private static FACE_LEFT;
  93133. private static FACE_DOWN;
  93134. private static FACE_UP;
  93135. /**
  93136. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93137. *
  93138. * @param float32Array The source data.
  93139. * @param inputWidth The width of the input panorama.
  93140. * @param inputHeight The height of the input panorama.
  93141. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93142. * @return The cubemap data
  93143. */
  93144. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93145. private static CreateCubemapTexture;
  93146. private static CalcProjectionSpherical;
  93147. }
  93148. }
  93149. declare module BABYLON {
  93150. /**
  93151. * Helper class dealing with the extraction of spherical polynomial dataArray
  93152. * from a cube map.
  93153. */
  93154. export class CubeMapToSphericalPolynomialTools {
  93155. private static FileFaces;
  93156. /**
  93157. * Converts a texture to the according Spherical Polynomial data.
  93158. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93159. *
  93160. * @param texture The texture to extract the information from.
  93161. * @return The Spherical Polynomial data.
  93162. */
  93163. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93164. /**
  93165. * Converts a cubemap to the according Spherical Polynomial data.
  93166. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93167. *
  93168. * @param cubeInfo The Cube map to extract the information from.
  93169. * @return The Spherical Polynomial data.
  93170. */
  93171. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93172. }
  93173. }
  93174. declare module BABYLON {
  93175. /**
  93176. * Class used to manipulate GUIDs
  93177. */
  93178. export class GUID {
  93179. /**
  93180. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93181. * Be aware Math.random() could cause collisions, but:
  93182. * "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"
  93183. * @returns a pseudo random id
  93184. */
  93185. static RandomId(): string;
  93186. }
  93187. }
  93188. declare module BABYLON {
  93189. /**
  93190. * Base class of all the textures in babylon.
  93191. * It groups all the common properties the materials, post process, lights... might need
  93192. * in order to make a correct use of the texture.
  93193. */
  93194. export class BaseTexture implements IAnimatable {
  93195. /**
  93196. * Default anisotropic filtering level for the application.
  93197. * It is set to 4 as a good tradeoff between perf and quality.
  93198. */
  93199. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93200. /**
  93201. * Gets or sets the unique id of the texture
  93202. */
  93203. uniqueId: number;
  93204. /**
  93205. * Define the name of the texture.
  93206. */
  93207. name: string;
  93208. /**
  93209. * Gets or sets an object used to store user defined information.
  93210. */
  93211. metadata: any;
  93212. /**
  93213. * For internal use only. Please do not use.
  93214. */
  93215. reservedDataStore: any;
  93216. private _hasAlpha;
  93217. /**
  93218. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93219. */
  93220. hasAlpha: boolean;
  93221. /**
  93222. * Defines if the alpha value should be determined via the rgb values.
  93223. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93224. */
  93225. getAlphaFromRGB: boolean;
  93226. /**
  93227. * Intensity or strength of the texture.
  93228. * It is commonly used by materials to fine tune the intensity of the texture
  93229. */
  93230. level: number;
  93231. /**
  93232. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93233. * This is part of the texture as textures usually maps to one uv set.
  93234. */
  93235. coordinatesIndex: number;
  93236. private _coordinatesMode;
  93237. /**
  93238. * How a texture is mapped.
  93239. *
  93240. * | Value | Type | Description |
  93241. * | ----- | ----------------------------------- | ----------- |
  93242. * | 0 | EXPLICIT_MODE | |
  93243. * | 1 | SPHERICAL_MODE | |
  93244. * | 2 | PLANAR_MODE | |
  93245. * | 3 | CUBIC_MODE | |
  93246. * | 4 | PROJECTION_MODE | |
  93247. * | 5 | SKYBOX_MODE | |
  93248. * | 6 | INVCUBIC_MODE | |
  93249. * | 7 | EQUIRECTANGULAR_MODE | |
  93250. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93251. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93252. */
  93253. coordinatesMode: number;
  93254. /**
  93255. * | Value | Type | Description |
  93256. * | ----- | ------------------ | ----------- |
  93257. * | 0 | CLAMP_ADDRESSMODE | |
  93258. * | 1 | WRAP_ADDRESSMODE | |
  93259. * | 2 | MIRROR_ADDRESSMODE | |
  93260. */
  93261. wrapU: number;
  93262. /**
  93263. * | Value | Type | Description |
  93264. * | ----- | ------------------ | ----------- |
  93265. * | 0 | CLAMP_ADDRESSMODE | |
  93266. * | 1 | WRAP_ADDRESSMODE | |
  93267. * | 2 | MIRROR_ADDRESSMODE | |
  93268. */
  93269. wrapV: number;
  93270. /**
  93271. * | Value | Type | Description |
  93272. * | ----- | ------------------ | ----------- |
  93273. * | 0 | CLAMP_ADDRESSMODE | |
  93274. * | 1 | WRAP_ADDRESSMODE | |
  93275. * | 2 | MIRROR_ADDRESSMODE | |
  93276. */
  93277. wrapR: number;
  93278. /**
  93279. * With compliant hardware and browser (supporting anisotropic filtering)
  93280. * this defines the level of anisotropic filtering in the texture.
  93281. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93282. */
  93283. anisotropicFilteringLevel: number;
  93284. /**
  93285. * Define if the texture is a cube texture or if false a 2d texture.
  93286. */
  93287. isCube: boolean;
  93288. /**
  93289. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93290. */
  93291. is3D: boolean;
  93292. /**
  93293. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93294. * HDR texture are usually stored in linear space.
  93295. * This only impacts the PBR and Background materials
  93296. */
  93297. gammaSpace: boolean;
  93298. /**
  93299. * Gets or sets whether or not the texture contains RGBD data.
  93300. */
  93301. isRGBD: boolean;
  93302. /**
  93303. * Is Z inverted in the texture (useful in a cube texture).
  93304. */
  93305. invertZ: boolean;
  93306. /**
  93307. * Are mip maps generated for this texture or not.
  93308. */
  93309. readonly noMipmap: boolean;
  93310. /**
  93311. * @hidden
  93312. */
  93313. lodLevelInAlpha: boolean;
  93314. /**
  93315. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93316. */
  93317. lodGenerationOffset: number;
  93318. /**
  93319. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93320. */
  93321. lodGenerationScale: number;
  93322. /**
  93323. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93324. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93325. * average roughness values.
  93326. */
  93327. linearSpecularLOD: boolean;
  93328. /**
  93329. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93330. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93331. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93332. */
  93333. irradianceTexture: Nullable<BaseTexture>;
  93334. /**
  93335. * Define if the texture is a render target.
  93336. */
  93337. isRenderTarget: boolean;
  93338. /**
  93339. * Define the unique id of the texture in the scene.
  93340. */
  93341. readonly uid: string;
  93342. /**
  93343. * Return a string representation of the texture.
  93344. * @returns the texture as a string
  93345. */
  93346. toString(): string;
  93347. /**
  93348. * Get the class name of the texture.
  93349. * @returns "BaseTexture"
  93350. */
  93351. getClassName(): string;
  93352. /**
  93353. * Define the list of animation attached to the texture.
  93354. */
  93355. animations: Animation[];
  93356. /**
  93357. * An event triggered when the texture is disposed.
  93358. */
  93359. onDisposeObservable: Observable<BaseTexture>;
  93360. private _onDisposeObserver;
  93361. /**
  93362. * Callback triggered when the texture has been disposed.
  93363. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93364. */
  93365. onDispose: () => void;
  93366. /**
  93367. * Define the current state of the loading sequence when in delayed load mode.
  93368. */
  93369. delayLoadState: number;
  93370. private _scene;
  93371. /** @hidden */
  93372. _texture: Nullable<InternalTexture>;
  93373. private _uid;
  93374. /**
  93375. * Define if the texture is preventinga material to render or not.
  93376. * If not and the texture is not ready, the engine will use a default black texture instead.
  93377. */
  93378. readonly isBlocking: boolean;
  93379. /**
  93380. * Instantiates a new BaseTexture.
  93381. * Base class of all the textures in babylon.
  93382. * It groups all the common properties the materials, post process, lights... might need
  93383. * in order to make a correct use of the texture.
  93384. * @param scene Define the scene the texture blongs to
  93385. */
  93386. constructor(scene: Nullable<Scene>);
  93387. /**
  93388. * Get the scene the texture belongs to.
  93389. * @returns the scene or null if undefined
  93390. */
  93391. getScene(): Nullable<Scene>;
  93392. /**
  93393. * Get the texture transform matrix used to offset tile the texture for istance.
  93394. * @returns the transformation matrix
  93395. */
  93396. getTextureMatrix(): Matrix;
  93397. /**
  93398. * Get the texture reflection matrix used to rotate/transform the reflection.
  93399. * @returns the reflection matrix
  93400. */
  93401. getReflectionTextureMatrix(): Matrix;
  93402. /**
  93403. * Get the underlying lower level texture from Babylon.
  93404. * @returns the insternal texture
  93405. */
  93406. getInternalTexture(): Nullable<InternalTexture>;
  93407. /**
  93408. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93409. * @returns true if ready or not blocking
  93410. */
  93411. isReadyOrNotBlocking(): boolean;
  93412. /**
  93413. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93414. * @returns true if fully ready
  93415. */
  93416. isReady(): boolean;
  93417. private _cachedSize;
  93418. /**
  93419. * Get the size of the texture.
  93420. * @returns the texture size.
  93421. */
  93422. getSize(): ISize;
  93423. /**
  93424. * Get the base size of the texture.
  93425. * It can be different from the size if the texture has been resized for POT for instance
  93426. * @returns the base size
  93427. */
  93428. getBaseSize(): ISize;
  93429. /**
  93430. * Update the sampling mode of the texture.
  93431. * Default is Trilinear mode.
  93432. *
  93433. * | Value | Type | Description |
  93434. * | ----- | ------------------ | ----------- |
  93435. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93436. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93437. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93438. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93439. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93440. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93441. * | 7 | NEAREST_LINEAR | |
  93442. * | 8 | NEAREST_NEAREST | |
  93443. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93444. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93445. * | 11 | LINEAR_LINEAR | |
  93446. * | 12 | LINEAR_NEAREST | |
  93447. *
  93448. * > _mag_: magnification filter (close to the viewer)
  93449. * > _min_: minification filter (far from the viewer)
  93450. * > _mip_: filter used between mip map levels
  93451. *@param samplingMode Define the new sampling mode of the texture
  93452. */
  93453. updateSamplingMode(samplingMode: number): void;
  93454. /**
  93455. * Scales the texture if is `canRescale()`
  93456. * @param ratio the resize factor we want to use to rescale
  93457. */
  93458. scale(ratio: number): void;
  93459. /**
  93460. * Get if the texture can rescale.
  93461. */
  93462. readonly canRescale: boolean;
  93463. /** @hidden */
  93464. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93465. /** @hidden */
  93466. _rebuild(): void;
  93467. /**
  93468. * Triggers the load sequence in delayed load mode.
  93469. */
  93470. delayLoad(): void;
  93471. /**
  93472. * Clones the texture.
  93473. * @returns the cloned texture
  93474. */
  93475. clone(): Nullable<BaseTexture>;
  93476. /**
  93477. * Get the texture underlying type (INT, FLOAT...)
  93478. */
  93479. readonly textureType: number;
  93480. /**
  93481. * Get the texture underlying format (RGB, RGBA...)
  93482. */
  93483. readonly textureFormat: number;
  93484. /**
  93485. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93486. * This will returns an RGBA array buffer containing either in values (0-255) or
  93487. * float values (0-1) depending of the underlying buffer type.
  93488. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93489. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93490. * @param buffer defines a user defined buffer to fill with data (can be null)
  93491. * @returns The Array buffer containing the pixels data.
  93492. */
  93493. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93494. /**
  93495. * Release and destroy the underlying lower level texture aka internalTexture.
  93496. */
  93497. releaseInternalTexture(): void;
  93498. /**
  93499. * Get the polynomial representation of the texture data.
  93500. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93501. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93502. */
  93503. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93504. /** @hidden */
  93505. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93506. /** @hidden */
  93507. readonly _lodTextureMid: Nullable<BaseTexture>;
  93508. /** @hidden */
  93509. readonly _lodTextureLow: Nullable<BaseTexture>;
  93510. /**
  93511. * Dispose the texture and release its associated resources.
  93512. */
  93513. dispose(): void;
  93514. /**
  93515. * Serialize the texture into a JSON representation that can be parsed later on.
  93516. * @returns the JSON representation of the texture
  93517. */
  93518. serialize(): any;
  93519. /**
  93520. * Helper function to be called back once a list of texture contains only ready textures.
  93521. * @param textures Define the list of textures to wait for
  93522. * @param callback Define the callback triggered once the entire list will be ready
  93523. */
  93524. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93525. }
  93526. }
  93527. declare module BABYLON {
  93528. /**
  93529. * Class used to store data associated with WebGL texture data for the engine
  93530. * This class should not be used directly
  93531. */
  93532. export class InternalTexture {
  93533. /** @hidden */
  93534. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93535. /**
  93536. * The source of the texture data is unknown
  93537. */
  93538. static DATASOURCE_UNKNOWN: number;
  93539. /**
  93540. * Texture data comes from an URL
  93541. */
  93542. static DATASOURCE_URL: number;
  93543. /**
  93544. * Texture data is only used for temporary storage
  93545. */
  93546. static DATASOURCE_TEMP: number;
  93547. /**
  93548. * Texture data comes from raw data (ArrayBuffer)
  93549. */
  93550. static DATASOURCE_RAW: number;
  93551. /**
  93552. * Texture content is dynamic (video or dynamic texture)
  93553. */
  93554. static DATASOURCE_DYNAMIC: number;
  93555. /**
  93556. * Texture content is generated by rendering to it
  93557. */
  93558. static DATASOURCE_RENDERTARGET: number;
  93559. /**
  93560. * Texture content is part of a multi render target process
  93561. */
  93562. static DATASOURCE_MULTIRENDERTARGET: number;
  93563. /**
  93564. * Texture data comes from a cube data file
  93565. */
  93566. static DATASOURCE_CUBE: number;
  93567. /**
  93568. * Texture data comes from a raw cube data
  93569. */
  93570. static DATASOURCE_CUBERAW: number;
  93571. /**
  93572. * Texture data come from a prefiltered cube data file
  93573. */
  93574. static DATASOURCE_CUBEPREFILTERED: number;
  93575. /**
  93576. * Texture content is raw 3D data
  93577. */
  93578. static DATASOURCE_RAW3D: number;
  93579. /**
  93580. * Texture content is a depth texture
  93581. */
  93582. static DATASOURCE_DEPTHTEXTURE: number;
  93583. /**
  93584. * Texture data comes from a raw cube data encoded with RGBD
  93585. */
  93586. static DATASOURCE_CUBERAW_RGBD: number;
  93587. /**
  93588. * Defines if the texture is ready
  93589. */
  93590. isReady: boolean;
  93591. /**
  93592. * Defines if the texture is a cube texture
  93593. */
  93594. isCube: boolean;
  93595. /**
  93596. * Defines if the texture contains 3D data
  93597. */
  93598. is3D: boolean;
  93599. /**
  93600. * Defines if the texture contains multiview data
  93601. */
  93602. isMultiview: boolean;
  93603. /**
  93604. * Gets the URL used to load this texture
  93605. */
  93606. url: string;
  93607. /**
  93608. * Gets the sampling mode of the texture
  93609. */
  93610. samplingMode: number;
  93611. /**
  93612. * Gets a boolean indicating if the texture needs mipmaps generation
  93613. */
  93614. generateMipMaps: boolean;
  93615. /**
  93616. * Gets the number of samples used by the texture (WebGL2+ only)
  93617. */
  93618. samples: number;
  93619. /**
  93620. * Gets the type of the texture (int, float...)
  93621. */
  93622. type: number;
  93623. /**
  93624. * Gets the format of the texture (RGB, RGBA...)
  93625. */
  93626. format: number;
  93627. /**
  93628. * Observable called when the texture is loaded
  93629. */
  93630. onLoadedObservable: Observable<InternalTexture>;
  93631. /**
  93632. * Gets the width of the texture
  93633. */
  93634. width: number;
  93635. /**
  93636. * Gets the height of the texture
  93637. */
  93638. height: number;
  93639. /**
  93640. * Gets the depth of the texture
  93641. */
  93642. depth: number;
  93643. /**
  93644. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93645. */
  93646. baseWidth: number;
  93647. /**
  93648. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93649. */
  93650. baseHeight: number;
  93651. /**
  93652. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93653. */
  93654. baseDepth: number;
  93655. /**
  93656. * Gets a boolean indicating if the texture is inverted on Y axis
  93657. */
  93658. invertY: boolean;
  93659. /** @hidden */
  93660. _invertVScale: boolean;
  93661. /** @hidden */
  93662. _associatedChannel: number;
  93663. /** @hidden */
  93664. _dataSource: number;
  93665. /** @hidden */
  93666. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93667. /** @hidden */
  93668. _bufferView: Nullable<ArrayBufferView>;
  93669. /** @hidden */
  93670. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93671. /** @hidden */
  93672. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93673. /** @hidden */
  93674. _size: number;
  93675. /** @hidden */
  93676. _extension: string;
  93677. /** @hidden */
  93678. _files: Nullable<string[]>;
  93679. /** @hidden */
  93680. _workingCanvas: Nullable<HTMLCanvasElement>;
  93681. /** @hidden */
  93682. _workingContext: Nullable<CanvasRenderingContext2D>;
  93683. /** @hidden */
  93684. _framebuffer: Nullable<WebGLFramebuffer>;
  93685. /** @hidden */
  93686. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93687. /** @hidden */
  93688. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93689. /** @hidden */
  93690. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93691. /** @hidden */
  93692. _attachments: Nullable<number[]>;
  93693. /** @hidden */
  93694. _cachedCoordinatesMode: Nullable<number>;
  93695. /** @hidden */
  93696. _cachedWrapU: Nullable<number>;
  93697. /** @hidden */
  93698. _cachedWrapV: Nullable<number>;
  93699. /** @hidden */
  93700. _cachedWrapR: Nullable<number>;
  93701. /** @hidden */
  93702. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93703. /** @hidden */
  93704. _isDisabled: boolean;
  93705. /** @hidden */
  93706. _compression: Nullable<string>;
  93707. /** @hidden */
  93708. _generateStencilBuffer: boolean;
  93709. /** @hidden */
  93710. _generateDepthBuffer: boolean;
  93711. /** @hidden */
  93712. _comparisonFunction: number;
  93713. /** @hidden */
  93714. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93715. /** @hidden */
  93716. _lodGenerationScale: number;
  93717. /** @hidden */
  93718. _lodGenerationOffset: number;
  93719. /** @hidden */
  93720. _colorTextureArray: Nullable<WebGLTexture>;
  93721. /** @hidden */
  93722. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93723. /** @hidden */
  93724. _lodTextureHigh: Nullable<BaseTexture>;
  93725. /** @hidden */
  93726. _lodTextureMid: Nullable<BaseTexture>;
  93727. /** @hidden */
  93728. _lodTextureLow: Nullable<BaseTexture>;
  93729. /** @hidden */
  93730. _isRGBD: boolean;
  93731. /** @hidden */
  93732. _linearSpecularLOD: boolean;
  93733. /** @hidden */
  93734. _irradianceTexture: Nullable<BaseTexture>;
  93735. /** @hidden */
  93736. _webGLTexture: Nullable<WebGLTexture>;
  93737. /** @hidden */
  93738. _references: number;
  93739. private _engine;
  93740. /**
  93741. * Gets the Engine the texture belongs to.
  93742. * @returns The babylon engine
  93743. */
  93744. getEngine(): Engine;
  93745. /**
  93746. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93747. */
  93748. readonly dataSource: number;
  93749. /**
  93750. * Creates a new InternalTexture
  93751. * @param engine defines the engine to use
  93752. * @param dataSource defines the type of data that will be used
  93753. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93754. */
  93755. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93756. /**
  93757. * Increments the number of references (ie. the number of Texture that point to it)
  93758. */
  93759. incrementReferences(): void;
  93760. /**
  93761. * Change the size of the texture (not the size of the content)
  93762. * @param width defines the new width
  93763. * @param height defines the new height
  93764. * @param depth defines the new depth (1 by default)
  93765. */
  93766. updateSize(width: int, height: int, depth?: int): void;
  93767. /** @hidden */
  93768. _rebuild(): void;
  93769. /** @hidden */
  93770. _swapAndDie(target: InternalTexture): void;
  93771. /**
  93772. * Dispose the current allocated resources
  93773. */
  93774. dispose(): void;
  93775. }
  93776. }
  93777. declare module BABYLON {
  93778. /**
  93779. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93780. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93781. */
  93782. export class EffectFallbacks {
  93783. private _defines;
  93784. private _currentRank;
  93785. private _maxRank;
  93786. private _mesh;
  93787. /**
  93788. * Removes the fallback from the bound mesh.
  93789. */
  93790. unBindMesh(): void;
  93791. /**
  93792. * Adds a fallback on the specified property.
  93793. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93794. * @param define The name of the define in the shader
  93795. */
  93796. addFallback(rank: number, define: string): void;
  93797. /**
  93798. * Sets the mesh to use CPU skinning when needing to fallback.
  93799. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93800. * @param mesh The mesh to use the fallbacks.
  93801. */
  93802. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93803. /**
  93804. * Checks to see if more fallbacks are still availible.
  93805. */
  93806. readonly hasMoreFallbacks: boolean;
  93807. /**
  93808. * Removes the defines that should be removed when falling back.
  93809. * @param currentDefines defines the current define statements for the shader.
  93810. * @param effect defines the current effect we try to compile
  93811. * @returns The resulting defines with defines of the current rank removed.
  93812. */
  93813. reduce(currentDefines: string, effect: Effect): string;
  93814. }
  93815. /**
  93816. * Options to be used when creating an effect.
  93817. */
  93818. export class EffectCreationOptions {
  93819. /**
  93820. * Atrributes that will be used in the shader.
  93821. */
  93822. attributes: string[];
  93823. /**
  93824. * Uniform varible names that will be set in the shader.
  93825. */
  93826. uniformsNames: string[];
  93827. /**
  93828. * Uniform buffer varible names that will be set in the shader.
  93829. */
  93830. uniformBuffersNames: string[];
  93831. /**
  93832. * Sampler texture variable names that will be set in the shader.
  93833. */
  93834. samplers: string[];
  93835. /**
  93836. * Define statements that will be set in the shader.
  93837. */
  93838. defines: any;
  93839. /**
  93840. * Possible fallbacks for this effect to improve performance when needed.
  93841. */
  93842. fallbacks: Nullable<EffectFallbacks>;
  93843. /**
  93844. * Callback that will be called when the shader is compiled.
  93845. */
  93846. onCompiled: Nullable<(effect: Effect) => void>;
  93847. /**
  93848. * Callback that will be called if an error occurs during shader compilation.
  93849. */
  93850. onError: Nullable<(effect: Effect, errors: string) => void>;
  93851. /**
  93852. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93853. */
  93854. indexParameters: any;
  93855. /**
  93856. * Max number of lights that can be used in the shader.
  93857. */
  93858. maxSimultaneousLights: number;
  93859. /**
  93860. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  93861. */
  93862. transformFeedbackVaryings: Nullable<string[]>;
  93863. }
  93864. /**
  93865. * Effect containing vertex and fragment shader that can be executed on an object.
  93866. */
  93867. export class Effect implements IDisposable {
  93868. /**
  93869. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93870. */
  93871. static ShadersRepository: string;
  93872. /**
  93873. * Name of the effect.
  93874. */
  93875. name: any;
  93876. /**
  93877. * String container all the define statements that should be set on the shader.
  93878. */
  93879. defines: string;
  93880. /**
  93881. * Callback that will be called when the shader is compiled.
  93882. */
  93883. onCompiled: Nullable<(effect: Effect) => void>;
  93884. /**
  93885. * Callback that will be called if an error occurs during shader compilation.
  93886. */
  93887. onError: Nullable<(effect: Effect, errors: string) => void>;
  93888. /**
  93889. * Callback that will be called when effect is bound.
  93890. */
  93891. onBind: Nullable<(effect: Effect) => void>;
  93892. /**
  93893. * Unique ID of the effect.
  93894. */
  93895. uniqueId: number;
  93896. /**
  93897. * Observable that will be called when the shader is compiled.
  93898. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  93899. */
  93900. onCompileObservable: Observable<Effect>;
  93901. /**
  93902. * Observable that will be called if an error occurs during shader compilation.
  93903. */
  93904. onErrorObservable: Observable<Effect>;
  93905. /** @hidden */
  93906. _onBindObservable: Nullable<Observable<Effect>>;
  93907. /**
  93908. * Observable that will be called when effect is bound.
  93909. */
  93910. readonly onBindObservable: Observable<Effect>;
  93911. /** @hidden */
  93912. _bonesComputationForcedToCPU: boolean;
  93913. private static _uniqueIdSeed;
  93914. private _engine;
  93915. private _uniformBuffersNames;
  93916. private _uniformsNames;
  93917. private _samplerList;
  93918. private _samplers;
  93919. private _isReady;
  93920. private _compilationError;
  93921. private _attributesNames;
  93922. private _attributes;
  93923. private _uniforms;
  93924. /**
  93925. * Key for the effect.
  93926. * @hidden
  93927. */
  93928. _key: string;
  93929. private _indexParameters;
  93930. private _fallbacks;
  93931. private _vertexSourceCode;
  93932. private _fragmentSourceCode;
  93933. private _vertexSourceCodeOverride;
  93934. private _fragmentSourceCodeOverride;
  93935. private _transformFeedbackVaryings;
  93936. /**
  93937. * Compiled shader to webGL program.
  93938. * @hidden
  93939. */
  93940. _pipelineContext: Nullable<IPipelineContext>;
  93941. private _valueCache;
  93942. private static _baseCache;
  93943. /**
  93944. * Instantiates an effect.
  93945. * An effect can be used to create/manage/execute vertex and fragment shaders.
  93946. * @param baseName Name of the effect.
  93947. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  93948. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  93949. * @param samplers List of sampler variables that will be passed to the shader.
  93950. * @param engine Engine to be used to render the effect
  93951. * @param defines Define statements to be added to the shader.
  93952. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  93953. * @param onCompiled Callback that will be called when the shader is compiled.
  93954. * @param onError Callback that will be called if an error occurs during shader compilation.
  93955. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  93956. */
  93957. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  93958. private _useFinalCode;
  93959. /**
  93960. * Unique key for this effect
  93961. */
  93962. readonly key: string;
  93963. /**
  93964. * If the effect has been compiled and prepared.
  93965. * @returns if the effect is compiled and prepared.
  93966. */
  93967. isReady(): boolean;
  93968. private _isReadyInternal;
  93969. /**
  93970. * The engine the effect was initialized with.
  93971. * @returns the engine.
  93972. */
  93973. getEngine(): Engine;
  93974. /**
  93975. * The pipeline context for this effect
  93976. * @returns the associated pipeline context
  93977. */
  93978. getPipelineContext(): Nullable<IPipelineContext>;
  93979. /**
  93980. * The set of names of attribute variables for the shader.
  93981. * @returns An array of attribute names.
  93982. */
  93983. getAttributesNames(): string[];
  93984. /**
  93985. * Returns the attribute at the given index.
  93986. * @param index The index of the attribute.
  93987. * @returns The location of the attribute.
  93988. */
  93989. getAttributeLocation(index: number): number;
  93990. /**
  93991. * Returns the attribute based on the name of the variable.
  93992. * @param name of the attribute to look up.
  93993. * @returns the attribute location.
  93994. */
  93995. getAttributeLocationByName(name: string): number;
  93996. /**
  93997. * The number of attributes.
  93998. * @returns the numnber of attributes.
  93999. */
  94000. getAttributesCount(): number;
  94001. /**
  94002. * Gets the index of a uniform variable.
  94003. * @param uniformName of the uniform to look up.
  94004. * @returns the index.
  94005. */
  94006. getUniformIndex(uniformName: string): number;
  94007. /**
  94008. * Returns the attribute based on the name of the variable.
  94009. * @param uniformName of the uniform to look up.
  94010. * @returns the location of the uniform.
  94011. */
  94012. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94013. /**
  94014. * Returns an array of sampler variable names
  94015. * @returns The array of sampler variable neames.
  94016. */
  94017. getSamplers(): string[];
  94018. /**
  94019. * The error from the last compilation.
  94020. * @returns the error string.
  94021. */
  94022. getCompilationError(): string;
  94023. /**
  94024. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94025. * @param func The callback to be used.
  94026. */
  94027. executeWhenCompiled(func: (effect: Effect) => void): void;
  94028. private _checkIsReady;
  94029. /** @hidden */
  94030. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94031. /** @hidden */
  94032. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94033. /** @hidden */
  94034. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94035. /**
  94036. * Recompiles the webGL program
  94037. * @param vertexSourceCode The source code for the vertex shader.
  94038. * @param fragmentSourceCode The source code for the fragment shader.
  94039. * @param onCompiled Callback called when completed.
  94040. * @param onError Callback called on error.
  94041. * @hidden
  94042. */
  94043. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94044. /**
  94045. * Prepares the effect
  94046. * @hidden
  94047. */
  94048. _prepareEffect(): void;
  94049. private _processCompilationErrors;
  94050. /**
  94051. * Checks if the effect is supported. (Must be called after compilation)
  94052. */
  94053. readonly isSupported: boolean;
  94054. /**
  94055. * Binds a texture to the engine to be used as output of the shader.
  94056. * @param channel Name of the output variable.
  94057. * @param texture Texture to bind.
  94058. * @hidden
  94059. */
  94060. _bindTexture(channel: string, texture: InternalTexture): void;
  94061. /**
  94062. * Sets a texture on the engine to be used in the shader.
  94063. * @param channel Name of the sampler variable.
  94064. * @param texture Texture to set.
  94065. */
  94066. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94067. /**
  94068. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94069. * @param channel Name of the sampler variable.
  94070. * @param texture Texture to set.
  94071. */
  94072. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94073. /**
  94074. * Sets an array of textures on the engine to be used in the shader.
  94075. * @param channel Name of the variable.
  94076. * @param textures Textures to set.
  94077. */
  94078. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94079. /**
  94080. * 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)
  94081. * @param channel Name of the sampler variable.
  94082. * @param postProcess Post process to get the input texture from.
  94083. */
  94084. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94085. /**
  94086. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94087. * 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)
  94088. * @param channel Name of the sampler variable.
  94089. * @param postProcess Post process to get the output texture from.
  94090. */
  94091. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94092. /** @hidden */
  94093. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94094. /** @hidden */
  94095. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94096. /** @hidden */
  94097. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94098. /** @hidden */
  94099. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94100. /**
  94101. * Binds a buffer to a uniform.
  94102. * @param buffer Buffer to bind.
  94103. * @param name Name of the uniform variable to bind to.
  94104. */
  94105. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94106. /**
  94107. * Binds block to a uniform.
  94108. * @param blockName Name of the block to bind.
  94109. * @param index Index to bind.
  94110. */
  94111. bindUniformBlock(blockName: string, index: number): void;
  94112. /**
  94113. * Sets an interger value on a uniform variable.
  94114. * @param uniformName Name of the variable.
  94115. * @param value Value to be set.
  94116. * @returns this effect.
  94117. */
  94118. setInt(uniformName: string, value: number): Effect;
  94119. /**
  94120. * Sets an int array on a uniform variable.
  94121. * @param uniformName Name of the variable.
  94122. * @param array array to be set.
  94123. * @returns this effect.
  94124. */
  94125. setIntArray(uniformName: string, array: Int32Array): Effect;
  94126. /**
  94127. * 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)
  94128. * @param uniformName Name of the variable.
  94129. * @param array array to be set.
  94130. * @returns this effect.
  94131. */
  94132. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94133. /**
  94134. * 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)
  94135. * @param uniformName Name of the variable.
  94136. * @param array array to be set.
  94137. * @returns this effect.
  94138. */
  94139. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94140. /**
  94141. * 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)
  94142. * @param uniformName Name of the variable.
  94143. * @param array array to be set.
  94144. * @returns this effect.
  94145. */
  94146. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94147. /**
  94148. * Sets an float array on a uniform variable.
  94149. * @param uniformName Name of the variable.
  94150. * @param array array to be set.
  94151. * @returns this effect.
  94152. */
  94153. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94154. /**
  94155. * 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)
  94156. * @param uniformName Name of the variable.
  94157. * @param array array to be set.
  94158. * @returns this effect.
  94159. */
  94160. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94161. /**
  94162. * 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)
  94163. * @param uniformName Name of the variable.
  94164. * @param array array to be set.
  94165. * @returns this effect.
  94166. */
  94167. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94168. /**
  94169. * 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)
  94170. * @param uniformName Name of the variable.
  94171. * @param array array to be set.
  94172. * @returns this effect.
  94173. */
  94174. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94175. /**
  94176. * Sets an array on a uniform variable.
  94177. * @param uniformName Name of the variable.
  94178. * @param array array to be set.
  94179. * @returns this effect.
  94180. */
  94181. setArray(uniformName: string, array: number[]): Effect;
  94182. /**
  94183. * 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)
  94184. * @param uniformName Name of the variable.
  94185. * @param array array to be set.
  94186. * @returns this effect.
  94187. */
  94188. setArray2(uniformName: string, array: number[]): Effect;
  94189. /**
  94190. * 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)
  94191. * @param uniformName Name of the variable.
  94192. * @param array array to be set.
  94193. * @returns this effect.
  94194. */
  94195. setArray3(uniformName: string, array: number[]): Effect;
  94196. /**
  94197. * 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)
  94198. * @param uniformName Name of the variable.
  94199. * @param array array to be set.
  94200. * @returns this effect.
  94201. */
  94202. setArray4(uniformName: string, array: number[]): Effect;
  94203. /**
  94204. * Sets matrices on a uniform variable.
  94205. * @param uniformName Name of the variable.
  94206. * @param matrices matrices to be set.
  94207. * @returns this effect.
  94208. */
  94209. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94210. /**
  94211. * Sets matrix on a uniform variable.
  94212. * @param uniformName Name of the variable.
  94213. * @param matrix matrix to be set.
  94214. * @returns this effect.
  94215. */
  94216. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94217. /**
  94218. * 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)
  94219. * @param uniformName Name of the variable.
  94220. * @param matrix matrix to be set.
  94221. * @returns this effect.
  94222. */
  94223. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94224. /**
  94225. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94226. * @param uniformName Name of the variable.
  94227. * @param matrix matrix to be set.
  94228. * @returns this effect.
  94229. */
  94230. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94231. /**
  94232. * Sets a float on a uniform variable.
  94233. * @param uniformName Name of the variable.
  94234. * @param value value to be set.
  94235. * @returns this effect.
  94236. */
  94237. setFloat(uniformName: string, value: number): Effect;
  94238. /**
  94239. * Sets a boolean on a uniform variable.
  94240. * @param uniformName Name of the variable.
  94241. * @param bool value to be set.
  94242. * @returns this effect.
  94243. */
  94244. setBool(uniformName: string, bool: boolean): Effect;
  94245. /**
  94246. * Sets a Vector2 on a uniform variable.
  94247. * @param uniformName Name of the variable.
  94248. * @param vector2 vector2 to be set.
  94249. * @returns this effect.
  94250. */
  94251. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94252. /**
  94253. * Sets a float2 on a uniform variable.
  94254. * @param uniformName Name of the variable.
  94255. * @param x First float in float2.
  94256. * @param y Second float in float2.
  94257. * @returns this effect.
  94258. */
  94259. setFloat2(uniformName: string, x: number, y: number): Effect;
  94260. /**
  94261. * Sets a Vector3 on a uniform variable.
  94262. * @param uniformName Name of the variable.
  94263. * @param vector3 Value to be set.
  94264. * @returns this effect.
  94265. */
  94266. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94267. /**
  94268. * Sets a float3 on a uniform variable.
  94269. * @param uniformName Name of the variable.
  94270. * @param x First float in float3.
  94271. * @param y Second float in float3.
  94272. * @param z Third float in float3.
  94273. * @returns this effect.
  94274. */
  94275. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94276. /**
  94277. * Sets a Vector4 on a uniform variable.
  94278. * @param uniformName Name of the variable.
  94279. * @param vector4 Value to be set.
  94280. * @returns this effect.
  94281. */
  94282. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94283. /**
  94284. * Sets a float4 on a uniform variable.
  94285. * @param uniformName Name of the variable.
  94286. * @param x First float in float4.
  94287. * @param y Second float in float4.
  94288. * @param z Third float in float4.
  94289. * @param w Fourth float in float4.
  94290. * @returns this effect.
  94291. */
  94292. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94293. /**
  94294. * Sets a Color3 on a uniform variable.
  94295. * @param uniformName Name of the variable.
  94296. * @param color3 Value to be set.
  94297. * @returns this effect.
  94298. */
  94299. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94300. /**
  94301. * Sets a Color4 on a uniform variable.
  94302. * @param uniformName Name of the variable.
  94303. * @param color3 Value to be set.
  94304. * @param alpha Alpha value to be set.
  94305. * @returns this effect.
  94306. */
  94307. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94308. /**
  94309. * Sets a Color4 on a uniform variable
  94310. * @param uniformName defines the name of the variable
  94311. * @param color4 defines the value to be set
  94312. * @returns this effect.
  94313. */
  94314. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94315. /** Release all associated resources */
  94316. dispose(): void;
  94317. /**
  94318. * This function will add a new shader to the shader store
  94319. * @param name the name of the shader
  94320. * @param pixelShader optional pixel shader content
  94321. * @param vertexShader optional vertex shader content
  94322. */
  94323. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94324. /**
  94325. * Store of each shader (The can be looked up using effect.key)
  94326. */
  94327. static ShadersStore: {
  94328. [key: string]: string;
  94329. };
  94330. /**
  94331. * Store of each included file for a shader (The can be looked up using effect.key)
  94332. */
  94333. static IncludesShadersStore: {
  94334. [key: string]: string;
  94335. };
  94336. /**
  94337. * Resets the cache of effects.
  94338. */
  94339. static ResetCache(): void;
  94340. }
  94341. }
  94342. declare module BABYLON {
  94343. /**
  94344. * Uniform buffer objects.
  94345. *
  94346. * Handles blocks of uniform on the GPU.
  94347. *
  94348. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94349. *
  94350. * For more information, please refer to :
  94351. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94352. */
  94353. export class UniformBuffer {
  94354. private _engine;
  94355. private _buffer;
  94356. private _data;
  94357. private _bufferData;
  94358. private _dynamic?;
  94359. private _uniformLocations;
  94360. private _uniformSizes;
  94361. private _uniformLocationPointer;
  94362. private _needSync;
  94363. private _noUBO;
  94364. private _currentEffect;
  94365. private static _MAX_UNIFORM_SIZE;
  94366. private static _tempBuffer;
  94367. /**
  94368. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94369. * This is dynamic to allow compat with webgl 1 and 2.
  94370. * You will need to pass the name of the uniform as well as the value.
  94371. */
  94372. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94373. /**
  94374. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94375. * This is dynamic to allow compat with webgl 1 and 2.
  94376. * You will need to pass the name of the uniform as well as the value.
  94377. */
  94378. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94379. /**
  94380. * Lambda to Update a single float in a uniform buffer.
  94381. * This is dynamic to allow compat with webgl 1 and 2.
  94382. * You will need to pass the name of the uniform as well as the value.
  94383. */
  94384. updateFloat: (name: string, x: number) => void;
  94385. /**
  94386. * Lambda to Update a vec2 of float in a uniform buffer.
  94387. * This is dynamic to allow compat with webgl 1 and 2.
  94388. * You will need to pass the name of the uniform as well as the value.
  94389. */
  94390. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94391. /**
  94392. * Lambda to Update a vec3 of float in a uniform buffer.
  94393. * This is dynamic to allow compat with webgl 1 and 2.
  94394. * You will need to pass the name of the uniform as well as the value.
  94395. */
  94396. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94397. /**
  94398. * Lambda to Update a vec4 of float in a uniform buffer.
  94399. * This is dynamic to allow compat with webgl 1 and 2.
  94400. * You will need to pass the name of the uniform as well as the value.
  94401. */
  94402. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94403. /**
  94404. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94405. * This is dynamic to allow compat with webgl 1 and 2.
  94406. * You will need to pass the name of the uniform as well as the value.
  94407. */
  94408. updateMatrix: (name: string, mat: Matrix) => void;
  94409. /**
  94410. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94411. * This is dynamic to allow compat with webgl 1 and 2.
  94412. * You will need to pass the name of the uniform as well as the value.
  94413. */
  94414. updateVector3: (name: string, vector: Vector3) => void;
  94415. /**
  94416. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94417. * This is dynamic to allow compat with webgl 1 and 2.
  94418. * You will need to pass the name of the uniform as well as the value.
  94419. */
  94420. updateVector4: (name: string, vector: Vector4) => void;
  94421. /**
  94422. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94423. * This is dynamic to allow compat with webgl 1 and 2.
  94424. * You will need to pass the name of the uniform as well as the value.
  94425. */
  94426. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94427. /**
  94428. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94429. * This is dynamic to allow compat with webgl 1 and 2.
  94430. * You will need to pass the name of the uniform as well as the value.
  94431. */
  94432. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94433. /**
  94434. * Instantiates a new Uniform buffer objects.
  94435. *
  94436. * Handles blocks of uniform on the GPU.
  94437. *
  94438. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94439. *
  94440. * For more information, please refer to :
  94441. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94442. * @param engine Define the engine the buffer is associated with
  94443. * @param data Define the data contained in the buffer
  94444. * @param dynamic Define if the buffer is updatable
  94445. */
  94446. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94447. /**
  94448. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94449. * or just falling back on setUniformXXX calls.
  94450. */
  94451. readonly useUbo: boolean;
  94452. /**
  94453. * Indicates if the WebGL underlying uniform buffer is in sync
  94454. * with the javascript cache data.
  94455. */
  94456. readonly isSync: boolean;
  94457. /**
  94458. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94459. * Also, a dynamic UniformBuffer will disable cache verification and always
  94460. * update the underlying WebGL uniform buffer to the GPU.
  94461. * @returns if Dynamic, otherwise false
  94462. */
  94463. isDynamic(): boolean;
  94464. /**
  94465. * The data cache on JS side.
  94466. * @returns the underlying data as a float array
  94467. */
  94468. getData(): Float32Array;
  94469. /**
  94470. * The underlying WebGL Uniform buffer.
  94471. * @returns the webgl buffer
  94472. */
  94473. getBuffer(): Nullable<DataBuffer>;
  94474. /**
  94475. * std140 layout specifies how to align data within an UBO structure.
  94476. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94477. * for specs.
  94478. */
  94479. private _fillAlignment;
  94480. /**
  94481. * Adds an uniform in the buffer.
  94482. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94483. * for the layout to be correct !
  94484. * @param name Name of the uniform, as used in the uniform block in the shader.
  94485. * @param size Data size, or data directly.
  94486. */
  94487. addUniform(name: string, size: number | number[]): void;
  94488. /**
  94489. * Adds a Matrix 4x4 to the uniform buffer.
  94490. * @param name Name of the uniform, as used in the uniform block in the shader.
  94491. * @param mat A 4x4 matrix.
  94492. */
  94493. addMatrix(name: string, mat: Matrix): void;
  94494. /**
  94495. * Adds a vec2 to the uniform buffer.
  94496. * @param name Name of the uniform, as used in the uniform block in the shader.
  94497. * @param x Define the x component value of the vec2
  94498. * @param y Define the y component value of the vec2
  94499. */
  94500. addFloat2(name: string, x: number, y: number): void;
  94501. /**
  94502. * Adds a vec3 to the uniform buffer.
  94503. * @param name Name of the uniform, as used in the uniform block in the shader.
  94504. * @param x Define the x component value of the vec3
  94505. * @param y Define the y component value of the vec3
  94506. * @param z Define the z component value of the vec3
  94507. */
  94508. addFloat3(name: string, x: number, y: number, z: number): void;
  94509. /**
  94510. * Adds a vec3 to the uniform buffer.
  94511. * @param name Name of the uniform, as used in the uniform block in the shader.
  94512. * @param color Define the vec3 from a Color
  94513. */
  94514. addColor3(name: string, color: Color3): void;
  94515. /**
  94516. * Adds a vec4 to the uniform buffer.
  94517. * @param name Name of the uniform, as used in the uniform block in the shader.
  94518. * @param color Define the rgb components from a Color
  94519. * @param alpha Define the a component of the vec4
  94520. */
  94521. addColor4(name: string, color: Color3, alpha: number): void;
  94522. /**
  94523. * Adds a vec3 to the uniform buffer.
  94524. * @param name Name of the uniform, as used in the uniform block in the shader.
  94525. * @param vector Define the vec3 components from a Vector
  94526. */
  94527. addVector3(name: string, vector: Vector3): void;
  94528. /**
  94529. * Adds a Matrix 3x3 to the uniform buffer.
  94530. * @param name Name of the uniform, as used in the uniform block in the shader.
  94531. */
  94532. addMatrix3x3(name: string): void;
  94533. /**
  94534. * Adds a Matrix 2x2 to the uniform buffer.
  94535. * @param name Name of the uniform, as used in the uniform block in the shader.
  94536. */
  94537. addMatrix2x2(name: string): void;
  94538. /**
  94539. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94540. */
  94541. create(): void;
  94542. /** @hidden */
  94543. _rebuild(): void;
  94544. /**
  94545. * Updates the WebGL Uniform Buffer on the GPU.
  94546. * If the `dynamic` flag is set to true, no cache comparison is done.
  94547. * Otherwise, the buffer will be updated only if the cache differs.
  94548. */
  94549. update(): void;
  94550. /**
  94551. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94552. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94553. * @param data Define the flattened data
  94554. * @param size Define the size of the data.
  94555. */
  94556. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94557. private _valueCache;
  94558. private _cacheMatrix;
  94559. private _updateMatrix3x3ForUniform;
  94560. private _updateMatrix3x3ForEffect;
  94561. private _updateMatrix2x2ForEffect;
  94562. private _updateMatrix2x2ForUniform;
  94563. private _updateFloatForEffect;
  94564. private _updateFloatForUniform;
  94565. private _updateFloat2ForEffect;
  94566. private _updateFloat2ForUniform;
  94567. private _updateFloat3ForEffect;
  94568. private _updateFloat3ForUniform;
  94569. private _updateFloat4ForEffect;
  94570. private _updateFloat4ForUniform;
  94571. private _updateMatrixForEffect;
  94572. private _updateMatrixForUniform;
  94573. private _updateVector3ForEffect;
  94574. private _updateVector3ForUniform;
  94575. private _updateVector4ForEffect;
  94576. private _updateVector4ForUniform;
  94577. private _updateColor3ForEffect;
  94578. private _updateColor3ForUniform;
  94579. private _updateColor4ForEffect;
  94580. private _updateColor4ForUniform;
  94581. /**
  94582. * Sets a sampler uniform on the effect.
  94583. * @param name Define the name of the sampler.
  94584. * @param texture Define the texture to set in the sampler
  94585. */
  94586. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94587. /**
  94588. * Directly updates the value of the uniform in the cache AND on the GPU.
  94589. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94590. * @param data Define the flattened data
  94591. */
  94592. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94593. /**
  94594. * Binds this uniform buffer to an effect.
  94595. * @param effect Define the effect to bind the buffer to
  94596. * @param name Name of the uniform block in the shader.
  94597. */
  94598. bindToEffect(effect: Effect, name: string): void;
  94599. /**
  94600. * Disposes the uniform buffer.
  94601. */
  94602. dispose(): void;
  94603. }
  94604. }
  94605. declare module BABYLON {
  94606. /**
  94607. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94609. */
  94610. export class Analyser {
  94611. /**
  94612. * Gets or sets the smoothing
  94613. * @ignorenaming
  94614. */
  94615. SMOOTHING: number;
  94616. /**
  94617. * Gets or sets the FFT table size
  94618. * @ignorenaming
  94619. */
  94620. FFT_SIZE: number;
  94621. /**
  94622. * Gets or sets the bar graph amplitude
  94623. * @ignorenaming
  94624. */
  94625. BARGRAPHAMPLITUDE: number;
  94626. /**
  94627. * Gets or sets the position of the debug canvas
  94628. * @ignorenaming
  94629. */
  94630. DEBUGCANVASPOS: {
  94631. x: number;
  94632. y: number;
  94633. };
  94634. /**
  94635. * Gets or sets the debug canvas size
  94636. * @ignorenaming
  94637. */
  94638. DEBUGCANVASSIZE: {
  94639. width: number;
  94640. height: number;
  94641. };
  94642. private _byteFreqs;
  94643. private _byteTime;
  94644. private _floatFreqs;
  94645. private _webAudioAnalyser;
  94646. private _debugCanvas;
  94647. private _debugCanvasContext;
  94648. private _scene;
  94649. private _registerFunc;
  94650. private _audioEngine;
  94651. /**
  94652. * Creates a new analyser
  94653. * @param scene defines hosting scene
  94654. */
  94655. constructor(scene: Scene);
  94656. /**
  94657. * Get the number of data values you will have to play with for the visualization
  94658. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94659. * @returns a number
  94660. */
  94661. getFrequencyBinCount(): number;
  94662. /**
  94663. * Gets the current frequency data as a byte array
  94664. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94665. * @returns a Uint8Array
  94666. */
  94667. getByteFrequencyData(): Uint8Array;
  94668. /**
  94669. * Gets the current waveform as a byte array
  94670. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94671. * @returns a Uint8Array
  94672. */
  94673. getByteTimeDomainData(): Uint8Array;
  94674. /**
  94675. * Gets the current frequency data as a float array
  94676. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94677. * @returns a Float32Array
  94678. */
  94679. getFloatFrequencyData(): Float32Array;
  94680. /**
  94681. * Renders the debug canvas
  94682. */
  94683. drawDebugCanvas(): void;
  94684. /**
  94685. * Stops rendering the debug canvas and removes it
  94686. */
  94687. stopDebugCanvas(): void;
  94688. /**
  94689. * Connects two audio nodes
  94690. * @param inputAudioNode defines first node to connect
  94691. * @param outputAudioNode defines second node to connect
  94692. */
  94693. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94694. /**
  94695. * Releases all associated resources
  94696. */
  94697. dispose(): void;
  94698. }
  94699. }
  94700. declare module BABYLON {
  94701. /**
  94702. * This represents an audio engine and it is responsible
  94703. * to play, synchronize and analyse sounds throughout the application.
  94704. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94705. */
  94706. export interface IAudioEngine extends IDisposable {
  94707. /**
  94708. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94709. */
  94710. readonly canUseWebAudio: boolean;
  94711. /**
  94712. * Gets the current AudioContext if available.
  94713. */
  94714. readonly audioContext: Nullable<AudioContext>;
  94715. /**
  94716. * The master gain node defines the global audio volume of your audio engine.
  94717. */
  94718. readonly masterGain: GainNode;
  94719. /**
  94720. * Gets whether or not mp3 are supported by your browser.
  94721. */
  94722. readonly isMP3supported: boolean;
  94723. /**
  94724. * Gets whether or not ogg are supported by your browser.
  94725. */
  94726. readonly isOGGsupported: boolean;
  94727. /**
  94728. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94729. * @ignoreNaming
  94730. */
  94731. WarnedWebAudioUnsupported: boolean;
  94732. /**
  94733. * Defines if the audio engine relies on a custom unlocked button.
  94734. * In this case, the embedded button will not be displayed.
  94735. */
  94736. useCustomUnlockedButton: boolean;
  94737. /**
  94738. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94739. */
  94740. readonly unlocked: boolean;
  94741. /**
  94742. * Event raised when audio has been unlocked on the browser.
  94743. */
  94744. onAudioUnlockedObservable: Observable<AudioEngine>;
  94745. /**
  94746. * Event raised when audio has been locked on the browser.
  94747. */
  94748. onAudioLockedObservable: Observable<AudioEngine>;
  94749. /**
  94750. * Flags the audio engine in Locked state.
  94751. * This happens due to new browser policies preventing audio to autoplay.
  94752. */
  94753. lock(): void;
  94754. /**
  94755. * Unlocks the audio engine once a user action has been done on the dom.
  94756. * This is helpful to resume play once browser policies have been satisfied.
  94757. */
  94758. unlock(): void;
  94759. }
  94760. /**
  94761. * This represents the default audio engine used in babylon.
  94762. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94764. */
  94765. export class AudioEngine implements IAudioEngine {
  94766. private _audioContext;
  94767. private _audioContextInitialized;
  94768. private _muteButton;
  94769. private _hostElement;
  94770. /**
  94771. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94772. */
  94773. canUseWebAudio: boolean;
  94774. /**
  94775. * The master gain node defines the global audio volume of your audio engine.
  94776. */
  94777. masterGain: GainNode;
  94778. /**
  94779. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94780. * @ignoreNaming
  94781. */
  94782. WarnedWebAudioUnsupported: boolean;
  94783. /**
  94784. * Gets whether or not mp3 are supported by your browser.
  94785. */
  94786. isMP3supported: boolean;
  94787. /**
  94788. * Gets whether or not ogg are supported by your browser.
  94789. */
  94790. isOGGsupported: boolean;
  94791. /**
  94792. * Gets whether audio has been unlocked on the device.
  94793. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94794. * a user interaction has happened.
  94795. */
  94796. unlocked: boolean;
  94797. /**
  94798. * Defines if the audio engine relies on a custom unlocked button.
  94799. * In this case, the embedded button will not be displayed.
  94800. */
  94801. useCustomUnlockedButton: boolean;
  94802. /**
  94803. * Event raised when audio has been unlocked on the browser.
  94804. */
  94805. onAudioUnlockedObservable: Observable<AudioEngine>;
  94806. /**
  94807. * Event raised when audio has been locked on the browser.
  94808. */
  94809. onAudioLockedObservable: Observable<AudioEngine>;
  94810. /**
  94811. * Gets the current AudioContext if available.
  94812. */
  94813. readonly audioContext: Nullable<AudioContext>;
  94814. private _connectedAnalyser;
  94815. /**
  94816. * Instantiates a new audio engine.
  94817. *
  94818. * There should be only one per page as some browsers restrict the number
  94819. * of audio contexts you can create.
  94820. * @param hostElement defines the host element where to display the mute icon if necessary
  94821. */
  94822. constructor(hostElement?: Nullable<HTMLElement>);
  94823. /**
  94824. * Flags the audio engine in Locked state.
  94825. * This happens due to new browser policies preventing audio to autoplay.
  94826. */
  94827. lock(): void;
  94828. /**
  94829. * Unlocks the audio engine once a user action has been done on the dom.
  94830. * This is helpful to resume play once browser policies have been satisfied.
  94831. */
  94832. unlock(): void;
  94833. private _resumeAudioContext;
  94834. private _initializeAudioContext;
  94835. private _tryToRun;
  94836. private _triggerRunningState;
  94837. private _triggerSuspendedState;
  94838. private _displayMuteButton;
  94839. private _moveButtonToTopLeft;
  94840. private _onResize;
  94841. private _hideMuteButton;
  94842. /**
  94843. * Destroy and release the resources associated with the audio ccontext.
  94844. */
  94845. dispose(): void;
  94846. /**
  94847. * Gets the global volume sets on the master gain.
  94848. * @returns the global volume if set or -1 otherwise
  94849. */
  94850. getGlobalVolume(): number;
  94851. /**
  94852. * Sets the global volume of your experience (sets on the master gain).
  94853. * @param newVolume Defines the new global volume of the application
  94854. */
  94855. setGlobalVolume(newVolume: number): void;
  94856. /**
  94857. * Connect the audio engine to an audio analyser allowing some amazing
  94858. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  94859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  94860. * @param analyser The analyser to connect to the engine
  94861. */
  94862. connectToAnalyser(analyser: Analyser): void;
  94863. }
  94864. }
  94865. declare module BABYLON {
  94866. /**
  94867. * Interface used to present a loading screen while loading a scene
  94868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94869. */
  94870. export interface ILoadingScreen {
  94871. /**
  94872. * Function called to display the loading screen
  94873. */
  94874. displayLoadingUI: () => void;
  94875. /**
  94876. * Function called to hide the loading screen
  94877. */
  94878. hideLoadingUI: () => void;
  94879. /**
  94880. * Gets or sets the color to use for the background
  94881. */
  94882. loadingUIBackgroundColor: string;
  94883. /**
  94884. * Gets or sets the text to display while loading
  94885. */
  94886. loadingUIText: string;
  94887. }
  94888. /**
  94889. * Class used for the default loading screen
  94890. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  94891. */
  94892. export class DefaultLoadingScreen implements ILoadingScreen {
  94893. private _renderingCanvas;
  94894. private _loadingText;
  94895. private _loadingDivBackgroundColor;
  94896. private _loadingDiv;
  94897. private _loadingTextDiv;
  94898. /** Gets or sets the logo url to use for the default loading screen */
  94899. static DefaultLogoUrl: string;
  94900. /** Gets or sets the spinner url to use for the default loading screen */
  94901. static DefaultSpinnerUrl: string;
  94902. /**
  94903. * Creates a new default loading screen
  94904. * @param _renderingCanvas defines the canvas used to render the scene
  94905. * @param _loadingText defines the default text to display
  94906. * @param _loadingDivBackgroundColor defines the default background color
  94907. */
  94908. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  94909. /**
  94910. * Function called to display the loading screen
  94911. */
  94912. displayLoadingUI(): void;
  94913. /**
  94914. * Function called to hide the loading screen
  94915. */
  94916. hideLoadingUI(): void;
  94917. /**
  94918. * Gets or sets the text to display while loading
  94919. */
  94920. loadingUIText: string;
  94921. /**
  94922. * Gets or sets the color to use for the background
  94923. */
  94924. loadingUIBackgroundColor: string;
  94925. private _resizeLoadingUI;
  94926. }
  94927. }
  94928. declare module BABYLON {
  94929. /** @hidden */
  94930. export class WebGLPipelineContext implements IPipelineContext {
  94931. engine: Engine;
  94932. program: Nullable<WebGLProgram>;
  94933. context?: WebGLRenderingContext;
  94934. vertexShader?: WebGLShader;
  94935. fragmentShader?: WebGLShader;
  94936. isParallelCompiled: boolean;
  94937. onCompiled?: () => void;
  94938. transformFeedback?: WebGLTransformFeedback | null;
  94939. readonly isAsync: boolean;
  94940. readonly isReady: boolean;
  94941. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  94942. }
  94943. }
  94944. declare module BABYLON {
  94945. /** @hidden */
  94946. export class WebGLDataBuffer extends DataBuffer {
  94947. private _buffer;
  94948. constructor(resource: WebGLBuffer);
  94949. readonly underlyingResource: any;
  94950. }
  94951. }
  94952. declare module BABYLON {
  94953. /** @hidden */
  94954. export class WebGL2ShaderProcessor implements IShaderProcessor {
  94955. attributeProcessor(attribute: string): string;
  94956. varyingProcessor(varying: string, isFragment: boolean): string;
  94957. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  94958. }
  94959. }
  94960. declare module BABYLON {
  94961. /**
  94962. * This class is used to track a performance counter which is number based.
  94963. * The user has access to many properties which give statistics of different nature.
  94964. *
  94965. * The implementer can track two kinds of Performance Counter: time and count.
  94966. * 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.
  94967. * 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.
  94968. */
  94969. export class PerfCounter {
  94970. /**
  94971. * Gets or sets a global boolean to turn on and off all the counters
  94972. */
  94973. static Enabled: boolean;
  94974. /**
  94975. * Returns the smallest value ever
  94976. */
  94977. readonly min: number;
  94978. /**
  94979. * Returns the biggest value ever
  94980. */
  94981. readonly max: number;
  94982. /**
  94983. * Returns the average value since the performance counter is running
  94984. */
  94985. readonly average: number;
  94986. /**
  94987. * Returns the average value of the last second the counter was monitored
  94988. */
  94989. readonly lastSecAverage: number;
  94990. /**
  94991. * Returns the current value
  94992. */
  94993. readonly current: number;
  94994. /**
  94995. * Gets the accumulated total
  94996. */
  94997. readonly total: number;
  94998. /**
  94999. * Gets the total value count
  95000. */
  95001. readonly count: number;
  95002. /**
  95003. * Creates a new counter
  95004. */
  95005. constructor();
  95006. /**
  95007. * Call this method to start monitoring a new frame.
  95008. * 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.
  95009. */
  95010. fetchNewFrame(): void;
  95011. /**
  95012. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95013. * @param newCount the count value to add to the monitored count
  95014. * @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.
  95015. */
  95016. addCount(newCount: number, fetchResult: boolean): void;
  95017. /**
  95018. * Start monitoring this performance counter
  95019. */
  95020. beginMonitoring(): void;
  95021. /**
  95022. * Compute the time lapsed since the previous beginMonitoring() call.
  95023. * @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
  95024. */
  95025. endMonitoring(newFrame?: boolean): void;
  95026. private _fetchResult;
  95027. private _startMonitoringTime;
  95028. private _min;
  95029. private _max;
  95030. private _average;
  95031. private _current;
  95032. private _totalValueCount;
  95033. private _totalAccumulated;
  95034. private _lastSecAverage;
  95035. private _lastSecAccumulated;
  95036. private _lastSecTime;
  95037. private _lastSecValueCount;
  95038. }
  95039. }
  95040. declare module BABYLON {
  95041. /**
  95042. * Interface for any object that can request an animation frame
  95043. */
  95044. export interface ICustomAnimationFrameRequester {
  95045. /**
  95046. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95047. */
  95048. renderFunction?: Function;
  95049. /**
  95050. * Called to request the next frame to render to
  95051. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95052. */
  95053. requestAnimationFrame: Function;
  95054. /**
  95055. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95056. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95057. */
  95058. requestID?: number;
  95059. }
  95060. }
  95061. declare module BABYLON {
  95062. /**
  95063. * Settings for finer control over video usage
  95064. */
  95065. export interface VideoTextureSettings {
  95066. /**
  95067. * Applies `autoplay` to video, if specified
  95068. */
  95069. autoPlay?: boolean;
  95070. /**
  95071. * Applies `loop` to video, if specified
  95072. */
  95073. loop?: boolean;
  95074. /**
  95075. * Automatically updates internal texture from video at every frame in the render loop
  95076. */
  95077. autoUpdateTexture: boolean;
  95078. /**
  95079. * Image src displayed during the video loading or until the user interacts with the video.
  95080. */
  95081. poster?: string;
  95082. }
  95083. /**
  95084. * If you want to display a video in your scene, this is the special texture for that.
  95085. * This special texture works similar to other textures, with the exception of a few parameters.
  95086. * @see https://doc.babylonjs.com/how_to/video_texture
  95087. */
  95088. export class VideoTexture extends Texture {
  95089. /**
  95090. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95091. */
  95092. readonly autoUpdateTexture: boolean;
  95093. /**
  95094. * The video instance used by the texture internally
  95095. */
  95096. readonly video: HTMLVideoElement;
  95097. private _onUserActionRequestedObservable;
  95098. /**
  95099. * Event triggerd when a dom action is required by the user to play the video.
  95100. * This happens due to recent changes in browser policies preventing video to auto start.
  95101. */
  95102. readonly onUserActionRequestedObservable: Observable<Texture>;
  95103. private _generateMipMaps;
  95104. private _engine;
  95105. private _stillImageCaptured;
  95106. private _displayingPosterTexture;
  95107. private _settings;
  95108. private _createInternalTextureOnEvent;
  95109. private _frameId;
  95110. /**
  95111. * Creates a video texture.
  95112. * If you want to display a video in your scene, this is the special texture for that.
  95113. * This special texture works similar to other textures, with the exception of a few parameters.
  95114. * @see https://doc.babylonjs.com/how_to/video_texture
  95115. * @param name optional name, will detect from video source, if not defined
  95116. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95117. * @param scene is obviously the current scene.
  95118. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95119. * @param invertY is false by default but can be used to invert video on Y axis
  95120. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95121. * @param settings allows finer control over video usage
  95122. */
  95123. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95124. private _getName;
  95125. private _getVideo;
  95126. private _createInternalTexture;
  95127. private reset;
  95128. /**
  95129. * @hidden Internal method to initiate `update`.
  95130. */
  95131. _rebuild(): void;
  95132. /**
  95133. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95134. */
  95135. update(): void;
  95136. /**
  95137. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95138. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95139. */
  95140. updateTexture(isVisible: boolean): void;
  95141. protected _updateInternalTexture: () => void;
  95142. /**
  95143. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95144. * @param url New url.
  95145. */
  95146. updateURL(url: string): void;
  95147. /**
  95148. * Dispose the texture and release its associated resources.
  95149. */
  95150. dispose(): void;
  95151. /**
  95152. * Creates a video texture straight from a stream.
  95153. * @param scene Define the scene the texture should be created in
  95154. * @param stream Define the stream the texture should be created from
  95155. * @returns The created video texture as a promise
  95156. */
  95157. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95158. /**
  95159. * Creates a video texture straight from your WebCam video feed.
  95160. * @param scene Define the scene the texture should be created in
  95161. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95162. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95163. * @returns The created video texture as a promise
  95164. */
  95165. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95166. minWidth: number;
  95167. maxWidth: number;
  95168. minHeight: number;
  95169. maxHeight: number;
  95170. deviceId: string;
  95171. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95172. /**
  95173. * Creates a video texture straight from your WebCam video feed.
  95174. * @param scene Define the scene the texture should be created in
  95175. * @param onReady Define a callback to triggered once the texture will be ready
  95176. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95177. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95178. */
  95179. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95180. minWidth: number;
  95181. maxWidth: number;
  95182. minHeight: number;
  95183. maxHeight: number;
  95184. deviceId: string;
  95185. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95186. }
  95187. }
  95188. declare module BABYLON {
  95189. /**
  95190. * Defines the interface used by objects containing a viewport (like a camera)
  95191. */
  95192. interface IViewportOwnerLike {
  95193. /**
  95194. * Gets or sets the viewport
  95195. */
  95196. viewport: IViewportLike;
  95197. }
  95198. /**
  95199. * Interface for attribute information associated with buffer instanciation
  95200. */
  95201. export class InstancingAttributeInfo {
  95202. /**
  95203. * Index/offset of the attribute in the vertex shader
  95204. */
  95205. index: number;
  95206. /**
  95207. * size of the attribute, 1, 2, 3 or 4
  95208. */
  95209. attributeSize: number;
  95210. /**
  95211. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95212. * default is FLOAT
  95213. */
  95214. attribyteType: number;
  95215. /**
  95216. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95217. */
  95218. normalized: boolean;
  95219. /**
  95220. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95221. */
  95222. offset: number;
  95223. /**
  95224. * Name of the GLSL attribute, for debugging purpose only
  95225. */
  95226. attributeName: string;
  95227. }
  95228. /**
  95229. * Define options used to create a depth texture
  95230. */
  95231. export class DepthTextureCreationOptions {
  95232. /** Specifies whether or not a stencil should be allocated in the texture */
  95233. generateStencil?: boolean;
  95234. /** Specifies whether or not bilinear filtering is enable on the texture */
  95235. bilinearFiltering?: boolean;
  95236. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95237. comparisonFunction?: number;
  95238. /** Specifies if the created texture is a cube texture */
  95239. isCube?: boolean;
  95240. }
  95241. /**
  95242. * Class used to describe the capabilities of the engine relatively to the current browser
  95243. */
  95244. export class EngineCapabilities {
  95245. /** Maximum textures units per fragment shader */
  95246. maxTexturesImageUnits: number;
  95247. /** Maximum texture units per vertex shader */
  95248. maxVertexTextureImageUnits: number;
  95249. /** Maximum textures units in the entire pipeline */
  95250. maxCombinedTexturesImageUnits: number;
  95251. /** Maximum texture size */
  95252. maxTextureSize: number;
  95253. /** Maximum cube texture size */
  95254. maxCubemapTextureSize: number;
  95255. /** Maximum render texture size */
  95256. maxRenderTextureSize: number;
  95257. /** Maximum number of vertex attributes */
  95258. maxVertexAttribs: number;
  95259. /** Maximum number of varyings */
  95260. maxVaryingVectors: number;
  95261. /** Maximum number of uniforms per vertex shader */
  95262. maxVertexUniformVectors: number;
  95263. /** Maximum number of uniforms per fragment shader */
  95264. maxFragmentUniformVectors: number;
  95265. /** Defines if standard derivates (dx/dy) are supported */
  95266. standardDerivatives: boolean;
  95267. /** Defines if s3tc texture compression is supported */
  95268. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95269. /** Defines if pvrtc texture compression is supported */
  95270. pvrtc: any;
  95271. /** Defines if etc1 texture compression is supported */
  95272. etc1: any;
  95273. /** Defines if etc2 texture compression is supported */
  95274. etc2: any;
  95275. /** Defines if astc texture compression is supported */
  95276. astc: any;
  95277. /** Defines if float textures are supported */
  95278. textureFloat: boolean;
  95279. /** Defines if vertex array objects are supported */
  95280. vertexArrayObject: boolean;
  95281. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95282. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95283. /** Gets the maximum level of anisotropy supported */
  95284. maxAnisotropy: number;
  95285. /** Defines if instancing is supported */
  95286. instancedArrays: boolean;
  95287. /** Defines if 32 bits indices are supported */
  95288. uintIndices: boolean;
  95289. /** Defines if high precision shaders are supported */
  95290. highPrecisionShaderSupported: boolean;
  95291. /** Defines if depth reading in the fragment shader is supported */
  95292. fragmentDepthSupported: boolean;
  95293. /** Defines if float texture linear filtering is supported*/
  95294. textureFloatLinearFiltering: boolean;
  95295. /** Defines if rendering to float textures is supported */
  95296. textureFloatRender: boolean;
  95297. /** Defines if half float textures are supported*/
  95298. textureHalfFloat: boolean;
  95299. /** Defines if half float texture linear filtering is supported*/
  95300. textureHalfFloatLinearFiltering: boolean;
  95301. /** Defines if rendering to half float textures is supported */
  95302. textureHalfFloatRender: boolean;
  95303. /** Defines if textureLOD shader command is supported */
  95304. textureLOD: boolean;
  95305. /** Defines if draw buffers extension is supported */
  95306. drawBuffersExtension: boolean;
  95307. /** Defines if depth textures are supported */
  95308. depthTextureExtension: boolean;
  95309. /** Defines if float color buffer are supported */
  95310. colorBufferFloat: boolean;
  95311. /** Gets disjoint timer query extension (null if not supported) */
  95312. timerQuery: EXT_disjoint_timer_query;
  95313. /** Defines if timestamp can be used with timer query */
  95314. canUseTimestampForTimerQuery: boolean;
  95315. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95316. multiview: any;
  95317. /** Function used to let the system compiles shaders in background */
  95318. parallelShaderCompile: {
  95319. COMPLETION_STATUS_KHR: number;
  95320. };
  95321. /** Max number of texture samples for MSAA */
  95322. maxMSAASamples: number;
  95323. }
  95324. /** Interface defining initialization parameters for Engine class */
  95325. export interface EngineOptions extends WebGLContextAttributes {
  95326. /**
  95327. * Defines if the engine should no exceed a specified device ratio
  95328. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95329. */
  95330. limitDeviceRatio?: number;
  95331. /**
  95332. * Defines if webvr should be enabled automatically
  95333. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95334. */
  95335. autoEnableWebVR?: boolean;
  95336. /**
  95337. * Defines if webgl2 should be turned off even if supported
  95338. * @see http://doc.babylonjs.com/features/webgl2
  95339. */
  95340. disableWebGL2Support?: boolean;
  95341. /**
  95342. * Defines if webaudio should be initialized as well
  95343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95344. */
  95345. audioEngine?: boolean;
  95346. /**
  95347. * Defines if animations should run using a deterministic lock step
  95348. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95349. */
  95350. deterministicLockstep?: boolean;
  95351. /** Defines the maximum steps to use with deterministic lock step mode */
  95352. lockstepMaxSteps?: number;
  95353. /**
  95354. * Defines that engine should ignore context lost events
  95355. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95356. */
  95357. doNotHandleContextLost?: boolean;
  95358. /**
  95359. * Defines that engine should ignore modifying touch action attribute and style
  95360. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95361. */
  95362. doNotHandleTouchAction?: boolean;
  95363. /**
  95364. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95365. */
  95366. useHighPrecisionFloats?: boolean;
  95367. }
  95368. /**
  95369. * Defines the interface used by display changed events
  95370. */
  95371. export interface IDisplayChangedEventArgs {
  95372. /** Gets the vrDisplay object (if any) */
  95373. vrDisplay: Nullable<any>;
  95374. /** Gets a boolean indicating if webVR is supported */
  95375. vrSupported: boolean;
  95376. }
  95377. /**
  95378. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95379. */
  95380. export class Engine {
  95381. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95382. static ExceptionList: ({
  95383. key: string;
  95384. capture: string;
  95385. captureConstraint: number;
  95386. targets: string[];
  95387. } | {
  95388. key: string;
  95389. capture: null;
  95390. captureConstraint: null;
  95391. targets: string[];
  95392. })[];
  95393. /** Gets the list of created engines */
  95394. static readonly Instances: Engine[];
  95395. /**
  95396. * Gets the latest created engine
  95397. */
  95398. static readonly LastCreatedEngine: Nullable<Engine>;
  95399. /**
  95400. * Gets the latest created scene
  95401. */
  95402. static readonly LastCreatedScene: Nullable<Scene>;
  95403. /**
  95404. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95405. * @param flag defines which part of the materials must be marked as dirty
  95406. * @param predicate defines a predicate used to filter which materials should be affected
  95407. */
  95408. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95409. /** @hidden */
  95410. static _TextureLoaders: IInternalTextureLoader[];
  95411. /** Defines that alpha blending is disabled */
  95412. static readonly ALPHA_DISABLE: number;
  95413. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95414. static readonly ALPHA_ADD: number;
  95415. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95416. static readonly ALPHA_COMBINE: number;
  95417. /** Defines that alpha blending to DEST - SRC * DEST */
  95418. static readonly ALPHA_SUBTRACT: number;
  95419. /** Defines that alpha blending to SRC * DEST */
  95420. static readonly ALPHA_MULTIPLY: number;
  95421. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95422. static readonly ALPHA_MAXIMIZED: number;
  95423. /** Defines that alpha blending to SRC + DEST */
  95424. static readonly ALPHA_ONEONE: number;
  95425. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95426. static readonly ALPHA_PREMULTIPLIED: number;
  95427. /**
  95428. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95429. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95430. */
  95431. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95432. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95433. static readonly ALPHA_INTERPOLATE: number;
  95434. /**
  95435. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95436. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95437. */
  95438. static readonly ALPHA_SCREENMODE: number;
  95439. /** Defines that the ressource is not delayed*/
  95440. static readonly DELAYLOADSTATE_NONE: number;
  95441. /** Defines that the ressource was successfully delay loaded */
  95442. static readonly DELAYLOADSTATE_LOADED: number;
  95443. /** Defines that the ressource is currently delay loading */
  95444. static readonly DELAYLOADSTATE_LOADING: number;
  95445. /** Defines that the ressource is delayed and has not started loading */
  95446. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95447. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95448. static readonly NEVER: number;
  95449. /** 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 */
  95450. static readonly ALWAYS: number;
  95451. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95452. static readonly LESS: number;
  95453. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95454. static readonly EQUAL: number;
  95455. /** 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 */
  95456. static readonly LEQUAL: number;
  95457. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95458. static readonly GREATER: number;
  95459. /** 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 */
  95460. static readonly GEQUAL: number;
  95461. /** 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 */
  95462. static readonly NOTEQUAL: number;
  95463. /** Passed to stencilOperation to specify that stencil value must be kept */
  95464. static readonly KEEP: number;
  95465. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95466. static readonly REPLACE: number;
  95467. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95468. static readonly INCR: number;
  95469. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95470. static readonly DECR: number;
  95471. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95472. static readonly INVERT: number;
  95473. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95474. static readonly INCR_WRAP: number;
  95475. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95476. static readonly DECR_WRAP: number;
  95477. /** Texture is not repeating outside of 0..1 UVs */
  95478. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95479. /** Texture is repeating outside of 0..1 UVs */
  95480. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95481. /** Texture is repeating and mirrored */
  95482. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95483. /** ALPHA */
  95484. static readonly TEXTUREFORMAT_ALPHA: number;
  95485. /** LUMINANCE */
  95486. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95487. /** LUMINANCE_ALPHA */
  95488. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95489. /** RGB */
  95490. static readonly TEXTUREFORMAT_RGB: number;
  95491. /** RGBA */
  95492. static readonly TEXTUREFORMAT_RGBA: number;
  95493. /** RED */
  95494. static readonly TEXTUREFORMAT_RED: number;
  95495. /** RED (2nd reference) */
  95496. static readonly TEXTUREFORMAT_R: number;
  95497. /** RG */
  95498. static readonly TEXTUREFORMAT_RG: number;
  95499. /** RED_INTEGER */
  95500. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95501. /** RED_INTEGER (2nd reference) */
  95502. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95503. /** RG_INTEGER */
  95504. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95505. /** RGB_INTEGER */
  95506. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95507. /** RGBA_INTEGER */
  95508. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95509. /** UNSIGNED_BYTE */
  95510. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95511. /** UNSIGNED_BYTE (2nd reference) */
  95512. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95513. /** FLOAT */
  95514. static readonly TEXTURETYPE_FLOAT: number;
  95515. /** HALF_FLOAT */
  95516. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95517. /** BYTE */
  95518. static readonly TEXTURETYPE_BYTE: number;
  95519. /** SHORT */
  95520. static readonly TEXTURETYPE_SHORT: number;
  95521. /** UNSIGNED_SHORT */
  95522. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95523. /** INT */
  95524. static readonly TEXTURETYPE_INT: number;
  95525. /** UNSIGNED_INT */
  95526. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95527. /** UNSIGNED_SHORT_4_4_4_4 */
  95528. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95529. /** UNSIGNED_SHORT_5_5_5_1 */
  95530. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95531. /** UNSIGNED_SHORT_5_6_5 */
  95532. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95533. /** UNSIGNED_INT_2_10_10_10_REV */
  95534. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95535. /** UNSIGNED_INT_24_8 */
  95536. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95537. /** UNSIGNED_INT_10F_11F_11F_REV */
  95538. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95539. /** UNSIGNED_INT_5_9_9_9_REV */
  95540. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95541. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95542. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95543. /** nearest is mag = nearest and min = nearest and mip = linear */
  95544. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95545. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95546. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95547. /** Trilinear is mag = linear and min = linear and mip = linear */
  95548. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95549. /** nearest is mag = nearest and min = nearest and mip = linear */
  95550. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95552. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95553. /** Trilinear is mag = linear and min = linear and mip = linear */
  95554. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95555. /** mag = nearest and min = nearest and mip = nearest */
  95556. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95557. /** mag = nearest and min = linear and mip = nearest */
  95558. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95559. /** mag = nearest and min = linear and mip = linear */
  95560. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95561. /** mag = nearest and min = linear and mip = none */
  95562. static readonly TEXTURE_NEAREST_LINEAR: number;
  95563. /** mag = nearest and min = nearest and mip = none */
  95564. static readonly TEXTURE_NEAREST_NEAREST: number;
  95565. /** mag = linear and min = nearest and mip = nearest */
  95566. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95567. /** mag = linear and min = nearest and mip = linear */
  95568. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95569. /** mag = linear and min = linear and mip = none */
  95570. static readonly TEXTURE_LINEAR_LINEAR: number;
  95571. /** mag = linear and min = nearest and mip = none */
  95572. static readonly TEXTURE_LINEAR_NEAREST: number;
  95573. /** Explicit coordinates mode */
  95574. static readonly TEXTURE_EXPLICIT_MODE: number;
  95575. /** Spherical coordinates mode */
  95576. static readonly TEXTURE_SPHERICAL_MODE: number;
  95577. /** Planar coordinates mode */
  95578. static readonly TEXTURE_PLANAR_MODE: number;
  95579. /** Cubic coordinates mode */
  95580. static readonly TEXTURE_CUBIC_MODE: number;
  95581. /** Projection coordinates mode */
  95582. static readonly TEXTURE_PROJECTION_MODE: number;
  95583. /** Skybox coordinates mode */
  95584. static readonly TEXTURE_SKYBOX_MODE: number;
  95585. /** Inverse Cubic coordinates mode */
  95586. static readonly TEXTURE_INVCUBIC_MODE: number;
  95587. /** Equirectangular coordinates mode */
  95588. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95589. /** Equirectangular Fixed coordinates mode */
  95590. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95591. /** Equirectangular Fixed Mirrored coordinates mode */
  95592. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95593. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95594. static readonly SCALEMODE_FLOOR: number;
  95595. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95596. static readonly SCALEMODE_NEAREST: number;
  95597. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95598. static readonly SCALEMODE_CEILING: number;
  95599. /**
  95600. * Returns the current npm package of the sdk
  95601. */
  95602. static readonly NpmPackage: string;
  95603. /**
  95604. * Returns the current version of the framework
  95605. */
  95606. static readonly Version: string;
  95607. /**
  95608. * Returns a string describing the current engine
  95609. */
  95610. readonly description: string;
  95611. /**
  95612. * Gets or sets the epsilon value used by collision engine
  95613. */
  95614. static CollisionsEpsilon: number;
  95615. /**
  95616. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95617. */
  95618. static ShadersRepository: string;
  95619. /**
  95620. * Method called to create the default loading screen.
  95621. * This can be overriden in your own app.
  95622. * @param canvas The rendering canvas element
  95623. * @returns The loading screen
  95624. */
  95625. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95626. /**
  95627. * Method called to create the default rescale post process on each engine.
  95628. */
  95629. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95630. /** @hidden */
  95631. _shaderProcessor: IShaderProcessor;
  95632. /**
  95633. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95634. */
  95635. forcePOTTextures: boolean;
  95636. /**
  95637. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95638. */
  95639. isFullscreen: boolean;
  95640. /**
  95641. * Gets a boolean indicating if the pointer is currently locked
  95642. */
  95643. isPointerLock: boolean;
  95644. /**
  95645. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95646. */
  95647. cullBackFaces: boolean;
  95648. /**
  95649. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95650. */
  95651. renderEvenInBackground: boolean;
  95652. /**
  95653. * Gets or sets a boolean indicating that cache can be kept between frames
  95654. */
  95655. preventCacheWipeBetweenFrames: boolean;
  95656. /**
  95657. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95658. **/
  95659. enableOfflineSupport: boolean;
  95660. /**
  95661. * 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)
  95662. **/
  95663. disableManifestCheck: boolean;
  95664. /**
  95665. * Gets the list of created scenes
  95666. */
  95667. scenes: Scene[];
  95668. /**
  95669. * Event raised when a new scene is created
  95670. */
  95671. onNewSceneAddedObservable: Observable<Scene>;
  95672. /**
  95673. * Gets the list of created postprocesses
  95674. */
  95675. postProcesses: PostProcess[];
  95676. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95677. validateShaderPrograms: boolean;
  95678. /**
  95679. * Observable event triggered each time the rendering canvas is resized
  95680. */
  95681. onResizeObservable: Observable<Engine>;
  95682. /**
  95683. * Observable event triggered each time the canvas loses focus
  95684. */
  95685. onCanvasBlurObservable: Observable<Engine>;
  95686. /**
  95687. * Observable event triggered each time the canvas gains focus
  95688. */
  95689. onCanvasFocusObservable: Observable<Engine>;
  95690. /**
  95691. * Observable event triggered each time the canvas receives pointerout event
  95692. */
  95693. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95694. /**
  95695. * Observable event triggered before each texture is initialized
  95696. */
  95697. onBeforeTextureInitObservable: Observable<Texture>;
  95698. /**
  95699. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95700. */
  95701. disableUniformBuffers: boolean;
  95702. /** @hidden */
  95703. _uniformBuffers: UniformBuffer[];
  95704. /**
  95705. * Gets a boolean indicating that the engine supports uniform buffers
  95706. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95707. */
  95708. readonly supportsUniformBuffers: boolean;
  95709. /**
  95710. * Observable raised when the engine begins a new frame
  95711. */
  95712. onBeginFrameObservable: Observable<Engine>;
  95713. /**
  95714. * If set, will be used to request the next animation frame for the render loop
  95715. */
  95716. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95717. /**
  95718. * Observable raised when the engine ends the current frame
  95719. */
  95720. onEndFrameObservable: Observable<Engine>;
  95721. /**
  95722. * Observable raised when the engine is about to compile a shader
  95723. */
  95724. onBeforeShaderCompilationObservable: Observable<Engine>;
  95725. /**
  95726. * Observable raised when the engine has jsut compiled a shader
  95727. */
  95728. onAfterShaderCompilationObservable: Observable<Engine>;
  95729. /** @hidden */
  95730. _gl: WebGLRenderingContext;
  95731. private _renderingCanvas;
  95732. private _windowIsBackground;
  95733. protected _webGLVersion: number;
  95734. protected _highPrecisionShadersAllowed: boolean;
  95735. /** @hidden */
  95736. readonly _shouldUseHighPrecisionShader: boolean;
  95737. /**
  95738. * Gets a boolean indicating that only power of 2 textures are supported
  95739. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95740. */
  95741. readonly needPOTTextures: boolean;
  95742. /** @hidden */
  95743. _badOS: boolean;
  95744. /** @hidden */
  95745. _badDesktopOS: boolean;
  95746. /**
  95747. * Gets the audio engine
  95748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95749. * @ignorenaming
  95750. */
  95751. static audioEngine: IAudioEngine;
  95752. /**
  95753. * Default AudioEngine factory responsible of creating the Audio Engine.
  95754. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  95755. */
  95756. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  95757. /**
  95758. * Default offline support factory responsible of creating a tool used to store data locally.
  95759. * By default, this will create a Database object if the workload has been embedded.
  95760. */
  95761. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  95762. private _onFocus;
  95763. private _onBlur;
  95764. private _onCanvasPointerOut;
  95765. private _onCanvasBlur;
  95766. private _onCanvasFocus;
  95767. private _onFullscreenChange;
  95768. private _onPointerLockChange;
  95769. private _hardwareScalingLevel;
  95770. /** @hidden */
  95771. _caps: EngineCapabilities;
  95772. private _pointerLockRequested;
  95773. private _isStencilEnable;
  95774. protected _colorWrite: boolean;
  95775. private _loadingScreen;
  95776. /** @hidden */
  95777. _drawCalls: PerfCounter;
  95778. private _glVersion;
  95779. private _glRenderer;
  95780. private _glVendor;
  95781. private _videoTextureSupported;
  95782. private _renderingQueueLaunched;
  95783. private _activeRenderLoops;
  95784. private _deterministicLockstep;
  95785. private _lockstepMaxSteps;
  95786. /**
  95787. * Observable signaled when a context lost event is raised
  95788. */
  95789. onContextLostObservable: Observable<Engine>;
  95790. /**
  95791. * Observable signaled when a context restored event is raised
  95792. */
  95793. onContextRestoredObservable: Observable<Engine>;
  95794. private _onContextLost;
  95795. private _onContextRestored;
  95796. private _contextWasLost;
  95797. /** @hidden */
  95798. _doNotHandleContextLost: boolean;
  95799. /**
  95800. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95802. */
  95803. doNotHandleContextLost: boolean;
  95804. private _performanceMonitor;
  95805. private _fps;
  95806. private _deltaTime;
  95807. /**
  95808. * Turn this value on if you want to pause FPS computation when in background
  95809. */
  95810. disablePerformanceMonitorInBackground: boolean;
  95811. /**
  95812. * Gets the performance monitor attached to this engine
  95813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  95814. */
  95815. readonly performanceMonitor: PerformanceMonitor;
  95816. /**
  95817. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95818. */
  95819. disableVertexArrayObjects: boolean;
  95820. /** @hidden */
  95821. protected _depthCullingState: _DepthCullingState;
  95822. /** @hidden */
  95823. protected _stencilState: _StencilState;
  95824. /** @hidden */
  95825. protected _alphaState: _AlphaState;
  95826. /** @hidden */
  95827. protected _alphaMode: number;
  95828. /** @hidden */
  95829. _internalTexturesCache: InternalTexture[];
  95830. /** @hidden */
  95831. protected _activeChannel: number;
  95832. private _currentTextureChannel;
  95833. /** @hidden */
  95834. protected _boundTexturesCache: {
  95835. [key: string]: Nullable<InternalTexture>;
  95836. };
  95837. /** @hidden */
  95838. protected _currentEffect: Nullable<Effect>;
  95839. /** @hidden */
  95840. protected _currentProgram: Nullable<WebGLProgram>;
  95841. private _compiledEffects;
  95842. private _vertexAttribArraysEnabled;
  95843. /** @hidden */
  95844. protected _cachedViewport: Nullable<IViewportLike>;
  95845. private _cachedVertexArrayObject;
  95846. /** @hidden */
  95847. protected _cachedVertexBuffers: any;
  95848. /** @hidden */
  95849. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95850. /** @hidden */
  95851. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95852. /** @hidden */
  95853. _currentRenderTarget: Nullable<InternalTexture>;
  95854. private _uintIndicesCurrentlySet;
  95855. private _currentBoundBuffer;
  95856. /** @hidden */
  95857. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95858. private _currentBufferPointers;
  95859. private _currentInstanceLocations;
  95860. private _currentInstanceBuffers;
  95861. private _textureUnits;
  95862. /** @hidden */
  95863. _workingCanvas: Nullable<HTMLCanvasElement>;
  95864. /** @hidden */
  95865. _workingContext: Nullable<CanvasRenderingContext2D>;
  95866. private _rescalePostProcess;
  95867. private _dummyFramebuffer;
  95868. private _externalData;
  95869. /** @hidden */
  95870. _bindedRenderFunction: any;
  95871. private _vaoRecordInProgress;
  95872. private _mustWipeVertexAttributes;
  95873. private _emptyTexture;
  95874. private _emptyCubeTexture;
  95875. private _emptyTexture3D;
  95876. /** @hidden */
  95877. _frameHandler: number;
  95878. private _nextFreeTextureSlots;
  95879. private _maxSimultaneousTextures;
  95880. private _activeRequests;
  95881. private _texturesSupported;
  95882. /** @hidden */
  95883. _textureFormatInUse: Nullable<string>;
  95884. /**
  95885. * Gets the list of texture formats supported
  95886. */
  95887. readonly texturesSupported: Array<string>;
  95888. /**
  95889. * Gets the list of texture formats in use
  95890. */
  95891. readonly textureFormatInUse: Nullable<string>;
  95892. /**
  95893. * Gets the current viewport
  95894. */
  95895. readonly currentViewport: Nullable<IViewportLike>;
  95896. /**
  95897. * Gets the default empty texture
  95898. */
  95899. readonly emptyTexture: InternalTexture;
  95900. /**
  95901. * Gets the default empty 3D texture
  95902. */
  95903. readonly emptyTexture3D: InternalTexture;
  95904. /**
  95905. * Gets the default empty cube texture
  95906. */
  95907. readonly emptyCubeTexture: InternalTexture;
  95908. /**
  95909. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95910. */
  95911. readonly premultipliedAlpha: boolean;
  95912. /**
  95913. * Creates a new engine
  95914. * @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
  95915. * @param antialias defines enable antialiasing (default: false)
  95916. * @param options defines further options to be sent to the getContext() function
  95917. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95918. */
  95919. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95920. /**
  95921. * Initializes a webVR display and starts listening to display change events
  95922. * The onVRDisplayChangedObservable will be notified upon these changes
  95923. * @returns The onVRDisplayChangedObservable
  95924. */
  95925. initWebVR(): Observable<IDisplayChangedEventArgs>;
  95926. /** @hidden */
  95927. _prepareVRComponent(): void;
  95928. /** @hidden */
  95929. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  95930. /** @hidden */
  95931. _submitVRFrame(): void;
  95932. /**
  95933. * Call this function to leave webVR mode
  95934. * Will do nothing if webVR is not supported or if there is no webVR device
  95935. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95936. */
  95937. disableVR(): void;
  95938. /**
  95939. * Gets a boolean indicating that the system is in VR mode and is presenting
  95940. * @returns true if VR mode is engaged
  95941. */
  95942. isVRPresenting(): boolean;
  95943. /** @hidden */
  95944. _requestVRFrame(): void;
  95945. private _disableTouchAction;
  95946. private _rebuildInternalTextures;
  95947. private _rebuildEffects;
  95948. /**
  95949. * Gets a boolean indicating if all created effects are ready
  95950. * @returns true if all effects are ready
  95951. */
  95952. areAllEffectsReady(): boolean;
  95953. private _rebuildBuffers;
  95954. private _initGLContext;
  95955. /**
  95956. * Gets version of the current webGL context
  95957. */
  95958. readonly webGLVersion: number;
  95959. /**
  95960. * Gets a string idenfifying the name of the class
  95961. * @returns "Engine" string
  95962. */
  95963. getClassName(): string;
  95964. /**
  95965. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95966. */
  95967. readonly isStencilEnable: boolean;
  95968. /** @hidden */
  95969. _prepareWorkingCanvas(): void;
  95970. /**
  95971. * Reset the texture cache to empty state
  95972. */
  95973. resetTextureCache(): void;
  95974. /**
  95975. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  95976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95977. * @returns true if engine is in deterministic lock step mode
  95978. */
  95979. isDeterministicLockStep(): boolean;
  95980. /**
  95981. * Gets the max steps when engine is running in deterministic lock step
  95982. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95983. * @returns the max steps
  95984. */
  95985. getLockstepMaxSteps(): number;
  95986. /**
  95987. * Gets an object containing information about the current webGL context
  95988. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95989. */
  95990. getGlInfo(): {
  95991. vendor: string;
  95992. renderer: string;
  95993. version: string;
  95994. };
  95995. /**
  95996. * Gets current aspect ratio
  95997. * @param viewportOwner defines the camera to use to get the aspect ratio
  95998. * @param useScreen defines if screen size must be used (or the current render target if any)
  95999. * @returns a number defining the aspect ratio
  96000. */
  96001. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96002. /**
  96003. * Gets current screen aspect ratio
  96004. * @returns a number defining the aspect ratio
  96005. */
  96006. getScreenAspectRatio(): number;
  96007. /**
  96008. * Gets the current render width
  96009. * @param useScreen defines if screen size must be used (or the current render target if any)
  96010. * @returns a number defining the current render width
  96011. */
  96012. getRenderWidth(useScreen?: boolean): number;
  96013. /**
  96014. * Gets the current render height
  96015. * @param useScreen defines if screen size must be used (or the current render target if any)
  96016. * @returns a number defining the current render height
  96017. */
  96018. getRenderHeight(useScreen?: boolean): number;
  96019. /**
  96020. * Gets the HTML canvas attached with the current webGL context
  96021. * @returns a HTML canvas
  96022. */
  96023. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96024. /**
  96025. * Gets host window
  96026. * @returns the host window object
  96027. */
  96028. getHostWindow(): Window;
  96029. /**
  96030. * Gets host document
  96031. * @returns the host document object
  96032. */
  96033. getHostDocument(): Document;
  96034. /**
  96035. * Gets the client rect of the HTML canvas attached with the current webGL context
  96036. * @returns a client rectanglee
  96037. */
  96038. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96039. /**
  96040. * Defines the hardware scaling level.
  96041. * By default the hardware scaling level is computed from the window device ratio.
  96042. * 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.
  96043. * @param level defines the level to use
  96044. */
  96045. setHardwareScalingLevel(level: number): void;
  96046. /**
  96047. * Gets the current hardware scaling level.
  96048. * By default the hardware scaling level is computed from the window device ratio.
  96049. * 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.
  96050. * @returns a number indicating the current hardware scaling level
  96051. */
  96052. getHardwareScalingLevel(): number;
  96053. /**
  96054. * Gets the list of loaded textures
  96055. * @returns an array containing all loaded textures
  96056. */
  96057. getLoadedTexturesCache(): InternalTexture[];
  96058. /**
  96059. * Gets the object containing all engine capabilities
  96060. * @returns the EngineCapabilities object
  96061. */
  96062. getCaps(): EngineCapabilities;
  96063. /**
  96064. * Gets the current depth function
  96065. * @returns a number defining the depth function
  96066. */
  96067. getDepthFunction(): Nullable<number>;
  96068. /**
  96069. * Sets the current depth function
  96070. * @param depthFunc defines the function to use
  96071. */
  96072. setDepthFunction(depthFunc: number): void;
  96073. /**
  96074. * Sets the current depth function to GREATER
  96075. */
  96076. setDepthFunctionToGreater(): void;
  96077. /**
  96078. * Sets the current depth function to GEQUAL
  96079. */
  96080. setDepthFunctionToGreaterOrEqual(): void;
  96081. /**
  96082. * Sets the current depth function to LESS
  96083. */
  96084. setDepthFunctionToLess(): void;
  96085. private _cachedStencilBuffer;
  96086. private _cachedStencilFunction;
  96087. private _cachedStencilMask;
  96088. private _cachedStencilOperationPass;
  96089. private _cachedStencilOperationFail;
  96090. private _cachedStencilOperationDepthFail;
  96091. private _cachedStencilReference;
  96092. /**
  96093. * Caches the the state of the stencil buffer
  96094. */
  96095. cacheStencilState(): void;
  96096. /**
  96097. * Restores the state of the stencil buffer
  96098. */
  96099. restoreStencilState(): void;
  96100. /**
  96101. * Sets the current depth function to LEQUAL
  96102. */
  96103. setDepthFunctionToLessOrEqual(): void;
  96104. /**
  96105. * Gets a boolean indicating if stencil buffer is enabled
  96106. * @returns the current stencil buffer state
  96107. */
  96108. getStencilBuffer(): boolean;
  96109. /**
  96110. * Enable or disable the stencil buffer
  96111. * @param enable defines if the stencil buffer must be enabled or disabled
  96112. */
  96113. setStencilBuffer(enable: boolean): void;
  96114. /**
  96115. * Gets the current stencil mask
  96116. * @returns a number defining the new stencil mask to use
  96117. */
  96118. getStencilMask(): number;
  96119. /**
  96120. * Sets the current stencil mask
  96121. * @param mask defines the new stencil mask to use
  96122. */
  96123. setStencilMask(mask: number): void;
  96124. /**
  96125. * Gets the current stencil function
  96126. * @returns a number defining the stencil function to use
  96127. */
  96128. getStencilFunction(): number;
  96129. /**
  96130. * Gets the current stencil reference value
  96131. * @returns a number defining the stencil reference value to use
  96132. */
  96133. getStencilFunctionReference(): number;
  96134. /**
  96135. * Gets the current stencil mask
  96136. * @returns a number defining the stencil mask to use
  96137. */
  96138. getStencilFunctionMask(): number;
  96139. /**
  96140. * Sets the current stencil function
  96141. * @param stencilFunc defines the new stencil function to use
  96142. */
  96143. setStencilFunction(stencilFunc: number): void;
  96144. /**
  96145. * Sets the current stencil reference
  96146. * @param reference defines the new stencil reference to use
  96147. */
  96148. setStencilFunctionReference(reference: number): void;
  96149. /**
  96150. * Sets the current stencil mask
  96151. * @param mask defines the new stencil mask to use
  96152. */
  96153. setStencilFunctionMask(mask: number): void;
  96154. /**
  96155. * Gets the current stencil operation when stencil fails
  96156. * @returns a number defining stencil operation to use when stencil fails
  96157. */
  96158. getStencilOperationFail(): number;
  96159. /**
  96160. * Gets the current stencil operation when depth fails
  96161. * @returns a number defining stencil operation to use when depth fails
  96162. */
  96163. getStencilOperationDepthFail(): number;
  96164. /**
  96165. * Gets the current stencil operation when stencil passes
  96166. * @returns a number defining stencil operation to use when stencil passes
  96167. */
  96168. getStencilOperationPass(): number;
  96169. /**
  96170. * Sets the stencil operation to use when stencil fails
  96171. * @param operation defines the stencil operation to use when stencil fails
  96172. */
  96173. setStencilOperationFail(operation: number): void;
  96174. /**
  96175. * Sets the stencil operation to use when depth fails
  96176. * @param operation defines the stencil operation to use when depth fails
  96177. */
  96178. setStencilOperationDepthFail(operation: number): void;
  96179. /**
  96180. * Sets the stencil operation to use when stencil passes
  96181. * @param operation defines the stencil operation to use when stencil passes
  96182. */
  96183. setStencilOperationPass(operation: number): void;
  96184. /**
  96185. * Sets a boolean indicating if the dithering state is enabled or disabled
  96186. * @param value defines the dithering state
  96187. */
  96188. setDitheringState(value: boolean): void;
  96189. /**
  96190. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96191. * @param value defines the rasterizer state
  96192. */
  96193. setRasterizerState(value: boolean): void;
  96194. /**
  96195. * stop executing a render loop function and remove it from the execution array
  96196. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96197. */
  96198. stopRenderLoop(renderFunction?: () => void): void;
  96199. /** @hidden */
  96200. _renderLoop(): void;
  96201. /**
  96202. * Can be used to override the current requestAnimationFrame requester.
  96203. * @hidden
  96204. */
  96205. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96206. /**
  96207. * Register and execute a render loop. The engine can have more than one render function
  96208. * @param renderFunction defines the function to continuously execute
  96209. */
  96210. runRenderLoop(renderFunction: () => void): void;
  96211. /**
  96212. * Toggle full screen mode
  96213. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96214. */
  96215. switchFullscreen(requestPointerLock: boolean): void;
  96216. /**
  96217. * Enters full screen mode
  96218. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96219. */
  96220. enterFullscreen(requestPointerLock: boolean): void;
  96221. /**
  96222. * Exits full screen mode
  96223. */
  96224. exitFullscreen(): void;
  96225. /**
  96226. * Enters Pointerlock mode
  96227. */
  96228. enterPointerlock(): void;
  96229. /**
  96230. * Exits Pointerlock mode
  96231. */
  96232. exitPointerlock(): void;
  96233. /**
  96234. * Clear the current render buffer or the current render target (if any is set up)
  96235. * @param color defines the color to use
  96236. * @param backBuffer defines if the back buffer must be cleared
  96237. * @param depth defines if the depth buffer must be cleared
  96238. * @param stencil defines if the stencil buffer must be cleared
  96239. */
  96240. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96241. /**
  96242. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96243. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96244. * @param y defines the y-coordinate of the corner of the clear rectangle
  96245. * @param width defines the width of the clear rectangle
  96246. * @param height defines the height of the clear rectangle
  96247. * @param clearColor defines the clear color
  96248. */
  96249. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96250. /**
  96251. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96252. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96253. * @param y defines the y-coordinate of the corner of the clear rectangle
  96254. * @param width defines the width of the clear rectangle
  96255. * @param height defines the height of the clear rectangle
  96256. */
  96257. enableScissor(x: number, y: number, width: number, height: number): void;
  96258. /**
  96259. * Disable previously set scissor test rectangle
  96260. */
  96261. disableScissor(): void;
  96262. private _viewportCached;
  96263. /** @hidden */
  96264. _viewport(x: number, y: number, width: number, height: number): void;
  96265. /**
  96266. * Set the WebGL's viewport
  96267. * @param viewport defines the viewport element to be used
  96268. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96269. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96270. */
  96271. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96272. /**
  96273. * Directly set the WebGL Viewport
  96274. * @param x defines the x coordinate of the viewport (in screen space)
  96275. * @param y defines the y coordinate of the viewport (in screen space)
  96276. * @param width defines the width of the viewport (in screen space)
  96277. * @param height defines the height of the viewport (in screen space)
  96278. * @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
  96279. */
  96280. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96281. /**
  96282. * Begin a new frame
  96283. */
  96284. beginFrame(): void;
  96285. /**
  96286. * Enf the current frame
  96287. */
  96288. endFrame(): void;
  96289. /**
  96290. * Resize the view according to the canvas' size
  96291. */
  96292. resize(): void;
  96293. /**
  96294. * Force a specific size of the canvas
  96295. * @param width defines the new canvas' width
  96296. * @param height defines the new canvas' height
  96297. */
  96298. setSize(width: number, height: number): void;
  96299. /**
  96300. * Binds the frame buffer to the specified texture.
  96301. * @param texture The texture to render to or null for the default canvas
  96302. * @param faceIndex The face of the texture to render to in case of cube texture
  96303. * @param requiredWidth The width of the target to render to
  96304. * @param requiredHeight The height of the target to render to
  96305. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96306. * @param depthStencilTexture The depth stencil texture to use to render
  96307. * @param lodLevel defines le lod level to bind to the frame buffer
  96308. */
  96309. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96310. /** @hidden */
  96311. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96312. /**
  96313. * Unbind the current render target texture from the webGL context
  96314. * @param texture defines the render target texture to unbind
  96315. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96316. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96317. */
  96318. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96319. /**
  96320. * Force the mipmap generation for the given render target texture
  96321. * @param texture defines the render target texture to use
  96322. */
  96323. generateMipMapsForCubemap(texture: InternalTexture): void;
  96324. /**
  96325. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96326. */
  96327. flushFramebuffer(): void;
  96328. /**
  96329. * Unbind the current render target and bind the default framebuffer
  96330. */
  96331. restoreDefaultFramebuffer(): void;
  96332. /**
  96333. * Create an uniform buffer
  96334. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96335. * @param elements defines the content of the uniform buffer
  96336. * @returns the webGL uniform buffer
  96337. */
  96338. createUniformBuffer(elements: FloatArray): DataBuffer;
  96339. /**
  96340. * Create a dynamic uniform buffer
  96341. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96342. * @param elements defines the content of the uniform buffer
  96343. * @returns the webGL uniform buffer
  96344. */
  96345. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96346. /**
  96347. * Update an existing uniform buffer
  96348. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96349. * @param uniformBuffer defines the target uniform buffer
  96350. * @param elements defines the content to update
  96351. * @param offset defines the offset in the uniform buffer where update should start
  96352. * @param count defines the size of the data to update
  96353. */
  96354. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96355. private _resetVertexBufferBinding;
  96356. /**
  96357. * Creates a vertex buffer
  96358. * @param data the data for the vertex buffer
  96359. * @returns the new WebGL static buffer
  96360. */
  96361. createVertexBuffer(data: DataArray): DataBuffer;
  96362. /**
  96363. * Creates a dynamic vertex buffer
  96364. * @param data the data for the dynamic vertex buffer
  96365. * @returns the new WebGL dynamic buffer
  96366. */
  96367. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96368. /**
  96369. * Update a dynamic index buffer
  96370. * @param indexBuffer defines the target index buffer
  96371. * @param indices defines the data to update
  96372. * @param offset defines the offset in the target index buffer where update should start
  96373. */
  96374. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96375. /**
  96376. * Updates a dynamic vertex buffer.
  96377. * @param vertexBuffer the vertex buffer to update
  96378. * @param data the data used to update the vertex buffer
  96379. * @param byteOffset the byte offset of the data
  96380. * @param byteLength the byte length of the data
  96381. */
  96382. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96383. private _resetIndexBufferBinding;
  96384. /**
  96385. * Creates a new index buffer
  96386. * @param indices defines the content of the index buffer
  96387. * @param updatable defines if the index buffer must be updatable
  96388. * @returns a new webGL buffer
  96389. */
  96390. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96391. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96392. /**
  96393. * Bind a webGL buffer to the webGL context
  96394. * @param buffer defines the buffer to bind
  96395. */
  96396. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96397. /**
  96398. * Bind an uniform buffer to the current webGL context
  96399. * @param buffer defines the buffer to bind
  96400. */
  96401. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96402. /**
  96403. * Bind a buffer to the current webGL context at a given location
  96404. * @param buffer defines the buffer to bind
  96405. * @param location defines the index where to bind the buffer
  96406. */
  96407. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96408. /**
  96409. * Bind a specific block at a given index in a specific shader program
  96410. * @param pipelineContext defines the pipeline context to use
  96411. * @param blockName defines the block name
  96412. * @param index defines the index where to bind the block
  96413. */
  96414. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96415. private bindIndexBuffer;
  96416. private bindBuffer;
  96417. /**
  96418. * update the bound buffer with the given data
  96419. * @param data defines the data to update
  96420. */
  96421. updateArrayBuffer(data: Float32Array): void;
  96422. private _vertexAttribPointer;
  96423. private _bindIndexBufferWithCache;
  96424. private _bindVertexBuffersAttributes;
  96425. /**
  96426. * Records a vertex array object
  96427. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96428. * @param vertexBuffers defines the list of vertex buffers to store
  96429. * @param indexBuffer defines the index buffer to store
  96430. * @param effect defines the effect to store
  96431. * @returns the new vertex array object
  96432. */
  96433. recordVertexArrayObject(vertexBuffers: {
  96434. [key: string]: VertexBuffer;
  96435. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96436. /**
  96437. * Bind a specific vertex array object
  96438. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96439. * @param vertexArrayObject defines the vertex array object to bind
  96440. * @param indexBuffer defines the index buffer to bind
  96441. */
  96442. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96443. /**
  96444. * Bind webGl buffers directly to the webGL context
  96445. * @param vertexBuffer defines the vertex buffer to bind
  96446. * @param indexBuffer defines the index buffer to bind
  96447. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96448. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96449. * @param effect defines the effect associated with the vertex buffer
  96450. */
  96451. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96452. private _unbindVertexArrayObject;
  96453. /**
  96454. * Bind a list of vertex buffers to the webGL context
  96455. * @param vertexBuffers defines the list of vertex buffers to bind
  96456. * @param indexBuffer defines the index buffer to bind
  96457. * @param effect defines the effect associated with the vertex buffers
  96458. */
  96459. bindBuffers(vertexBuffers: {
  96460. [key: string]: Nullable<VertexBuffer>;
  96461. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96462. /**
  96463. * Unbind all instance attributes
  96464. */
  96465. unbindInstanceAttributes(): void;
  96466. /**
  96467. * Release and free the memory of a vertex array object
  96468. * @param vao defines the vertex array object to delete
  96469. */
  96470. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96471. /** @hidden */
  96472. _releaseBuffer(buffer: DataBuffer): boolean;
  96473. protected _deleteBuffer(buffer: DataBuffer): void;
  96474. /**
  96475. * Creates a webGL buffer to use with instanciation
  96476. * @param capacity defines the size of the buffer
  96477. * @returns the webGL buffer
  96478. */
  96479. createInstancesBuffer(capacity: number): DataBuffer;
  96480. /**
  96481. * Delete a webGL buffer used with instanciation
  96482. * @param buffer defines the webGL buffer to delete
  96483. */
  96484. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96485. /**
  96486. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96487. * @param instancesBuffer defines the webGL buffer to update and bind
  96488. * @param data defines the data to store in the buffer
  96489. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96490. */
  96491. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96492. /**
  96493. * Apply all cached states (depth, culling, stencil and alpha)
  96494. */
  96495. applyStates(): void;
  96496. /**
  96497. * Send a draw order
  96498. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96499. * @param indexStart defines the starting index
  96500. * @param indexCount defines the number of index to draw
  96501. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96502. */
  96503. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96504. /**
  96505. * Draw a list of points
  96506. * @param verticesStart defines the index of first vertex to draw
  96507. * @param verticesCount defines the count of vertices to draw
  96508. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96509. */
  96510. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96511. /**
  96512. * Draw a list of unindexed primitives
  96513. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96514. * @param verticesStart defines the index of first vertex to draw
  96515. * @param verticesCount defines the count of vertices to draw
  96516. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96517. */
  96518. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96519. /**
  96520. * Draw a list of indexed primitives
  96521. * @param fillMode defines the primitive to use
  96522. * @param indexStart defines the starting index
  96523. * @param indexCount defines the number of index to draw
  96524. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96525. */
  96526. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96527. /**
  96528. * Draw a list of unindexed primitives
  96529. * @param fillMode defines the primitive to use
  96530. * @param verticesStart defines the index of first vertex to draw
  96531. * @param verticesCount defines the count of vertices to draw
  96532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96533. */
  96534. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96535. private _drawMode;
  96536. /** @hidden */
  96537. _releaseEffect(effect: Effect): void;
  96538. /** @hidden */
  96539. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96540. /**
  96541. * Create a new effect (used to store vertex/fragment shaders)
  96542. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96543. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96544. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96545. * @param samplers defines an array of string used to represent textures
  96546. * @param defines defines the string containing the defines to use to compile the shaders
  96547. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96548. * @param onCompiled defines a function to call when the effect creation is successful
  96549. * @param onError defines a function to call when the effect creation has failed
  96550. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96551. * @returns the new Effect
  96552. */
  96553. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96554. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96555. private _compileShader;
  96556. private _compileRawShader;
  96557. /**
  96558. * Directly creates a webGL program
  96559. * @param pipelineContext defines the pipeline context to attach to
  96560. * @param vertexCode defines the vertex shader code to use
  96561. * @param fragmentCode defines the fragment shader code to use
  96562. * @param context defines the webGL context to use (if not set, the current one will be used)
  96563. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96564. * @returns the new webGL program
  96565. */
  96566. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96567. /**
  96568. * Creates a webGL program
  96569. * @param pipelineContext defines the pipeline context to attach to
  96570. * @param vertexCode defines the vertex shader code to use
  96571. * @param fragmentCode defines the fragment shader code to use
  96572. * @param defines defines the string containing the defines to use to compile the shaders
  96573. * @param context defines the webGL context to use (if not set, the current one will be used)
  96574. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96575. * @returns the new webGL program
  96576. */
  96577. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96578. /**
  96579. * Creates a new pipeline context
  96580. * @returns the new pipeline
  96581. */
  96582. createPipelineContext(): IPipelineContext;
  96583. private _createShaderProgram;
  96584. private _finalizePipelineContext;
  96585. /** @hidden */
  96586. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96587. /** @hidden */
  96588. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96589. /** @hidden */
  96590. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96591. /**
  96592. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96593. * @param pipelineContext defines the pipeline context to use
  96594. * @param uniformsNames defines the list of uniform names
  96595. * @returns an array of webGL uniform locations
  96596. */
  96597. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96598. /**
  96599. * Gets the lsit of active attributes for a given webGL program
  96600. * @param pipelineContext defines the pipeline context to use
  96601. * @param attributesNames defines the list of attribute names to get
  96602. * @returns an array of indices indicating the offset of each attribute
  96603. */
  96604. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96605. /**
  96606. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96607. * @param effect defines the effect to activate
  96608. */
  96609. enableEffect(effect: Nullable<Effect>): void;
  96610. /**
  96611. * Set the value of an uniform to an array of int32
  96612. * @param uniform defines the webGL uniform location where to store the value
  96613. * @param array defines the array of int32 to store
  96614. */
  96615. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96616. /**
  96617. * Set the value of an uniform to an array of int32 (stored as vec2)
  96618. * @param uniform defines the webGL uniform location where to store the value
  96619. * @param array defines the array of int32 to store
  96620. */
  96621. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96622. /**
  96623. * Set the value of an uniform to an array of int32 (stored as vec3)
  96624. * @param uniform defines the webGL uniform location where to store the value
  96625. * @param array defines the array of int32 to store
  96626. */
  96627. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96628. /**
  96629. * Set the value of an uniform to an array of int32 (stored as vec4)
  96630. * @param uniform defines the webGL uniform location where to store the value
  96631. * @param array defines the array of int32 to store
  96632. */
  96633. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96634. /**
  96635. * Set the value of an uniform to an array of float32
  96636. * @param uniform defines the webGL uniform location where to store the value
  96637. * @param array defines the array of float32 to store
  96638. */
  96639. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96640. /**
  96641. * Set the value of an uniform to an array of float32 (stored as vec2)
  96642. * @param uniform defines the webGL uniform location where to store the value
  96643. * @param array defines the array of float32 to store
  96644. */
  96645. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96646. /**
  96647. * Set the value of an uniform to an array of float32 (stored as vec3)
  96648. * @param uniform defines the webGL uniform location where to store the value
  96649. * @param array defines the array of float32 to store
  96650. */
  96651. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96652. /**
  96653. * Set the value of an uniform to an array of float32 (stored as vec4)
  96654. * @param uniform defines the webGL uniform location where to store the value
  96655. * @param array defines the array of float32 to store
  96656. */
  96657. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96658. /**
  96659. * Set the value of an uniform to an array of number
  96660. * @param uniform defines the webGL uniform location where to store the value
  96661. * @param array defines the array of number to store
  96662. */
  96663. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96664. /**
  96665. * Set the value of an uniform to an array of number (stored as vec2)
  96666. * @param uniform defines the webGL uniform location where to store the value
  96667. * @param array defines the array of number to store
  96668. */
  96669. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96670. /**
  96671. * Set the value of an uniform to an array of number (stored as vec3)
  96672. * @param uniform defines the webGL uniform location where to store the value
  96673. * @param array defines the array of number to store
  96674. */
  96675. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96676. /**
  96677. * Set the value of an uniform to an array of number (stored as vec4)
  96678. * @param uniform defines the webGL uniform location where to store the value
  96679. * @param array defines the array of number to store
  96680. */
  96681. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96682. /**
  96683. * Set the value of an uniform to an array of float32 (stored as matrices)
  96684. * @param uniform defines the webGL uniform location where to store the value
  96685. * @param matrices defines the array of float32 to store
  96686. */
  96687. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96688. /**
  96689. * Set the value of an uniform to a matrix (3x3)
  96690. * @param uniform defines the webGL uniform location where to store the value
  96691. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96692. */
  96693. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96694. /**
  96695. * Set the value of an uniform to a matrix (2x2)
  96696. * @param uniform defines the webGL uniform location where to store the value
  96697. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96698. */
  96699. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96700. /**
  96701. * Set the value of an uniform to a number (int)
  96702. * @param uniform defines the webGL uniform location where to store the value
  96703. * @param value defines the int number to store
  96704. */
  96705. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96706. /**
  96707. * Set the value of an uniform to a number (float)
  96708. * @param uniform defines the webGL uniform location where to store the value
  96709. * @param value defines the float number to store
  96710. */
  96711. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96712. /**
  96713. * Set the value of an uniform to a vec2
  96714. * @param uniform defines the webGL uniform location where to store the value
  96715. * @param x defines the 1st component of the value
  96716. * @param y defines the 2nd component of the value
  96717. */
  96718. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96719. /**
  96720. * Set the value of an uniform to a vec3
  96721. * @param uniform defines the webGL uniform location where to store the value
  96722. * @param x defines the 1st component of the value
  96723. * @param y defines the 2nd component of the value
  96724. * @param z defines the 3rd component of the value
  96725. */
  96726. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96727. /**
  96728. * Set the value of an uniform to a boolean
  96729. * @param uniform defines the webGL uniform location where to store the value
  96730. * @param bool defines the boolean to store
  96731. */
  96732. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96733. /**
  96734. * Set the value of an uniform to a vec4
  96735. * @param uniform defines the webGL uniform location where to store the value
  96736. * @param x defines the 1st component of the value
  96737. * @param y defines the 2nd component of the value
  96738. * @param z defines the 3rd component of the value
  96739. * @param w defines the 4th component of the value
  96740. */
  96741. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96742. /**
  96743. * Sets a Color4 on a uniform variable
  96744. * @param uniform defines the uniform location
  96745. * @param color4 defines the value to be set
  96746. */
  96747. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96748. /**
  96749. * Set various states to the webGL context
  96750. * @param culling defines backface culling state
  96751. * @param zOffset defines the value to apply to zOffset (0 by default)
  96752. * @param force defines if states must be applied even if cache is up to date
  96753. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  96754. */
  96755. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96756. /**
  96757. * Set the z offset to apply to current rendering
  96758. * @param value defines the offset to apply
  96759. */
  96760. setZOffset(value: number): void;
  96761. /**
  96762. * Gets the current value of the zOffset
  96763. * @returns the current zOffset state
  96764. */
  96765. getZOffset(): number;
  96766. /**
  96767. * Enable or disable depth buffering
  96768. * @param enable defines the state to set
  96769. */
  96770. setDepthBuffer(enable: boolean): void;
  96771. /**
  96772. * Gets a boolean indicating if depth writing is enabled
  96773. * @returns the current depth writing state
  96774. */
  96775. getDepthWrite(): boolean;
  96776. /**
  96777. * Enable or disable depth writing
  96778. * @param enable defines the state to set
  96779. */
  96780. setDepthWrite(enable: boolean): void;
  96781. /**
  96782. * Enable or disable color writing
  96783. * @param enable defines the state to set
  96784. */
  96785. setColorWrite(enable: boolean): void;
  96786. /**
  96787. * Gets a boolean indicating if color writing is enabled
  96788. * @returns the current color writing state
  96789. */
  96790. getColorWrite(): boolean;
  96791. /**
  96792. * Sets alpha constants used by some alpha blending modes
  96793. * @param r defines the red component
  96794. * @param g defines the green component
  96795. * @param b defines the blue component
  96796. * @param a defines the alpha component
  96797. */
  96798. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96799. /**
  96800. * Sets the current alpha mode
  96801. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96802. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96803. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96804. */
  96805. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96806. /**
  96807. * Gets the current alpha mode
  96808. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96809. * @returns the current alpha mode
  96810. */
  96811. getAlphaMode(): number;
  96812. /**
  96813. * Clears the list of texture accessible through engine.
  96814. * This can help preventing texture load conflict due to name collision.
  96815. */
  96816. clearInternalTexturesCache(): void;
  96817. /**
  96818. * Force the entire cache to be cleared
  96819. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96820. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96821. */
  96822. wipeCaches(bruteForce?: boolean): void;
  96823. /**
  96824. * Set the compressed texture format to use, based on the formats you have, and the formats
  96825. * supported by the hardware / browser.
  96826. *
  96827. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  96828. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  96829. * to API arguments needed to compressed textures. This puts the burden on the container
  96830. * generator to house the arcane code for determining these for current & future formats.
  96831. *
  96832. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  96833. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  96834. *
  96835. * Note: The result of this call is not taken into account when a texture is base64.
  96836. *
  96837. * @param formatsAvailable defines the list of those format families you have created
  96838. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  96839. *
  96840. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  96841. * @returns The extension selected.
  96842. */
  96843. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  96844. /** @hidden */
  96845. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96846. min: number;
  96847. mag: number;
  96848. };
  96849. /** @hidden */
  96850. _createTexture(): WebGLTexture;
  96851. /**
  96852. * Usually called from Texture.ts.
  96853. * Passed information to create a WebGLTexture
  96854. * @param urlArg defines a value which contains one of the following:
  96855. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96856. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96857. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96858. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96859. * @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)
  96860. * @param scene needed for loading to the correct scene
  96861. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96862. * @param onLoad optional callback to be called upon successful completion
  96863. * @param onError optional callback to be called upon failure
  96864. * @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
  96865. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96866. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96867. * @param forcedExtension defines the extension to use to pick the right loader
  96868. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96869. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96870. */
  96871. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96872. /**
  96873. * @hidden
  96874. * Rescales a texture
  96875. * @param source input texutre
  96876. * @param destination destination texture
  96877. * @param scene scene to use to render the resize
  96878. * @param internalFormat format to use when resizing
  96879. * @param onComplete callback to be called when resize has completed
  96880. */
  96881. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  96882. private _unpackFlipYCached;
  96883. /**
  96884. * In case you are sharing the context with other applications, it might
  96885. * be interested to not cache the unpack flip y state to ensure a consistent
  96886. * value would be set.
  96887. */
  96888. enableUnpackFlipYCached: boolean;
  96889. /** @hidden */
  96890. _unpackFlipY(value: boolean): void;
  96891. /** @hidden */
  96892. _getUnpackAlignement(): number;
  96893. /**
  96894. * Creates a dynamic texture
  96895. * @param width defines the width of the texture
  96896. * @param height defines the height of the texture
  96897. * @param generateMipMaps defines if the engine should generate the mip levels
  96898. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96899. * @returns the dynamic texture inside an InternalTexture
  96900. */
  96901. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  96902. /**
  96903. * Update the sampling mode of a given texture
  96904. * @param samplingMode defines the required sampling mode
  96905. * @param texture defines the texture to update
  96906. */
  96907. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96908. /**
  96909. * Update the content of a dynamic texture
  96910. * @param texture defines the texture to update
  96911. * @param canvas defines the canvas containing the source
  96912. * @param invertY defines if data must be stored with Y axis inverted
  96913. * @param premulAlpha defines if alpha is stored as premultiplied
  96914. * @param format defines the format of the data
  96915. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  96916. */
  96917. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  96918. /**
  96919. * Update a video texture
  96920. * @param texture defines the texture to update
  96921. * @param video defines the video element to use
  96922. * @param invertY defines if data must be stored with Y axis inverted
  96923. */
  96924. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96925. /**
  96926. * Updates a depth texture Comparison Mode and Function.
  96927. * If the comparison Function is equal to 0, the mode will be set to none.
  96928. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96929. * @param texture The texture to set the comparison function for
  96930. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96931. */
  96932. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96933. /** @hidden */
  96934. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96935. width: number;
  96936. height: number;
  96937. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96938. /**
  96939. * Creates a depth stencil texture.
  96940. * This is only available in WebGL 2 or with the depth texture extension available.
  96941. * @param size The size of face edge in the texture.
  96942. * @param options The options defining the texture.
  96943. * @returns The texture
  96944. */
  96945. createDepthStencilTexture(size: number | {
  96946. width: number;
  96947. height: number;
  96948. }, options: DepthTextureCreationOptions): InternalTexture;
  96949. /**
  96950. * Creates a depth stencil texture.
  96951. * This is only available in WebGL 2 or with the depth texture extension available.
  96952. * @param size The size of face edge in the texture.
  96953. * @param options The options defining the texture.
  96954. * @returns The texture
  96955. */
  96956. private _createDepthStencilTexture;
  96957. /**
  96958. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96959. * @param renderTarget The render target to set the frame buffer for
  96960. */
  96961. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96962. /**
  96963. * Creates a new render target texture
  96964. * @param size defines the size of the texture
  96965. * @param options defines the options used to create the texture
  96966. * @returns a new render target texture stored in an InternalTexture
  96967. */
  96968. createRenderTargetTexture(size: number | {
  96969. width: number;
  96970. height: number;
  96971. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96972. /** @hidden */
  96973. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96974. /**
  96975. * Updates the sample count of a render target texture
  96976. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  96977. * @param texture defines the texture to update
  96978. * @param samples defines the sample count to set
  96979. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  96980. */
  96981. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  96982. /** @hidden */
  96983. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96984. /** @hidden */
  96985. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96986. /** @hidden */
  96987. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96988. /** @hidden */
  96989. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96990. /**
  96991. * @hidden
  96992. */
  96993. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96994. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96995. private _prepareWebGLTexture;
  96996. /** @hidden */
  96997. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  96998. /** @hidden */
  96999. _releaseFramebufferObjects(texture: InternalTexture): void;
  97000. /** @hidden */
  97001. _releaseTexture(texture: InternalTexture): void;
  97002. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97003. protected _setProgram(program: WebGLProgram): void;
  97004. protected _boundUniforms: {
  97005. [key: number]: WebGLUniformLocation;
  97006. };
  97007. /**
  97008. * Binds an effect to the webGL context
  97009. * @param effect defines the effect to bind
  97010. */
  97011. bindSamplers(effect: Effect): void;
  97012. private _activateCurrentTexture;
  97013. /** @hidden */
  97014. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97015. /** @hidden */
  97016. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97017. /**
  97018. * Sets a texture to the webGL context from a postprocess
  97019. * @param channel defines the channel to use
  97020. * @param postProcess defines the source postprocess
  97021. */
  97022. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97023. /**
  97024. * Binds the output of the passed in post process to the texture channel specified
  97025. * @param channel The channel the texture should be bound to
  97026. * @param postProcess The post process which's output should be bound
  97027. */
  97028. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97029. /**
  97030. * Unbind all textures from the webGL context
  97031. */
  97032. unbindAllTextures(): void;
  97033. /**
  97034. * Sets a texture to the according uniform.
  97035. * @param channel The texture channel
  97036. * @param uniform The uniform to set
  97037. * @param texture The texture to apply
  97038. */
  97039. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97040. /**
  97041. * Sets a depth stencil texture from a render target to the according uniform.
  97042. * @param channel The texture channel
  97043. * @param uniform The uniform to set
  97044. * @param texture The render target texture containing the depth stencil texture to apply
  97045. */
  97046. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97047. private _bindSamplerUniformToChannel;
  97048. private _getTextureWrapMode;
  97049. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97050. /**
  97051. * Sets an array of texture to the webGL context
  97052. * @param channel defines the channel where the texture array must be set
  97053. * @param uniform defines the associated uniform location
  97054. * @param textures defines the array of textures to bind
  97055. */
  97056. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97057. /** @hidden */
  97058. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97059. private _setTextureParameterFloat;
  97060. private _setTextureParameterInteger;
  97061. /**
  97062. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97063. * @param x defines the x coordinate of the rectangle where pixels must be read
  97064. * @param y defines the y coordinate of the rectangle where pixels must be read
  97065. * @param width defines the width of the rectangle where pixels must be read
  97066. * @param height defines the height of the rectangle where pixels must be read
  97067. * @returns a Uint8Array containing RGBA colors
  97068. */
  97069. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97070. /**
  97071. * Add an externaly attached data from its key.
  97072. * This method call will fail and return false, if such key already exists.
  97073. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97074. * @param key the unique key that identifies the data
  97075. * @param data the data object to associate to the key for this Engine instance
  97076. * @return true if no such key were already present and the data was added successfully, false otherwise
  97077. */
  97078. addExternalData<T>(key: string, data: T): boolean;
  97079. /**
  97080. * Get an externaly attached data from its key
  97081. * @param key the unique key that identifies the data
  97082. * @return the associated data, if present (can be null), or undefined if not present
  97083. */
  97084. getExternalData<T>(key: string): T;
  97085. /**
  97086. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97087. * @param key the unique key that identifies the data
  97088. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97089. * @return the associated data, can be null if the factory returned null.
  97090. */
  97091. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97092. /**
  97093. * Remove an externaly attached data from the Engine instance
  97094. * @param key the unique key that identifies the data
  97095. * @return true if the data was successfully removed, false if it doesn't exist
  97096. */
  97097. removeExternalData(key: string): boolean;
  97098. /**
  97099. * Unbind all vertex attributes from the webGL context
  97100. */
  97101. unbindAllAttributes(): void;
  97102. /**
  97103. * 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
  97104. */
  97105. releaseEffects(): void;
  97106. /**
  97107. * Dispose and release all associated resources
  97108. */
  97109. dispose(): void;
  97110. /**
  97111. * Display the loading screen
  97112. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97113. */
  97114. displayLoadingUI(): void;
  97115. /**
  97116. * Hide the loading screen
  97117. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97118. */
  97119. hideLoadingUI(): void;
  97120. /**
  97121. * Gets the current loading screen object
  97122. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97123. */
  97124. /**
  97125. * Sets the current loading screen object
  97126. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97127. */
  97128. loadingScreen: ILoadingScreen;
  97129. /**
  97130. * Sets the current loading screen text
  97131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97132. */
  97133. loadingUIText: string;
  97134. /**
  97135. * Sets the current loading screen background color
  97136. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97137. */
  97138. loadingUIBackgroundColor: string;
  97139. /**
  97140. * Attach a new callback raised when context lost event is fired
  97141. * @param callback defines the callback to call
  97142. */
  97143. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97144. /**
  97145. * Attach a new callback raised when context restored event is fired
  97146. * @param callback defines the callback to call
  97147. */
  97148. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97149. /**
  97150. * Gets the source code of the vertex shader associated with a specific webGL program
  97151. * @param program defines the program to use
  97152. * @returns a string containing the source code of the vertex shader associated with the program
  97153. */
  97154. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97155. /**
  97156. * Gets the source code of the fragment shader associated with a specific webGL program
  97157. * @param program defines the program to use
  97158. * @returns a string containing the source code of the fragment shader associated with the program
  97159. */
  97160. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97161. /**
  97162. * Get the current error code of the webGL context
  97163. * @returns the error code
  97164. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97165. */
  97166. getError(): number;
  97167. /**
  97168. * Gets the current framerate
  97169. * @returns a number representing the framerate
  97170. */
  97171. getFps(): number;
  97172. /**
  97173. * Gets the time spent between current and previous frame
  97174. * @returns a number representing the delta time in ms
  97175. */
  97176. getDeltaTime(): number;
  97177. private _measureFps;
  97178. /** @hidden */
  97179. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97180. private _canRenderToFloatFramebuffer;
  97181. private _canRenderToHalfFloatFramebuffer;
  97182. private _canRenderToFramebuffer;
  97183. /** @hidden */
  97184. _getWebGLTextureType(type: number): number;
  97185. /** @hidden */
  97186. _getInternalFormat(format: number): number;
  97187. /** @hidden */
  97188. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97189. /** @hidden */
  97190. _getRGBAMultiSampleBufferFormat(type: number): number;
  97191. /** @hidden */
  97192. _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;
  97193. /** @hidden */
  97194. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97195. /**
  97196. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97197. * @returns true if the engine can be created
  97198. * @ignorenaming
  97199. */
  97200. static isSupported(): boolean;
  97201. /**
  97202. * Find the next highest power of two.
  97203. * @param x Number to start search from.
  97204. * @return Next highest power of two.
  97205. */
  97206. static CeilingPOT(x: number): number;
  97207. /**
  97208. * Find the next lowest power of two.
  97209. * @param x Number to start search from.
  97210. * @return Next lowest power of two.
  97211. */
  97212. static FloorPOT(x: number): number;
  97213. /**
  97214. * Find the nearest power of two.
  97215. * @param x Number to start search from.
  97216. * @return Next nearest power of two.
  97217. */
  97218. static NearestPOT(x: number): number;
  97219. /**
  97220. * Get the closest exponent of two
  97221. * @param value defines the value to approximate
  97222. * @param max defines the maximum value to return
  97223. * @param mode defines how to define the closest value
  97224. * @returns closest exponent of two of the given value
  97225. */
  97226. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97227. /**
  97228. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97229. * @param func - the function to be called
  97230. * @param requester - the object that will request the next frame. Falls back to window.
  97231. * @returns frame number
  97232. */
  97233. static QueueNewFrame(func: () => void, requester?: any): number;
  97234. /**
  97235. * Ask the browser to promote the current element to pointerlock mode
  97236. * @param element defines the DOM element to promote
  97237. */
  97238. static _RequestPointerlock(element: HTMLElement): void;
  97239. /**
  97240. * Asks the browser to exit pointerlock mode
  97241. */
  97242. static _ExitPointerlock(): void;
  97243. /**
  97244. * Ask the browser to promote the current element to fullscreen rendering mode
  97245. * @param element defines the DOM element to promote
  97246. */
  97247. static _RequestFullscreen(element: HTMLElement): void;
  97248. /**
  97249. * Asks the browser to exit fullscreen mode
  97250. */
  97251. static _ExitFullscreen(): void;
  97252. }
  97253. }
  97254. declare module BABYLON {
  97255. /**
  97256. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97257. * during the life time of the application.
  97258. */
  97259. export class EngineStore {
  97260. /** Gets the list of created engines */
  97261. static Instances: Engine[];
  97262. /** @hidden */
  97263. static _LastCreatedScene: Nullable<Scene>;
  97264. /**
  97265. * Gets the latest created engine
  97266. */
  97267. static readonly LastCreatedEngine: Nullable<Engine>;
  97268. /**
  97269. * Gets the latest created scene
  97270. */
  97271. static readonly LastCreatedScene: Nullable<Scene>;
  97272. /**
  97273. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97274. * @ignorenaming
  97275. */
  97276. static UseFallbackTexture: boolean;
  97277. /**
  97278. * Texture content used if a texture cannot loaded
  97279. * @ignorenaming
  97280. */
  97281. static FallbackTexture: string;
  97282. }
  97283. }
  97284. declare module BABYLON {
  97285. /**
  97286. * Helper class that provides a small promise polyfill
  97287. */
  97288. export class PromisePolyfill {
  97289. /**
  97290. * Static function used to check if the polyfill is required
  97291. * If this is the case then the function will inject the polyfill to window.Promise
  97292. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97293. */
  97294. static Apply(force?: boolean): void;
  97295. }
  97296. }
  97297. declare module BABYLON {
  97298. /**
  97299. * Interface for screenshot methods with describe argument called `size` as object with options
  97300. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97301. */
  97302. export interface IScreenshotSize {
  97303. /**
  97304. * number in pixels for canvas height
  97305. */
  97306. height?: number;
  97307. /**
  97308. * multiplier allowing render at a higher or lower resolution
  97309. * If value is defined then height and width will be ignored and taken from camera
  97310. */
  97311. precision?: number;
  97312. /**
  97313. * number in pixels for canvas width
  97314. */
  97315. width?: number;
  97316. }
  97317. }
  97318. declare module BABYLON {
  97319. interface IColor4Like {
  97320. r: float;
  97321. g: float;
  97322. b: float;
  97323. a: float;
  97324. }
  97325. /**
  97326. * Class containing a set of static utilities functions
  97327. */
  97328. export class Tools {
  97329. /**
  97330. * Gets or sets the base URL to use to load assets
  97331. */
  97332. static BaseUrl: string;
  97333. /**
  97334. * Enable/Disable Custom HTTP Request Headers globally.
  97335. * default = false
  97336. * @see CustomRequestHeaders
  97337. */
  97338. static UseCustomRequestHeaders: boolean;
  97339. /**
  97340. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97341. * i.e. when loading files, where the server/service expects an Authorization header
  97342. */
  97343. static CustomRequestHeaders: {
  97344. [key: string]: string;
  97345. };
  97346. /**
  97347. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97348. */
  97349. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97350. /**
  97351. * Default behaviour for cors in the application.
  97352. * It can be a string if the expected behavior is identical in the entire app.
  97353. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97354. */
  97355. static CorsBehavior: string | ((url: string | string[]) => string);
  97356. /**
  97357. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97358. * @ignorenaming
  97359. */
  97360. static UseFallbackTexture: boolean;
  97361. /**
  97362. * Use this object to register external classes like custom textures or material
  97363. * to allow the laoders to instantiate them
  97364. */
  97365. static RegisteredExternalClasses: {
  97366. [key: string]: Object;
  97367. };
  97368. /**
  97369. * Texture content used if a texture cannot loaded
  97370. * @ignorenaming
  97371. */
  97372. static fallbackTexture: string;
  97373. /**
  97374. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97375. * @param u defines the coordinate on X axis
  97376. * @param v defines the coordinate on Y axis
  97377. * @param width defines the width of the source data
  97378. * @param height defines the height of the source data
  97379. * @param pixels defines the source byte array
  97380. * @param color defines the output color
  97381. */
  97382. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97383. /**
  97384. * Interpolates between a and b via alpha
  97385. * @param a The lower value (returned when alpha = 0)
  97386. * @param b The upper value (returned when alpha = 1)
  97387. * @param alpha The interpolation-factor
  97388. * @return The mixed value
  97389. */
  97390. static Mix(a: number, b: number, alpha: number): number;
  97391. /**
  97392. * Tries to instantiate a new object from a given class name
  97393. * @param className defines the class name to instantiate
  97394. * @returns the new object or null if the system was not able to do the instantiation
  97395. */
  97396. static Instantiate(className: string): any;
  97397. /**
  97398. * Provides a slice function that will work even on IE
  97399. * @param data defines the array to slice
  97400. * @param start defines the start of the data (optional)
  97401. * @param end defines the end of the data (optional)
  97402. * @returns the new sliced array
  97403. */
  97404. static Slice<T>(data: T, start?: number, end?: number): T;
  97405. /**
  97406. * Polyfill for setImmediate
  97407. * @param action defines the action to execute after the current execution block
  97408. */
  97409. static SetImmediate(action: () => void): void;
  97410. /**
  97411. * Function indicating if a number is an exponent of 2
  97412. * @param value defines the value to test
  97413. * @returns true if the value is an exponent of 2
  97414. */
  97415. static IsExponentOfTwo(value: number): boolean;
  97416. private static _tmpFloatArray;
  97417. /**
  97418. * Returns the nearest 32-bit single precision float representation of a Number
  97419. * @param value A Number. If the parameter is of a different type, it will get converted
  97420. * to a number or to NaN if it cannot be converted
  97421. * @returns number
  97422. */
  97423. static FloatRound(value: number): number;
  97424. /**
  97425. * Extracts the filename from a path
  97426. * @param path defines the path to use
  97427. * @returns the filename
  97428. */
  97429. static GetFilename(path: string): string;
  97430. /**
  97431. * Extracts the "folder" part of a path (everything before the filename).
  97432. * @param uri The URI to extract the info from
  97433. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97434. * @returns The "folder" part of the path
  97435. */
  97436. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97437. /**
  97438. * Extracts text content from a DOM element hierarchy
  97439. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97440. */
  97441. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97442. /**
  97443. * Convert an angle in radians to degrees
  97444. * @param angle defines the angle to convert
  97445. * @returns the angle in degrees
  97446. */
  97447. static ToDegrees(angle: number): number;
  97448. /**
  97449. * Convert an angle in degrees to radians
  97450. * @param angle defines the angle to convert
  97451. * @returns the angle in radians
  97452. */
  97453. static ToRadians(angle: number): number;
  97454. /**
  97455. * Encode a buffer to a base64 string
  97456. * @param buffer defines the buffer to encode
  97457. * @returns the encoded string
  97458. */
  97459. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97460. /**
  97461. * Returns an array if obj is not an array
  97462. * @param obj defines the object to evaluate as an array
  97463. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97464. * @returns either obj directly if obj is an array or a new array containing obj
  97465. */
  97466. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97467. /**
  97468. * Gets the pointer prefix to use
  97469. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97470. */
  97471. static GetPointerPrefix(): string;
  97472. /**
  97473. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97474. * @param url define the url we are trying
  97475. * @param element define the dom element where to configure the cors policy
  97476. */
  97477. static SetCorsBehavior(url: string | string[], element: {
  97478. crossOrigin: string | null;
  97479. }): void;
  97480. /**
  97481. * Removes unwanted characters from an url
  97482. * @param url defines the url to clean
  97483. * @returns the cleaned url
  97484. */
  97485. static CleanUrl(url: string): string;
  97486. /**
  97487. * Gets or sets a function used to pre-process url before using them to load assets
  97488. */
  97489. static PreprocessUrl: (url: string) => string;
  97490. /**
  97491. * Loads an image as an HTMLImageElement.
  97492. * @param input url string, ArrayBuffer, or Blob to load
  97493. * @param onLoad callback called when the image successfully loads
  97494. * @param onError callback called when the image fails to load
  97495. * @param offlineProvider offline provider for caching
  97496. * @returns the HTMLImageElement of the loaded image
  97497. */
  97498. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97499. /**
  97500. * Loads a file
  97501. * @param url url string, ArrayBuffer, or Blob to load
  97502. * @param onSuccess callback called when the file successfully loads
  97503. * @param onProgress callback called while file is loading (if the server supports this mode)
  97504. * @param offlineProvider defines the offline provider for caching
  97505. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97506. * @param onError callback called when the file fails to load
  97507. * @returns a file request object
  97508. */
  97509. 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;
  97510. /**
  97511. * Loads a file from a url
  97512. * @param url the file url to load
  97513. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97514. */
  97515. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97516. /**
  97517. * Load a script (identified by an url). When the url returns, the
  97518. * content of this file is added into a new script element, attached to the DOM (body element)
  97519. * @param scriptUrl defines the url of the script to laod
  97520. * @param onSuccess defines the callback called when the script is loaded
  97521. * @param onError defines the callback to call if an error occurs
  97522. * @param scriptId defines the id of the script element
  97523. */
  97524. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97525. /**
  97526. * Load an asynchronous script (identified by an url). When the url returns, the
  97527. * content of this file is added into a new script element, attached to the DOM (body element)
  97528. * @param scriptUrl defines the url of the script to laod
  97529. * @param scriptId defines the id of the script element
  97530. * @returns a promise request object
  97531. */
  97532. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97533. /**
  97534. * Loads a file from a blob
  97535. * @param fileToLoad defines the blob to use
  97536. * @param callback defines the callback to call when data is loaded
  97537. * @param progressCallback defines the callback to call during loading process
  97538. * @returns a file request object
  97539. */
  97540. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97541. /**
  97542. * Loads a file
  97543. * @param fileToLoad defines the file to load
  97544. * @param callback defines the callback to call when data is loaded
  97545. * @param progressCallBack defines the callback to call during loading process
  97546. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97547. * @returns a file request object
  97548. */
  97549. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97550. /**
  97551. * Creates a data url from a given string content
  97552. * @param content defines the content to convert
  97553. * @returns the new data url link
  97554. */
  97555. static FileAsURL(content: string): string;
  97556. /**
  97557. * Format the given number to a specific decimal format
  97558. * @param value defines the number to format
  97559. * @param decimals defines the number of decimals to use
  97560. * @returns the formatted string
  97561. */
  97562. static Format(value: number, decimals?: number): string;
  97563. /**
  97564. * Tries to copy an object by duplicating every property
  97565. * @param source defines the source object
  97566. * @param destination defines the target object
  97567. * @param doNotCopyList defines a list of properties to avoid
  97568. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97569. */
  97570. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97571. /**
  97572. * Gets a boolean indicating if the given object has no own property
  97573. * @param obj defines the object to test
  97574. * @returns true if object has no own property
  97575. */
  97576. static IsEmpty(obj: any): boolean;
  97577. /**
  97578. * Function used to register events at window level
  97579. * @param windowElement defines the Window object to use
  97580. * @param events defines the events to register
  97581. */
  97582. static RegisterTopRootEvents(windowElement: Window, events: {
  97583. name: string;
  97584. handler: Nullable<(e: FocusEvent) => any>;
  97585. }[]): void;
  97586. /**
  97587. * Function used to unregister events from window level
  97588. * @param windowElement defines the Window object to use
  97589. * @param events defines the events to unregister
  97590. */
  97591. static UnregisterTopRootEvents(windowElement: Window, events: {
  97592. name: string;
  97593. handler: Nullable<(e: FocusEvent) => any>;
  97594. }[]): void;
  97595. /**
  97596. * @ignore
  97597. */
  97598. static _ScreenshotCanvas: HTMLCanvasElement;
  97599. /**
  97600. * Dumps the current bound framebuffer
  97601. * @param width defines the rendering width
  97602. * @param height defines the rendering height
  97603. * @param engine defines the hosting engine
  97604. * @param successCallback defines the callback triggered once the data are available
  97605. * @param mimeType defines the mime type of the result
  97606. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97607. */
  97608. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97609. /**
  97610. * Converts the canvas data to blob.
  97611. * This acts as a polyfill for browsers not supporting the to blob function.
  97612. * @param canvas Defines the canvas to extract the data from
  97613. * @param successCallback Defines the callback triggered once the data are available
  97614. * @param mimeType Defines the mime type of the result
  97615. */
  97616. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97617. /**
  97618. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97619. * @param successCallback defines the callback triggered once the data are available
  97620. * @param mimeType defines the mime type of the result
  97621. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97622. */
  97623. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97624. /**
  97625. * Downloads a blob in the browser
  97626. * @param blob defines the blob to download
  97627. * @param fileName defines the name of the downloaded file
  97628. */
  97629. static Download(blob: Blob, fileName: string): void;
  97630. /**
  97631. * Captures a screenshot of the current rendering
  97632. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97633. * @param engine defines the rendering engine
  97634. * @param camera defines the source camera
  97635. * @param size This parameter can be set to a single number or to an object with the
  97636. * following (optional) properties: precision, width, height. If a single number is passed,
  97637. * it will be used for both width and height. If an object is passed, the screenshot size
  97638. * will be derived from the parameters. The precision property is a multiplier allowing
  97639. * rendering at a higher or lower resolution
  97640. * @param successCallback defines the callback receives a single parameter which contains the
  97641. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97642. * src parameter of an <img> to display it
  97643. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97644. * Check your browser for supported MIME types
  97645. */
  97646. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97647. /**
  97648. * Captures a screenshot of the current rendering
  97649. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97650. * @param engine defines the rendering engine
  97651. * @param camera defines the source camera
  97652. * @param size This parameter can be set to a single number or to an object with the
  97653. * following (optional) properties: precision, width, height. If a single number is passed,
  97654. * it will be used for both width and height. If an object is passed, the screenshot size
  97655. * will be derived from the parameters. The precision property is a multiplier allowing
  97656. * rendering at a higher or lower resolution
  97657. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97658. * Check your browser for supported MIME types
  97659. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97660. * to the src parameter of an <img> to display it
  97661. */
  97662. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97663. /**
  97664. * Generates an image screenshot from the specified camera.
  97665. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97666. * @param engine The engine to use for rendering
  97667. * @param camera The camera to use for rendering
  97668. * @param size This parameter can be set to a single number or to an object with the
  97669. * following (optional) properties: precision, width, height. If a single number is passed,
  97670. * it will be used for both width and height. If an object is passed, the screenshot size
  97671. * will be derived from the parameters. The precision property is a multiplier allowing
  97672. * rendering at a higher or lower resolution
  97673. * @param successCallback The callback receives a single parameter which contains the
  97674. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97675. * src parameter of an <img> to display it
  97676. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97677. * Check your browser for supported MIME types
  97678. * @param samples Texture samples (default: 1)
  97679. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97680. * @param fileName A name for for the downloaded file.
  97681. */
  97682. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97683. /**
  97684. * Generates an image screenshot from the specified camera.
  97685. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97686. * @param engine The engine to use for rendering
  97687. * @param camera The camera to use for rendering
  97688. * @param size This parameter can be set to a single number or to an object with the
  97689. * following (optional) properties: precision, width, height. If a single number is passed,
  97690. * it will be used for both width and height. If an object is passed, the screenshot size
  97691. * will be derived from the parameters. The precision property is a multiplier allowing
  97692. * rendering at a higher or lower resolution
  97693. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97694. * Check your browser for supported MIME types
  97695. * @param samples Texture samples (default: 1)
  97696. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97697. * @param fileName A name for for the downloaded file.
  97698. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97699. * to the src parameter of an <img> to display it
  97700. */
  97701. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97702. /**
  97703. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97704. * Be aware Math.random() could cause collisions, but:
  97705. * "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"
  97706. * @returns a pseudo random id
  97707. */
  97708. static RandomId(): string;
  97709. /**
  97710. * Test if the given uri is a base64 string
  97711. * @param uri The uri to test
  97712. * @return True if the uri is a base64 string or false otherwise
  97713. */
  97714. static IsBase64(uri: string): boolean;
  97715. /**
  97716. * Decode the given base64 uri.
  97717. * @param uri The uri to decode
  97718. * @return The decoded base64 data.
  97719. */
  97720. static DecodeBase64(uri: string): ArrayBuffer;
  97721. /**
  97722. * Gets the absolute url.
  97723. * @param url the input url
  97724. * @return the absolute url
  97725. */
  97726. static GetAbsoluteUrl(url: string): string;
  97727. /**
  97728. * No log
  97729. */
  97730. static readonly NoneLogLevel: number;
  97731. /**
  97732. * Only message logs
  97733. */
  97734. static readonly MessageLogLevel: number;
  97735. /**
  97736. * Only warning logs
  97737. */
  97738. static readonly WarningLogLevel: number;
  97739. /**
  97740. * Only error logs
  97741. */
  97742. static readonly ErrorLogLevel: number;
  97743. /**
  97744. * All logs
  97745. */
  97746. static readonly AllLogLevel: number;
  97747. /**
  97748. * Gets a value indicating the number of loading errors
  97749. * @ignorenaming
  97750. */
  97751. static readonly errorsCount: number;
  97752. /**
  97753. * Callback called when a new log is added
  97754. */
  97755. static OnNewCacheEntry: (entry: string) => void;
  97756. /**
  97757. * Log a message to the console
  97758. * @param message defines the message to log
  97759. */
  97760. static Log(message: string): void;
  97761. /**
  97762. * Write a warning message to the console
  97763. * @param message defines the message to log
  97764. */
  97765. static Warn(message: string): void;
  97766. /**
  97767. * Write an error message to the console
  97768. * @param message defines the message to log
  97769. */
  97770. static Error(message: string): void;
  97771. /**
  97772. * Gets current log cache (list of logs)
  97773. */
  97774. static readonly LogCache: string;
  97775. /**
  97776. * Clears the log cache
  97777. */
  97778. static ClearLogCache(): void;
  97779. /**
  97780. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  97781. */
  97782. static LogLevels: number;
  97783. /**
  97784. * Checks if the window object exists
  97785. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  97786. */
  97787. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  97788. /**
  97789. * No performance log
  97790. */
  97791. static readonly PerformanceNoneLogLevel: number;
  97792. /**
  97793. * Use user marks to log performance
  97794. */
  97795. static readonly PerformanceUserMarkLogLevel: number;
  97796. /**
  97797. * Log performance to the console
  97798. */
  97799. static readonly PerformanceConsoleLogLevel: number;
  97800. private static _performance;
  97801. /**
  97802. * Sets the current performance log level
  97803. */
  97804. static PerformanceLogLevel: number;
  97805. private static _StartPerformanceCounterDisabled;
  97806. private static _EndPerformanceCounterDisabled;
  97807. private static _StartUserMark;
  97808. private static _EndUserMark;
  97809. private static _StartPerformanceConsole;
  97810. private static _EndPerformanceConsole;
  97811. /**
  97812. * Starts a performance counter
  97813. */
  97814. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97815. /**
  97816. * Ends a specific performance coutner
  97817. */
  97818. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  97819. /**
  97820. * Gets either window.performance.now() if supported or Date.now() else
  97821. */
  97822. static readonly Now: number;
  97823. /**
  97824. * This method will return the name of the class used to create the instance of the given object.
  97825. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  97826. * @param object the object to get the class name from
  97827. * @param isType defines if the object is actually a type
  97828. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  97829. */
  97830. static GetClassName(object: any, isType?: boolean): string;
  97831. /**
  97832. * Gets the first element of an array satisfying a given predicate
  97833. * @param array defines the array to browse
  97834. * @param predicate defines the predicate to use
  97835. * @returns null if not found or the element
  97836. */
  97837. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  97838. /**
  97839. * This method will return the name of the full name of the class, including its owning module (if any).
  97840. * 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).
  97841. * @param object the object to get the class name from
  97842. * @param isType defines if the object is actually a type
  97843. * @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.
  97844. * @ignorenaming
  97845. */
  97846. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  97847. /**
  97848. * Returns a promise that resolves after the given amount of time.
  97849. * @param delay Number of milliseconds to delay
  97850. * @returns Promise that resolves after the given amount of time
  97851. */
  97852. static DelayAsync(delay: number): Promise<void>;
  97853. }
  97854. /**
  97855. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  97856. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  97857. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  97858. * @param name The name of the class, case should be preserved
  97859. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  97860. */
  97861. export function className(name: string, module?: string): (target: Object) => void;
  97862. /**
  97863. * An implementation of a loop for asynchronous functions.
  97864. */
  97865. export class AsyncLoop {
  97866. /**
  97867. * Defines the number of iterations for the loop
  97868. */
  97869. iterations: number;
  97870. /**
  97871. * Defines the current index of the loop.
  97872. */
  97873. index: number;
  97874. private _done;
  97875. private _fn;
  97876. private _successCallback;
  97877. /**
  97878. * Constructor.
  97879. * @param iterations the number of iterations.
  97880. * @param func the function to run each iteration
  97881. * @param successCallback the callback that will be called upon succesful execution
  97882. * @param offset starting offset.
  97883. */
  97884. constructor(
  97885. /**
  97886. * Defines the number of iterations for the loop
  97887. */
  97888. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  97889. /**
  97890. * Execute the next iteration. Must be called after the last iteration was finished.
  97891. */
  97892. executeNext(): void;
  97893. /**
  97894. * Break the loop and run the success callback.
  97895. */
  97896. breakLoop(): void;
  97897. /**
  97898. * Create and run an async loop.
  97899. * @param iterations the number of iterations.
  97900. * @param fn the function to run each iteration
  97901. * @param successCallback the callback that will be called upon succesful execution
  97902. * @param offset starting offset.
  97903. * @returns the created async loop object
  97904. */
  97905. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  97906. /**
  97907. * A for-loop that will run a given number of iterations synchronous and the rest async.
  97908. * @param iterations total number of iterations
  97909. * @param syncedIterations number of synchronous iterations in each async iteration.
  97910. * @param fn the function to call each iteration.
  97911. * @param callback a success call back that will be called when iterating stops.
  97912. * @param breakFunction a break condition (optional)
  97913. * @param timeout timeout settings for the setTimeout function. default - 0.
  97914. * @returns the created async loop object
  97915. */
  97916. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  97917. }
  97918. }
  97919. declare module BABYLON {
  97920. /** @hidden */
  97921. export interface ICollisionCoordinator {
  97922. createCollider(): Collider;
  97923. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97924. init(scene: Scene): void;
  97925. }
  97926. /** @hidden */
  97927. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  97928. private _scene;
  97929. private _scaledPosition;
  97930. private _scaledVelocity;
  97931. private _finalPosition;
  97932. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  97933. createCollider(): Collider;
  97934. init(scene: Scene): void;
  97935. private _collideWithWorld;
  97936. }
  97937. }
  97938. declare module BABYLON {
  97939. /**
  97940. * Class used to manage all inputs for the scene.
  97941. */
  97942. export class InputManager {
  97943. /** The distance in pixel that you have to move to prevent some events */
  97944. static DragMovementThreshold: number;
  97945. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  97946. static LongPressDelay: number;
  97947. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  97948. static DoubleClickDelay: number;
  97949. /** If you need to check double click without raising a single click at first click, enable this flag */
  97950. static ExclusiveDoubleClickMode: boolean;
  97951. private _wheelEventName;
  97952. private _onPointerMove;
  97953. private _onPointerDown;
  97954. private _onPointerUp;
  97955. private _initClickEvent;
  97956. private _initActionManager;
  97957. private _delayedSimpleClick;
  97958. private _delayedSimpleClickTimeout;
  97959. private _previousDelayedSimpleClickTimeout;
  97960. private _meshPickProceed;
  97961. private _previousButtonPressed;
  97962. private _currentPickResult;
  97963. private _previousPickResult;
  97964. private _totalPointersPressed;
  97965. private _doubleClickOccured;
  97966. private _pointerOverMesh;
  97967. private _pickedDownMesh;
  97968. private _pickedUpMesh;
  97969. private _pointerX;
  97970. private _pointerY;
  97971. private _unTranslatedPointerX;
  97972. private _unTranslatedPointerY;
  97973. private _startingPointerPosition;
  97974. private _previousStartingPointerPosition;
  97975. private _startingPointerTime;
  97976. private _previousStartingPointerTime;
  97977. private _pointerCaptures;
  97978. private _onKeyDown;
  97979. private _onKeyUp;
  97980. private _onCanvasFocusObserver;
  97981. private _onCanvasBlurObserver;
  97982. private _scene;
  97983. /**
  97984. * Creates a new InputManager
  97985. * @param scene defines the hosting scene
  97986. */
  97987. constructor(scene: Scene);
  97988. /**
  97989. * Gets the mesh that is currently under the pointer
  97990. */
  97991. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97992. /**
  97993. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  97994. */
  97995. readonly unTranslatedPointer: Vector2;
  97996. /**
  97997. * Gets or sets the current on-screen X position of the pointer
  97998. */
  97999. pointerX: number;
  98000. /**
  98001. * Gets or sets the current on-screen Y position of the pointer
  98002. */
  98003. pointerY: number;
  98004. private _updatePointerPosition;
  98005. private _processPointerMove;
  98006. private _setRayOnPointerInfo;
  98007. private _checkPrePointerObservable;
  98008. /**
  98009. * Use this method to simulate a pointer move on a mesh
  98010. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98011. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98012. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98013. */
  98014. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98015. /**
  98016. * Use this method to simulate a pointer down on a mesh
  98017. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98018. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98019. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98020. */
  98021. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98022. private _processPointerDown;
  98023. /** @hidden */
  98024. _isPointerSwiping(): boolean;
  98025. /**
  98026. * Use this method to simulate a pointer up on a mesh
  98027. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98028. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98029. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98030. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98031. */
  98032. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98033. private _processPointerUp;
  98034. /**
  98035. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98036. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98037. * @returns true if the pointer was captured
  98038. */
  98039. isPointerCaptured(pointerId?: number): boolean;
  98040. /**
  98041. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98042. * @param attachUp defines if you want to attach events to pointerup
  98043. * @param attachDown defines if you want to attach events to pointerdown
  98044. * @param attachMove defines if you want to attach events to pointermove
  98045. */
  98046. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98047. /**
  98048. * Detaches all event handlers
  98049. */
  98050. detachControl(): void;
  98051. /**
  98052. * Force the value of meshUnderPointer
  98053. * @param mesh defines the mesh to use
  98054. */
  98055. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98056. /**
  98057. * Gets the mesh under the pointer
  98058. * @returns a Mesh or null if no mesh is under the pointer
  98059. */
  98060. getPointerOverMesh(): Nullable<AbstractMesh>;
  98061. }
  98062. }
  98063. declare module BABYLON {
  98064. /**
  98065. * Helper class used to generate session unique ID
  98066. */
  98067. export class UniqueIdGenerator {
  98068. private static _UniqueIdCounter;
  98069. /**
  98070. * Gets an unique (relatively to the current scene) Id
  98071. */
  98072. static readonly UniqueId: number;
  98073. }
  98074. }
  98075. declare module BABYLON {
  98076. /**
  98077. * This class defines the direct association between an animation and a target
  98078. */
  98079. export class TargetedAnimation {
  98080. /**
  98081. * Animation to perform
  98082. */
  98083. animation: Animation;
  98084. /**
  98085. * Target to animate
  98086. */
  98087. target: any;
  98088. /**
  98089. * Serialize the object
  98090. * @returns the JSON object representing the current entity
  98091. */
  98092. serialize(): any;
  98093. }
  98094. /**
  98095. * Use this class to create coordinated animations on multiple targets
  98096. */
  98097. export class AnimationGroup implements IDisposable {
  98098. /** The name of the animation group */
  98099. name: string;
  98100. private _scene;
  98101. private _targetedAnimations;
  98102. private _animatables;
  98103. private _from;
  98104. private _to;
  98105. private _isStarted;
  98106. private _isPaused;
  98107. private _speedRatio;
  98108. private _loopAnimation;
  98109. /**
  98110. * Gets or sets the unique id of the node
  98111. */
  98112. uniqueId: number;
  98113. /**
  98114. * This observable will notify when one animation have ended
  98115. */
  98116. onAnimationEndObservable: Observable<TargetedAnimation>;
  98117. /**
  98118. * Observer raised when one animation loops
  98119. */
  98120. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98121. /**
  98122. * This observable will notify when all animations have ended.
  98123. */
  98124. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98125. /**
  98126. * This observable will notify when all animations have paused.
  98127. */
  98128. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98129. /**
  98130. * This observable will notify when all animations are playing.
  98131. */
  98132. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98133. /**
  98134. * Gets the first frame
  98135. */
  98136. readonly from: number;
  98137. /**
  98138. * Gets the last frame
  98139. */
  98140. readonly to: number;
  98141. /**
  98142. * Define if the animations are started
  98143. */
  98144. readonly isStarted: boolean;
  98145. /**
  98146. * Gets a value indicating that the current group is playing
  98147. */
  98148. readonly isPlaying: boolean;
  98149. /**
  98150. * Gets or sets the speed ratio to use for all animations
  98151. */
  98152. /**
  98153. * Gets or sets the speed ratio to use for all animations
  98154. */
  98155. speedRatio: number;
  98156. /**
  98157. * Gets or sets if all animations should loop or not
  98158. */
  98159. loopAnimation: boolean;
  98160. /**
  98161. * Gets the targeted animations for this animation group
  98162. */
  98163. readonly targetedAnimations: Array<TargetedAnimation>;
  98164. /**
  98165. * returning the list of animatables controlled by this animation group.
  98166. */
  98167. readonly animatables: Array<Animatable>;
  98168. /**
  98169. * Instantiates a new Animation Group.
  98170. * This helps managing several animations at once.
  98171. * @see http://doc.babylonjs.com/how_to/group
  98172. * @param name Defines the name of the group
  98173. * @param scene Defines the scene the group belongs to
  98174. */
  98175. constructor(
  98176. /** The name of the animation group */
  98177. name: string, scene?: Nullable<Scene>);
  98178. /**
  98179. * Add an animation (with its target) in the group
  98180. * @param animation defines the animation we want to add
  98181. * @param target defines the target of the animation
  98182. * @returns the TargetedAnimation object
  98183. */
  98184. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98185. /**
  98186. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98187. * It can add constant keys at begin or end
  98188. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98189. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98190. * @returns the animation group
  98191. */
  98192. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98193. /**
  98194. * Start all animations on given targets
  98195. * @param loop defines if animations must loop
  98196. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98197. * @param from defines the from key (optional)
  98198. * @param to defines the to key (optional)
  98199. * @returns the current animation group
  98200. */
  98201. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98202. /**
  98203. * Pause all animations
  98204. * @returns the animation group
  98205. */
  98206. pause(): AnimationGroup;
  98207. /**
  98208. * Play all animations to initial state
  98209. * This function will start() the animations if they were not started or will restart() them if they were paused
  98210. * @param loop defines if animations must loop
  98211. * @returns the animation group
  98212. */
  98213. play(loop?: boolean): AnimationGroup;
  98214. /**
  98215. * Reset all animations to initial state
  98216. * @returns the animation group
  98217. */
  98218. reset(): AnimationGroup;
  98219. /**
  98220. * Restart animations from key 0
  98221. * @returns the animation group
  98222. */
  98223. restart(): AnimationGroup;
  98224. /**
  98225. * Stop all animations
  98226. * @returns the animation group
  98227. */
  98228. stop(): AnimationGroup;
  98229. /**
  98230. * Set animation weight for all animatables
  98231. * @param weight defines the weight to use
  98232. * @return the animationGroup
  98233. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98234. */
  98235. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98236. /**
  98237. * Synchronize and normalize all animatables with a source animatable
  98238. * @param root defines the root animatable to synchronize with
  98239. * @return the animationGroup
  98240. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98241. */
  98242. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98243. /**
  98244. * Goes to a specific frame in this animation group
  98245. * @param frame the frame number to go to
  98246. * @return the animationGroup
  98247. */
  98248. goToFrame(frame: number): AnimationGroup;
  98249. /**
  98250. * Dispose all associated resources
  98251. */
  98252. dispose(): void;
  98253. private _checkAnimationGroupEnded;
  98254. /**
  98255. * Clone the current animation group and returns a copy
  98256. * @param newName defines the name of the new group
  98257. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98258. * @returns the new aniamtion group
  98259. */
  98260. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98261. /**
  98262. * Serializes the animationGroup to an object
  98263. * @returns Serialized object
  98264. */
  98265. serialize(): any;
  98266. /**
  98267. * Returns a new AnimationGroup object parsed from the source provided.
  98268. * @param parsedAnimationGroup defines the source
  98269. * @param scene defines the scene that will receive the animationGroup
  98270. * @returns a new AnimationGroup
  98271. */
  98272. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98273. /**
  98274. * Returns the string "AnimationGroup"
  98275. * @returns "AnimationGroup"
  98276. */
  98277. getClassName(): string;
  98278. /**
  98279. * Creates a detailled string about the object
  98280. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98281. * @returns a string representing the object
  98282. */
  98283. toString(fullDetails?: boolean): string;
  98284. }
  98285. }
  98286. declare module BABYLON {
  98287. /**
  98288. * Define an interface for all classes that will hold resources
  98289. */
  98290. export interface IDisposable {
  98291. /**
  98292. * Releases all held resources
  98293. */
  98294. dispose(): void;
  98295. }
  98296. /** Interface defining initialization parameters for Scene class */
  98297. export interface SceneOptions {
  98298. /**
  98299. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98300. * It will improve performance when the number of geometries becomes important.
  98301. */
  98302. useGeometryUniqueIdsMap?: boolean;
  98303. /**
  98304. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98305. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98306. */
  98307. useMaterialMeshMap?: boolean;
  98308. /**
  98309. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98310. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98311. */
  98312. useClonedMeshhMap?: boolean;
  98313. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98314. virtual?: boolean;
  98315. }
  98316. /**
  98317. * Represents a scene to be rendered by the engine.
  98318. * @see http://doc.babylonjs.com/features/scene
  98319. */
  98320. export class Scene extends AbstractScene implements IAnimatable {
  98321. /** The fog is deactivated */
  98322. static readonly FOGMODE_NONE: number;
  98323. /** The fog density is following an exponential function */
  98324. static readonly FOGMODE_EXP: number;
  98325. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98326. static readonly FOGMODE_EXP2: number;
  98327. /** The fog density is following a linear function. */
  98328. static readonly FOGMODE_LINEAR: number;
  98329. /**
  98330. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98332. */
  98333. static MinDeltaTime: number;
  98334. /**
  98335. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98336. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98337. */
  98338. static MaxDeltaTime: number;
  98339. /**
  98340. * Factory used to create the default material.
  98341. * @param name The name of the material to create
  98342. * @param scene The scene to create the material for
  98343. * @returns The default material
  98344. */
  98345. static DefaultMaterialFactory(scene: Scene): Material;
  98346. /**
  98347. * Factory used to create the a collision coordinator.
  98348. * @returns The collision coordinator
  98349. */
  98350. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98351. /** @hidden */
  98352. _inputManager: InputManager;
  98353. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98354. cameraToUseForPointers: Nullable<Camera>;
  98355. /** @hidden */
  98356. readonly _isScene: boolean;
  98357. /**
  98358. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98359. */
  98360. autoClear: boolean;
  98361. /**
  98362. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98363. */
  98364. autoClearDepthAndStencil: boolean;
  98365. /**
  98366. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98367. */
  98368. clearColor: Color4;
  98369. /**
  98370. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98371. */
  98372. ambientColor: Color3;
  98373. /**
  98374. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98375. * It should only be one of the following (if not the default embedded one):
  98376. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98377. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98378. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98379. * The material properties need to be setup according to the type of texture in use.
  98380. */
  98381. environmentBRDFTexture: BaseTexture;
  98382. /** @hidden */
  98383. protected _environmentTexture: Nullable<BaseTexture>;
  98384. /**
  98385. * Texture used in all pbr material as the reflection texture.
  98386. * As in the majority of the scene they are the same (exception for multi room and so on),
  98387. * this is easier to reference from here than from all the materials.
  98388. */
  98389. /**
  98390. * Texture used in all pbr material as the reflection texture.
  98391. * As in the majority of the scene they are the same (exception for multi room and so on),
  98392. * this is easier to set here than in all the materials.
  98393. */
  98394. environmentTexture: Nullable<BaseTexture>;
  98395. /** @hidden */
  98396. protected _environmentIntensity: number;
  98397. /**
  98398. * Intensity of the environment in all pbr material.
  98399. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98400. * As in the majority of the scene they are the same (exception for multi room and so on),
  98401. * this is easier to reference from here than from all the materials.
  98402. */
  98403. /**
  98404. * Intensity of the environment in all pbr material.
  98405. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98406. * As in the majority of the scene they are the same (exception for multi room and so on),
  98407. * this is easier to set here than in all the materials.
  98408. */
  98409. environmentIntensity: number;
  98410. /** @hidden */
  98411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98412. /**
  98413. * Default image processing configuration used either in the rendering
  98414. * Forward main pass or through the imageProcessingPostProcess if present.
  98415. * As in the majority of the scene they are the same (exception for multi camera),
  98416. * this is easier to reference from here than from all the materials and post process.
  98417. *
  98418. * No setter as we it is a shared configuration, you can set the values instead.
  98419. */
  98420. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98421. private _forceWireframe;
  98422. /**
  98423. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98424. */
  98425. forceWireframe: boolean;
  98426. private _forcePointsCloud;
  98427. /**
  98428. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98429. */
  98430. forcePointsCloud: boolean;
  98431. /**
  98432. * Gets or sets the active clipplane 1
  98433. */
  98434. clipPlane: Nullable<Plane>;
  98435. /**
  98436. * Gets or sets the active clipplane 2
  98437. */
  98438. clipPlane2: Nullable<Plane>;
  98439. /**
  98440. * Gets or sets the active clipplane 3
  98441. */
  98442. clipPlane3: Nullable<Plane>;
  98443. /**
  98444. * Gets or sets the active clipplane 4
  98445. */
  98446. clipPlane4: Nullable<Plane>;
  98447. /**
  98448. * Gets or sets a boolean indicating if animations are enabled
  98449. */
  98450. animationsEnabled: boolean;
  98451. private _animationPropertiesOverride;
  98452. /**
  98453. * Gets or sets the animation properties override
  98454. */
  98455. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98456. /**
  98457. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98458. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98459. */
  98460. useConstantAnimationDeltaTime: boolean;
  98461. /**
  98462. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98463. * Please note that it requires to run a ray cast through the scene on every frame
  98464. */
  98465. constantlyUpdateMeshUnderPointer: boolean;
  98466. /**
  98467. * Defines the HTML cursor to use when hovering over interactive elements
  98468. */
  98469. hoverCursor: string;
  98470. /**
  98471. * Defines the HTML default cursor to use (empty by default)
  98472. */
  98473. defaultCursor: string;
  98474. /**
  98475. * This is used to call preventDefault() on pointer down
  98476. * in order to block unwanted artifacts like system double clicks
  98477. */
  98478. preventDefaultOnPointerDown: boolean;
  98479. /**
  98480. * This is used to call preventDefault() on pointer up
  98481. * in order to block unwanted artifacts like system double clicks
  98482. */
  98483. preventDefaultOnPointerUp: boolean;
  98484. /**
  98485. * Gets or sets user defined metadata
  98486. */
  98487. metadata: any;
  98488. /**
  98489. * For internal use only. Please do not use.
  98490. */
  98491. reservedDataStore: any;
  98492. /**
  98493. * Gets the name of the plugin used to load this scene (null by default)
  98494. */
  98495. loadingPluginName: string;
  98496. /**
  98497. * Use this array to add regular expressions used to disable offline support for specific urls
  98498. */
  98499. disableOfflineSupportExceptionRules: RegExp[];
  98500. /**
  98501. * An event triggered when the scene is disposed.
  98502. */
  98503. onDisposeObservable: Observable<Scene>;
  98504. private _onDisposeObserver;
  98505. /** Sets a function to be executed when this scene is disposed. */
  98506. onDispose: () => void;
  98507. /**
  98508. * An event triggered before rendering the scene (right after animations and physics)
  98509. */
  98510. onBeforeRenderObservable: Observable<Scene>;
  98511. private _onBeforeRenderObserver;
  98512. /** Sets a function to be executed before rendering this scene */
  98513. beforeRender: Nullable<() => void>;
  98514. /**
  98515. * An event triggered after rendering the scene
  98516. */
  98517. onAfterRenderObservable: Observable<Scene>;
  98518. /**
  98519. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98520. */
  98521. onAfterRenderCameraObservable: Observable<Camera>;
  98522. private _onAfterRenderObserver;
  98523. /** Sets a function to be executed after rendering this scene */
  98524. afterRender: Nullable<() => void>;
  98525. /**
  98526. * An event triggered before animating the scene
  98527. */
  98528. onBeforeAnimationsObservable: Observable<Scene>;
  98529. /**
  98530. * An event triggered after animations processing
  98531. */
  98532. onAfterAnimationsObservable: Observable<Scene>;
  98533. /**
  98534. * An event triggered before draw calls are ready to be sent
  98535. */
  98536. onBeforeDrawPhaseObservable: Observable<Scene>;
  98537. /**
  98538. * An event triggered after draw calls have been sent
  98539. */
  98540. onAfterDrawPhaseObservable: Observable<Scene>;
  98541. /**
  98542. * An event triggered when the scene is ready
  98543. */
  98544. onReadyObservable: Observable<Scene>;
  98545. /**
  98546. * An event triggered before rendering a camera
  98547. */
  98548. onBeforeCameraRenderObservable: Observable<Camera>;
  98549. private _onBeforeCameraRenderObserver;
  98550. /** Sets a function to be executed before rendering a camera*/
  98551. beforeCameraRender: () => void;
  98552. /**
  98553. * An event triggered after rendering a camera
  98554. */
  98555. onAfterCameraRenderObservable: Observable<Camera>;
  98556. private _onAfterCameraRenderObserver;
  98557. /** Sets a function to be executed after rendering a camera*/
  98558. afterCameraRender: () => void;
  98559. /**
  98560. * An event triggered when active meshes evaluation is about to start
  98561. */
  98562. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98563. /**
  98564. * An event triggered when active meshes evaluation is done
  98565. */
  98566. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98567. /**
  98568. * An event triggered when particles rendering is about to start
  98569. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98570. */
  98571. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98572. /**
  98573. * An event triggered when particles rendering is done
  98574. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98575. */
  98576. onAfterParticlesRenderingObservable: Observable<Scene>;
  98577. /**
  98578. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98579. */
  98580. onDataLoadedObservable: Observable<Scene>;
  98581. /**
  98582. * An event triggered when a camera is created
  98583. */
  98584. onNewCameraAddedObservable: Observable<Camera>;
  98585. /**
  98586. * An event triggered when a camera is removed
  98587. */
  98588. onCameraRemovedObservable: Observable<Camera>;
  98589. /**
  98590. * An event triggered when a light is created
  98591. */
  98592. onNewLightAddedObservable: Observable<Light>;
  98593. /**
  98594. * An event triggered when a light is removed
  98595. */
  98596. onLightRemovedObservable: Observable<Light>;
  98597. /**
  98598. * An event triggered when a geometry is created
  98599. */
  98600. onNewGeometryAddedObservable: Observable<Geometry>;
  98601. /**
  98602. * An event triggered when a geometry is removed
  98603. */
  98604. onGeometryRemovedObservable: Observable<Geometry>;
  98605. /**
  98606. * An event triggered when a transform node is created
  98607. */
  98608. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98609. /**
  98610. * An event triggered when a transform node is removed
  98611. */
  98612. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98613. /**
  98614. * An event triggered when a mesh is created
  98615. */
  98616. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98617. /**
  98618. * An event triggered when a mesh is removed
  98619. */
  98620. onMeshRemovedObservable: Observable<AbstractMesh>;
  98621. /**
  98622. * An event triggered when a skeleton is created
  98623. */
  98624. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98625. /**
  98626. * An event triggered when a skeleton is removed
  98627. */
  98628. onSkeletonRemovedObservable: Observable<Skeleton>;
  98629. /**
  98630. * An event triggered when a material is created
  98631. */
  98632. onNewMaterialAddedObservable: Observable<Material>;
  98633. /**
  98634. * An event triggered when a material is removed
  98635. */
  98636. onMaterialRemovedObservable: Observable<Material>;
  98637. /**
  98638. * An event triggered when a texture is created
  98639. */
  98640. onNewTextureAddedObservable: Observable<BaseTexture>;
  98641. /**
  98642. * An event triggered when a texture is removed
  98643. */
  98644. onTextureRemovedObservable: Observable<BaseTexture>;
  98645. /**
  98646. * An event triggered when render targets are about to be rendered
  98647. * Can happen multiple times per frame.
  98648. */
  98649. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98650. /**
  98651. * An event triggered when render targets were rendered.
  98652. * Can happen multiple times per frame.
  98653. */
  98654. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98655. /**
  98656. * An event triggered before calculating deterministic simulation step
  98657. */
  98658. onBeforeStepObservable: Observable<Scene>;
  98659. /**
  98660. * An event triggered after calculating deterministic simulation step
  98661. */
  98662. onAfterStepObservable: Observable<Scene>;
  98663. /**
  98664. * An event triggered when the activeCamera property is updated
  98665. */
  98666. onActiveCameraChanged: Observable<Scene>;
  98667. /**
  98668. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98669. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98670. * 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)
  98671. */
  98672. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98673. /**
  98674. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98675. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98676. * 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)
  98677. */
  98678. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98679. /**
  98680. * This Observable will when a mesh has been imported into the scene.
  98681. */
  98682. onMeshImportedObservable: Observable<AbstractMesh>;
  98683. /**
  98684. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98685. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98686. */
  98687. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98688. /** @hidden */
  98689. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98690. /**
  98691. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98692. */
  98693. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98694. /**
  98695. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98696. */
  98697. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98698. /**
  98699. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98700. */
  98701. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98702. /** Callback called when a pointer move is detected */
  98703. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98704. /** Callback called when a pointer down is detected */
  98705. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98706. /** Callback called when a pointer up is detected */
  98707. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98708. /** Callback called when a pointer pick is detected */
  98709. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98710. /**
  98711. * 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).
  98712. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98713. */
  98714. onPrePointerObservable: Observable<PointerInfoPre>;
  98715. /**
  98716. * Observable event triggered each time an input event is received from the rendering canvas
  98717. */
  98718. onPointerObservable: Observable<PointerInfo>;
  98719. /**
  98720. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  98721. */
  98722. readonly unTranslatedPointer: Vector2;
  98723. /**
  98724. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  98725. */
  98726. static DragMovementThreshold: number;
  98727. /**
  98728. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  98729. */
  98730. static LongPressDelay: number;
  98731. /**
  98732. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  98733. */
  98734. static DoubleClickDelay: number;
  98735. /** If you need to check double click without raising a single click at first click, enable this flag */
  98736. static ExclusiveDoubleClickMode: boolean;
  98737. /** @hidden */
  98738. _mirroredCameraPosition: Nullable<Vector3>;
  98739. /**
  98740. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  98741. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  98742. */
  98743. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  98744. /**
  98745. * Observable event triggered each time an keyboard event is received from the hosting window
  98746. */
  98747. onKeyboardObservable: Observable<KeyboardInfo>;
  98748. private _useRightHandedSystem;
  98749. /**
  98750. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  98751. */
  98752. useRightHandedSystem: boolean;
  98753. private _timeAccumulator;
  98754. private _currentStepId;
  98755. private _currentInternalStep;
  98756. /**
  98757. * Sets the step Id used by deterministic lock step
  98758. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98759. * @param newStepId defines the step Id
  98760. */
  98761. setStepId(newStepId: number): void;
  98762. /**
  98763. * Gets the step Id used by deterministic lock step
  98764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98765. * @returns the step Id
  98766. */
  98767. getStepId(): number;
  98768. /**
  98769. * Gets the internal step used by deterministic lock step
  98770. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98771. * @returns the internal step
  98772. */
  98773. getInternalStep(): number;
  98774. private _fogEnabled;
  98775. /**
  98776. * Gets or sets a boolean indicating if fog is enabled on this scene
  98777. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98778. * (Default is true)
  98779. */
  98780. fogEnabled: boolean;
  98781. private _fogMode;
  98782. /**
  98783. * Gets or sets the fog mode to use
  98784. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98785. * | mode | value |
  98786. * | --- | --- |
  98787. * | FOGMODE_NONE | 0 |
  98788. * | FOGMODE_EXP | 1 |
  98789. * | FOGMODE_EXP2 | 2 |
  98790. * | FOGMODE_LINEAR | 3 |
  98791. */
  98792. fogMode: number;
  98793. /**
  98794. * Gets or sets the fog color to use
  98795. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98796. * (Default is Color3(0.2, 0.2, 0.3))
  98797. */
  98798. fogColor: Color3;
  98799. /**
  98800. * Gets or sets the fog density to use
  98801. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98802. * (Default is 0.1)
  98803. */
  98804. fogDensity: number;
  98805. /**
  98806. * Gets or sets the fog start distance to use
  98807. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98808. * (Default is 0)
  98809. */
  98810. fogStart: number;
  98811. /**
  98812. * Gets or sets the fog end distance to use
  98813. * @see http://doc.babylonjs.com/babylon101/environment#fog
  98814. * (Default is 1000)
  98815. */
  98816. fogEnd: number;
  98817. private _shadowsEnabled;
  98818. /**
  98819. * Gets or sets a boolean indicating if shadows are enabled on this scene
  98820. */
  98821. shadowsEnabled: boolean;
  98822. private _lightsEnabled;
  98823. /**
  98824. * Gets or sets a boolean indicating if lights are enabled on this scene
  98825. */
  98826. lightsEnabled: boolean;
  98827. /** All of the active cameras added to this scene. */
  98828. activeCameras: Camera[];
  98829. /** @hidden */
  98830. _activeCamera: Nullable<Camera>;
  98831. /** Gets or sets the current active camera */
  98832. activeCamera: Nullable<Camera>;
  98833. private _defaultMaterial;
  98834. /** The default material used on meshes when no material is affected */
  98835. /** The default material used on meshes when no material is affected */
  98836. defaultMaterial: Material;
  98837. private _texturesEnabled;
  98838. /**
  98839. * Gets or sets a boolean indicating if textures are enabled on this scene
  98840. */
  98841. texturesEnabled: boolean;
  98842. /**
  98843. * Gets or sets a boolean indicating if particles are enabled on this scene
  98844. */
  98845. particlesEnabled: boolean;
  98846. /**
  98847. * Gets or sets a boolean indicating if sprites are enabled on this scene
  98848. */
  98849. spritesEnabled: boolean;
  98850. private _skeletonsEnabled;
  98851. /**
  98852. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  98853. */
  98854. skeletonsEnabled: boolean;
  98855. /**
  98856. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  98857. */
  98858. lensFlaresEnabled: boolean;
  98859. /**
  98860. * Gets or sets a boolean indicating if collisions are enabled on this scene
  98861. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98862. */
  98863. collisionsEnabled: boolean;
  98864. private _collisionCoordinator;
  98865. /** @hidden */
  98866. readonly collisionCoordinator: ICollisionCoordinator;
  98867. /**
  98868. * Defines the gravity applied to this scene (used only for collisions)
  98869. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98870. */
  98871. gravity: Vector3;
  98872. /**
  98873. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  98874. */
  98875. postProcessesEnabled: boolean;
  98876. /**
  98877. * The list of postprocesses added to the scene
  98878. */
  98879. postProcesses: PostProcess[];
  98880. /**
  98881. * Gets the current postprocess manager
  98882. */
  98883. postProcessManager: PostProcessManager;
  98884. /**
  98885. * Gets or sets a boolean indicating if render targets are enabled on this scene
  98886. */
  98887. renderTargetsEnabled: boolean;
  98888. /**
  98889. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  98890. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  98891. */
  98892. dumpNextRenderTargets: boolean;
  98893. /**
  98894. * The list of user defined render targets added to the scene
  98895. */
  98896. customRenderTargets: RenderTargetTexture[];
  98897. /**
  98898. * Defines if texture loading must be delayed
  98899. * If true, textures will only be loaded when they need to be rendered
  98900. */
  98901. useDelayedTextureLoading: boolean;
  98902. /**
  98903. * Gets the list of meshes imported to the scene through SceneLoader
  98904. */
  98905. importedMeshesFiles: String[];
  98906. /**
  98907. * Gets or sets a boolean indicating if probes are enabled on this scene
  98908. */
  98909. probesEnabled: boolean;
  98910. /**
  98911. * Gets or sets the current offline provider to use to store scene data
  98912. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  98913. */
  98914. offlineProvider: IOfflineProvider;
  98915. /**
  98916. * Gets or sets the action manager associated with the scene
  98917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98918. */
  98919. actionManager: AbstractActionManager;
  98920. private _meshesForIntersections;
  98921. /**
  98922. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  98923. */
  98924. proceduralTexturesEnabled: boolean;
  98925. private _engine;
  98926. private _totalVertices;
  98927. /** @hidden */
  98928. _activeIndices: PerfCounter;
  98929. /** @hidden */
  98930. _activeParticles: PerfCounter;
  98931. /** @hidden */
  98932. _activeBones: PerfCounter;
  98933. private _animationRatio;
  98934. /** @hidden */
  98935. _animationTimeLast: number;
  98936. /** @hidden */
  98937. _animationTime: number;
  98938. /**
  98939. * Gets or sets a general scale for animation speed
  98940. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  98941. */
  98942. animationTimeScale: number;
  98943. /** @hidden */
  98944. _cachedMaterial: Nullable<Material>;
  98945. /** @hidden */
  98946. _cachedEffect: Nullable<Effect>;
  98947. /** @hidden */
  98948. _cachedVisibility: Nullable<number>;
  98949. private _renderId;
  98950. private _frameId;
  98951. private _executeWhenReadyTimeoutId;
  98952. private _intermediateRendering;
  98953. private _viewUpdateFlag;
  98954. private _projectionUpdateFlag;
  98955. /** @hidden */
  98956. _toBeDisposed: Nullable<IDisposable>[];
  98957. private _activeRequests;
  98958. /** @hidden */
  98959. _pendingData: any[];
  98960. private _isDisposed;
  98961. /**
  98962. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  98963. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  98964. */
  98965. dispatchAllSubMeshesOfActiveMeshes: boolean;
  98966. private _activeMeshes;
  98967. private _processedMaterials;
  98968. private _renderTargets;
  98969. /** @hidden */
  98970. _activeParticleSystems: SmartArray<IParticleSystem>;
  98971. private _activeSkeletons;
  98972. private _softwareSkinnedMeshes;
  98973. private _renderingManager;
  98974. /** @hidden */
  98975. _activeAnimatables: Animatable[];
  98976. private _transformMatrix;
  98977. private _sceneUbo;
  98978. /** @hidden */
  98979. _viewMatrix: Matrix;
  98980. private _projectionMatrix;
  98981. /** @hidden */
  98982. _forcedViewPosition: Nullable<Vector3>;
  98983. /** @hidden */
  98984. _frustumPlanes: Plane[];
  98985. /**
  98986. * Gets the list of frustum planes (built from the active camera)
  98987. */
  98988. readonly frustumPlanes: Plane[];
  98989. /**
  98990. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  98991. * This is useful if there are more lights that the maximum simulteanous authorized
  98992. */
  98993. requireLightSorting: boolean;
  98994. /** @hidden */
  98995. readonly useMaterialMeshMap: boolean;
  98996. /** @hidden */
  98997. readonly useClonedMeshhMap: boolean;
  98998. private _externalData;
  98999. private _uid;
  99000. /**
  99001. * @hidden
  99002. * Backing store of defined scene components.
  99003. */
  99004. _components: ISceneComponent[];
  99005. /**
  99006. * @hidden
  99007. * Backing store of defined scene components.
  99008. */
  99009. _serializableComponents: ISceneSerializableComponent[];
  99010. /**
  99011. * List of components to register on the next registration step.
  99012. */
  99013. private _transientComponents;
  99014. /**
  99015. * Registers the transient components if needed.
  99016. */
  99017. private _registerTransientComponents;
  99018. /**
  99019. * @hidden
  99020. * Add a component to the scene.
  99021. * Note that the ccomponent could be registered on th next frame if this is called after
  99022. * the register component stage.
  99023. * @param component Defines the component to add to the scene
  99024. */
  99025. _addComponent(component: ISceneComponent): void;
  99026. /**
  99027. * @hidden
  99028. * Gets a component from the scene.
  99029. * @param name defines the name of the component to retrieve
  99030. * @returns the component or null if not present
  99031. */
  99032. _getComponent(name: string): Nullable<ISceneComponent>;
  99033. /**
  99034. * @hidden
  99035. * Defines the actions happening before camera updates.
  99036. */
  99037. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99038. /**
  99039. * @hidden
  99040. * Defines the actions happening before clear the canvas.
  99041. */
  99042. _beforeClearStage: Stage<SimpleStageAction>;
  99043. /**
  99044. * @hidden
  99045. * Defines the actions when collecting render targets for the frame.
  99046. */
  99047. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99048. /**
  99049. * @hidden
  99050. * Defines the actions happening for one camera in the frame.
  99051. */
  99052. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99053. /**
  99054. * @hidden
  99055. * Defines the actions happening during the per mesh ready checks.
  99056. */
  99057. _isReadyForMeshStage: Stage<MeshStageAction>;
  99058. /**
  99059. * @hidden
  99060. * Defines the actions happening before evaluate active mesh checks.
  99061. */
  99062. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99063. /**
  99064. * @hidden
  99065. * Defines the actions happening during the evaluate sub mesh checks.
  99066. */
  99067. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99068. /**
  99069. * @hidden
  99070. * Defines the actions happening during the active mesh stage.
  99071. */
  99072. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99073. /**
  99074. * @hidden
  99075. * Defines the actions happening during the per camera render target step.
  99076. */
  99077. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99078. /**
  99079. * @hidden
  99080. * Defines the actions happening just before the active camera is drawing.
  99081. */
  99082. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99083. /**
  99084. * @hidden
  99085. * Defines the actions happening just before a render target is drawing.
  99086. */
  99087. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99088. /**
  99089. * @hidden
  99090. * Defines the actions happening just before a rendering group is drawing.
  99091. */
  99092. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99093. /**
  99094. * @hidden
  99095. * Defines the actions happening just before a mesh is drawing.
  99096. */
  99097. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99098. /**
  99099. * @hidden
  99100. * Defines the actions happening just after a mesh has been drawn.
  99101. */
  99102. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99103. /**
  99104. * @hidden
  99105. * Defines the actions happening just after a rendering group has been drawn.
  99106. */
  99107. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99108. /**
  99109. * @hidden
  99110. * Defines the actions happening just after the active camera has been drawn.
  99111. */
  99112. _afterCameraDrawStage: Stage<CameraStageAction>;
  99113. /**
  99114. * @hidden
  99115. * Defines the actions happening just after a render target has been drawn.
  99116. */
  99117. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99118. /**
  99119. * @hidden
  99120. * Defines the actions happening just after rendering all cameras and computing intersections.
  99121. */
  99122. _afterRenderStage: Stage<SimpleStageAction>;
  99123. /**
  99124. * @hidden
  99125. * Defines the actions happening when a pointer move event happens.
  99126. */
  99127. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99128. /**
  99129. * @hidden
  99130. * Defines the actions happening when a pointer down event happens.
  99131. */
  99132. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99133. /**
  99134. * @hidden
  99135. * Defines the actions happening when a pointer up event happens.
  99136. */
  99137. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99138. /**
  99139. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99140. */
  99141. private geometriesByUniqueId;
  99142. /**
  99143. * Creates a new Scene
  99144. * @param engine defines the engine to use to render this scene
  99145. * @param options defines the scene options
  99146. */
  99147. constructor(engine: Engine, options?: SceneOptions);
  99148. /**
  99149. * Gets a string idenfifying the name of the class
  99150. * @returns "Scene" string
  99151. */
  99152. getClassName(): string;
  99153. private _defaultMeshCandidates;
  99154. /**
  99155. * @hidden
  99156. */
  99157. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99158. private _defaultSubMeshCandidates;
  99159. /**
  99160. * @hidden
  99161. */
  99162. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99163. /**
  99164. * Sets the default candidate providers for the scene.
  99165. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99166. * and getCollidingSubMeshCandidates to their default function
  99167. */
  99168. setDefaultCandidateProviders(): void;
  99169. /**
  99170. * Gets the mesh that is currently under the pointer
  99171. */
  99172. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99173. /**
  99174. * Gets or sets the current on-screen X position of the pointer
  99175. */
  99176. pointerX: number;
  99177. /**
  99178. * Gets or sets the current on-screen Y position of the pointer
  99179. */
  99180. pointerY: number;
  99181. /**
  99182. * Gets the cached material (ie. the latest rendered one)
  99183. * @returns the cached material
  99184. */
  99185. getCachedMaterial(): Nullable<Material>;
  99186. /**
  99187. * Gets the cached effect (ie. the latest rendered one)
  99188. * @returns the cached effect
  99189. */
  99190. getCachedEffect(): Nullable<Effect>;
  99191. /**
  99192. * Gets the cached visibility state (ie. the latest rendered one)
  99193. * @returns the cached visibility state
  99194. */
  99195. getCachedVisibility(): Nullable<number>;
  99196. /**
  99197. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99198. * @param material defines the current material
  99199. * @param effect defines the current effect
  99200. * @param visibility defines the current visibility state
  99201. * @returns true if one parameter is not cached
  99202. */
  99203. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99204. /**
  99205. * Gets the engine associated with the scene
  99206. * @returns an Engine
  99207. */
  99208. getEngine(): Engine;
  99209. /**
  99210. * Gets the total number of vertices rendered per frame
  99211. * @returns the total number of vertices rendered per frame
  99212. */
  99213. getTotalVertices(): number;
  99214. /**
  99215. * Gets the performance counter for total vertices
  99216. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99217. */
  99218. readonly totalVerticesPerfCounter: PerfCounter;
  99219. /**
  99220. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99221. * @returns the total number of active indices rendered per frame
  99222. */
  99223. getActiveIndices(): number;
  99224. /**
  99225. * Gets the performance counter for active indices
  99226. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99227. */
  99228. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99229. /**
  99230. * Gets the total number of active particles rendered per frame
  99231. * @returns the total number of active particles rendered per frame
  99232. */
  99233. getActiveParticles(): number;
  99234. /**
  99235. * Gets the performance counter for active particles
  99236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99237. */
  99238. readonly activeParticlesPerfCounter: PerfCounter;
  99239. /**
  99240. * Gets the total number of active bones rendered per frame
  99241. * @returns the total number of active bones rendered per frame
  99242. */
  99243. getActiveBones(): number;
  99244. /**
  99245. * Gets the performance counter for active bones
  99246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99247. */
  99248. readonly activeBonesPerfCounter: PerfCounter;
  99249. /**
  99250. * Gets the array of active meshes
  99251. * @returns an array of AbstractMesh
  99252. */
  99253. getActiveMeshes(): SmartArray<AbstractMesh>;
  99254. /**
  99255. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99256. * @returns a number
  99257. */
  99258. getAnimationRatio(): number;
  99259. /**
  99260. * Gets an unique Id for the current render phase
  99261. * @returns a number
  99262. */
  99263. getRenderId(): number;
  99264. /**
  99265. * Gets an unique Id for the current frame
  99266. * @returns a number
  99267. */
  99268. getFrameId(): number;
  99269. /** Call this function if you want to manually increment the render Id*/
  99270. incrementRenderId(): void;
  99271. private _createUbo;
  99272. /**
  99273. * Use this method to simulate a pointer move on a mesh
  99274. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99275. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99276. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99277. * @returns the current scene
  99278. */
  99279. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99280. /**
  99281. * Use this method to simulate a pointer down on a mesh
  99282. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99283. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99284. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99285. * @returns the current scene
  99286. */
  99287. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99288. /**
  99289. * Use this method to simulate a pointer up on a mesh
  99290. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99291. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99292. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99293. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99294. * @returns the current scene
  99295. */
  99296. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99297. /**
  99298. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99299. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99300. * @returns true if the pointer was captured
  99301. */
  99302. isPointerCaptured(pointerId?: number): boolean;
  99303. /**
  99304. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99305. * @param attachUp defines if you want to attach events to pointerup
  99306. * @param attachDown defines if you want to attach events to pointerdown
  99307. * @param attachMove defines if you want to attach events to pointermove
  99308. */
  99309. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99310. /** Detaches all event handlers*/
  99311. detachControl(): void;
  99312. /**
  99313. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99314. * Delay loaded resources are not taking in account
  99315. * @return true if all required resources are ready
  99316. */
  99317. isReady(): boolean;
  99318. /** Resets all cached information relative to material (including effect and visibility) */
  99319. resetCachedMaterial(): void;
  99320. /**
  99321. * Registers a function to be called before every frame render
  99322. * @param func defines the function to register
  99323. */
  99324. registerBeforeRender(func: () => void): void;
  99325. /**
  99326. * Unregisters a function called before every frame render
  99327. * @param func defines the function to unregister
  99328. */
  99329. unregisterBeforeRender(func: () => void): void;
  99330. /**
  99331. * Registers a function to be called after every frame render
  99332. * @param func defines the function to register
  99333. */
  99334. registerAfterRender(func: () => void): void;
  99335. /**
  99336. * Unregisters a function called after every frame render
  99337. * @param func defines the function to unregister
  99338. */
  99339. unregisterAfterRender(func: () => void): void;
  99340. private _executeOnceBeforeRender;
  99341. /**
  99342. * The provided function will run before render once and will be disposed afterwards.
  99343. * A timeout delay can be provided so that the function will be executed in N ms.
  99344. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99345. * @param func The function to be executed.
  99346. * @param timeout optional delay in ms
  99347. */
  99348. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99349. /** @hidden */
  99350. _addPendingData(data: any): void;
  99351. /** @hidden */
  99352. _removePendingData(data: any): void;
  99353. /**
  99354. * Returns the number of items waiting to be loaded
  99355. * @returns the number of items waiting to be loaded
  99356. */
  99357. getWaitingItemsCount(): number;
  99358. /**
  99359. * Returns a boolean indicating if the scene is still loading data
  99360. */
  99361. readonly isLoading: boolean;
  99362. /**
  99363. * Registers a function to be executed when the scene is ready
  99364. * @param {Function} func - the function to be executed
  99365. */
  99366. executeWhenReady(func: () => void): void;
  99367. /**
  99368. * Returns a promise that resolves when the scene is ready
  99369. * @returns A promise that resolves when the scene is ready
  99370. */
  99371. whenReadyAsync(): Promise<void>;
  99372. /** @hidden */
  99373. _checkIsReady(): void;
  99374. /**
  99375. * Gets all animatable attached to the scene
  99376. */
  99377. readonly animatables: Animatable[];
  99378. /**
  99379. * Resets the last animation time frame.
  99380. * Useful to override when animations start running when loading a scene for the first time.
  99381. */
  99382. resetLastAnimationTimeFrame(): void;
  99383. /**
  99384. * Gets the current view matrix
  99385. * @returns a Matrix
  99386. */
  99387. getViewMatrix(): Matrix;
  99388. /**
  99389. * Gets the current projection matrix
  99390. * @returns a Matrix
  99391. */
  99392. getProjectionMatrix(): Matrix;
  99393. /**
  99394. * Gets the current transform matrix
  99395. * @returns a Matrix made of View * Projection
  99396. */
  99397. getTransformMatrix(): Matrix;
  99398. /**
  99399. * Sets the current transform matrix
  99400. * @param viewL defines the View matrix to use
  99401. * @param projectionL defines the Projection matrix to use
  99402. * @param viewR defines the right View matrix to use (if provided)
  99403. * @param projectionR defines the right Projection matrix to use (if provided)
  99404. */
  99405. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99406. /**
  99407. * Gets the uniform buffer used to store scene data
  99408. * @returns a UniformBuffer
  99409. */
  99410. getSceneUniformBuffer(): UniformBuffer;
  99411. /**
  99412. * Gets an unique (relatively to the current scene) Id
  99413. * @returns an unique number for the scene
  99414. */
  99415. getUniqueId(): number;
  99416. /**
  99417. * Add a mesh to the list of scene's meshes
  99418. * @param newMesh defines the mesh to add
  99419. * @param recursive if all child meshes should also be added to the scene
  99420. */
  99421. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99422. /**
  99423. * Remove a mesh for the list of scene's meshes
  99424. * @param toRemove defines the mesh to remove
  99425. * @param recursive if all child meshes should also be removed from the scene
  99426. * @returns the index where the mesh was in the mesh list
  99427. */
  99428. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99429. /**
  99430. * Add a transform node to the list of scene's transform nodes
  99431. * @param newTransformNode defines the transform node to add
  99432. */
  99433. addTransformNode(newTransformNode: TransformNode): void;
  99434. /**
  99435. * Remove a transform node for the list of scene's transform nodes
  99436. * @param toRemove defines the transform node to remove
  99437. * @returns the index where the transform node was in the transform node list
  99438. */
  99439. removeTransformNode(toRemove: TransformNode): number;
  99440. /**
  99441. * Remove a skeleton for the list of scene's skeletons
  99442. * @param toRemove defines the skeleton to remove
  99443. * @returns the index where the skeleton was in the skeleton list
  99444. */
  99445. removeSkeleton(toRemove: Skeleton): number;
  99446. /**
  99447. * Remove a morph target for the list of scene's morph targets
  99448. * @param toRemove defines the morph target to remove
  99449. * @returns the index where the morph target was in the morph target list
  99450. */
  99451. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99452. /**
  99453. * Remove a light for the list of scene's lights
  99454. * @param toRemove defines the light to remove
  99455. * @returns the index where the light was in the light list
  99456. */
  99457. removeLight(toRemove: Light): number;
  99458. /**
  99459. * Remove a camera for the list of scene's cameras
  99460. * @param toRemove defines the camera to remove
  99461. * @returns the index where the camera was in the camera list
  99462. */
  99463. removeCamera(toRemove: Camera): number;
  99464. /**
  99465. * Remove a particle system for the list of scene's particle systems
  99466. * @param toRemove defines the particle system to remove
  99467. * @returns the index where the particle system was in the particle system list
  99468. */
  99469. removeParticleSystem(toRemove: IParticleSystem): number;
  99470. /**
  99471. * Remove a animation for the list of scene's animations
  99472. * @param toRemove defines the animation to remove
  99473. * @returns the index where the animation was in the animation list
  99474. */
  99475. removeAnimation(toRemove: Animation): number;
  99476. /**
  99477. * Will stop the animation of the given target
  99478. * @param target - the target
  99479. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99480. * @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)
  99481. */
  99482. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99483. /**
  99484. * Removes the given animation group from this scene.
  99485. * @param toRemove The animation group to remove
  99486. * @returns The index of the removed animation group
  99487. */
  99488. removeAnimationGroup(toRemove: AnimationGroup): number;
  99489. /**
  99490. * Removes the given multi-material from this scene.
  99491. * @param toRemove The multi-material to remove
  99492. * @returns The index of the removed multi-material
  99493. */
  99494. removeMultiMaterial(toRemove: MultiMaterial): number;
  99495. /**
  99496. * Removes the given material from this scene.
  99497. * @param toRemove The material to remove
  99498. * @returns The index of the removed material
  99499. */
  99500. removeMaterial(toRemove: Material): number;
  99501. /**
  99502. * Removes the given action manager from this scene.
  99503. * @param toRemove The action manager to remove
  99504. * @returns The index of the removed action manager
  99505. */
  99506. removeActionManager(toRemove: AbstractActionManager): number;
  99507. /**
  99508. * Removes the given texture from this scene.
  99509. * @param toRemove The texture to remove
  99510. * @returns The index of the removed texture
  99511. */
  99512. removeTexture(toRemove: BaseTexture): number;
  99513. /**
  99514. * Adds the given light to this scene
  99515. * @param newLight The light to add
  99516. */
  99517. addLight(newLight: Light): void;
  99518. /**
  99519. * Sorts the list list based on light priorities
  99520. */
  99521. sortLightsByPriority(): void;
  99522. /**
  99523. * Adds the given camera to this scene
  99524. * @param newCamera The camera to add
  99525. */
  99526. addCamera(newCamera: Camera): void;
  99527. /**
  99528. * Adds the given skeleton to this scene
  99529. * @param newSkeleton The skeleton to add
  99530. */
  99531. addSkeleton(newSkeleton: Skeleton): void;
  99532. /**
  99533. * Adds the given particle system to this scene
  99534. * @param newParticleSystem The particle system to add
  99535. */
  99536. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99537. /**
  99538. * Adds the given animation to this scene
  99539. * @param newAnimation The animation to add
  99540. */
  99541. addAnimation(newAnimation: Animation): void;
  99542. /**
  99543. * Adds the given animation group to this scene.
  99544. * @param newAnimationGroup The animation group to add
  99545. */
  99546. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99547. /**
  99548. * Adds the given multi-material to this scene
  99549. * @param newMultiMaterial The multi-material to add
  99550. */
  99551. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99552. /**
  99553. * Adds the given material to this scene
  99554. * @param newMaterial The material to add
  99555. */
  99556. addMaterial(newMaterial: Material): void;
  99557. /**
  99558. * Adds the given morph target to this scene
  99559. * @param newMorphTargetManager The morph target to add
  99560. */
  99561. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99562. /**
  99563. * Adds the given geometry to this scene
  99564. * @param newGeometry The geometry to add
  99565. */
  99566. addGeometry(newGeometry: Geometry): void;
  99567. /**
  99568. * Adds the given action manager to this scene
  99569. * @param newActionManager The action manager to add
  99570. */
  99571. addActionManager(newActionManager: AbstractActionManager): void;
  99572. /**
  99573. * Adds the given texture to this scene.
  99574. * @param newTexture The texture to add
  99575. */
  99576. addTexture(newTexture: BaseTexture): void;
  99577. /**
  99578. * Switch active camera
  99579. * @param newCamera defines the new active camera
  99580. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99581. */
  99582. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99583. /**
  99584. * sets the active camera of the scene using its ID
  99585. * @param id defines the camera's ID
  99586. * @return the new active camera or null if none found.
  99587. */
  99588. setActiveCameraByID(id: string): Nullable<Camera>;
  99589. /**
  99590. * sets the active camera of the scene using its name
  99591. * @param name defines the camera's name
  99592. * @returns the new active camera or null if none found.
  99593. */
  99594. setActiveCameraByName(name: string): Nullable<Camera>;
  99595. /**
  99596. * get an animation group using its name
  99597. * @param name defines the material's name
  99598. * @return the animation group or null if none found.
  99599. */
  99600. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99601. /**
  99602. * Get a material using its unique id
  99603. * @param uniqueId defines the material's unique id
  99604. * @return the material or null if none found.
  99605. */
  99606. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99607. /**
  99608. * get a material using its id
  99609. * @param id defines the material's ID
  99610. * @return the material or null if none found.
  99611. */
  99612. getMaterialByID(id: string): Nullable<Material>;
  99613. /**
  99614. * Gets a the last added material using a given id
  99615. * @param id defines the material's ID
  99616. * @return the last material with the given id or null if none found.
  99617. */
  99618. getLastMaterialByID(id: string): Nullable<Material>;
  99619. /**
  99620. * Gets a material using its name
  99621. * @param name defines the material's name
  99622. * @return the material or null if none found.
  99623. */
  99624. getMaterialByName(name: string): Nullable<Material>;
  99625. /**
  99626. * Get a texture using its unique id
  99627. * @param uniqueId defines the texture's unique id
  99628. * @return the texture or null if none found.
  99629. */
  99630. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99631. /**
  99632. * Gets a camera using its id
  99633. * @param id defines the id to look for
  99634. * @returns the camera or null if not found
  99635. */
  99636. getCameraByID(id: string): Nullable<Camera>;
  99637. /**
  99638. * Gets a camera using its unique id
  99639. * @param uniqueId defines the unique id to look for
  99640. * @returns the camera or null if not found
  99641. */
  99642. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99643. /**
  99644. * Gets a camera using its name
  99645. * @param name defines the camera's name
  99646. * @return the camera or null if none found.
  99647. */
  99648. getCameraByName(name: string): Nullable<Camera>;
  99649. /**
  99650. * Gets a bone using its id
  99651. * @param id defines the bone's id
  99652. * @return the bone or null if not found
  99653. */
  99654. getBoneByID(id: string): Nullable<Bone>;
  99655. /**
  99656. * Gets a bone using its id
  99657. * @param name defines the bone's name
  99658. * @return the bone or null if not found
  99659. */
  99660. getBoneByName(name: string): Nullable<Bone>;
  99661. /**
  99662. * Gets a light node using its name
  99663. * @param name defines the the light's name
  99664. * @return the light or null if none found.
  99665. */
  99666. getLightByName(name: string): Nullable<Light>;
  99667. /**
  99668. * Gets a light node using its id
  99669. * @param id defines the light's id
  99670. * @return the light or null if none found.
  99671. */
  99672. getLightByID(id: string): Nullable<Light>;
  99673. /**
  99674. * Gets a light node using its scene-generated unique ID
  99675. * @param uniqueId defines the light's unique id
  99676. * @return the light or null if none found.
  99677. */
  99678. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99679. /**
  99680. * Gets a particle system by id
  99681. * @param id defines the particle system id
  99682. * @return the corresponding system or null if none found
  99683. */
  99684. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99685. /**
  99686. * Gets a geometry using its ID
  99687. * @param id defines the geometry's id
  99688. * @return the geometry or null if none found.
  99689. */
  99690. getGeometryByID(id: string): Nullable<Geometry>;
  99691. private _getGeometryByUniqueID;
  99692. /**
  99693. * Add a new geometry to this scene
  99694. * @param geometry defines the geometry to be added to the scene.
  99695. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99696. * @return a boolean defining if the geometry was added or not
  99697. */
  99698. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99699. /**
  99700. * Removes an existing geometry
  99701. * @param geometry defines the geometry to be removed from the scene
  99702. * @return a boolean defining if the geometry was removed or not
  99703. */
  99704. removeGeometry(geometry: Geometry): boolean;
  99705. /**
  99706. * Gets the list of geometries attached to the scene
  99707. * @returns an array of Geometry
  99708. */
  99709. getGeometries(): Geometry[];
  99710. /**
  99711. * Gets the first added mesh found of a given ID
  99712. * @param id defines the id to search for
  99713. * @return the mesh found or null if not found at all
  99714. */
  99715. getMeshByID(id: string): Nullable<AbstractMesh>;
  99716. /**
  99717. * Gets a list of meshes using their id
  99718. * @param id defines the id to search for
  99719. * @returns a list of meshes
  99720. */
  99721. getMeshesByID(id: string): Array<AbstractMesh>;
  99722. /**
  99723. * Gets the first added transform node found of a given ID
  99724. * @param id defines the id to search for
  99725. * @return the found transform node or null if not found at all.
  99726. */
  99727. getTransformNodeByID(id: string): Nullable<TransformNode>;
  99728. /**
  99729. * Gets a transform node with its auto-generated unique id
  99730. * @param uniqueId efines the unique id to search for
  99731. * @return the found transform node or null if not found at all.
  99732. */
  99733. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  99734. /**
  99735. * Gets a list of transform nodes using their id
  99736. * @param id defines the id to search for
  99737. * @returns a list of transform nodes
  99738. */
  99739. getTransformNodesByID(id: string): Array<TransformNode>;
  99740. /**
  99741. * Gets a mesh with its auto-generated unique id
  99742. * @param uniqueId defines the unique id to search for
  99743. * @return the found mesh or null if not found at all.
  99744. */
  99745. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  99746. /**
  99747. * Gets a the last added mesh using a given id
  99748. * @param id defines the id to search for
  99749. * @return the found mesh or null if not found at all.
  99750. */
  99751. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  99752. /**
  99753. * Gets a the last added node (Mesh, Camera, Light) using a given id
  99754. * @param id defines the id to search for
  99755. * @return the found node or null if not found at all
  99756. */
  99757. getLastEntryByID(id: string): Nullable<Node>;
  99758. /**
  99759. * Gets a node (Mesh, Camera, Light) using a given id
  99760. * @param id defines the id to search for
  99761. * @return the found node or null if not found at all
  99762. */
  99763. getNodeByID(id: string): Nullable<Node>;
  99764. /**
  99765. * Gets a node (Mesh, Camera, Light) using a given name
  99766. * @param name defines the name to search for
  99767. * @return the found node or null if not found at all.
  99768. */
  99769. getNodeByName(name: string): Nullable<Node>;
  99770. /**
  99771. * Gets a mesh using a given name
  99772. * @param name defines the name to search for
  99773. * @return the found mesh or null if not found at all.
  99774. */
  99775. getMeshByName(name: string): Nullable<AbstractMesh>;
  99776. /**
  99777. * Gets a transform node using a given name
  99778. * @param name defines the name to search for
  99779. * @return the found transform node or null if not found at all.
  99780. */
  99781. getTransformNodeByName(name: string): Nullable<TransformNode>;
  99782. /**
  99783. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  99784. * @param id defines the id to search for
  99785. * @return the found skeleton or null if not found at all.
  99786. */
  99787. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  99788. /**
  99789. * Gets a skeleton using a given auto generated unique id
  99790. * @param uniqueId defines the unique id to search for
  99791. * @return the found skeleton or null if not found at all.
  99792. */
  99793. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  99794. /**
  99795. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  99796. * @param id defines the id to search for
  99797. * @return the found skeleton or null if not found at all.
  99798. */
  99799. getSkeletonById(id: string): Nullable<Skeleton>;
  99800. /**
  99801. * Gets a skeleton using a given name
  99802. * @param name defines the name to search for
  99803. * @return the found skeleton or null if not found at all.
  99804. */
  99805. getSkeletonByName(name: string): Nullable<Skeleton>;
  99806. /**
  99807. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  99808. * @param id defines the id to search for
  99809. * @return the found morph target manager or null if not found at all.
  99810. */
  99811. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  99812. /**
  99813. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  99814. * @param id defines the id to search for
  99815. * @return the found morph target or null if not found at all.
  99816. */
  99817. getMorphTargetById(id: string): Nullable<MorphTarget>;
  99818. /**
  99819. * Gets a boolean indicating if the given mesh is active
  99820. * @param mesh defines the mesh to look for
  99821. * @returns true if the mesh is in the active list
  99822. */
  99823. isActiveMesh(mesh: AbstractMesh): boolean;
  99824. /**
  99825. * Return a unique id as a string which can serve as an identifier for the scene
  99826. */
  99827. readonly uid: string;
  99828. /**
  99829. * Add an externaly attached data from its key.
  99830. * This method call will fail and return false, if such key already exists.
  99831. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  99832. * @param key the unique key that identifies the data
  99833. * @param data the data object to associate to the key for this Engine instance
  99834. * @return true if no such key were already present and the data was added successfully, false otherwise
  99835. */
  99836. addExternalData<T>(key: string, data: T): boolean;
  99837. /**
  99838. * Get an externaly attached data from its key
  99839. * @param key the unique key that identifies the data
  99840. * @return the associated data, if present (can be null), or undefined if not present
  99841. */
  99842. getExternalData<T>(key: string): Nullable<T>;
  99843. /**
  99844. * Get an externaly attached data from its key, create it using a factory if it's not already present
  99845. * @param key the unique key that identifies the data
  99846. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  99847. * @return the associated data, can be null if the factory returned null.
  99848. */
  99849. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  99850. /**
  99851. * Remove an externaly attached data from the Engine instance
  99852. * @param key the unique key that identifies the data
  99853. * @return true if the data was successfully removed, false if it doesn't exist
  99854. */
  99855. removeExternalData(key: string): boolean;
  99856. private _evaluateSubMesh;
  99857. /**
  99858. * Clear the processed materials smart array preventing retention point in material dispose.
  99859. */
  99860. freeProcessedMaterials(): void;
  99861. private _preventFreeActiveMeshesAndRenderingGroups;
  99862. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  99863. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  99864. * when disposing several meshes in a row or a hierarchy of meshes.
  99865. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  99866. */
  99867. blockfreeActiveMeshesAndRenderingGroups: boolean;
  99868. /**
  99869. * Clear the active meshes smart array preventing retention point in mesh dispose.
  99870. */
  99871. freeActiveMeshes(): void;
  99872. /**
  99873. * Clear the info related to rendering groups preventing retention points during dispose.
  99874. */
  99875. freeRenderingGroups(): void;
  99876. /** @hidden */
  99877. _isInIntermediateRendering(): boolean;
  99878. /**
  99879. * Lambda returning the list of potentially active meshes.
  99880. */
  99881. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  99882. /**
  99883. * Lambda returning the list of potentially active sub meshes.
  99884. */
  99885. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  99886. /**
  99887. * Lambda returning the list of potentially intersecting sub meshes.
  99888. */
  99889. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  99890. /**
  99891. * Lambda returning the list of potentially colliding sub meshes.
  99892. */
  99893. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  99894. private _activeMeshesFrozen;
  99895. /**
  99896. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  99897. * @returns the current scene
  99898. */
  99899. freezeActiveMeshes(): Scene;
  99900. /**
  99901. * Use this function to restart evaluating active meshes on every frame
  99902. * @returns the current scene
  99903. */
  99904. unfreezeActiveMeshes(): Scene;
  99905. private _evaluateActiveMeshes;
  99906. private _activeMesh;
  99907. /**
  99908. * Update the transform matrix to update from the current active camera
  99909. * @param force defines a boolean used to force the update even if cache is up to date
  99910. */
  99911. updateTransformMatrix(force?: boolean): void;
  99912. private _bindFrameBuffer;
  99913. /** @hidden */
  99914. _allowPostProcessClearColor: boolean;
  99915. /** @hidden */
  99916. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  99917. private _processSubCameras;
  99918. private _checkIntersections;
  99919. /** @hidden */
  99920. _advancePhysicsEngineStep(step: number): void;
  99921. /**
  99922. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  99923. */
  99924. getDeterministicFrameTime: () => number;
  99925. /** @hidden */
  99926. _animate(): void;
  99927. /** Execute all animations (for a frame) */
  99928. animate(): void;
  99929. /**
  99930. * Render the scene
  99931. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  99932. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  99933. */
  99934. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  99935. /**
  99936. * Freeze all materials
  99937. * A frozen material will not be updatable but should be faster to render
  99938. */
  99939. freezeMaterials(): void;
  99940. /**
  99941. * Unfreeze all materials
  99942. * A frozen material will not be updatable but should be faster to render
  99943. */
  99944. unfreezeMaterials(): void;
  99945. /**
  99946. * Releases all held ressources
  99947. */
  99948. dispose(): void;
  99949. /**
  99950. * Gets if the scene is already disposed
  99951. */
  99952. readonly isDisposed: boolean;
  99953. /**
  99954. * Call this function to reduce memory footprint of the scene.
  99955. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  99956. */
  99957. clearCachedVertexData(): void;
  99958. /**
  99959. * This function will remove the local cached buffer data from texture.
  99960. * It will save memory but will prevent the texture from being rebuilt
  99961. */
  99962. cleanCachedTextureBuffer(): void;
  99963. /**
  99964. * Get the world extend vectors with an optional filter
  99965. *
  99966. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  99967. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  99968. */
  99969. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  99970. min: Vector3;
  99971. max: Vector3;
  99972. };
  99973. /**
  99974. * Creates a ray that can be used to pick in the scene
  99975. * @param x defines the x coordinate of the origin (on-screen)
  99976. * @param y defines the y coordinate of the origin (on-screen)
  99977. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99978. * @param camera defines the camera to use for the picking
  99979. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99980. * @returns a Ray
  99981. */
  99982. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  99983. /**
  99984. * Creates a ray that can be used to pick in the scene
  99985. * @param x defines the x coordinate of the origin (on-screen)
  99986. * @param y defines the y coordinate of the origin (on-screen)
  99987. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  99988. * @param result defines the ray where to store the picking ray
  99989. * @param camera defines the camera to use for the picking
  99990. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  99991. * @returns the current scene
  99992. */
  99993. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  99994. /**
  99995. * Creates a ray that can be used to pick in the scene
  99996. * @param x defines the x coordinate of the origin (on-screen)
  99997. * @param y defines the y coordinate of the origin (on-screen)
  99998. * @param camera defines the camera to use for the picking
  99999. * @returns a Ray
  100000. */
  100001. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100002. /**
  100003. * Creates a ray that can be used to pick in the scene
  100004. * @param x defines the x coordinate of the origin (on-screen)
  100005. * @param y defines the y coordinate of the origin (on-screen)
  100006. * @param result defines the ray where to store the picking ray
  100007. * @param camera defines the camera to use for the picking
  100008. * @returns the current scene
  100009. */
  100010. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100011. /** Launch a ray to try to pick a mesh in the scene
  100012. * @param x position on screen
  100013. * @param y position on screen
  100014. * @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
  100015. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100016. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100017. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100018. * @returns a PickingInfo
  100019. */
  100020. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100021. /** Use the given ray to pick a mesh in the scene
  100022. * @param ray The ray to use to pick meshes
  100023. * @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
  100024. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100025. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100026. * @returns a PickingInfo
  100027. */
  100028. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100029. /**
  100030. * Launch a ray to try to pick a mesh in the scene
  100031. * @param x X position on screen
  100032. * @param y Y position on screen
  100033. * @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
  100034. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100035. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100036. * @returns an array of PickingInfo
  100037. */
  100038. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100039. /**
  100040. * Launch a ray to try to pick a mesh in the scene
  100041. * @param ray Ray to use
  100042. * @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
  100043. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100044. * @returns an array of PickingInfo
  100045. */
  100046. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100047. /**
  100048. * Force the value of meshUnderPointer
  100049. * @param mesh defines the mesh to use
  100050. */
  100051. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100052. /**
  100053. * Gets the mesh under the pointer
  100054. * @returns a Mesh or null if no mesh is under the pointer
  100055. */
  100056. getPointerOverMesh(): Nullable<AbstractMesh>;
  100057. /** @hidden */
  100058. _rebuildGeometries(): void;
  100059. /** @hidden */
  100060. _rebuildTextures(): void;
  100061. private _getByTags;
  100062. /**
  100063. * Get a list of meshes by tags
  100064. * @param tagsQuery defines the tags query to use
  100065. * @param forEach defines a predicate used to filter results
  100066. * @returns an array of Mesh
  100067. */
  100068. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100069. /**
  100070. * Get a list of cameras by tags
  100071. * @param tagsQuery defines the tags query to use
  100072. * @param forEach defines a predicate used to filter results
  100073. * @returns an array of Camera
  100074. */
  100075. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100076. /**
  100077. * Get a list of lights by tags
  100078. * @param tagsQuery defines the tags query to use
  100079. * @param forEach defines a predicate used to filter results
  100080. * @returns an array of Light
  100081. */
  100082. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100083. /**
  100084. * Get a list of materials by tags
  100085. * @param tagsQuery defines the tags query to use
  100086. * @param forEach defines a predicate used to filter results
  100087. * @returns an array of Material
  100088. */
  100089. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100090. /**
  100091. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100092. * This allowed control for front to back rendering or reversly depending of the special needs.
  100093. *
  100094. * @param renderingGroupId The rendering group id corresponding to its index
  100095. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100096. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100097. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100098. */
  100099. 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;
  100100. /**
  100101. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100102. *
  100103. * @param renderingGroupId The rendering group id corresponding to its index
  100104. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100105. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100106. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100107. */
  100108. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100109. /**
  100110. * Gets the current auto clear configuration for one rendering group of the rendering
  100111. * manager.
  100112. * @param index the rendering group index to get the information for
  100113. * @returns The auto clear setup for the requested rendering group
  100114. */
  100115. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100116. private _blockMaterialDirtyMechanism;
  100117. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100118. blockMaterialDirtyMechanism: boolean;
  100119. /**
  100120. * Will flag all materials as dirty to trigger new shader compilation
  100121. * @param flag defines the flag used to specify which material part must be marked as dirty
  100122. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100123. */
  100124. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100125. /** @hidden */
  100126. _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;
  100127. /** @hidden */
  100128. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100129. }
  100130. }
  100131. declare module BABYLON {
  100132. /**
  100133. * Set of assets to keep when moving a scene into an asset container.
  100134. */
  100135. export class KeepAssets extends AbstractScene {
  100136. }
  100137. /**
  100138. * Container with a set of assets that can be added or removed from a scene.
  100139. */
  100140. export class AssetContainer extends AbstractScene {
  100141. /**
  100142. * The scene the AssetContainer belongs to.
  100143. */
  100144. scene: Scene;
  100145. /**
  100146. * Instantiates an AssetContainer.
  100147. * @param scene The scene the AssetContainer belongs to.
  100148. */
  100149. constructor(scene: Scene);
  100150. /**
  100151. * Adds all the assets from the container to the scene.
  100152. */
  100153. addAllToScene(): void;
  100154. /**
  100155. * Removes all the assets in the container from the scene
  100156. */
  100157. removeAllFromScene(): void;
  100158. /**
  100159. * Disposes all the assets in the container
  100160. */
  100161. dispose(): void;
  100162. private _moveAssets;
  100163. /**
  100164. * Removes all the assets contained in the scene and adds them to the container.
  100165. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100166. */
  100167. moveAllFromScene(keepAssets?: KeepAssets): void;
  100168. /**
  100169. * 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.
  100170. * @returns the root mesh
  100171. */
  100172. createRootMesh(): Mesh;
  100173. }
  100174. }
  100175. declare module BABYLON {
  100176. /**
  100177. * Defines how the parser contract is defined.
  100178. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100179. */
  100180. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100181. /**
  100182. * Defines how the individual parser contract is defined.
  100183. * These parser can parse an individual asset
  100184. */
  100185. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100186. /**
  100187. * Base class of the scene acting as a container for the different elements composing a scene.
  100188. * This class is dynamically extended by the different components of the scene increasing
  100189. * flexibility and reducing coupling
  100190. */
  100191. export abstract class AbstractScene {
  100192. /**
  100193. * Stores the list of available parsers in the application.
  100194. */
  100195. private static _BabylonFileParsers;
  100196. /**
  100197. * Stores the list of available individual parsers in the application.
  100198. */
  100199. private static _IndividualBabylonFileParsers;
  100200. /**
  100201. * Adds a parser in the list of available ones
  100202. * @param name Defines the name of the parser
  100203. * @param parser Defines the parser to add
  100204. */
  100205. static AddParser(name: string, parser: BabylonFileParser): void;
  100206. /**
  100207. * Gets a general parser from the list of avaialble ones
  100208. * @param name Defines the name of the parser
  100209. * @returns the requested parser or null
  100210. */
  100211. static GetParser(name: string): Nullable<BabylonFileParser>;
  100212. /**
  100213. * Adds n individual parser in the list of available ones
  100214. * @param name Defines the name of the parser
  100215. * @param parser Defines the parser to add
  100216. */
  100217. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100218. /**
  100219. * Gets an individual parser from the list of avaialble ones
  100220. * @param name Defines the name of the parser
  100221. * @returns the requested parser or null
  100222. */
  100223. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100224. /**
  100225. * Parser json data and populate both a scene and its associated container object
  100226. * @param jsonData Defines the data to parse
  100227. * @param scene Defines the scene to parse the data for
  100228. * @param container Defines the container attached to the parsing sequence
  100229. * @param rootUrl Defines the root url of the data
  100230. */
  100231. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100232. /**
  100233. * Gets the list of root nodes (ie. nodes with no parent)
  100234. */
  100235. rootNodes: Node[];
  100236. /** All of the cameras added to this scene
  100237. * @see http://doc.babylonjs.com/babylon101/cameras
  100238. */
  100239. cameras: Camera[];
  100240. /**
  100241. * All of the lights added to this scene
  100242. * @see http://doc.babylonjs.com/babylon101/lights
  100243. */
  100244. lights: Light[];
  100245. /**
  100246. * All of the (abstract) meshes added to this scene
  100247. */
  100248. meshes: AbstractMesh[];
  100249. /**
  100250. * The list of skeletons added to the scene
  100251. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100252. */
  100253. skeletons: Skeleton[];
  100254. /**
  100255. * All of the particle systems added to this scene
  100256. * @see http://doc.babylonjs.com/babylon101/particles
  100257. */
  100258. particleSystems: IParticleSystem[];
  100259. /**
  100260. * Gets a list of Animations associated with the scene
  100261. */
  100262. animations: Animation[];
  100263. /**
  100264. * All of the animation groups added to this scene
  100265. * @see http://doc.babylonjs.com/how_to/group
  100266. */
  100267. animationGroups: AnimationGroup[];
  100268. /**
  100269. * All of the multi-materials added to this scene
  100270. * @see http://doc.babylonjs.com/how_to/multi_materials
  100271. */
  100272. multiMaterials: MultiMaterial[];
  100273. /**
  100274. * All of the materials added to this scene
  100275. * In the context of a Scene, it is not supposed to be modified manually.
  100276. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100277. * Note also that the order of the Material wihin the array is not significant and might change.
  100278. * @see http://doc.babylonjs.com/babylon101/materials
  100279. */
  100280. materials: Material[];
  100281. /**
  100282. * The list of morph target managers added to the scene
  100283. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100284. */
  100285. morphTargetManagers: MorphTargetManager[];
  100286. /**
  100287. * The list of geometries used in the scene.
  100288. */
  100289. geometries: Geometry[];
  100290. /**
  100291. * All of the tranform nodes added to this scene
  100292. * In the context of a Scene, it is not supposed to be modified manually.
  100293. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100294. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100295. * @see http://doc.babylonjs.com/how_to/transformnode
  100296. */
  100297. transformNodes: TransformNode[];
  100298. /**
  100299. * ActionManagers available on the scene.
  100300. */
  100301. actionManagers: AbstractActionManager[];
  100302. /**
  100303. * Textures to keep.
  100304. */
  100305. textures: BaseTexture[];
  100306. /**
  100307. * Environment texture for the scene
  100308. */
  100309. environmentTexture: Nullable<BaseTexture>;
  100310. }
  100311. }
  100312. declare module BABYLON {
  100313. /**
  100314. * Interface used to define options for Sound class
  100315. */
  100316. export interface ISoundOptions {
  100317. /**
  100318. * Does the sound autoplay once loaded.
  100319. */
  100320. autoplay?: boolean;
  100321. /**
  100322. * Does the sound loop after it finishes playing once.
  100323. */
  100324. loop?: boolean;
  100325. /**
  100326. * Sound's volume
  100327. */
  100328. volume?: number;
  100329. /**
  100330. * Is it a spatial sound?
  100331. */
  100332. spatialSound?: boolean;
  100333. /**
  100334. * Maximum distance to hear that sound
  100335. */
  100336. maxDistance?: number;
  100337. /**
  100338. * Uses user defined attenuation function
  100339. */
  100340. useCustomAttenuation?: boolean;
  100341. /**
  100342. * Define the roll off factor of spatial sounds.
  100343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100344. */
  100345. rolloffFactor?: number;
  100346. /**
  100347. * Define the reference distance the sound should be heard perfectly.
  100348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100349. */
  100350. refDistance?: number;
  100351. /**
  100352. * Define the distance attenuation model the sound will follow.
  100353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100354. */
  100355. distanceModel?: string;
  100356. /**
  100357. * Defines the playback speed (1 by default)
  100358. */
  100359. playbackRate?: number;
  100360. /**
  100361. * Defines if the sound is from a streaming source
  100362. */
  100363. streaming?: boolean;
  100364. /**
  100365. * Defines an optional length (in seconds) inside the sound file
  100366. */
  100367. length?: number;
  100368. /**
  100369. * Defines an optional offset (in seconds) inside the sound file
  100370. */
  100371. offset?: number;
  100372. /**
  100373. * If true, URLs will not be required to state the audio file codec to use.
  100374. */
  100375. skipCodecCheck?: boolean;
  100376. }
  100377. /**
  100378. * Defines a sound that can be played in the application.
  100379. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100381. */
  100382. export class Sound {
  100383. /**
  100384. * The name of the sound in the scene.
  100385. */
  100386. name: string;
  100387. /**
  100388. * Does the sound autoplay once loaded.
  100389. */
  100390. autoplay: boolean;
  100391. /**
  100392. * Does the sound loop after it finishes playing once.
  100393. */
  100394. loop: boolean;
  100395. /**
  100396. * Does the sound use a custom attenuation curve to simulate the falloff
  100397. * happening when the source gets further away from the camera.
  100398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100399. */
  100400. useCustomAttenuation: boolean;
  100401. /**
  100402. * The sound track id this sound belongs to.
  100403. */
  100404. soundTrackId: number;
  100405. /**
  100406. * Is this sound currently played.
  100407. */
  100408. isPlaying: boolean;
  100409. /**
  100410. * Is this sound currently paused.
  100411. */
  100412. isPaused: boolean;
  100413. /**
  100414. * Does this sound enables spatial sound.
  100415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100416. */
  100417. spatialSound: boolean;
  100418. /**
  100419. * Define the reference distance the sound should be heard perfectly.
  100420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100421. */
  100422. refDistance: number;
  100423. /**
  100424. * Define the roll off factor of spatial sounds.
  100425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100426. */
  100427. rolloffFactor: number;
  100428. /**
  100429. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100431. */
  100432. maxDistance: number;
  100433. /**
  100434. * Define the distance attenuation model the sound will follow.
  100435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100436. */
  100437. distanceModel: string;
  100438. /**
  100439. * @hidden
  100440. * Back Compat
  100441. **/
  100442. onended: () => any;
  100443. /**
  100444. * Observable event when the current playing sound finishes.
  100445. */
  100446. onEndedObservable: Observable<Sound>;
  100447. private _panningModel;
  100448. private _playbackRate;
  100449. private _streaming;
  100450. private _startTime;
  100451. private _startOffset;
  100452. private _position;
  100453. /** @hidden */
  100454. _positionInEmitterSpace: boolean;
  100455. private _localDirection;
  100456. private _volume;
  100457. private _isReadyToPlay;
  100458. private _isDirectional;
  100459. private _readyToPlayCallback;
  100460. private _audioBuffer;
  100461. private _soundSource;
  100462. private _streamingSource;
  100463. private _soundPanner;
  100464. private _soundGain;
  100465. private _inputAudioNode;
  100466. private _outputAudioNode;
  100467. private _coneInnerAngle;
  100468. private _coneOuterAngle;
  100469. private _coneOuterGain;
  100470. private _scene;
  100471. private _connectedTransformNode;
  100472. private _customAttenuationFunction;
  100473. private _registerFunc;
  100474. private _isOutputConnected;
  100475. private _htmlAudioElement;
  100476. private _urlType;
  100477. private _length?;
  100478. private _offset?;
  100479. /** @hidden */
  100480. static _SceneComponentInitialization: (scene: Scene) => void;
  100481. /**
  100482. * Create a sound and attach it to a scene
  100483. * @param name Name of your sound
  100484. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100485. * @param scene defines the scene the sound belongs to
  100486. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100487. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100488. */
  100489. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100490. /**
  100491. * Release the sound and its associated resources
  100492. */
  100493. dispose(): void;
  100494. /**
  100495. * Gets if the sounds is ready to be played or not.
  100496. * @returns true if ready, otherwise false
  100497. */
  100498. isReady(): boolean;
  100499. private _soundLoaded;
  100500. /**
  100501. * Sets the data of the sound from an audiobuffer
  100502. * @param audioBuffer The audioBuffer containing the data
  100503. */
  100504. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100505. /**
  100506. * Updates the current sounds options such as maxdistance, loop...
  100507. * @param options A JSON object containing values named as the object properties
  100508. */
  100509. updateOptions(options: ISoundOptions): void;
  100510. private _createSpatialParameters;
  100511. private _updateSpatialParameters;
  100512. /**
  100513. * Switch the panning model to HRTF:
  100514. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100516. */
  100517. switchPanningModelToHRTF(): void;
  100518. /**
  100519. * Switch the panning model to Equal Power:
  100520. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100522. */
  100523. switchPanningModelToEqualPower(): void;
  100524. private _switchPanningModel;
  100525. /**
  100526. * Connect this sound to a sound track audio node like gain...
  100527. * @param soundTrackAudioNode the sound track audio node to connect to
  100528. */
  100529. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100530. /**
  100531. * Transform this sound into a directional source
  100532. * @param coneInnerAngle Size of the inner cone in degree
  100533. * @param coneOuterAngle Size of the outer cone in degree
  100534. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100535. */
  100536. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100537. /**
  100538. * Gets or sets the inner angle for the directional cone.
  100539. */
  100540. /**
  100541. * Gets or sets the inner angle for the directional cone.
  100542. */
  100543. directionalConeInnerAngle: number;
  100544. /**
  100545. * Gets or sets the outer angle for the directional cone.
  100546. */
  100547. /**
  100548. * Gets or sets the outer angle for the directional cone.
  100549. */
  100550. directionalConeOuterAngle: number;
  100551. /**
  100552. * Sets the position of the emitter if spatial sound is enabled
  100553. * @param newPosition Defines the new posisiton
  100554. */
  100555. setPosition(newPosition: Vector3): void;
  100556. /**
  100557. * Sets the local direction of the emitter if spatial sound is enabled
  100558. * @param newLocalDirection Defines the new local direction
  100559. */
  100560. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100561. private _updateDirection;
  100562. /** @hidden */
  100563. updateDistanceFromListener(): void;
  100564. /**
  100565. * Sets a new custom attenuation function for the sound.
  100566. * @param callback Defines the function used for the attenuation
  100567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100568. */
  100569. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100570. /**
  100571. * Play the sound
  100572. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100573. * @param offset (optional) Start the sound at a specific time in seconds
  100574. * @param length (optional) Sound duration (in seconds)
  100575. */
  100576. play(time?: number, offset?: number, length?: number): void;
  100577. private _onended;
  100578. /**
  100579. * Stop the sound
  100580. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100581. */
  100582. stop(time?: number): void;
  100583. /**
  100584. * Put the sound in pause
  100585. */
  100586. pause(): void;
  100587. /**
  100588. * Sets a dedicated volume for this sounds
  100589. * @param newVolume Define the new volume of the sound
  100590. * @param time Define time for gradual change to new volume
  100591. */
  100592. setVolume(newVolume: number, time?: number): void;
  100593. /**
  100594. * Set the sound play back rate
  100595. * @param newPlaybackRate Define the playback rate the sound should be played at
  100596. */
  100597. setPlaybackRate(newPlaybackRate: number): void;
  100598. /**
  100599. * Gets the volume of the sound.
  100600. * @returns the volume of the sound
  100601. */
  100602. getVolume(): number;
  100603. /**
  100604. * Attach the sound to a dedicated mesh
  100605. * @param transformNode The transform node to connect the sound with
  100606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100607. */
  100608. attachToMesh(transformNode: TransformNode): void;
  100609. /**
  100610. * Detach the sound from the previously attached mesh
  100611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100612. */
  100613. detachFromMesh(): void;
  100614. private _onRegisterAfterWorldMatrixUpdate;
  100615. /**
  100616. * Clone the current sound in the scene.
  100617. * @returns the new sound clone
  100618. */
  100619. clone(): Nullable<Sound>;
  100620. /**
  100621. * Gets the current underlying audio buffer containing the data
  100622. * @returns the audio buffer
  100623. */
  100624. getAudioBuffer(): Nullable<AudioBuffer>;
  100625. /**
  100626. * Serializes the Sound in a JSON representation
  100627. * @returns the JSON representation of the sound
  100628. */
  100629. serialize(): any;
  100630. /**
  100631. * Parse a JSON representation of a sound to innstantiate in a given scene
  100632. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100633. * @param scene Define the scene the new parsed sound should be created in
  100634. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100635. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100636. * @returns the newly parsed sound
  100637. */
  100638. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100639. }
  100640. }
  100641. declare module BABYLON {
  100642. /**
  100643. * This defines an action helpful to play a defined sound on a triggered action.
  100644. */
  100645. export class PlaySoundAction extends Action {
  100646. private _sound;
  100647. /**
  100648. * Instantiate the action
  100649. * @param triggerOptions defines the trigger options
  100650. * @param sound defines the sound to play
  100651. * @param condition defines the trigger related conditions
  100652. */
  100653. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100654. /** @hidden */
  100655. _prepare(): void;
  100656. /**
  100657. * Execute the action and play the sound.
  100658. */
  100659. execute(): void;
  100660. /**
  100661. * Serializes the actions and its related information.
  100662. * @param parent defines the object to serialize in
  100663. * @returns the serialized object
  100664. */
  100665. serialize(parent: any): any;
  100666. }
  100667. /**
  100668. * This defines an action helpful to stop a defined sound on a triggered action.
  100669. */
  100670. export class StopSoundAction extends Action {
  100671. private _sound;
  100672. /**
  100673. * Instantiate the action
  100674. * @param triggerOptions defines the trigger options
  100675. * @param sound defines the sound to stop
  100676. * @param condition defines the trigger related conditions
  100677. */
  100678. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100679. /** @hidden */
  100680. _prepare(): void;
  100681. /**
  100682. * Execute the action and stop the sound.
  100683. */
  100684. execute(): void;
  100685. /**
  100686. * Serializes the actions and its related information.
  100687. * @param parent defines the object to serialize in
  100688. * @returns the serialized object
  100689. */
  100690. serialize(parent: any): any;
  100691. }
  100692. }
  100693. declare module BABYLON {
  100694. /**
  100695. * This defines an action responsible to change the value of a property
  100696. * by interpolating between its current value and the newly set one once triggered.
  100697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100698. */
  100699. export class InterpolateValueAction extends Action {
  100700. /**
  100701. * Defines the path of the property where the value should be interpolated
  100702. */
  100703. propertyPath: string;
  100704. /**
  100705. * Defines the target value at the end of the interpolation.
  100706. */
  100707. value: any;
  100708. /**
  100709. * Defines the time it will take for the property to interpolate to the value.
  100710. */
  100711. duration: number;
  100712. /**
  100713. * Defines if the other scene animations should be stopped when the action has been triggered
  100714. */
  100715. stopOtherAnimations?: boolean;
  100716. /**
  100717. * Defines a callback raised once the interpolation animation has been done.
  100718. */
  100719. onInterpolationDone?: () => void;
  100720. /**
  100721. * Observable triggered once the interpolation animation has been done.
  100722. */
  100723. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  100724. private _target;
  100725. private _effectiveTarget;
  100726. private _property;
  100727. /**
  100728. * Instantiate the action
  100729. * @param triggerOptions defines the trigger options
  100730. * @param target defines the object containing the value to interpolate
  100731. * @param propertyPath defines the path to the property in the target object
  100732. * @param value defines the target value at the end of the interpolation
  100733. * @param duration deines the time it will take for the property to interpolate to the value.
  100734. * @param condition defines the trigger related conditions
  100735. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  100736. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  100737. */
  100738. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  100739. /** @hidden */
  100740. _prepare(): void;
  100741. /**
  100742. * Execute the action starts the value interpolation.
  100743. */
  100744. execute(): void;
  100745. /**
  100746. * Serializes the actions and its related information.
  100747. * @param parent defines the object to serialize in
  100748. * @returns the serialized object
  100749. */
  100750. serialize(parent: any): any;
  100751. }
  100752. }
  100753. declare module BABYLON {
  100754. /**
  100755. * Options allowed during the creation of a sound track.
  100756. */
  100757. export interface ISoundTrackOptions {
  100758. /**
  100759. * The volume the sound track should take during creation
  100760. */
  100761. volume?: number;
  100762. /**
  100763. * Define if the sound track is the main sound track of the scene
  100764. */
  100765. mainTrack?: boolean;
  100766. }
  100767. /**
  100768. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  100769. * It will be also used in a future release to apply effects on a specific track.
  100770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100771. */
  100772. export class SoundTrack {
  100773. /**
  100774. * The unique identifier of the sound track in the scene.
  100775. */
  100776. id: number;
  100777. /**
  100778. * The list of sounds included in the sound track.
  100779. */
  100780. soundCollection: Array<Sound>;
  100781. private _outputAudioNode;
  100782. private _scene;
  100783. private _isMainTrack;
  100784. private _connectedAnalyser;
  100785. private _options;
  100786. private _isInitialized;
  100787. /**
  100788. * Creates a new sound track.
  100789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  100790. * @param scene Define the scene the sound track belongs to
  100791. * @param options
  100792. */
  100793. constructor(scene: Scene, options?: ISoundTrackOptions);
  100794. private _initializeSoundTrackAudioGraph;
  100795. /**
  100796. * Release the sound track and its associated resources
  100797. */
  100798. dispose(): void;
  100799. /**
  100800. * Adds a sound to this sound track
  100801. * @param sound define the cound to add
  100802. * @ignoreNaming
  100803. */
  100804. AddSound(sound: Sound): void;
  100805. /**
  100806. * Removes a sound to this sound track
  100807. * @param sound define the cound to remove
  100808. * @ignoreNaming
  100809. */
  100810. RemoveSound(sound: Sound): void;
  100811. /**
  100812. * Set a global volume for the full sound track.
  100813. * @param newVolume Define the new volume of the sound track
  100814. */
  100815. setVolume(newVolume: number): void;
  100816. /**
  100817. * Switch the panning model to HRTF:
  100818. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100820. */
  100821. switchPanningModelToHRTF(): void;
  100822. /**
  100823. * Switch the panning model to Equal Power:
  100824. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100826. */
  100827. switchPanningModelToEqualPower(): void;
  100828. /**
  100829. * Connect the sound track to an audio analyser allowing some amazing
  100830. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100832. * @param analyser The analyser to connect to the engine
  100833. */
  100834. connectToAnalyser(analyser: Analyser): void;
  100835. }
  100836. }
  100837. declare module BABYLON {
  100838. interface AbstractScene {
  100839. /**
  100840. * The list of sounds used in the scene.
  100841. */
  100842. sounds: Nullable<Array<Sound>>;
  100843. }
  100844. interface Scene {
  100845. /**
  100846. * @hidden
  100847. * Backing field
  100848. */
  100849. _mainSoundTrack: SoundTrack;
  100850. /**
  100851. * The main sound track played by the scene.
  100852. * It cotains your primary collection of sounds.
  100853. */
  100854. mainSoundTrack: SoundTrack;
  100855. /**
  100856. * The list of sound tracks added to the scene
  100857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100858. */
  100859. soundTracks: Nullable<Array<SoundTrack>>;
  100860. /**
  100861. * Gets a sound using a given name
  100862. * @param name defines the name to search for
  100863. * @return the found sound or null if not found at all.
  100864. */
  100865. getSoundByName(name: string): Nullable<Sound>;
  100866. /**
  100867. * Gets or sets if audio support is enabled
  100868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100869. */
  100870. audioEnabled: boolean;
  100871. /**
  100872. * Gets or sets if audio will be output to headphones
  100873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100874. */
  100875. headphone: boolean;
  100876. /**
  100877. * Gets or sets custom audio listener position provider
  100878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100879. */
  100880. audioListenerPositionProvider: Nullable<() => Vector3>;
  100881. }
  100882. /**
  100883. * Defines the sound scene component responsible to manage any sounds
  100884. * in a given scene.
  100885. */
  100886. export class AudioSceneComponent implements ISceneSerializableComponent {
  100887. /**
  100888. * The component name helpfull to identify the component in the list of scene components.
  100889. */
  100890. readonly name: string;
  100891. /**
  100892. * The scene the component belongs to.
  100893. */
  100894. scene: Scene;
  100895. private _audioEnabled;
  100896. /**
  100897. * Gets whether audio is enabled or not.
  100898. * Please use related enable/disable method to switch state.
  100899. */
  100900. readonly audioEnabled: boolean;
  100901. private _headphone;
  100902. /**
  100903. * Gets whether audio is outputing to headphone or not.
  100904. * Please use the according Switch methods to change output.
  100905. */
  100906. readonly headphone: boolean;
  100907. private _audioListenerPositionProvider;
  100908. /**
  100909. * Gets the current audio listener position provider
  100910. */
  100911. /**
  100912. * Sets a custom listener position for all sounds in the scene
  100913. * By default, this is the position of the first active camera
  100914. */
  100915. audioListenerPositionProvider: Nullable<() => Vector3>;
  100916. /**
  100917. * Creates a new instance of the component for the given scene
  100918. * @param scene Defines the scene to register the component in
  100919. */
  100920. constructor(scene: Scene);
  100921. /**
  100922. * Registers the component in a given scene
  100923. */
  100924. register(): void;
  100925. /**
  100926. * Rebuilds the elements related to this component in case of
  100927. * context lost for instance.
  100928. */
  100929. rebuild(): void;
  100930. /**
  100931. * Serializes the component data to the specified json object
  100932. * @param serializationObject The object to serialize to
  100933. */
  100934. serialize(serializationObject: any): void;
  100935. /**
  100936. * Adds all the elements from the container to the scene
  100937. * @param container the container holding the elements
  100938. */
  100939. addFromContainer(container: AbstractScene): void;
  100940. /**
  100941. * Removes all the elements in the container from the scene
  100942. * @param container contains the elements to remove
  100943. * @param dispose if the removed element should be disposed (default: false)
  100944. */
  100945. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  100946. /**
  100947. * Disposes the component and the associated ressources.
  100948. */
  100949. dispose(): void;
  100950. /**
  100951. * Disables audio in the associated scene.
  100952. */
  100953. disableAudio(): void;
  100954. /**
  100955. * Enables audio in the associated scene.
  100956. */
  100957. enableAudio(): void;
  100958. /**
  100959. * Switch audio to headphone output.
  100960. */
  100961. switchAudioModeForHeadphones(): void;
  100962. /**
  100963. * Switch audio to normal speakers.
  100964. */
  100965. switchAudioModeForNormalSpeakers(): void;
  100966. private _afterRender;
  100967. }
  100968. }
  100969. declare module BABYLON {
  100970. /**
  100971. * Wraps one or more Sound objects and selects one with random weight for playback.
  100972. */
  100973. export class WeightedSound {
  100974. /** When true a Sound will be selected and played when the current playing Sound completes. */
  100975. loop: boolean;
  100976. private _coneInnerAngle;
  100977. private _coneOuterAngle;
  100978. private _volume;
  100979. /** A Sound is currently playing. */
  100980. isPlaying: boolean;
  100981. /** A Sound is currently paused. */
  100982. isPaused: boolean;
  100983. private _sounds;
  100984. private _weights;
  100985. private _currentIndex?;
  100986. /**
  100987. * Creates a new WeightedSound from the list of sounds given.
  100988. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  100989. * @param sounds Array of Sounds that will be selected from.
  100990. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  100991. */
  100992. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  100993. /**
  100994. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  100995. */
  100996. /**
  100997. * The size of cone in degress for a directional sound in which there will be no attenuation.
  100998. */
  100999. directionalConeInnerAngle: number;
  101000. /**
  101001. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101002. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101003. */
  101004. /**
  101005. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101006. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101007. */
  101008. directionalConeOuterAngle: number;
  101009. /**
  101010. * Playback volume.
  101011. */
  101012. /**
  101013. * Playback volume.
  101014. */
  101015. volume: number;
  101016. private _onended;
  101017. /**
  101018. * Suspend playback
  101019. */
  101020. pause(): void;
  101021. /**
  101022. * Stop playback
  101023. */
  101024. stop(): void;
  101025. /**
  101026. * Start playback.
  101027. * @param startOffset Position the clip head at a specific time in seconds.
  101028. */
  101029. play(startOffset?: number): void;
  101030. }
  101031. }
  101032. declare module BABYLON {
  101033. /**
  101034. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101035. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101036. */
  101037. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101038. /**
  101039. * Gets the name of the behavior.
  101040. */
  101041. readonly name: string;
  101042. /**
  101043. * The easing function used by animations
  101044. */
  101045. static EasingFunction: BackEase;
  101046. /**
  101047. * The easing mode used by animations
  101048. */
  101049. static EasingMode: number;
  101050. /**
  101051. * The duration of the animation, in milliseconds
  101052. */
  101053. transitionDuration: number;
  101054. /**
  101055. * Length of the distance animated by the transition when lower radius is reached
  101056. */
  101057. lowerRadiusTransitionRange: number;
  101058. /**
  101059. * Length of the distance animated by the transition when upper radius is reached
  101060. */
  101061. upperRadiusTransitionRange: number;
  101062. private _autoTransitionRange;
  101063. /**
  101064. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101065. */
  101066. /**
  101067. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101068. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101069. */
  101070. autoTransitionRange: boolean;
  101071. private _attachedCamera;
  101072. private _onAfterCheckInputsObserver;
  101073. private _onMeshTargetChangedObserver;
  101074. /**
  101075. * Initializes the behavior.
  101076. */
  101077. init(): void;
  101078. /**
  101079. * Attaches the behavior to its arc rotate camera.
  101080. * @param camera Defines the camera to attach the behavior to
  101081. */
  101082. attach(camera: ArcRotateCamera): void;
  101083. /**
  101084. * Detaches the behavior from its current arc rotate camera.
  101085. */
  101086. detach(): void;
  101087. private _radiusIsAnimating;
  101088. private _radiusBounceTransition;
  101089. private _animatables;
  101090. private _cachedWheelPrecision;
  101091. /**
  101092. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101093. * @param radiusLimit The limit to check against.
  101094. * @return Bool to indicate if at limit.
  101095. */
  101096. private _isRadiusAtLimit;
  101097. /**
  101098. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101099. * @param radiusDelta The delta by which to animate to. Can be negative.
  101100. */
  101101. private _applyBoundRadiusAnimation;
  101102. /**
  101103. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101104. */
  101105. protected _clearAnimationLocks(): void;
  101106. /**
  101107. * Stops and removes all animations that have been applied to the camera
  101108. */
  101109. stopAllAnimations(): void;
  101110. }
  101111. }
  101112. declare module BABYLON {
  101113. /**
  101114. * 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.
  101115. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101116. */
  101117. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101118. /**
  101119. * Gets the name of the behavior.
  101120. */
  101121. readonly name: string;
  101122. private _mode;
  101123. private _radiusScale;
  101124. private _positionScale;
  101125. private _defaultElevation;
  101126. private _elevationReturnTime;
  101127. private _elevationReturnWaitTime;
  101128. private _zoomStopsAnimation;
  101129. private _framingTime;
  101130. /**
  101131. * The easing function used by animations
  101132. */
  101133. static EasingFunction: ExponentialEase;
  101134. /**
  101135. * The easing mode used by animations
  101136. */
  101137. static EasingMode: number;
  101138. /**
  101139. * Sets the current mode used by the behavior
  101140. */
  101141. /**
  101142. * Gets current mode used by the behavior.
  101143. */
  101144. mode: number;
  101145. /**
  101146. * Sets the scale applied to the radius (1 by default)
  101147. */
  101148. /**
  101149. * Gets the scale applied to the radius
  101150. */
  101151. radiusScale: number;
  101152. /**
  101153. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101154. */
  101155. /**
  101156. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101157. */
  101158. positionScale: number;
  101159. /**
  101160. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101161. * behaviour is triggered, in radians.
  101162. */
  101163. /**
  101164. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101165. * behaviour is triggered, in radians.
  101166. */
  101167. defaultElevation: number;
  101168. /**
  101169. * Sets the time (in milliseconds) taken to return to the default beta position.
  101170. * Negative value indicates camera should not return to default.
  101171. */
  101172. /**
  101173. * Gets the time (in milliseconds) taken to return to the default beta position.
  101174. * Negative value indicates camera should not return to default.
  101175. */
  101176. elevationReturnTime: number;
  101177. /**
  101178. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101179. */
  101180. /**
  101181. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101182. */
  101183. elevationReturnWaitTime: number;
  101184. /**
  101185. * Sets the flag that indicates if user zooming should stop animation.
  101186. */
  101187. /**
  101188. * Gets the flag that indicates if user zooming should stop animation.
  101189. */
  101190. zoomStopsAnimation: boolean;
  101191. /**
  101192. * Sets the transition time when framing the mesh, in milliseconds
  101193. */
  101194. /**
  101195. * Gets the transition time when framing the mesh, in milliseconds
  101196. */
  101197. framingTime: number;
  101198. /**
  101199. * Define if the behavior should automatically change the configured
  101200. * camera limits and sensibilities.
  101201. */
  101202. autoCorrectCameraLimitsAndSensibility: boolean;
  101203. private _onPrePointerObservableObserver;
  101204. private _onAfterCheckInputsObserver;
  101205. private _onMeshTargetChangedObserver;
  101206. private _attachedCamera;
  101207. private _isPointerDown;
  101208. private _lastInteractionTime;
  101209. /**
  101210. * Initializes the behavior.
  101211. */
  101212. init(): void;
  101213. /**
  101214. * Attaches the behavior to its arc rotate camera.
  101215. * @param camera Defines the camera to attach the behavior to
  101216. */
  101217. attach(camera: ArcRotateCamera): void;
  101218. /**
  101219. * Detaches the behavior from its current arc rotate camera.
  101220. */
  101221. detach(): void;
  101222. private _animatables;
  101223. private _betaIsAnimating;
  101224. private _betaTransition;
  101225. private _radiusTransition;
  101226. private _vectorTransition;
  101227. /**
  101228. * Targets the given mesh and updates zoom level accordingly.
  101229. * @param mesh The mesh to target.
  101230. * @param radius Optional. If a cached radius position already exists, overrides default.
  101231. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101232. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101233. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101234. */
  101235. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101236. /**
  101237. * Targets the given mesh with its children and updates zoom level accordingly.
  101238. * @param mesh The mesh to target.
  101239. * @param radius Optional. If a cached radius position already exists, overrides default.
  101240. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101241. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101242. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101243. */
  101244. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101245. /**
  101246. * Targets the given meshes with their children and updates zoom level accordingly.
  101247. * @param meshes The mesh to target.
  101248. * @param radius Optional. If a cached radius position already exists, overrides default.
  101249. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101250. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101251. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101252. */
  101253. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101254. /**
  101255. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101256. * @param minimumWorld Determines the smaller position of the bounding box extend
  101257. * @param maximumWorld Determines the bigger position of the bounding box extend
  101258. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101259. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101260. */
  101261. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101262. /**
  101263. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101264. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101265. * frustum width.
  101266. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101267. * to fully enclose the mesh in the viewing frustum.
  101268. */
  101269. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101270. /**
  101271. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101272. * is automatically returned to its default position (expected to be above ground plane).
  101273. */
  101274. private _maintainCameraAboveGround;
  101275. /**
  101276. * Returns the frustum slope based on the canvas ratio and camera FOV
  101277. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101278. */
  101279. private _getFrustumSlope;
  101280. /**
  101281. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101282. */
  101283. private _clearAnimationLocks;
  101284. /**
  101285. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101286. */
  101287. private _applyUserInteraction;
  101288. /**
  101289. * Stops and removes all animations that have been applied to the camera
  101290. */
  101291. stopAllAnimations(): void;
  101292. /**
  101293. * Gets a value indicating if the user is moving the camera
  101294. */
  101295. readonly isUserIsMoving: boolean;
  101296. /**
  101297. * The camera can move all the way towards the mesh.
  101298. */
  101299. static IgnoreBoundsSizeMode: number;
  101300. /**
  101301. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101302. */
  101303. static FitFrustumSidesMode: number;
  101304. }
  101305. }
  101306. declare module BABYLON {
  101307. /**
  101308. * Base class for Camera Pointer Inputs.
  101309. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101310. * for example usage.
  101311. */
  101312. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101313. /**
  101314. * Defines the camera the input is attached to.
  101315. */
  101316. abstract camera: Camera;
  101317. /**
  101318. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101319. */
  101320. protected _altKey: boolean;
  101321. protected _ctrlKey: boolean;
  101322. protected _metaKey: boolean;
  101323. protected _shiftKey: boolean;
  101324. /**
  101325. * Which mouse buttons were pressed at time of last mouse event.
  101326. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101327. */
  101328. protected _buttonsPressed: number;
  101329. /**
  101330. * Defines the buttons associated with the input to handle camera move.
  101331. */
  101332. buttons: number[];
  101333. /**
  101334. * Attach the input controls to a specific dom element to get the input from.
  101335. * @param element Defines the element the controls should be listened from
  101336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101337. */
  101338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101339. /**
  101340. * Detach the current controls from the specified dom element.
  101341. * @param element Defines the element to stop listening the inputs from
  101342. */
  101343. detachControl(element: Nullable<HTMLElement>): void;
  101344. /**
  101345. * Gets the class name of the current input.
  101346. * @returns the class name
  101347. */
  101348. getClassName(): string;
  101349. /**
  101350. * Get the friendly name associated with the input class.
  101351. * @returns the input friendly name
  101352. */
  101353. getSimpleName(): string;
  101354. /**
  101355. * Called on pointer POINTERDOUBLETAP event.
  101356. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101357. */
  101358. protected onDoubleTap(type: string): void;
  101359. /**
  101360. * Called on pointer POINTERMOVE event if only a single touch is active.
  101361. * Override this method to provide functionality.
  101362. */
  101363. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101364. /**
  101365. * Called on pointer POINTERMOVE event if multiple touches are active.
  101366. * Override this method to provide functionality.
  101367. */
  101368. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101369. /**
  101370. * Called on JS contextmenu event.
  101371. * Override this method to provide functionality.
  101372. */
  101373. protected onContextMenu(evt: PointerEvent): void;
  101374. /**
  101375. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101376. * press.
  101377. * Override this method to provide functionality.
  101378. */
  101379. protected onButtonDown(evt: PointerEvent): void;
  101380. /**
  101381. * Called each time a new POINTERUP event occurs. Ie, for each button
  101382. * release.
  101383. * Override this method to provide functionality.
  101384. */
  101385. protected onButtonUp(evt: PointerEvent): void;
  101386. /**
  101387. * Called when window becomes inactive.
  101388. * Override this method to provide functionality.
  101389. */
  101390. protected onLostFocus(): void;
  101391. private _pointerInput;
  101392. private _observer;
  101393. private _onLostFocus;
  101394. private pointA;
  101395. private pointB;
  101396. }
  101397. }
  101398. declare module BABYLON {
  101399. /**
  101400. * Manage the pointers inputs to control an arc rotate camera.
  101401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101402. */
  101403. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101404. /**
  101405. * Defines the camera the input is attached to.
  101406. */
  101407. camera: ArcRotateCamera;
  101408. /**
  101409. * Gets the class name of the current input.
  101410. * @returns the class name
  101411. */
  101412. getClassName(): string;
  101413. /**
  101414. * Defines the buttons associated with the input to handle camera move.
  101415. */
  101416. buttons: number[];
  101417. /**
  101418. * Defines the pointer angular sensibility along the X axis or how fast is
  101419. * the camera rotating.
  101420. */
  101421. angularSensibilityX: number;
  101422. /**
  101423. * Defines the pointer angular sensibility along the Y axis or how fast is
  101424. * the camera rotating.
  101425. */
  101426. angularSensibilityY: number;
  101427. /**
  101428. * Defines the pointer pinch precision or how fast is the camera zooming.
  101429. */
  101430. pinchPrecision: number;
  101431. /**
  101432. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101433. * from 0.
  101434. * It defines the percentage of current camera.radius to use as delta when
  101435. * pinch zoom is used.
  101436. */
  101437. pinchDeltaPercentage: number;
  101438. /**
  101439. * Defines the pointer panning sensibility or how fast is the camera moving.
  101440. */
  101441. panningSensibility: number;
  101442. /**
  101443. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101444. */
  101445. multiTouchPanning: boolean;
  101446. /**
  101447. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101448. * zoom (pinch) through multitouch.
  101449. */
  101450. multiTouchPanAndZoom: boolean;
  101451. /**
  101452. * Revers pinch action direction.
  101453. */
  101454. pinchInwards: boolean;
  101455. private _isPanClick;
  101456. private _twoFingerActivityCount;
  101457. private _isPinching;
  101458. /**
  101459. * Called on pointer POINTERMOVE event if only a single touch is active.
  101460. */
  101461. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101462. /**
  101463. * Called on pointer POINTERDOUBLETAP event.
  101464. */
  101465. protected onDoubleTap(type: string): void;
  101466. /**
  101467. * Called on pointer POINTERMOVE event if multiple touches are active.
  101468. */
  101469. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101470. /**
  101471. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101472. * press.
  101473. */
  101474. protected onButtonDown(evt: PointerEvent): void;
  101475. /**
  101476. * Called each time a new POINTERUP event occurs. Ie, for each button
  101477. * release.
  101478. */
  101479. protected onButtonUp(evt: PointerEvent): void;
  101480. /**
  101481. * Called when window becomes inactive.
  101482. */
  101483. protected onLostFocus(): void;
  101484. }
  101485. }
  101486. declare module BABYLON {
  101487. /**
  101488. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101490. */
  101491. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101492. /**
  101493. * Defines the camera the input is attached to.
  101494. */
  101495. camera: ArcRotateCamera;
  101496. /**
  101497. * Defines the list of key codes associated with the up action (increase alpha)
  101498. */
  101499. keysUp: number[];
  101500. /**
  101501. * Defines the list of key codes associated with the down action (decrease alpha)
  101502. */
  101503. keysDown: number[];
  101504. /**
  101505. * Defines the list of key codes associated with the left action (increase beta)
  101506. */
  101507. keysLeft: number[];
  101508. /**
  101509. * Defines the list of key codes associated with the right action (decrease beta)
  101510. */
  101511. keysRight: number[];
  101512. /**
  101513. * Defines the list of key codes associated with the reset action.
  101514. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101515. */
  101516. keysReset: number[];
  101517. /**
  101518. * Defines the panning sensibility of the inputs.
  101519. * (How fast is the camera paning)
  101520. */
  101521. panningSensibility: number;
  101522. /**
  101523. * Defines the zooming sensibility of the inputs.
  101524. * (How fast is the camera zooming)
  101525. */
  101526. zoomingSensibility: number;
  101527. /**
  101528. * Defines wether maintaining the alt key down switch the movement mode from
  101529. * orientation to zoom.
  101530. */
  101531. useAltToZoom: boolean;
  101532. /**
  101533. * Rotation speed of the camera
  101534. */
  101535. angularSpeed: number;
  101536. private _keys;
  101537. private _ctrlPressed;
  101538. private _altPressed;
  101539. private _onCanvasBlurObserver;
  101540. private _onKeyboardObserver;
  101541. private _engine;
  101542. private _scene;
  101543. /**
  101544. * Attach the input controls to a specific dom element to get the input from.
  101545. * @param element Defines the element the controls should be listened from
  101546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101547. */
  101548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101549. /**
  101550. * Detach the current controls from the specified dom element.
  101551. * @param element Defines the element to stop listening the inputs from
  101552. */
  101553. detachControl(element: Nullable<HTMLElement>): void;
  101554. /**
  101555. * Update the current camera state depending on the inputs that have been used this frame.
  101556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101557. */
  101558. checkInputs(): void;
  101559. /**
  101560. * Gets the class name of the current intput.
  101561. * @returns the class name
  101562. */
  101563. getClassName(): string;
  101564. /**
  101565. * Get the friendly name associated with the input class.
  101566. * @returns the input friendly name
  101567. */
  101568. getSimpleName(): string;
  101569. }
  101570. }
  101571. declare module BABYLON {
  101572. /**
  101573. * Manage the mouse wheel inputs to control an arc rotate camera.
  101574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101575. */
  101576. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101577. /**
  101578. * Defines the camera the input is attached to.
  101579. */
  101580. camera: ArcRotateCamera;
  101581. /**
  101582. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101583. */
  101584. wheelPrecision: number;
  101585. /**
  101586. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101587. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101588. */
  101589. wheelDeltaPercentage: number;
  101590. private _wheel;
  101591. private _observer;
  101592. private computeDeltaFromMouseWheelLegacyEvent;
  101593. /**
  101594. * Attach the input controls to a specific dom element to get the input from.
  101595. * @param element Defines the element the controls should be listened from
  101596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101597. */
  101598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101599. /**
  101600. * Detach the current controls from the specified dom element.
  101601. * @param element Defines the element to stop listening the inputs from
  101602. */
  101603. detachControl(element: Nullable<HTMLElement>): void;
  101604. /**
  101605. * Gets the class name of the current intput.
  101606. * @returns the class name
  101607. */
  101608. getClassName(): string;
  101609. /**
  101610. * Get the friendly name associated with the input class.
  101611. * @returns the input friendly name
  101612. */
  101613. getSimpleName(): string;
  101614. }
  101615. }
  101616. declare module BABYLON {
  101617. /**
  101618. * Default Inputs manager for the ArcRotateCamera.
  101619. * It groups all the default supported inputs for ease of use.
  101620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101621. */
  101622. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101623. /**
  101624. * Instantiates a new ArcRotateCameraInputsManager.
  101625. * @param camera Defines the camera the inputs belong to
  101626. */
  101627. constructor(camera: ArcRotateCamera);
  101628. /**
  101629. * Add mouse wheel input support to the input manager.
  101630. * @returns the current input manager
  101631. */
  101632. addMouseWheel(): ArcRotateCameraInputsManager;
  101633. /**
  101634. * Add pointers input support to the input manager.
  101635. * @returns the current input manager
  101636. */
  101637. addPointers(): ArcRotateCameraInputsManager;
  101638. /**
  101639. * Add keyboard input support to the input manager.
  101640. * @returns the current input manager
  101641. */
  101642. addKeyboard(): ArcRotateCameraInputsManager;
  101643. }
  101644. }
  101645. declare module BABYLON {
  101646. /**
  101647. * This represents an orbital type of camera.
  101648. *
  101649. * 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.
  101650. * 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.
  101651. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101652. */
  101653. export class ArcRotateCamera extends TargetCamera {
  101654. /**
  101655. * Defines the rotation angle of the camera along the longitudinal axis.
  101656. */
  101657. alpha: number;
  101658. /**
  101659. * Defines the rotation angle of the camera along the latitudinal axis.
  101660. */
  101661. beta: number;
  101662. /**
  101663. * Defines the radius of the camera from it s target point.
  101664. */
  101665. radius: number;
  101666. protected _target: Vector3;
  101667. protected _targetHost: Nullable<AbstractMesh>;
  101668. /**
  101669. * Defines the target point of the camera.
  101670. * The camera looks towards it form the radius distance.
  101671. */
  101672. target: Vector3;
  101673. /**
  101674. * Define the current local position of the camera in the scene
  101675. */
  101676. position: Vector3;
  101677. protected _upVector: Vector3;
  101678. protected _upToYMatrix: Matrix;
  101679. protected _YToUpMatrix: Matrix;
  101680. /**
  101681. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101682. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101683. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101684. */
  101685. upVector: Vector3;
  101686. /**
  101687. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101688. */
  101689. setMatUp(): void;
  101690. /**
  101691. * Current inertia value on the longitudinal axis.
  101692. * The bigger this number the longer it will take for the camera to stop.
  101693. */
  101694. inertialAlphaOffset: number;
  101695. /**
  101696. * Current inertia value on the latitudinal axis.
  101697. * The bigger this number the longer it will take for the camera to stop.
  101698. */
  101699. inertialBetaOffset: number;
  101700. /**
  101701. * Current inertia value on the radius axis.
  101702. * The bigger this number the longer it will take for the camera to stop.
  101703. */
  101704. inertialRadiusOffset: number;
  101705. /**
  101706. * Minimum allowed angle on the longitudinal axis.
  101707. * This can help limiting how the Camera is able to move in the scene.
  101708. */
  101709. lowerAlphaLimit: Nullable<number>;
  101710. /**
  101711. * Maximum allowed angle on the longitudinal axis.
  101712. * This can help limiting how the Camera is able to move in the scene.
  101713. */
  101714. upperAlphaLimit: Nullable<number>;
  101715. /**
  101716. * Minimum allowed angle on the latitudinal axis.
  101717. * This can help limiting how the Camera is able to move in the scene.
  101718. */
  101719. lowerBetaLimit: number;
  101720. /**
  101721. * Maximum allowed angle on the latitudinal axis.
  101722. * This can help limiting how the Camera is able to move in the scene.
  101723. */
  101724. upperBetaLimit: number;
  101725. /**
  101726. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  101727. * This can help limiting how the Camera is able to move in the scene.
  101728. */
  101729. lowerRadiusLimit: Nullable<number>;
  101730. /**
  101731. * Maximum allowed distance of the camera to the target (The camera can not get further).
  101732. * This can help limiting how the Camera is able to move in the scene.
  101733. */
  101734. upperRadiusLimit: Nullable<number>;
  101735. /**
  101736. * Defines the current inertia value used during panning of the camera along the X axis.
  101737. */
  101738. inertialPanningX: number;
  101739. /**
  101740. * Defines the current inertia value used during panning of the camera along the Y axis.
  101741. */
  101742. inertialPanningY: number;
  101743. /**
  101744. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  101745. * Basically if your fingers moves away from more than this distance you will be considered
  101746. * in pinch mode.
  101747. */
  101748. pinchToPanMaxDistance: number;
  101749. /**
  101750. * Defines the maximum distance the camera can pan.
  101751. * This could help keeping the cammera always in your scene.
  101752. */
  101753. panningDistanceLimit: Nullable<number>;
  101754. /**
  101755. * Defines the target of the camera before paning.
  101756. */
  101757. panningOriginTarget: Vector3;
  101758. /**
  101759. * Defines the value of the inertia used during panning.
  101760. * 0 would mean stop inertia and one would mean no decelleration at all.
  101761. */
  101762. panningInertia: number;
  101763. /**
  101764. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  101765. */
  101766. angularSensibilityX: number;
  101767. /**
  101768. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  101769. */
  101770. angularSensibilityY: number;
  101771. /**
  101772. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  101773. */
  101774. pinchPrecision: number;
  101775. /**
  101776. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  101777. * It will be used instead of pinchDeltaPrecision if different from 0.
  101778. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101779. */
  101780. pinchDeltaPercentage: number;
  101781. /**
  101782. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  101783. */
  101784. panningSensibility: number;
  101785. /**
  101786. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  101787. */
  101788. keysUp: number[];
  101789. /**
  101790. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  101791. */
  101792. keysDown: number[];
  101793. /**
  101794. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  101795. */
  101796. keysLeft: number[];
  101797. /**
  101798. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  101799. */
  101800. keysRight: number[];
  101801. /**
  101802. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101803. */
  101804. wheelPrecision: number;
  101805. /**
  101806. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  101807. * It will be used instead of pinchDeltaPrecision if different from 0.
  101808. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  101809. */
  101810. wheelDeltaPercentage: number;
  101811. /**
  101812. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  101813. */
  101814. zoomOnFactor: number;
  101815. /**
  101816. * Defines a screen offset for the camera position.
  101817. */
  101818. targetScreenOffset: Vector2;
  101819. /**
  101820. * Allows the camera to be completely reversed.
  101821. * If false the camera can not arrive upside down.
  101822. */
  101823. allowUpsideDown: boolean;
  101824. /**
  101825. * Define if double tap/click is used to restore the previously saved state of the camera.
  101826. */
  101827. useInputToRestoreState: boolean;
  101828. /** @hidden */
  101829. _viewMatrix: Matrix;
  101830. /** @hidden */
  101831. _useCtrlForPanning: boolean;
  101832. /** @hidden */
  101833. _panningMouseButton: number;
  101834. /**
  101835. * Defines the input associated to the camera.
  101836. */
  101837. inputs: ArcRotateCameraInputsManager;
  101838. /** @hidden */
  101839. _reset: () => void;
  101840. /**
  101841. * Defines the allowed panning axis.
  101842. */
  101843. panningAxis: Vector3;
  101844. protected _localDirection: Vector3;
  101845. protected _transformedDirection: Vector3;
  101846. private _bouncingBehavior;
  101847. /**
  101848. * Gets the bouncing behavior of the camera if it has been enabled.
  101849. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101850. */
  101851. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  101852. /**
  101853. * Defines if the bouncing behavior of the camera is enabled on the camera.
  101854. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101855. */
  101856. useBouncingBehavior: boolean;
  101857. private _framingBehavior;
  101858. /**
  101859. * Gets the framing behavior of the camera if it has been enabled.
  101860. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101861. */
  101862. readonly framingBehavior: Nullable<FramingBehavior>;
  101863. /**
  101864. * Defines if the framing behavior of the camera is enabled on the camera.
  101865. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101866. */
  101867. useFramingBehavior: boolean;
  101868. private _autoRotationBehavior;
  101869. /**
  101870. * Gets the auto rotation behavior of the camera if it has been enabled.
  101871. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101872. */
  101873. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  101874. /**
  101875. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  101876. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  101877. */
  101878. useAutoRotationBehavior: boolean;
  101879. /**
  101880. * Observable triggered when the mesh target has been changed on the camera.
  101881. */
  101882. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  101883. /**
  101884. * Event raised when the camera is colliding with a mesh.
  101885. */
  101886. onCollide: (collidedMesh: AbstractMesh) => void;
  101887. /**
  101888. * Defines whether the camera should check collision with the objects oh the scene.
  101889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  101890. */
  101891. checkCollisions: boolean;
  101892. /**
  101893. * Defines the collision radius of the camera.
  101894. * This simulates a sphere around the camera.
  101895. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101896. */
  101897. collisionRadius: Vector3;
  101898. protected _collider: Collider;
  101899. protected _previousPosition: Vector3;
  101900. protected _collisionVelocity: Vector3;
  101901. protected _newPosition: Vector3;
  101902. protected _previousAlpha: number;
  101903. protected _previousBeta: number;
  101904. protected _previousRadius: number;
  101905. protected _collisionTriggered: boolean;
  101906. protected _targetBoundingCenter: Nullable<Vector3>;
  101907. private _computationVector;
  101908. /**
  101909. * Instantiates a new ArcRotateCamera in a given scene
  101910. * @param name Defines the name of the camera
  101911. * @param alpha Defines the camera rotation along the logitudinal axis
  101912. * @param beta Defines the camera rotation along the latitudinal axis
  101913. * @param radius Defines the camera distance from its target
  101914. * @param target Defines the camera target
  101915. * @param scene Defines the scene the camera belongs to
  101916. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  101917. */
  101918. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101919. /** @hidden */
  101920. _initCache(): void;
  101921. /** @hidden */
  101922. _updateCache(ignoreParentClass?: boolean): void;
  101923. protected _getTargetPosition(): Vector3;
  101924. private _storedAlpha;
  101925. private _storedBeta;
  101926. private _storedRadius;
  101927. private _storedTarget;
  101928. private _storedTargetScreenOffset;
  101929. /**
  101930. * Stores the current state of the camera (alpha, beta, radius and target)
  101931. * @returns the camera itself
  101932. */
  101933. storeState(): Camera;
  101934. /**
  101935. * @hidden
  101936. * Restored camera state. You must call storeState() first
  101937. */
  101938. _restoreStateValues(): boolean;
  101939. /** @hidden */
  101940. _isSynchronizedViewMatrix(): boolean;
  101941. /**
  101942. * Attached controls to the current camera.
  101943. * @param element Defines the element the controls should be listened from
  101944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101945. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  101946. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  101947. */
  101948. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  101949. /**
  101950. * Detach the current controls from the camera.
  101951. * The camera will stop reacting to inputs.
  101952. * @param element Defines the element to stop listening the inputs from
  101953. */
  101954. detachControl(element: HTMLElement): void;
  101955. /** @hidden */
  101956. _checkInputs(): void;
  101957. protected _checkLimits(): void;
  101958. /**
  101959. * Rebuilds angles (alpha, beta) and radius from the give position and target
  101960. */
  101961. rebuildAnglesAndRadius(): void;
  101962. /**
  101963. * Use a position to define the current camera related information like aplha, beta and radius
  101964. * @param position Defines the position to set the camera at
  101965. */
  101966. setPosition(position: Vector3): void;
  101967. /**
  101968. * Defines the target the camera should look at.
  101969. * This will automatically adapt alpha beta and radius to fit within the new target.
  101970. * @param target Defines the new target as a Vector or a mesh
  101971. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  101972. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  101973. */
  101974. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  101975. /** @hidden */
  101976. _getViewMatrix(): Matrix;
  101977. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  101978. /**
  101979. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  101980. * @param meshes Defines the mesh to zoom on
  101981. * @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)
  101982. */
  101983. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  101984. /**
  101985. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  101986. * The target will be changed but the radius
  101987. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  101988. * @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)
  101989. */
  101990. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  101991. min: Vector3;
  101992. max: Vector3;
  101993. distance: number;
  101994. }, doNotUpdateMaxZ?: boolean): void;
  101995. /**
  101996. * @override
  101997. * Override Camera.createRigCamera
  101998. */
  101999. createRigCamera(name: string, cameraIndex: number): Camera;
  102000. /**
  102001. * @hidden
  102002. * @override
  102003. * Override Camera._updateRigCameras
  102004. */
  102005. _updateRigCameras(): void;
  102006. /**
  102007. * Destroy the camera and release the current resources hold by it.
  102008. */
  102009. dispose(): void;
  102010. /**
  102011. * Gets the current object class name.
  102012. * @return the class name
  102013. */
  102014. getClassName(): string;
  102015. }
  102016. }
  102017. declare module BABYLON {
  102018. /**
  102019. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102020. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102021. */
  102022. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102023. /**
  102024. * Gets the name of the behavior.
  102025. */
  102026. readonly name: string;
  102027. private _zoomStopsAnimation;
  102028. private _idleRotationSpeed;
  102029. private _idleRotationWaitTime;
  102030. private _idleRotationSpinupTime;
  102031. /**
  102032. * Sets the flag that indicates if user zooming should stop animation.
  102033. */
  102034. /**
  102035. * Gets the flag that indicates if user zooming should stop animation.
  102036. */
  102037. zoomStopsAnimation: boolean;
  102038. /**
  102039. * Sets the default speed at which the camera rotates around the model.
  102040. */
  102041. /**
  102042. * Gets the default speed at which the camera rotates around the model.
  102043. */
  102044. idleRotationSpeed: number;
  102045. /**
  102046. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102047. */
  102048. /**
  102049. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102050. */
  102051. idleRotationWaitTime: number;
  102052. /**
  102053. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102054. */
  102055. /**
  102056. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102057. */
  102058. idleRotationSpinupTime: number;
  102059. /**
  102060. * Gets a value indicating if the camera is currently rotating because of this behavior
  102061. */
  102062. readonly rotationInProgress: boolean;
  102063. private _onPrePointerObservableObserver;
  102064. private _onAfterCheckInputsObserver;
  102065. private _attachedCamera;
  102066. private _isPointerDown;
  102067. private _lastFrameTime;
  102068. private _lastInteractionTime;
  102069. private _cameraRotationSpeed;
  102070. /**
  102071. * Initializes the behavior.
  102072. */
  102073. init(): void;
  102074. /**
  102075. * Attaches the behavior to its arc rotate camera.
  102076. * @param camera Defines the camera to attach the behavior to
  102077. */
  102078. attach(camera: ArcRotateCamera): void;
  102079. /**
  102080. * Detaches the behavior from its current arc rotate camera.
  102081. */
  102082. detach(): void;
  102083. /**
  102084. * Returns true if user is scrolling.
  102085. * @return true if user is scrolling.
  102086. */
  102087. private _userIsZooming;
  102088. private _lastFrameRadius;
  102089. private _shouldAnimationStopForInteraction;
  102090. /**
  102091. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102092. */
  102093. private _applyUserInteraction;
  102094. private _userIsMoving;
  102095. }
  102096. }
  102097. declare module BABYLON {
  102098. /**
  102099. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102100. */
  102101. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102102. private ui;
  102103. /**
  102104. * The name of the behavior
  102105. */
  102106. name: string;
  102107. /**
  102108. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102109. */
  102110. distanceAwayFromFace: number;
  102111. /**
  102112. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102113. */
  102114. distanceAwayFromBottomOfFace: number;
  102115. private _faceVectors;
  102116. private _target;
  102117. private _scene;
  102118. private _onRenderObserver;
  102119. private _tmpMatrix;
  102120. private _tmpVector;
  102121. /**
  102122. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102123. * @param ui The transform node that should be attched to the mesh
  102124. */
  102125. constructor(ui: TransformNode);
  102126. /**
  102127. * Initializes the behavior
  102128. */
  102129. init(): void;
  102130. private _closestFace;
  102131. private _zeroVector;
  102132. private _lookAtTmpMatrix;
  102133. private _lookAtToRef;
  102134. /**
  102135. * Attaches the AttachToBoxBehavior to the passed in mesh
  102136. * @param target The mesh that the specified node will be attached to
  102137. */
  102138. attach(target: Mesh): void;
  102139. /**
  102140. * Detaches the behavior from the mesh
  102141. */
  102142. detach(): void;
  102143. }
  102144. }
  102145. declare module BABYLON {
  102146. /**
  102147. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102148. */
  102149. export class FadeInOutBehavior implements Behavior<Mesh> {
  102150. /**
  102151. * Time in milliseconds to delay before fading in (Default: 0)
  102152. */
  102153. delay: number;
  102154. /**
  102155. * Time in milliseconds for the mesh to fade in (Default: 300)
  102156. */
  102157. fadeInTime: number;
  102158. private _millisecondsPerFrame;
  102159. private _hovered;
  102160. private _hoverValue;
  102161. private _ownerNode;
  102162. /**
  102163. * Instatiates the FadeInOutBehavior
  102164. */
  102165. constructor();
  102166. /**
  102167. * The name of the behavior
  102168. */
  102169. readonly name: string;
  102170. /**
  102171. * Initializes the behavior
  102172. */
  102173. init(): void;
  102174. /**
  102175. * Attaches the fade behavior on the passed in mesh
  102176. * @param ownerNode The mesh that will be faded in/out once attached
  102177. */
  102178. attach(ownerNode: Mesh): void;
  102179. /**
  102180. * Detaches the behavior from the mesh
  102181. */
  102182. detach(): void;
  102183. /**
  102184. * Triggers the mesh to begin fading in or out
  102185. * @param value if the object should fade in or out (true to fade in)
  102186. */
  102187. fadeIn(value: boolean): void;
  102188. private _update;
  102189. private _setAllVisibility;
  102190. }
  102191. }
  102192. declare module BABYLON {
  102193. /**
  102194. * Class containing a set of static utilities functions for managing Pivots
  102195. * @hidden
  102196. */
  102197. export class PivotTools {
  102198. private static _PivotCached;
  102199. private static _OldPivotPoint;
  102200. private static _PivotTranslation;
  102201. private static _PivotTmpVector;
  102202. /** @hidden */
  102203. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102204. /** @hidden */
  102205. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102206. }
  102207. }
  102208. declare module BABYLON {
  102209. /**
  102210. * Class containing static functions to help procedurally build meshes
  102211. */
  102212. export class PlaneBuilder {
  102213. /**
  102214. * Creates a plane mesh
  102215. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102216. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102217. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102219. * * 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
  102220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102221. * @param name defines the name of the mesh
  102222. * @param options defines the options used to create the mesh
  102223. * @param scene defines the hosting scene
  102224. * @returns the plane mesh
  102225. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102226. */
  102227. static CreatePlane(name: string, options: {
  102228. size?: number;
  102229. width?: number;
  102230. height?: number;
  102231. sideOrientation?: number;
  102232. frontUVs?: Vector4;
  102233. backUVs?: Vector4;
  102234. updatable?: boolean;
  102235. sourcePlane?: Plane;
  102236. }, scene?: Nullable<Scene>): Mesh;
  102237. }
  102238. }
  102239. declare module BABYLON {
  102240. /**
  102241. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102242. */
  102243. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102244. private static _AnyMouseID;
  102245. /**
  102246. * Abstract mesh the behavior is set on
  102247. */
  102248. attachedNode: AbstractMesh;
  102249. private _dragPlane;
  102250. private _scene;
  102251. private _pointerObserver;
  102252. private _beforeRenderObserver;
  102253. private static _planeScene;
  102254. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102255. /**
  102256. * 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)
  102257. */
  102258. maxDragAngle: number;
  102259. /**
  102260. * @hidden
  102261. */
  102262. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102263. /**
  102264. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102265. */
  102266. currentDraggingPointerID: number;
  102267. /**
  102268. * The last position where the pointer hit the drag plane in world space
  102269. */
  102270. lastDragPosition: Vector3;
  102271. /**
  102272. * If the behavior is currently in a dragging state
  102273. */
  102274. dragging: boolean;
  102275. /**
  102276. * 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)
  102277. */
  102278. dragDeltaRatio: number;
  102279. /**
  102280. * If the drag plane orientation should be updated during the dragging (Default: true)
  102281. */
  102282. updateDragPlane: boolean;
  102283. private _debugMode;
  102284. private _moving;
  102285. /**
  102286. * Fires each time the attached mesh is dragged with the pointer
  102287. * * delta between last drag position and current drag position in world space
  102288. * * dragDistance along the drag axis
  102289. * * dragPlaneNormal normal of the current drag plane used during the drag
  102290. * * dragPlanePoint in world space where the drag intersects the drag plane
  102291. */
  102292. onDragObservable: Observable<{
  102293. delta: Vector3;
  102294. dragPlanePoint: Vector3;
  102295. dragPlaneNormal: Vector3;
  102296. dragDistance: number;
  102297. pointerId: number;
  102298. }>;
  102299. /**
  102300. * Fires each time a drag begins (eg. mouse down on mesh)
  102301. */
  102302. onDragStartObservable: Observable<{
  102303. dragPlanePoint: Vector3;
  102304. pointerId: number;
  102305. }>;
  102306. /**
  102307. * Fires each time a drag ends (eg. mouse release after drag)
  102308. */
  102309. onDragEndObservable: Observable<{
  102310. dragPlanePoint: Vector3;
  102311. pointerId: number;
  102312. }>;
  102313. /**
  102314. * If the attached mesh should be moved when dragged
  102315. */
  102316. moveAttached: boolean;
  102317. /**
  102318. * If the drag behavior will react to drag events (Default: true)
  102319. */
  102320. enabled: boolean;
  102321. /**
  102322. * If pointer events should start and release the drag (Default: true)
  102323. */
  102324. startAndReleaseDragOnPointerEvents: boolean;
  102325. /**
  102326. * If camera controls should be detached during the drag
  102327. */
  102328. detachCameraControls: boolean;
  102329. /**
  102330. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102331. */
  102332. useObjectOrienationForDragging: boolean;
  102333. private _options;
  102334. /**
  102335. * Creates a pointer drag behavior that can be attached to a mesh
  102336. * @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)
  102337. */
  102338. constructor(options?: {
  102339. dragAxis?: Vector3;
  102340. dragPlaneNormal?: Vector3;
  102341. });
  102342. /**
  102343. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102344. */
  102345. validateDrag: (targetPosition: Vector3) => boolean;
  102346. /**
  102347. * The name of the behavior
  102348. */
  102349. readonly name: string;
  102350. /**
  102351. * Initializes the behavior
  102352. */
  102353. init(): void;
  102354. private _tmpVector;
  102355. private _alternatePickedPoint;
  102356. private _worldDragAxis;
  102357. private _targetPosition;
  102358. private _attachedElement;
  102359. /**
  102360. * Attaches the drag behavior the passed in mesh
  102361. * @param ownerNode The mesh that will be dragged around once attached
  102362. * @param predicate Predicate to use for pick filtering
  102363. */
  102364. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102365. /**
  102366. * Force relase the drag action by code.
  102367. */
  102368. releaseDrag(): void;
  102369. private _startDragRay;
  102370. private _lastPointerRay;
  102371. /**
  102372. * Simulates the start of a pointer drag event on the behavior
  102373. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102374. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102375. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102376. */
  102377. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102378. private _startDrag;
  102379. private _dragDelta;
  102380. private _moveDrag;
  102381. private _pickWithRayOnDragPlane;
  102382. private _pointA;
  102383. private _pointB;
  102384. private _pointC;
  102385. private _lineA;
  102386. private _lineB;
  102387. private _localAxis;
  102388. private _lookAt;
  102389. private _updateDragPlanePosition;
  102390. /**
  102391. * Detaches the behavior from the mesh
  102392. */
  102393. detach(): void;
  102394. }
  102395. }
  102396. declare module BABYLON {
  102397. /**
  102398. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102399. */
  102400. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102401. private _dragBehaviorA;
  102402. private _dragBehaviorB;
  102403. private _startDistance;
  102404. private _initialScale;
  102405. private _targetScale;
  102406. private _ownerNode;
  102407. private _sceneRenderObserver;
  102408. /**
  102409. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102410. */
  102411. constructor();
  102412. /**
  102413. * The name of the behavior
  102414. */
  102415. readonly name: string;
  102416. /**
  102417. * Initializes the behavior
  102418. */
  102419. init(): void;
  102420. private _getCurrentDistance;
  102421. /**
  102422. * Attaches the scale behavior the passed in mesh
  102423. * @param ownerNode The mesh that will be scaled around once attached
  102424. */
  102425. attach(ownerNode: Mesh): void;
  102426. /**
  102427. * Detaches the behavior from the mesh
  102428. */
  102429. detach(): void;
  102430. }
  102431. }
  102432. declare module BABYLON {
  102433. /**
  102434. * 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
  102435. */
  102436. export class SixDofDragBehavior implements Behavior<Mesh> {
  102437. private static _virtualScene;
  102438. private _ownerNode;
  102439. private _sceneRenderObserver;
  102440. private _scene;
  102441. private _targetPosition;
  102442. private _virtualOriginMesh;
  102443. private _virtualDragMesh;
  102444. private _pointerObserver;
  102445. private _moving;
  102446. private _startingOrientation;
  102447. /**
  102448. * 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)
  102449. */
  102450. private zDragFactor;
  102451. /**
  102452. * If the object should rotate to face the drag origin
  102453. */
  102454. rotateDraggedObject: boolean;
  102455. /**
  102456. * If the behavior is currently in a dragging state
  102457. */
  102458. dragging: boolean;
  102459. /**
  102460. * 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)
  102461. */
  102462. dragDeltaRatio: number;
  102463. /**
  102464. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102465. */
  102466. currentDraggingPointerID: number;
  102467. /**
  102468. * If camera controls should be detached during the drag
  102469. */
  102470. detachCameraControls: boolean;
  102471. /**
  102472. * Fires each time a drag starts
  102473. */
  102474. onDragStartObservable: Observable<{}>;
  102475. /**
  102476. * Fires each time a drag ends (eg. mouse release after drag)
  102477. */
  102478. onDragEndObservable: Observable<{}>;
  102479. /**
  102480. * 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
  102481. */
  102482. constructor();
  102483. /**
  102484. * The name of the behavior
  102485. */
  102486. readonly name: string;
  102487. /**
  102488. * Initializes the behavior
  102489. */
  102490. init(): void;
  102491. /**
  102492. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102493. */
  102494. private readonly _pointerCamera;
  102495. /**
  102496. * Attaches the scale behavior the passed in mesh
  102497. * @param ownerNode The mesh that will be scaled around once attached
  102498. */
  102499. attach(ownerNode: Mesh): void;
  102500. /**
  102501. * Detaches the behavior from the mesh
  102502. */
  102503. detach(): void;
  102504. }
  102505. }
  102506. declare module BABYLON {
  102507. /**
  102508. * Class used to apply inverse kinematics to bones
  102509. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102510. */
  102511. export class BoneIKController {
  102512. private static _tmpVecs;
  102513. private static _tmpQuat;
  102514. private static _tmpMats;
  102515. /**
  102516. * Gets or sets the target mesh
  102517. */
  102518. targetMesh: AbstractMesh;
  102519. /** Gets or sets the mesh used as pole */
  102520. poleTargetMesh: AbstractMesh;
  102521. /**
  102522. * Gets or sets the bone used as pole
  102523. */
  102524. poleTargetBone: Nullable<Bone>;
  102525. /**
  102526. * Gets or sets the target position
  102527. */
  102528. targetPosition: Vector3;
  102529. /**
  102530. * Gets or sets the pole target position
  102531. */
  102532. poleTargetPosition: Vector3;
  102533. /**
  102534. * Gets or sets the pole target local offset
  102535. */
  102536. poleTargetLocalOffset: Vector3;
  102537. /**
  102538. * Gets or sets the pole angle
  102539. */
  102540. poleAngle: number;
  102541. /**
  102542. * Gets or sets the mesh associated with the controller
  102543. */
  102544. mesh: AbstractMesh;
  102545. /**
  102546. * 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)
  102547. */
  102548. slerpAmount: number;
  102549. private _bone1Quat;
  102550. private _bone1Mat;
  102551. private _bone2Ang;
  102552. private _bone1;
  102553. private _bone2;
  102554. private _bone1Length;
  102555. private _bone2Length;
  102556. private _maxAngle;
  102557. private _maxReach;
  102558. private _rightHandedSystem;
  102559. private _bendAxis;
  102560. private _slerping;
  102561. private _adjustRoll;
  102562. /**
  102563. * Gets or sets maximum allowed angle
  102564. */
  102565. maxAngle: number;
  102566. /**
  102567. * Creates a new BoneIKController
  102568. * @param mesh defines the mesh to control
  102569. * @param bone defines the bone to control
  102570. * @param options defines options to set up the controller
  102571. */
  102572. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102573. targetMesh?: AbstractMesh;
  102574. poleTargetMesh?: AbstractMesh;
  102575. poleTargetBone?: Bone;
  102576. poleTargetLocalOffset?: Vector3;
  102577. poleAngle?: number;
  102578. bendAxis?: Vector3;
  102579. maxAngle?: number;
  102580. slerpAmount?: number;
  102581. });
  102582. private _setMaxAngle;
  102583. /**
  102584. * Force the controller to update the bones
  102585. */
  102586. update(): void;
  102587. }
  102588. }
  102589. declare module BABYLON {
  102590. /**
  102591. * Class used to make a bone look toward a point in space
  102592. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102593. */
  102594. export class BoneLookController {
  102595. private static _tmpVecs;
  102596. private static _tmpQuat;
  102597. private static _tmpMats;
  102598. /**
  102599. * The target Vector3 that the bone will look at
  102600. */
  102601. target: Vector3;
  102602. /**
  102603. * The mesh that the bone is attached to
  102604. */
  102605. mesh: AbstractMesh;
  102606. /**
  102607. * The bone that will be looking to the target
  102608. */
  102609. bone: Bone;
  102610. /**
  102611. * The up axis of the coordinate system that is used when the bone is rotated
  102612. */
  102613. upAxis: Vector3;
  102614. /**
  102615. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102616. */
  102617. upAxisSpace: Space;
  102618. /**
  102619. * Used to make an adjustment to the yaw of the bone
  102620. */
  102621. adjustYaw: number;
  102622. /**
  102623. * Used to make an adjustment to the pitch of the bone
  102624. */
  102625. adjustPitch: number;
  102626. /**
  102627. * Used to make an adjustment to the roll of the bone
  102628. */
  102629. adjustRoll: number;
  102630. /**
  102631. * 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)
  102632. */
  102633. slerpAmount: number;
  102634. private _minYaw;
  102635. private _maxYaw;
  102636. private _minPitch;
  102637. private _maxPitch;
  102638. private _minYawSin;
  102639. private _minYawCos;
  102640. private _maxYawSin;
  102641. private _maxYawCos;
  102642. private _midYawConstraint;
  102643. private _minPitchTan;
  102644. private _maxPitchTan;
  102645. private _boneQuat;
  102646. private _slerping;
  102647. private _transformYawPitch;
  102648. private _transformYawPitchInv;
  102649. private _firstFrameSkipped;
  102650. private _yawRange;
  102651. private _fowardAxis;
  102652. /**
  102653. * Gets or sets the minimum yaw angle that the bone can look to
  102654. */
  102655. minYaw: number;
  102656. /**
  102657. * Gets or sets the maximum yaw angle that the bone can look to
  102658. */
  102659. maxYaw: number;
  102660. /**
  102661. * Gets or sets the minimum pitch angle that the bone can look to
  102662. */
  102663. minPitch: number;
  102664. /**
  102665. * Gets or sets the maximum pitch angle that the bone can look to
  102666. */
  102667. maxPitch: number;
  102668. /**
  102669. * Create a BoneLookController
  102670. * @param mesh the mesh that the bone belongs to
  102671. * @param bone the bone that will be looking to the target
  102672. * @param target the target Vector3 to look at
  102673. * @param options optional settings:
  102674. * * maxYaw: the maximum angle the bone will yaw to
  102675. * * minYaw: the minimum angle the bone will yaw to
  102676. * * maxPitch: the maximum angle the bone will pitch to
  102677. * * minPitch: the minimum angle the bone will yaw to
  102678. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102679. * * upAxis: the up axis of the coordinate system
  102680. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102681. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102682. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102683. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102684. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102685. * * adjustRoll: used to make an adjustment to the roll of the bone
  102686. **/
  102687. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102688. maxYaw?: number;
  102689. minYaw?: number;
  102690. maxPitch?: number;
  102691. minPitch?: number;
  102692. slerpAmount?: number;
  102693. upAxis?: Vector3;
  102694. upAxisSpace?: Space;
  102695. yawAxis?: Vector3;
  102696. pitchAxis?: Vector3;
  102697. adjustYaw?: number;
  102698. adjustPitch?: number;
  102699. adjustRoll?: number;
  102700. });
  102701. /**
  102702. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102703. */
  102704. update(): void;
  102705. private _getAngleDiff;
  102706. private _getAngleBetween;
  102707. private _isAngleBetween;
  102708. }
  102709. }
  102710. declare module BABYLON {
  102711. /**
  102712. * Manage the gamepad inputs to control an arc rotate camera.
  102713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102714. */
  102715. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102716. /**
  102717. * Defines the camera the input is attached to.
  102718. */
  102719. camera: ArcRotateCamera;
  102720. /**
  102721. * Defines the gamepad the input is gathering event from.
  102722. */
  102723. gamepad: Nullable<Gamepad>;
  102724. /**
  102725. * Defines the gamepad rotation sensiblity.
  102726. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102727. */
  102728. gamepadRotationSensibility: number;
  102729. /**
  102730. * Defines the gamepad move sensiblity.
  102731. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102732. */
  102733. gamepadMoveSensibility: number;
  102734. private _onGamepadConnectedObserver;
  102735. private _onGamepadDisconnectedObserver;
  102736. /**
  102737. * Attach the input controls to a specific dom element to get the input from.
  102738. * @param element Defines the element the controls should be listened from
  102739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102740. */
  102741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102742. /**
  102743. * Detach the current controls from the specified dom element.
  102744. * @param element Defines the element to stop listening the inputs from
  102745. */
  102746. detachControl(element: Nullable<HTMLElement>): void;
  102747. /**
  102748. * Update the current camera state depending on the inputs that have been used this frame.
  102749. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102750. */
  102751. checkInputs(): void;
  102752. /**
  102753. * Gets the class name of the current intput.
  102754. * @returns the class name
  102755. */
  102756. getClassName(): string;
  102757. /**
  102758. * Get the friendly name associated with the input class.
  102759. * @returns the input friendly name
  102760. */
  102761. getSimpleName(): string;
  102762. }
  102763. }
  102764. declare module BABYLON {
  102765. interface ArcRotateCameraInputsManager {
  102766. /**
  102767. * Add orientation input support to the input manager.
  102768. * @returns the current input manager
  102769. */
  102770. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  102771. }
  102772. /**
  102773. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  102774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102775. */
  102776. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  102777. /**
  102778. * Defines the camera the input is attached to.
  102779. */
  102780. camera: ArcRotateCamera;
  102781. /**
  102782. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  102783. */
  102784. alphaCorrection: number;
  102785. /**
  102786. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  102787. */
  102788. gammaCorrection: number;
  102789. private _alpha;
  102790. private _gamma;
  102791. private _dirty;
  102792. private _deviceOrientationHandler;
  102793. /**
  102794. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  102795. */
  102796. constructor();
  102797. /**
  102798. * Attach the input controls to a specific dom element to get the input from.
  102799. * @param element Defines the element the controls should be listened from
  102800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102801. */
  102802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102803. /** @hidden */
  102804. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  102805. /**
  102806. * Update the current camera state depending on the inputs that have been used this frame.
  102807. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102808. */
  102809. checkInputs(): void;
  102810. /**
  102811. * Detach the current controls from the specified dom element.
  102812. * @param element Defines the element to stop listening the inputs from
  102813. */
  102814. detachControl(element: Nullable<HTMLElement>): void;
  102815. /**
  102816. * Gets the class name of the current intput.
  102817. * @returns the class name
  102818. */
  102819. getClassName(): string;
  102820. /**
  102821. * Get the friendly name associated with the input class.
  102822. * @returns the input friendly name
  102823. */
  102824. getSimpleName(): string;
  102825. }
  102826. }
  102827. declare module BABYLON {
  102828. /**
  102829. * Listen to mouse events to control the camera.
  102830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102831. */
  102832. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  102833. /**
  102834. * Defines the camera the input is attached to.
  102835. */
  102836. camera: FlyCamera;
  102837. /**
  102838. * Defines if touch is enabled. (Default is true.)
  102839. */
  102840. touchEnabled: boolean;
  102841. /**
  102842. * Defines the buttons associated with the input to handle camera rotation.
  102843. */
  102844. buttons: number[];
  102845. /**
  102846. * Assign buttons for Yaw control.
  102847. */
  102848. buttonsYaw: number[];
  102849. /**
  102850. * Assign buttons for Pitch control.
  102851. */
  102852. buttonsPitch: number[];
  102853. /**
  102854. * Assign buttons for Roll control.
  102855. */
  102856. buttonsRoll: number[];
  102857. /**
  102858. * Detect if any button is being pressed while mouse is moved.
  102859. * -1 = Mouse locked.
  102860. * 0 = Left button.
  102861. * 1 = Middle Button.
  102862. * 2 = Right Button.
  102863. */
  102864. activeButton: number;
  102865. /**
  102866. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  102867. * Higher values reduce its sensitivity.
  102868. */
  102869. angularSensibility: number;
  102870. private _mousemoveCallback;
  102871. private _observer;
  102872. private _rollObserver;
  102873. private previousPosition;
  102874. private noPreventDefault;
  102875. private element;
  102876. /**
  102877. * Listen to mouse events to control the camera.
  102878. * @param touchEnabled Define if touch is enabled. (Default is true.)
  102879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102880. */
  102881. constructor(touchEnabled?: boolean);
  102882. /**
  102883. * Attach the mouse control to the HTML DOM element.
  102884. * @param element Defines the element that listens to the input events.
  102885. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  102886. */
  102887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102888. /**
  102889. * Detach the current controls from the specified dom element.
  102890. * @param element Defines the element to stop listening the inputs from
  102891. */
  102892. detachControl(element: Nullable<HTMLElement>): void;
  102893. /**
  102894. * Gets the class name of the current input.
  102895. * @returns the class name.
  102896. */
  102897. getClassName(): string;
  102898. /**
  102899. * Get the friendly name associated with the input class.
  102900. * @returns the input's friendly name.
  102901. */
  102902. getSimpleName(): string;
  102903. private _pointerInput;
  102904. private _onMouseMove;
  102905. /**
  102906. * Rotate camera by mouse offset.
  102907. */
  102908. private rotateCamera;
  102909. }
  102910. }
  102911. declare module BABYLON {
  102912. /**
  102913. * Default Inputs manager for the FlyCamera.
  102914. * It groups all the default supported inputs for ease of use.
  102915. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102916. */
  102917. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  102918. /**
  102919. * Instantiates a new FlyCameraInputsManager.
  102920. * @param camera Defines the camera the inputs belong to.
  102921. */
  102922. constructor(camera: FlyCamera);
  102923. /**
  102924. * Add keyboard input support to the input manager.
  102925. * @returns the new FlyCameraKeyboardMoveInput().
  102926. */
  102927. addKeyboard(): FlyCameraInputsManager;
  102928. /**
  102929. * Add mouse input support to the input manager.
  102930. * @param touchEnabled Enable touch screen support.
  102931. * @returns the new FlyCameraMouseInput().
  102932. */
  102933. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  102934. }
  102935. }
  102936. declare module BABYLON {
  102937. /**
  102938. * This is a flying camera, designed for 3D movement and rotation in all directions,
  102939. * such as in a 3D Space Shooter or a Flight Simulator.
  102940. */
  102941. export class FlyCamera extends TargetCamera {
  102942. /**
  102943. * Define the collision ellipsoid of the camera.
  102944. * This is helpful for simulating a camera body, like a player's body.
  102945. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102946. */
  102947. ellipsoid: Vector3;
  102948. /**
  102949. * Define an offset for the position of the ellipsoid around the camera.
  102950. * This can be helpful if the camera is attached away from the player's body center,
  102951. * such as at its head.
  102952. */
  102953. ellipsoidOffset: Vector3;
  102954. /**
  102955. * Enable or disable collisions of the camera with the rest of the scene objects.
  102956. */
  102957. checkCollisions: boolean;
  102958. /**
  102959. * Enable or disable gravity on the camera.
  102960. */
  102961. applyGravity: boolean;
  102962. /**
  102963. * Define the current direction the camera is moving to.
  102964. */
  102965. cameraDirection: Vector3;
  102966. /**
  102967. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  102968. * This overrides and empties cameraRotation.
  102969. */
  102970. rotationQuaternion: Quaternion;
  102971. /**
  102972. * Track Roll to maintain the wanted Rolling when looking around.
  102973. */
  102974. _trackRoll: number;
  102975. /**
  102976. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  102977. */
  102978. rollCorrect: number;
  102979. /**
  102980. * Mimic a banked turn, Rolling the camera when Yawing.
  102981. * It's recommended to use rollCorrect = 10 for faster banking correction.
  102982. */
  102983. bankedTurn: boolean;
  102984. /**
  102985. * Limit in radians for how much Roll banking will add. (Default: 90°)
  102986. */
  102987. bankedTurnLimit: number;
  102988. /**
  102989. * Value of 0 disables the banked Roll.
  102990. * Value of 1 is equal to the Yaw angle in radians.
  102991. */
  102992. bankedTurnMultiplier: number;
  102993. /**
  102994. * The inputs manager loads all the input sources, such as keyboard and mouse.
  102995. */
  102996. inputs: FlyCameraInputsManager;
  102997. /**
  102998. * Gets the input sensibility for mouse input.
  102999. * Higher values reduce sensitivity.
  103000. */
  103001. /**
  103002. * Sets the input sensibility for a mouse input.
  103003. * Higher values reduce sensitivity.
  103004. */
  103005. angularSensibility: number;
  103006. /**
  103007. * Get the keys for camera movement forward.
  103008. */
  103009. /**
  103010. * Set the keys for camera movement forward.
  103011. */
  103012. keysForward: number[];
  103013. /**
  103014. * Get the keys for camera movement backward.
  103015. */
  103016. keysBackward: number[];
  103017. /**
  103018. * Get the keys for camera movement up.
  103019. */
  103020. /**
  103021. * Set the keys for camera movement up.
  103022. */
  103023. keysUp: number[];
  103024. /**
  103025. * Get the keys for camera movement down.
  103026. */
  103027. /**
  103028. * Set the keys for camera movement down.
  103029. */
  103030. keysDown: number[];
  103031. /**
  103032. * Get the keys for camera movement left.
  103033. */
  103034. /**
  103035. * Set the keys for camera movement left.
  103036. */
  103037. keysLeft: number[];
  103038. /**
  103039. * Set the keys for camera movement right.
  103040. */
  103041. /**
  103042. * Set the keys for camera movement right.
  103043. */
  103044. keysRight: number[];
  103045. /**
  103046. * Event raised when the camera collides with a mesh in the scene.
  103047. */
  103048. onCollide: (collidedMesh: AbstractMesh) => void;
  103049. private _collider;
  103050. private _needMoveForGravity;
  103051. private _oldPosition;
  103052. private _diffPosition;
  103053. private _newPosition;
  103054. /** @hidden */
  103055. _localDirection: Vector3;
  103056. /** @hidden */
  103057. _transformedDirection: Vector3;
  103058. /**
  103059. * Instantiates a FlyCamera.
  103060. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103061. * such as in a 3D Space Shooter or a Flight Simulator.
  103062. * @param name Define the name of the camera in the scene.
  103063. * @param position Define the starting position of the camera in the scene.
  103064. * @param scene Define the scene the camera belongs to.
  103065. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103066. */
  103067. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103068. /**
  103069. * Attach a control to the HTML DOM element.
  103070. * @param element Defines the element that listens to the input events.
  103071. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103072. */
  103073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103074. /**
  103075. * Detach a control from the HTML DOM element.
  103076. * The camera will stop reacting to that input.
  103077. * @param element Defines the element that listens to the input events.
  103078. */
  103079. detachControl(element: HTMLElement): void;
  103080. private _collisionMask;
  103081. /**
  103082. * Get the mask that the camera ignores in collision events.
  103083. */
  103084. /**
  103085. * Set the mask that the camera ignores in collision events.
  103086. */
  103087. collisionMask: number;
  103088. /** @hidden */
  103089. _collideWithWorld(displacement: Vector3): void;
  103090. /** @hidden */
  103091. private _onCollisionPositionChange;
  103092. /** @hidden */
  103093. _checkInputs(): void;
  103094. /** @hidden */
  103095. _decideIfNeedsToMove(): boolean;
  103096. /** @hidden */
  103097. _updatePosition(): void;
  103098. /**
  103099. * Restore the Roll to its target value at the rate specified.
  103100. * @param rate - Higher means slower restoring.
  103101. * @hidden
  103102. */
  103103. restoreRoll(rate: number): void;
  103104. /**
  103105. * Destroy the camera and release the current resources held by it.
  103106. */
  103107. dispose(): void;
  103108. /**
  103109. * Get the current object class name.
  103110. * @returns the class name.
  103111. */
  103112. getClassName(): string;
  103113. }
  103114. }
  103115. declare module BABYLON {
  103116. /**
  103117. * Listen to keyboard events to control the camera.
  103118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103119. */
  103120. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103121. /**
  103122. * Defines the camera the input is attached to.
  103123. */
  103124. camera: FlyCamera;
  103125. /**
  103126. * The list of keyboard keys used to control the forward move of the camera.
  103127. */
  103128. keysForward: number[];
  103129. /**
  103130. * The list of keyboard keys used to control the backward move of the camera.
  103131. */
  103132. keysBackward: number[];
  103133. /**
  103134. * The list of keyboard keys used to control the forward move of the camera.
  103135. */
  103136. keysUp: number[];
  103137. /**
  103138. * The list of keyboard keys used to control the backward move of the camera.
  103139. */
  103140. keysDown: number[];
  103141. /**
  103142. * The list of keyboard keys used to control the right strafe move of the camera.
  103143. */
  103144. keysRight: number[];
  103145. /**
  103146. * The list of keyboard keys used to control the left strafe move of the camera.
  103147. */
  103148. keysLeft: number[];
  103149. private _keys;
  103150. private _onCanvasBlurObserver;
  103151. private _onKeyboardObserver;
  103152. private _engine;
  103153. private _scene;
  103154. /**
  103155. * Attach the input controls to a specific dom element to get the input from.
  103156. * @param element Defines the element the controls should be listened from
  103157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103158. */
  103159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103160. /**
  103161. * Detach the current controls from the specified dom element.
  103162. * @param element Defines the element to stop listening the inputs from
  103163. */
  103164. detachControl(element: Nullable<HTMLElement>): void;
  103165. /**
  103166. * Gets the class name of the current intput.
  103167. * @returns the class name
  103168. */
  103169. getClassName(): string;
  103170. /** @hidden */
  103171. _onLostFocus(e: FocusEvent): void;
  103172. /**
  103173. * Get the friendly name associated with the input class.
  103174. * @returns the input friendly name
  103175. */
  103176. getSimpleName(): string;
  103177. /**
  103178. * Update the current camera state depending on the inputs that have been used this frame.
  103179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103180. */
  103181. checkInputs(): void;
  103182. }
  103183. }
  103184. declare module BABYLON {
  103185. /**
  103186. * Manage the mouse wheel inputs to control a follow camera.
  103187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103188. */
  103189. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103190. /**
  103191. * Defines the camera the input is attached to.
  103192. */
  103193. camera: FollowCamera;
  103194. /**
  103195. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103196. */
  103197. axisControlRadius: boolean;
  103198. /**
  103199. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103200. */
  103201. axisControlHeight: boolean;
  103202. /**
  103203. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103204. */
  103205. axisControlRotation: boolean;
  103206. /**
  103207. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103208. * relation to mouseWheel events.
  103209. */
  103210. wheelPrecision: number;
  103211. /**
  103212. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103213. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103214. */
  103215. wheelDeltaPercentage: number;
  103216. private _wheel;
  103217. private _observer;
  103218. /**
  103219. * Attach the input controls to a specific dom element to get the input from.
  103220. * @param element Defines the element the controls should be listened from
  103221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103222. */
  103223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103224. /**
  103225. * Detach the current controls from the specified dom element.
  103226. * @param element Defines the element to stop listening the inputs from
  103227. */
  103228. detachControl(element: Nullable<HTMLElement>): void;
  103229. /**
  103230. * Gets the class name of the current intput.
  103231. * @returns the class name
  103232. */
  103233. getClassName(): string;
  103234. /**
  103235. * Get the friendly name associated with the input class.
  103236. * @returns the input friendly name
  103237. */
  103238. getSimpleName(): string;
  103239. }
  103240. }
  103241. declare module BABYLON {
  103242. /**
  103243. * Manage the pointers inputs to control an follow camera.
  103244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103245. */
  103246. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103247. /**
  103248. * Defines the camera the input is attached to.
  103249. */
  103250. camera: FollowCamera;
  103251. /**
  103252. * Gets the class name of the current input.
  103253. * @returns the class name
  103254. */
  103255. getClassName(): string;
  103256. /**
  103257. * Defines the pointer angular sensibility along the X axis or how fast is
  103258. * the camera rotating.
  103259. * A negative number will reverse the axis direction.
  103260. */
  103261. angularSensibilityX: number;
  103262. /**
  103263. * Defines the pointer angular sensibility along the Y axis or how fast is
  103264. * the camera rotating.
  103265. * A negative number will reverse the axis direction.
  103266. */
  103267. angularSensibilityY: number;
  103268. /**
  103269. * Defines the pointer pinch precision or how fast is the camera zooming.
  103270. * A negative number will reverse the axis direction.
  103271. */
  103272. pinchPrecision: number;
  103273. /**
  103274. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103275. * from 0.
  103276. * It defines the percentage of current camera.radius to use as delta when
  103277. * pinch zoom is used.
  103278. */
  103279. pinchDeltaPercentage: number;
  103280. /**
  103281. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103282. */
  103283. axisXControlRadius: boolean;
  103284. /**
  103285. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103286. */
  103287. axisXControlHeight: boolean;
  103288. /**
  103289. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103290. */
  103291. axisXControlRotation: boolean;
  103292. /**
  103293. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103294. */
  103295. axisYControlRadius: boolean;
  103296. /**
  103297. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103298. */
  103299. axisYControlHeight: boolean;
  103300. /**
  103301. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103302. */
  103303. axisYControlRotation: boolean;
  103304. /**
  103305. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103306. */
  103307. axisPinchControlRadius: boolean;
  103308. /**
  103309. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103310. */
  103311. axisPinchControlHeight: boolean;
  103312. /**
  103313. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103314. */
  103315. axisPinchControlRotation: boolean;
  103316. /**
  103317. * Log error messages if basic misconfiguration has occurred.
  103318. */
  103319. warningEnable: boolean;
  103320. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103321. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103322. private _warningCounter;
  103323. private _warning;
  103324. }
  103325. }
  103326. declare module BABYLON {
  103327. /**
  103328. * Default Inputs manager for the FollowCamera.
  103329. * It groups all the default supported inputs for ease of use.
  103330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103331. */
  103332. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103333. /**
  103334. * Instantiates a new FollowCameraInputsManager.
  103335. * @param camera Defines the camera the inputs belong to
  103336. */
  103337. constructor(camera: FollowCamera);
  103338. /**
  103339. * Add keyboard input support to the input manager.
  103340. * @returns the current input manager
  103341. */
  103342. addKeyboard(): FollowCameraInputsManager;
  103343. /**
  103344. * Add mouse wheel input support to the input manager.
  103345. * @returns the current input manager
  103346. */
  103347. addMouseWheel(): FollowCameraInputsManager;
  103348. /**
  103349. * Add pointers input support to the input manager.
  103350. * @returns the current input manager
  103351. */
  103352. addPointers(): FollowCameraInputsManager;
  103353. /**
  103354. * Add orientation input support to the input manager.
  103355. * @returns the current input manager
  103356. */
  103357. addVRDeviceOrientation(): FollowCameraInputsManager;
  103358. }
  103359. }
  103360. declare module BABYLON {
  103361. /**
  103362. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103363. * an arc rotate version arcFollowCamera are available.
  103364. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103365. */
  103366. export class FollowCamera extends TargetCamera {
  103367. /**
  103368. * Distance the follow camera should follow an object at
  103369. */
  103370. radius: number;
  103371. /**
  103372. * Minimum allowed distance of the camera to the axis of rotation
  103373. * (The camera can not get closer).
  103374. * This can help limiting how the Camera is able to move in the scene.
  103375. */
  103376. lowerRadiusLimit: Nullable<number>;
  103377. /**
  103378. * Maximum allowed distance of the camera to the axis of rotation
  103379. * (The camera can not get further).
  103380. * This can help limiting how the Camera is able to move in the scene.
  103381. */
  103382. upperRadiusLimit: Nullable<number>;
  103383. /**
  103384. * Define a rotation offset between the camera and the object it follows
  103385. */
  103386. rotationOffset: number;
  103387. /**
  103388. * Minimum allowed angle to camera position relative to target object.
  103389. * This can help limiting how the Camera is able to move in the scene.
  103390. */
  103391. lowerRotationOffsetLimit: Nullable<number>;
  103392. /**
  103393. * Maximum allowed angle to camera position relative to target object.
  103394. * This can help limiting how the Camera is able to move in the scene.
  103395. */
  103396. upperRotationOffsetLimit: Nullable<number>;
  103397. /**
  103398. * Define a height offset between the camera and the object it follows.
  103399. * It can help following an object from the top (like a car chaing a plane)
  103400. */
  103401. heightOffset: number;
  103402. /**
  103403. * Minimum allowed height of camera position relative to target object.
  103404. * This can help limiting how the Camera is able to move in the scene.
  103405. */
  103406. lowerHeightOffsetLimit: Nullable<number>;
  103407. /**
  103408. * Maximum allowed height of camera position relative to target object.
  103409. * This can help limiting how the Camera is able to move in the scene.
  103410. */
  103411. upperHeightOffsetLimit: Nullable<number>;
  103412. /**
  103413. * Define how fast the camera can accelerate to follow it s target.
  103414. */
  103415. cameraAcceleration: number;
  103416. /**
  103417. * Define the speed limit of the camera following an object.
  103418. */
  103419. maxCameraSpeed: number;
  103420. /**
  103421. * Define the target of the camera.
  103422. */
  103423. lockedTarget: Nullable<AbstractMesh>;
  103424. /**
  103425. * Defines the input associated with the camera.
  103426. */
  103427. inputs: FollowCameraInputsManager;
  103428. /**
  103429. * Instantiates the follow camera.
  103430. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103431. * @param name Define the name of the camera in the scene
  103432. * @param position Define the position of the camera
  103433. * @param scene Define the scene the camera belong to
  103434. * @param lockedTarget Define the target of the camera
  103435. */
  103436. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103437. private _follow;
  103438. /**
  103439. * Attached controls to the current camera.
  103440. * @param element Defines the element the controls should be listened from
  103441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103442. */
  103443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103444. /**
  103445. * Detach the current controls from the camera.
  103446. * The camera will stop reacting to inputs.
  103447. * @param element Defines the element to stop listening the inputs from
  103448. */
  103449. detachControl(element: HTMLElement): void;
  103450. /** @hidden */
  103451. _checkInputs(): void;
  103452. private _checkLimits;
  103453. /**
  103454. * Gets the camera class name.
  103455. * @returns the class name
  103456. */
  103457. getClassName(): string;
  103458. }
  103459. /**
  103460. * Arc Rotate version of the follow camera.
  103461. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103462. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103463. */
  103464. export class ArcFollowCamera extends TargetCamera {
  103465. /** The longitudinal angle of the camera */
  103466. alpha: number;
  103467. /** The latitudinal angle of the camera */
  103468. beta: number;
  103469. /** The radius of the camera from its target */
  103470. radius: number;
  103471. /** Define the camera target (the messh it should follow) */
  103472. target: Nullable<AbstractMesh>;
  103473. private _cartesianCoordinates;
  103474. /**
  103475. * Instantiates a new ArcFollowCamera
  103476. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103477. * @param name Define the name of the camera
  103478. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103479. * @param beta Define the rotation angle of the camera around the elevation axis
  103480. * @param radius Define the radius of the camera from its target point
  103481. * @param target Define the target of the camera
  103482. * @param scene Define the scene the camera belongs to
  103483. */
  103484. constructor(name: string,
  103485. /** The longitudinal angle of the camera */
  103486. alpha: number,
  103487. /** The latitudinal angle of the camera */
  103488. beta: number,
  103489. /** The radius of the camera from its target */
  103490. radius: number,
  103491. /** Define the camera target (the messh it should follow) */
  103492. target: Nullable<AbstractMesh>, scene: Scene);
  103493. private _follow;
  103494. /** @hidden */
  103495. _checkInputs(): void;
  103496. /**
  103497. * Returns the class name of the object.
  103498. * It is mostly used internally for serialization purposes.
  103499. */
  103500. getClassName(): string;
  103501. }
  103502. }
  103503. declare module BABYLON {
  103504. /**
  103505. * Manage the keyboard inputs to control the movement of a follow camera.
  103506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103507. */
  103508. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103509. /**
  103510. * Defines the camera the input is attached to.
  103511. */
  103512. camera: FollowCamera;
  103513. /**
  103514. * Defines the list of key codes associated with the up action (increase heightOffset)
  103515. */
  103516. keysHeightOffsetIncr: number[];
  103517. /**
  103518. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103519. */
  103520. keysHeightOffsetDecr: number[];
  103521. /**
  103522. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103523. */
  103524. keysHeightOffsetModifierAlt: boolean;
  103525. /**
  103526. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103527. */
  103528. keysHeightOffsetModifierCtrl: boolean;
  103529. /**
  103530. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103531. */
  103532. keysHeightOffsetModifierShift: boolean;
  103533. /**
  103534. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103535. */
  103536. keysRotationOffsetIncr: number[];
  103537. /**
  103538. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103539. */
  103540. keysRotationOffsetDecr: number[];
  103541. /**
  103542. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103543. */
  103544. keysRotationOffsetModifierAlt: boolean;
  103545. /**
  103546. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103547. */
  103548. keysRotationOffsetModifierCtrl: boolean;
  103549. /**
  103550. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103551. */
  103552. keysRotationOffsetModifierShift: boolean;
  103553. /**
  103554. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103555. */
  103556. keysRadiusIncr: number[];
  103557. /**
  103558. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103559. */
  103560. keysRadiusDecr: number[];
  103561. /**
  103562. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103563. */
  103564. keysRadiusModifierAlt: boolean;
  103565. /**
  103566. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103567. */
  103568. keysRadiusModifierCtrl: boolean;
  103569. /**
  103570. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103571. */
  103572. keysRadiusModifierShift: boolean;
  103573. /**
  103574. * Defines the rate of change of heightOffset.
  103575. */
  103576. heightSensibility: number;
  103577. /**
  103578. * Defines the rate of change of rotationOffset.
  103579. */
  103580. rotationSensibility: number;
  103581. /**
  103582. * Defines the rate of change of radius.
  103583. */
  103584. radiusSensibility: number;
  103585. private _keys;
  103586. private _ctrlPressed;
  103587. private _altPressed;
  103588. private _shiftPressed;
  103589. private _onCanvasBlurObserver;
  103590. private _onKeyboardObserver;
  103591. private _engine;
  103592. private _scene;
  103593. /**
  103594. * Attach the input controls to a specific dom element to get the input from.
  103595. * @param element Defines the element the controls should be listened from
  103596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103597. */
  103598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103599. /**
  103600. * Detach the current controls from the specified dom element.
  103601. * @param element Defines the element to stop listening the inputs from
  103602. */
  103603. detachControl(element: Nullable<HTMLElement>): void;
  103604. /**
  103605. * Update the current camera state depending on the inputs that have been used this frame.
  103606. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103607. */
  103608. checkInputs(): void;
  103609. /**
  103610. * Gets the class name of the current input.
  103611. * @returns the class name
  103612. */
  103613. getClassName(): string;
  103614. /**
  103615. * Get the friendly name associated with the input class.
  103616. * @returns the input friendly name
  103617. */
  103618. getSimpleName(): string;
  103619. /**
  103620. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103621. * allow modification of the heightOffset value.
  103622. */
  103623. private _modifierHeightOffset;
  103624. /**
  103625. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103626. * allow modification of the rotationOffset value.
  103627. */
  103628. private _modifierRotationOffset;
  103629. /**
  103630. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103631. * allow modification of the radius value.
  103632. */
  103633. private _modifierRadius;
  103634. }
  103635. }
  103636. declare module BABYLON {
  103637. interface FreeCameraInputsManager {
  103638. /**
  103639. * @hidden
  103640. */
  103641. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103642. /**
  103643. * Add orientation input support to the input manager.
  103644. * @returns the current input manager
  103645. */
  103646. addDeviceOrientation(): FreeCameraInputsManager;
  103647. }
  103648. /**
  103649. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103650. * Screen rotation is taken into account.
  103651. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103652. */
  103653. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103654. private _camera;
  103655. private _screenOrientationAngle;
  103656. private _constantTranform;
  103657. private _screenQuaternion;
  103658. private _alpha;
  103659. private _beta;
  103660. private _gamma;
  103661. /**
  103662. * Can be used to detect if a device orientation sensor is availible on a device
  103663. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103664. * @returns a promise that will resolve on orientation change
  103665. */
  103666. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103667. /**
  103668. * @hidden
  103669. */
  103670. _onDeviceOrientationChangedObservable: Observable<void>;
  103671. /**
  103672. * Instantiates a new input
  103673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103674. */
  103675. constructor();
  103676. /**
  103677. * Define the camera controlled by the input.
  103678. */
  103679. camera: FreeCamera;
  103680. /**
  103681. * Attach the input controls to a specific dom element to get the input from.
  103682. * @param element Defines the element the controls should be listened from
  103683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103684. */
  103685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103686. private _orientationChanged;
  103687. private _deviceOrientation;
  103688. /**
  103689. * Detach the current controls from the specified dom element.
  103690. * @param element Defines the element to stop listening the inputs from
  103691. */
  103692. detachControl(element: Nullable<HTMLElement>): void;
  103693. /**
  103694. * Update the current camera state depending on the inputs that have been used this frame.
  103695. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103696. */
  103697. checkInputs(): void;
  103698. /**
  103699. * Gets the class name of the current intput.
  103700. * @returns the class name
  103701. */
  103702. getClassName(): string;
  103703. /**
  103704. * Get the friendly name associated with the input class.
  103705. * @returns the input friendly name
  103706. */
  103707. getSimpleName(): string;
  103708. }
  103709. }
  103710. declare module BABYLON {
  103711. /**
  103712. * Manage the gamepad inputs to control a free camera.
  103713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103714. */
  103715. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103716. /**
  103717. * Define the camera the input is attached to.
  103718. */
  103719. camera: FreeCamera;
  103720. /**
  103721. * Define the Gamepad controlling the input
  103722. */
  103723. gamepad: Nullable<Gamepad>;
  103724. /**
  103725. * Defines the gamepad rotation sensiblity.
  103726. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103727. */
  103728. gamepadAngularSensibility: number;
  103729. /**
  103730. * Defines the gamepad move sensiblity.
  103731. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103732. */
  103733. gamepadMoveSensibility: number;
  103734. private _onGamepadConnectedObserver;
  103735. private _onGamepadDisconnectedObserver;
  103736. private _cameraTransform;
  103737. private _deltaTransform;
  103738. private _vector3;
  103739. private _vector2;
  103740. /**
  103741. * Attach the input controls to a specific dom element to get the input from.
  103742. * @param element Defines the element the controls should be listened from
  103743. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103744. */
  103745. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103746. /**
  103747. * Detach the current controls from the specified dom element.
  103748. * @param element Defines the element to stop listening the inputs from
  103749. */
  103750. detachControl(element: Nullable<HTMLElement>): void;
  103751. /**
  103752. * Update the current camera state depending on the inputs that have been used this frame.
  103753. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103754. */
  103755. checkInputs(): void;
  103756. /**
  103757. * Gets the class name of the current intput.
  103758. * @returns the class name
  103759. */
  103760. getClassName(): string;
  103761. /**
  103762. * Get the friendly name associated with the input class.
  103763. * @returns the input friendly name
  103764. */
  103765. getSimpleName(): string;
  103766. }
  103767. }
  103768. declare module BABYLON {
  103769. /**
  103770. * Defines the potential axis of a Joystick
  103771. */
  103772. export enum JoystickAxis {
  103773. /** X axis */
  103774. X = 0,
  103775. /** Y axis */
  103776. Y = 1,
  103777. /** Z axis */
  103778. Z = 2
  103779. }
  103780. /**
  103781. * Class used to define virtual joystick (used in touch mode)
  103782. */
  103783. export class VirtualJoystick {
  103784. /**
  103785. * Gets or sets a boolean indicating that left and right values must be inverted
  103786. */
  103787. reverseLeftRight: boolean;
  103788. /**
  103789. * Gets or sets a boolean indicating that up and down values must be inverted
  103790. */
  103791. reverseUpDown: boolean;
  103792. /**
  103793. * Gets the offset value for the position (ie. the change of the position value)
  103794. */
  103795. deltaPosition: Vector3;
  103796. /**
  103797. * Gets a boolean indicating if the virtual joystick was pressed
  103798. */
  103799. pressed: boolean;
  103800. /**
  103801. * Canvas the virtual joystick will render onto, default z-index of this is 5
  103802. */
  103803. static Canvas: Nullable<HTMLCanvasElement>;
  103804. private static _globalJoystickIndex;
  103805. private static vjCanvasContext;
  103806. private static vjCanvasWidth;
  103807. private static vjCanvasHeight;
  103808. private static halfWidth;
  103809. private _action;
  103810. private _axisTargetedByLeftAndRight;
  103811. private _axisTargetedByUpAndDown;
  103812. private _joystickSensibility;
  103813. private _inversedSensibility;
  103814. private _joystickPointerID;
  103815. private _joystickColor;
  103816. private _joystickPointerPos;
  103817. private _joystickPreviousPointerPos;
  103818. private _joystickPointerStartPos;
  103819. private _deltaJoystickVector;
  103820. private _leftJoystick;
  103821. private _touches;
  103822. private _onPointerDownHandlerRef;
  103823. private _onPointerMoveHandlerRef;
  103824. private _onPointerUpHandlerRef;
  103825. private _onResize;
  103826. /**
  103827. * Creates a new virtual joystick
  103828. * @param leftJoystick defines that the joystick is for left hand (false by default)
  103829. */
  103830. constructor(leftJoystick?: boolean);
  103831. /**
  103832. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  103833. * @param newJoystickSensibility defines the new sensibility
  103834. */
  103835. setJoystickSensibility(newJoystickSensibility: number): void;
  103836. private _onPointerDown;
  103837. private _onPointerMove;
  103838. private _onPointerUp;
  103839. /**
  103840. * Change the color of the virtual joystick
  103841. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  103842. */
  103843. setJoystickColor(newColor: string): void;
  103844. /**
  103845. * Defines a callback to call when the joystick is touched
  103846. * @param action defines the callback
  103847. */
  103848. setActionOnTouch(action: () => any): void;
  103849. /**
  103850. * Defines which axis you'd like to control for left & right
  103851. * @param axis defines the axis to use
  103852. */
  103853. setAxisForLeftRight(axis: JoystickAxis): void;
  103854. /**
  103855. * Defines which axis you'd like to control for up & down
  103856. * @param axis defines the axis to use
  103857. */
  103858. setAxisForUpDown(axis: JoystickAxis): void;
  103859. private _drawVirtualJoystick;
  103860. /**
  103861. * Release internal HTML canvas
  103862. */
  103863. releaseCanvas(): void;
  103864. }
  103865. }
  103866. declare module BABYLON {
  103867. interface FreeCameraInputsManager {
  103868. /**
  103869. * Add virtual joystick input support to the input manager.
  103870. * @returns the current input manager
  103871. */
  103872. addVirtualJoystick(): FreeCameraInputsManager;
  103873. }
  103874. /**
  103875. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  103876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103877. */
  103878. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  103879. /**
  103880. * Defines the camera the input is attached to.
  103881. */
  103882. camera: FreeCamera;
  103883. private _leftjoystick;
  103884. private _rightjoystick;
  103885. /**
  103886. * Gets the left stick of the virtual joystick.
  103887. * @returns The virtual Joystick
  103888. */
  103889. getLeftJoystick(): VirtualJoystick;
  103890. /**
  103891. * Gets the right stick of the virtual joystick.
  103892. * @returns The virtual Joystick
  103893. */
  103894. getRightJoystick(): VirtualJoystick;
  103895. /**
  103896. * Update the current camera state depending on the inputs that have been used this frame.
  103897. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103898. */
  103899. checkInputs(): void;
  103900. /**
  103901. * Attach the input controls to a specific dom element to get the input from.
  103902. * @param element Defines the element the controls should be listened from
  103903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103904. */
  103905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103906. /**
  103907. * Detach the current controls from the specified dom element.
  103908. * @param element Defines the element to stop listening the inputs from
  103909. */
  103910. detachControl(element: Nullable<HTMLElement>): void;
  103911. /**
  103912. * Gets the class name of the current intput.
  103913. * @returns the class name
  103914. */
  103915. getClassName(): string;
  103916. /**
  103917. * Get the friendly name associated with the input class.
  103918. * @returns the input friendly name
  103919. */
  103920. getSimpleName(): string;
  103921. }
  103922. }
  103923. declare module BABYLON {
  103924. /**
  103925. * This represents a FPS type of camera controlled by touch.
  103926. * This is like a universal camera minus the Gamepad controls.
  103927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103928. */
  103929. export class TouchCamera extends FreeCamera {
  103930. /**
  103931. * Defines the touch sensibility for rotation.
  103932. * The higher the faster.
  103933. */
  103934. touchAngularSensibility: number;
  103935. /**
  103936. * Defines the touch sensibility for move.
  103937. * The higher the faster.
  103938. */
  103939. touchMoveSensibility: number;
  103940. /**
  103941. * Instantiates a new touch camera.
  103942. * This represents a FPS type of camera controlled by touch.
  103943. * This is like a universal camera minus the Gamepad controls.
  103944. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103945. * @param name Define the name of the camera in the scene
  103946. * @param position Define the start position of the camera in the scene
  103947. * @param scene Define the scene the camera belongs to
  103948. */
  103949. constructor(name: string, position: Vector3, scene: Scene);
  103950. /**
  103951. * Gets the current object class name.
  103952. * @return the class name
  103953. */
  103954. getClassName(): string;
  103955. /** @hidden */
  103956. _setupInputs(): void;
  103957. }
  103958. }
  103959. declare module BABYLON {
  103960. /**
  103961. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  103962. * being tilted forward or back and left or right.
  103963. */
  103964. export class DeviceOrientationCamera extends FreeCamera {
  103965. private _initialQuaternion;
  103966. private _quaternionCache;
  103967. private _tmpDragQuaternion;
  103968. private _disablePointerInputWhenUsingDeviceOrientation;
  103969. /**
  103970. * Creates a new device orientation camera
  103971. * @param name The name of the camera
  103972. * @param position The start position camera
  103973. * @param scene The scene the camera belongs to
  103974. */
  103975. constructor(name: string, position: Vector3, scene: Scene);
  103976. /**
  103977. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  103978. */
  103979. disablePointerInputWhenUsingDeviceOrientation: boolean;
  103980. private _dragFactor;
  103981. /**
  103982. * Enabled turning on the y axis when the orientation sensor is active
  103983. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  103984. */
  103985. enableHorizontalDragging(dragFactor?: number): void;
  103986. /**
  103987. * Gets the current instance class name ("DeviceOrientationCamera").
  103988. * This helps avoiding instanceof at run time.
  103989. * @returns the class name
  103990. */
  103991. getClassName(): string;
  103992. /**
  103993. * @hidden
  103994. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  103995. */
  103996. _checkInputs(): void;
  103997. /**
  103998. * Reset the camera to its default orientation on the specified axis only.
  103999. * @param axis The axis to reset
  104000. */
  104001. resetToCurrentRotation(axis?: Axis): void;
  104002. }
  104003. }
  104004. declare module BABYLON {
  104005. /**
  104006. * Defines supported buttons for XBox360 compatible gamepads
  104007. */
  104008. export enum Xbox360Button {
  104009. /** A */
  104010. A = 0,
  104011. /** B */
  104012. B = 1,
  104013. /** X */
  104014. X = 2,
  104015. /** Y */
  104016. Y = 3,
  104017. /** Start */
  104018. Start = 4,
  104019. /** Back */
  104020. Back = 5,
  104021. /** Left button */
  104022. LB = 6,
  104023. /** Right button */
  104024. RB = 7,
  104025. /** Left stick */
  104026. LeftStick = 8,
  104027. /** Right stick */
  104028. RightStick = 9
  104029. }
  104030. /** Defines values for XBox360 DPad */
  104031. export enum Xbox360Dpad {
  104032. /** Up */
  104033. Up = 0,
  104034. /** Down */
  104035. Down = 1,
  104036. /** Left */
  104037. Left = 2,
  104038. /** Right */
  104039. Right = 3
  104040. }
  104041. /**
  104042. * Defines a XBox360 gamepad
  104043. */
  104044. export class Xbox360Pad extends Gamepad {
  104045. private _leftTrigger;
  104046. private _rightTrigger;
  104047. private _onlefttriggerchanged;
  104048. private _onrighttriggerchanged;
  104049. private _onbuttondown;
  104050. private _onbuttonup;
  104051. private _ondpaddown;
  104052. private _ondpadup;
  104053. /** Observable raised when a button is pressed */
  104054. onButtonDownObservable: Observable<Xbox360Button>;
  104055. /** Observable raised when a button is released */
  104056. onButtonUpObservable: Observable<Xbox360Button>;
  104057. /** Observable raised when a pad is pressed */
  104058. onPadDownObservable: Observable<Xbox360Dpad>;
  104059. /** Observable raised when a pad is released */
  104060. onPadUpObservable: Observable<Xbox360Dpad>;
  104061. private _buttonA;
  104062. private _buttonB;
  104063. private _buttonX;
  104064. private _buttonY;
  104065. private _buttonBack;
  104066. private _buttonStart;
  104067. private _buttonLB;
  104068. private _buttonRB;
  104069. private _buttonLeftStick;
  104070. private _buttonRightStick;
  104071. private _dPadUp;
  104072. private _dPadDown;
  104073. private _dPadLeft;
  104074. private _dPadRight;
  104075. private _isXboxOnePad;
  104076. /**
  104077. * Creates a new XBox360 gamepad object
  104078. * @param id defines the id of this gamepad
  104079. * @param index defines its index
  104080. * @param gamepad defines the internal HTML gamepad object
  104081. * @param xboxOne defines if it is a XBox One gamepad
  104082. */
  104083. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104084. /**
  104085. * Defines the callback to call when left trigger is pressed
  104086. * @param callback defines the callback to use
  104087. */
  104088. onlefttriggerchanged(callback: (value: number) => void): void;
  104089. /**
  104090. * Defines the callback to call when right trigger is pressed
  104091. * @param callback defines the callback to use
  104092. */
  104093. onrighttriggerchanged(callback: (value: number) => void): void;
  104094. /**
  104095. * Gets the left trigger value
  104096. */
  104097. /**
  104098. * Sets the left trigger value
  104099. */
  104100. leftTrigger: number;
  104101. /**
  104102. * Gets the right trigger value
  104103. */
  104104. /**
  104105. * Sets the right trigger value
  104106. */
  104107. rightTrigger: number;
  104108. /**
  104109. * Defines the callback to call when a button is pressed
  104110. * @param callback defines the callback to use
  104111. */
  104112. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104113. /**
  104114. * Defines the callback to call when a button is released
  104115. * @param callback defines the callback to use
  104116. */
  104117. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104118. /**
  104119. * Defines the callback to call when a pad is pressed
  104120. * @param callback defines the callback to use
  104121. */
  104122. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104123. /**
  104124. * Defines the callback to call when a pad is released
  104125. * @param callback defines the callback to use
  104126. */
  104127. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104128. private _setButtonValue;
  104129. private _setDPadValue;
  104130. /**
  104131. * Gets the value of the `A` button
  104132. */
  104133. /**
  104134. * Sets the value of the `A` button
  104135. */
  104136. buttonA: number;
  104137. /**
  104138. * Gets the value of the `B` button
  104139. */
  104140. /**
  104141. * Sets the value of the `B` button
  104142. */
  104143. buttonB: number;
  104144. /**
  104145. * Gets the value of the `X` button
  104146. */
  104147. /**
  104148. * Sets the value of the `X` button
  104149. */
  104150. buttonX: number;
  104151. /**
  104152. * Gets the value of the `Y` button
  104153. */
  104154. /**
  104155. * Sets the value of the `Y` button
  104156. */
  104157. buttonY: number;
  104158. /**
  104159. * Gets the value of the `Start` button
  104160. */
  104161. /**
  104162. * Sets the value of the `Start` button
  104163. */
  104164. buttonStart: number;
  104165. /**
  104166. * Gets the value of the `Back` button
  104167. */
  104168. /**
  104169. * Sets the value of the `Back` button
  104170. */
  104171. buttonBack: number;
  104172. /**
  104173. * Gets the value of the `Left` button
  104174. */
  104175. /**
  104176. * Sets the value of the `Left` button
  104177. */
  104178. buttonLB: number;
  104179. /**
  104180. * Gets the value of the `Right` button
  104181. */
  104182. /**
  104183. * Sets the value of the `Right` button
  104184. */
  104185. buttonRB: number;
  104186. /**
  104187. * Gets the value of the Left joystick
  104188. */
  104189. /**
  104190. * Sets the value of the Left joystick
  104191. */
  104192. buttonLeftStick: number;
  104193. /**
  104194. * Gets the value of the Right joystick
  104195. */
  104196. /**
  104197. * Sets the value of the Right joystick
  104198. */
  104199. buttonRightStick: number;
  104200. /**
  104201. * Gets the value of D-pad up
  104202. */
  104203. /**
  104204. * Sets the value of D-pad up
  104205. */
  104206. dPadUp: number;
  104207. /**
  104208. * Gets the value of D-pad down
  104209. */
  104210. /**
  104211. * Sets the value of D-pad down
  104212. */
  104213. dPadDown: number;
  104214. /**
  104215. * Gets the value of D-pad left
  104216. */
  104217. /**
  104218. * Sets the value of D-pad left
  104219. */
  104220. dPadLeft: number;
  104221. /**
  104222. * Gets the value of D-pad right
  104223. */
  104224. /**
  104225. * Sets the value of D-pad right
  104226. */
  104227. dPadRight: number;
  104228. /**
  104229. * Force the gamepad to synchronize with device values
  104230. */
  104231. update(): void;
  104232. /**
  104233. * Disposes the gamepad
  104234. */
  104235. dispose(): void;
  104236. }
  104237. }
  104238. declare module BABYLON {
  104239. /**
  104240. * Defines supported buttons for DualShock compatible gamepads
  104241. */
  104242. export enum DualShockButton {
  104243. /** Cross */
  104244. Cross = 0,
  104245. /** Circle */
  104246. Circle = 1,
  104247. /** Square */
  104248. Square = 2,
  104249. /** Triangle */
  104250. Triangle = 3,
  104251. /** Options */
  104252. Options = 4,
  104253. /** Share */
  104254. Share = 5,
  104255. /** L1 */
  104256. L1 = 6,
  104257. /** R1 */
  104258. R1 = 7,
  104259. /** Left stick */
  104260. LeftStick = 8,
  104261. /** Right stick */
  104262. RightStick = 9
  104263. }
  104264. /** Defines values for DualShock DPad */
  104265. export enum DualShockDpad {
  104266. /** Up */
  104267. Up = 0,
  104268. /** Down */
  104269. Down = 1,
  104270. /** Left */
  104271. Left = 2,
  104272. /** Right */
  104273. Right = 3
  104274. }
  104275. /**
  104276. * Defines a DualShock gamepad
  104277. */
  104278. export class DualShockPad extends Gamepad {
  104279. private _leftTrigger;
  104280. private _rightTrigger;
  104281. private _onlefttriggerchanged;
  104282. private _onrighttriggerchanged;
  104283. private _onbuttondown;
  104284. private _onbuttonup;
  104285. private _ondpaddown;
  104286. private _ondpadup;
  104287. /** Observable raised when a button is pressed */
  104288. onButtonDownObservable: Observable<DualShockButton>;
  104289. /** Observable raised when a button is released */
  104290. onButtonUpObservable: Observable<DualShockButton>;
  104291. /** Observable raised when a pad is pressed */
  104292. onPadDownObservable: Observable<DualShockDpad>;
  104293. /** Observable raised when a pad is released */
  104294. onPadUpObservable: Observable<DualShockDpad>;
  104295. private _buttonCross;
  104296. private _buttonCircle;
  104297. private _buttonSquare;
  104298. private _buttonTriangle;
  104299. private _buttonShare;
  104300. private _buttonOptions;
  104301. private _buttonL1;
  104302. private _buttonR1;
  104303. private _buttonLeftStick;
  104304. private _buttonRightStick;
  104305. private _dPadUp;
  104306. private _dPadDown;
  104307. private _dPadLeft;
  104308. private _dPadRight;
  104309. /**
  104310. * Creates a new DualShock gamepad object
  104311. * @param id defines the id of this gamepad
  104312. * @param index defines its index
  104313. * @param gamepad defines the internal HTML gamepad object
  104314. */
  104315. constructor(id: string, index: number, gamepad: any);
  104316. /**
  104317. * Defines the callback to call when left trigger is pressed
  104318. * @param callback defines the callback to use
  104319. */
  104320. onlefttriggerchanged(callback: (value: number) => void): void;
  104321. /**
  104322. * Defines the callback to call when right trigger is pressed
  104323. * @param callback defines the callback to use
  104324. */
  104325. onrighttriggerchanged(callback: (value: number) => void): void;
  104326. /**
  104327. * Gets the left trigger value
  104328. */
  104329. /**
  104330. * Sets the left trigger value
  104331. */
  104332. leftTrigger: number;
  104333. /**
  104334. * Gets the right trigger value
  104335. */
  104336. /**
  104337. * Sets the right trigger value
  104338. */
  104339. rightTrigger: number;
  104340. /**
  104341. * Defines the callback to call when a button is pressed
  104342. * @param callback defines the callback to use
  104343. */
  104344. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104345. /**
  104346. * Defines the callback to call when a button is released
  104347. * @param callback defines the callback to use
  104348. */
  104349. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104350. /**
  104351. * Defines the callback to call when a pad is pressed
  104352. * @param callback defines the callback to use
  104353. */
  104354. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104355. /**
  104356. * Defines the callback to call when a pad is released
  104357. * @param callback defines the callback to use
  104358. */
  104359. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104360. private _setButtonValue;
  104361. private _setDPadValue;
  104362. /**
  104363. * Gets the value of the `Cross` button
  104364. */
  104365. /**
  104366. * Sets the value of the `Cross` button
  104367. */
  104368. buttonCross: number;
  104369. /**
  104370. * Gets the value of the `Circle` button
  104371. */
  104372. /**
  104373. * Sets the value of the `Circle` button
  104374. */
  104375. buttonCircle: number;
  104376. /**
  104377. * Gets the value of the `Square` button
  104378. */
  104379. /**
  104380. * Sets the value of the `Square` button
  104381. */
  104382. buttonSquare: number;
  104383. /**
  104384. * Gets the value of the `Triangle` button
  104385. */
  104386. /**
  104387. * Sets the value of the `Triangle` button
  104388. */
  104389. buttonTriangle: number;
  104390. /**
  104391. * Gets the value of the `Options` button
  104392. */
  104393. /**
  104394. * Sets the value of the `Options` button
  104395. */
  104396. buttonOptions: number;
  104397. /**
  104398. * Gets the value of the `Share` button
  104399. */
  104400. /**
  104401. * Sets the value of the `Share` button
  104402. */
  104403. buttonShare: number;
  104404. /**
  104405. * Gets the value of the `L1` button
  104406. */
  104407. /**
  104408. * Sets the value of the `L1` button
  104409. */
  104410. buttonL1: number;
  104411. /**
  104412. * Gets the value of the `R1` button
  104413. */
  104414. /**
  104415. * Sets the value of the `R1` button
  104416. */
  104417. buttonR1: number;
  104418. /**
  104419. * Gets the value of the Left joystick
  104420. */
  104421. /**
  104422. * Sets the value of the Left joystick
  104423. */
  104424. buttonLeftStick: number;
  104425. /**
  104426. * Gets the value of the Right joystick
  104427. */
  104428. /**
  104429. * Sets the value of the Right joystick
  104430. */
  104431. buttonRightStick: number;
  104432. /**
  104433. * Gets the value of D-pad up
  104434. */
  104435. /**
  104436. * Sets the value of D-pad up
  104437. */
  104438. dPadUp: number;
  104439. /**
  104440. * Gets the value of D-pad down
  104441. */
  104442. /**
  104443. * Sets the value of D-pad down
  104444. */
  104445. dPadDown: number;
  104446. /**
  104447. * Gets the value of D-pad left
  104448. */
  104449. /**
  104450. * Sets the value of D-pad left
  104451. */
  104452. dPadLeft: number;
  104453. /**
  104454. * Gets the value of D-pad right
  104455. */
  104456. /**
  104457. * Sets the value of D-pad right
  104458. */
  104459. dPadRight: number;
  104460. /**
  104461. * Force the gamepad to synchronize with device values
  104462. */
  104463. update(): void;
  104464. /**
  104465. * Disposes the gamepad
  104466. */
  104467. dispose(): void;
  104468. }
  104469. }
  104470. declare module BABYLON {
  104471. /**
  104472. * Manager for handling gamepads
  104473. */
  104474. export class GamepadManager {
  104475. private _scene?;
  104476. private _babylonGamepads;
  104477. private _oneGamepadConnected;
  104478. /** @hidden */
  104479. _isMonitoring: boolean;
  104480. private _gamepadEventSupported;
  104481. private _gamepadSupport;
  104482. /**
  104483. * observable to be triggered when the gamepad controller has been connected
  104484. */
  104485. onGamepadConnectedObservable: Observable<Gamepad>;
  104486. /**
  104487. * observable to be triggered when the gamepad controller has been disconnected
  104488. */
  104489. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104490. private _onGamepadConnectedEvent;
  104491. private _onGamepadDisconnectedEvent;
  104492. /**
  104493. * Initializes the gamepad manager
  104494. * @param _scene BabylonJS scene
  104495. */
  104496. constructor(_scene?: Scene | undefined);
  104497. /**
  104498. * The gamepads in the game pad manager
  104499. */
  104500. readonly gamepads: Gamepad[];
  104501. /**
  104502. * Get the gamepad controllers based on type
  104503. * @param type The type of gamepad controller
  104504. * @returns Nullable gamepad
  104505. */
  104506. getGamepadByType(type?: number): Nullable<Gamepad>;
  104507. /**
  104508. * Disposes the gamepad manager
  104509. */
  104510. dispose(): void;
  104511. private _addNewGamepad;
  104512. private _startMonitoringGamepads;
  104513. private _stopMonitoringGamepads;
  104514. /** @hidden */
  104515. _checkGamepadsStatus(): void;
  104516. private _updateGamepadObjects;
  104517. }
  104518. }
  104519. declare module BABYLON {
  104520. interface Scene {
  104521. /** @hidden */
  104522. _gamepadManager: Nullable<GamepadManager>;
  104523. /**
  104524. * Gets the gamepad manager associated with the scene
  104525. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104526. */
  104527. gamepadManager: GamepadManager;
  104528. }
  104529. /**
  104530. * Interface representing a free camera inputs manager
  104531. */
  104532. interface FreeCameraInputsManager {
  104533. /**
  104534. * Adds gamepad input support to the FreeCameraInputsManager.
  104535. * @returns the FreeCameraInputsManager
  104536. */
  104537. addGamepad(): FreeCameraInputsManager;
  104538. }
  104539. /**
  104540. * Interface representing an arc rotate camera inputs manager
  104541. */
  104542. interface ArcRotateCameraInputsManager {
  104543. /**
  104544. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104545. * @returns the camera inputs manager
  104546. */
  104547. addGamepad(): ArcRotateCameraInputsManager;
  104548. }
  104549. /**
  104550. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104551. */
  104552. export class GamepadSystemSceneComponent implements ISceneComponent {
  104553. /**
  104554. * The component name helpfull to identify the component in the list of scene components.
  104555. */
  104556. readonly name: string;
  104557. /**
  104558. * The scene the component belongs to.
  104559. */
  104560. scene: Scene;
  104561. /**
  104562. * Creates a new instance of the component for the given scene
  104563. * @param scene Defines the scene to register the component in
  104564. */
  104565. constructor(scene: Scene);
  104566. /**
  104567. * Registers the component in a given scene
  104568. */
  104569. register(): void;
  104570. /**
  104571. * Rebuilds the elements related to this component in case of
  104572. * context lost for instance.
  104573. */
  104574. rebuild(): void;
  104575. /**
  104576. * Disposes the component and the associated ressources
  104577. */
  104578. dispose(): void;
  104579. private _beforeCameraUpdate;
  104580. }
  104581. }
  104582. declare module BABYLON {
  104583. /**
  104584. * 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,
  104585. * which still works and will still be found in many Playgrounds.
  104586. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104587. */
  104588. export class UniversalCamera extends TouchCamera {
  104589. /**
  104590. * Defines the gamepad rotation sensiblity.
  104591. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104592. */
  104593. gamepadAngularSensibility: number;
  104594. /**
  104595. * Defines the gamepad move sensiblity.
  104596. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104597. */
  104598. gamepadMoveSensibility: number;
  104599. /**
  104600. * 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,
  104601. * which still works and will still be found in many Playgrounds.
  104602. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104603. * @param name Define the name of the camera in the scene
  104604. * @param position Define the start position of the camera in the scene
  104605. * @param scene Define the scene the camera belongs to
  104606. */
  104607. constructor(name: string, position: Vector3, scene: Scene);
  104608. /**
  104609. * Gets the current object class name.
  104610. * @return the class name
  104611. */
  104612. getClassName(): string;
  104613. }
  104614. }
  104615. declare module BABYLON {
  104616. /**
  104617. * This represents a FPS type of camera. This is only here for back compat purpose.
  104618. * Please use the UniversalCamera instead as both are identical.
  104619. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104620. */
  104621. export class GamepadCamera extends UniversalCamera {
  104622. /**
  104623. * Instantiates a new Gamepad Camera
  104624. * This represents a FPS type of camera. This is only here for back compat purpose.
  104625. * Please use the UniversalCamera instead as both are identical.
  104626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104627. * @param name Define the name of the camera in the scene
  104628. * @param position Define the start position of the camera in the scene
  104629. * @param scene Define the scene the camera belongs to
  104630. */
  104631. constructor(name: string, position: Vector3, scene: Scene);
  104632. /**
  104633. * Gets the current object class name.
  104634. * @return the class name
  104635. */
  104636. getClassName(): string;
  104637. }
  104638. }
  104639. declare module BABYLON {
  104640. /** @hidden */
  104641. export var passPixelShader: {
  104642. name: string;
  104643. shader: string;
  104644. };
  104645. }
  104646. declare module BABYLON {
  104647. /** @hidden */
  104648. export var passCubePixelShader: {
  104649. name: string;
  104650. shader: string;
  104651. };
  104652. }
  104653. declare module BABYLON {
  104654. /**
  104655. * PassPostProcess which produces an output the same as it's input
  104656. */
  104657. export class PassPostProcess extends PostProcess {
  104658. /**
  104659. * Creates the PassPostProcess
  104660. * @param name The name of the effect.
  104661. * @param options The required width/height ratio to downsize to before computing the render pass.
  104662. * @param camera The camera to apply the render pass to.
  104663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104664. * @param engine The engine which the post process will be applied. (default: current engine)
  104665. * @param reusable If the post process can be reused on the same frame. (default: false)
  104666. * @param textureType The type of texture to be used when performing the post processing.
  104667. * @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)
  104668. */
  104669. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104670. }
  104671. /**
  104672. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104673. */
  104674. export class PassCubePostProcess extends PostProcess {
  104675. private _face;
  104676. /**
  104677. * Gets or sets the cube face to display.
  104678. * * 0 is +X
  104679. * * 1 is -X
  104680. * * 2 is +Y
  104681. * * 3 is -Y
  104682. * * 4 is +Z
  104683. * * 5 is -Z
  104684. */
  104685. face: number;
  104686. /**
  104687. * Creates the PassCubePostProcess
  104688. * @param name The name of the effect.
  104689. * @param options The required width/height ratio to downsize to before computing the render pass.
  104690. * @param camera The camera to apply the render pass to.
  104691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104692. * @param engine The engine which the post process will be applied. (default: current engine)
  104693. * @param reusable If the post process can be reused on the same frame. (default: false)
  104694. * @param textureType The type of texture to be used when performing the post processing.
  104695. * @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)
  104696. */
  104697. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104698. }
  104699. }
  104700. declare module BABYLON {
  104701. /** @hidden */
  104702. export var anaglyphPixelShader: {
  104703. name: string;
  104704. shader: string;
  104705. };
  104706. }
  104707. declare module BABYLON {
  104708. /**
  104709. * Postprocess used to generate anaglyphic rendering
  104710. */
  104711. export class AnaglyphPostProcess extends PostProcess {
  104712. private _passedProcess;
  104713. /**
  104714. * Creates a new AnaglyphPostProcess
  104715. * @param name defines postprocess name
  104716. * @param options defines creation options or target ratio scale
  104717. * @param rigCameras defines cameras using this postprocess
  104718. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  104719. * @param engine defines hosting engine
  104720. * @param reusable defines if the postprocess will be reused multiple times per frame
  104721. */
  104722. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  104723. }
  104724. }
  104725. declare module BABYLON {
  104726. /**
  104727. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  104728. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104729. */
  104730. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  104731. /**
  104732. * Creates a new AnaglyphArcRotateCamera
  104733. * @param name defines camera name
  104734. * @param alpha defines alpha angle (in radians)
  104735. * @param beta defines beta angle (in radians)
  104736. * @param radius defines radius
  104737. * @param target defines camera target
  104738. * @param interaxialDistance defines distance between each color axis
  104739. * @param scene defines the hosting scene
  104740. */
  104741. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  104742. /**
  104743. * Gets camera class name
  104744. * @returns AnaglyphArcRotateCamera
  104745. */
  104746. getClassName(): string;
  104747. }
  104748. }
  104749. declare module BABYLON {
  104750. /**
  104751. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  104752. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104753. */
  104754. export class AnaglyphFreeCamera extends FreeCamera {
  104755. /**
  104756. * Creates a new AnaglyphFreeCamera
  104757. * @param name defines camera name
  104758. * @param position defines initial position
  104759. * @param interaxialDistance defines distance between each color axis
  104760. * @param scene defines the hosting scene
  104761. */
  104762. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104763. /**
  104764. * Gets camera class name
  104765. * @returns AnaglyphFreeCamera
  104766. */
  104767. getClassName(): string;
  104768. }
  104769. }
  104770. declare module BABYLON {
  104771. /**
  104772. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  104773. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104774. */
  104775. export class AnaglyphGamepadCamera extends GamepadCamera {
  104776. /**
  104777. * Creates a new AnaglyphGamepadCamera
  104778. * @param name defines camera name
  104779. * @param position defines initial position
  104780. * @param interaxialDistance defines distance between each color axis
  104781. * @param scene defines the hosting scene
  104782. */
  104783. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104784. /**
  104785. * Gets camera class name
  104786. * @returns AnaglyphGamepadCamera
  104787. */
  104788. getClassName(): string;
  104789. }
  104790. }
  104791. declare module BABYLON {
  104792. /**
  104793. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  104794. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  104795. */
  104796. export class AnaglyphUniversalCamera extends UniversalCamera {
  104797. /**
  104798. * Creates a new AnaglyphUniversalCamera
  104799. * @param name defines camera name
  104800. * @param position defines initial position
  104801. * @param interaxialDistance defines distance between each color axis
  104802. * @param scene defines the hosting scene
  104803. */
  104804. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  104805. /**
  104806. * Gets camera class name
  104807. * @returns AnaglyphUniversalCamera
  104808. */
  104809. getClassName(): string;
  104810. }
  104811. }
  104812. declare module BABYLON {
  104813. /** @hidden */
  104814. export var stereoscopicInterlacePixelShader: {
  104815. name: string;
  104816. shader: string;
  104817. };
  104818. }
  104819. declare module BABYLON {
  104820. /**
  104821. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  104822. */
  104823. export class StereoscopicInterlacePostProcess extends PostProcess {
  104824. private _stepSize;
  104825. private _passedProcess;
  104826. /**
  104827. * Initializes a StereoscopicInterlacePostProcess
  104828. * @param name The name of the effect.
  104829. * @param rigCameras The rig cameras to be appled to the post process
  104830. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  104831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104832. * @param engine The engine which the post process will be applied. (default: current engine)
  104833. * @param reusable If the post process can be reused on the same frame. (default: false)
  104834. */
  104835. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  104836. }
  104837. }
  104838. declare module BABYLON {
  104839. /**
  104840. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  104841. * @see http://doc.babylonjs.com/features/cameras
  104842. */
  104843. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  104844. /**
  104845. * Creates a new StereoscopicArcRotateCamera
  104846. * @param name defines camera name
  104847. * @param alpha defines alpha angle (in radians)
  104848. * @param beta defines beta angle (in radians)
  104849. * @param radius defines radius
  104850. * @param target defines camera target
  104851. * @param interaxialDistance defines distance between each color axis
  104852. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104853. * @param scene defines the hosting scene
  104854. */
  104855. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104856. /**
  104857. * Gets camera class name
  104858. * @returns StereoscopicArcRotateCamera
  104859. */
  104860. getClassName(): string;
  104861. }
  104862. }
  104863. declare module BABYLON {
  104864. /**
  104865. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  104866. * @see http://doc.babylonjs.com/features/cameras
  104867. */
  104868. export class StereoscopicFreeCamera extends FreeCamera {
  104869. /**
  104870. * Creates a new StereoscopicFreeCamera
  104871. * @param name defines camera name
  104872. * @param position defines initial position
  104873. * @param interaxialDistance defines distance between each color axis
  104874. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104875. * @param scene defines the hosting scene
  104876. */
  104877. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104878. /**
  104879. * Gets camera class name
  104880. * @returns StereoscopicFreeCamera
  104881. */
  104882. getClassName(): string;
  104883. }
  104884. }
  104885. declare module BABYLON {
  104886. /**
  104887. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  104888. * @see http://doc.babylonjs.com/features/cameras
  104889. */
  104890. export class StereoscopicGamepadCamera extends GamepadCamera {
  104891. /**
  104892. * Creates a new StereoscopicGamepadCamera
  104893. * @param name defines camera name
  104894. * @param position defines initial position
  104895. * @param interaxialDistance defines distance between each color axis
  104896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104897. * @param scene defines the hosting scene
  104898. */
  104899. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104900. /**
  104901. * Gets camera class name
  104902. * @returns StereoscopicGamepadCamera
  104903. */
  104904. getClassName(): string;
  104905. }
  104906. }
  104907. declare module BABYLON {
  104908. /**
  104909. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  104910. * @see http://doc.babylonjs.com/features/cameras
  104911. */
  104912. export class StereoscopicUniversalCamera extends UniversalCamera {
  104913. /**
  104914. * Creates a new StereoscopicUniversalCamera
  104915. * @param name defines camera name
  104916. * @param position defines initial position
  104917. * @param interaxialDistance defines distance between each color axis
  104918. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  104919. * @param scene defines the hosting scene
  104920. */
  104921. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  104922. /**
  104923. * Gets camera class name
  104924. * @returns StereoscopicUniversalCamera
  104925. */
  104926. getClassName(): string;
  104927. }
  104928. }
  104929. declare module BABYLON {
  104930. /**
  104931. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  104932. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104933. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104934. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104935. */
  104936. export class VirtualJoysticksCamera extends FreeCamera {
  104937. /**
  104938. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  104939. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  104940. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  104941. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  104942. * @param name Define the name of the camera in the scene
  104943. * @param position Define the start position of the camera in the scene
  104944. * @param scene Define the scene the camera belongs to
  104945. */
  104946. constructor(name: string, position: Vector3, scene: Scene);
  104947. /**
  104948. * Gets the current object class name.
  104949. * @return the class name
  104950. */
  104951. getClassName(): string;
  104952. }
  104953. }
  104954. declare module BABYLON {
  104955. /**
  104956. * This represents all the required metrics to create a VR camera.
  104957. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  104958. */
  104959. export class VRCameraMetrics {
  104960. /**
  104961. * Define the horizontal resolution off the screen.
  104962. */
  104963. hResolution: number;
  104964. /**
  104965. * Define the vertical resolution off the screen.
  104966. */
  104967. vResolution: number;
  104968. /**
  104969. * Define the horizontal screen size.
  104970. */
  104971. hScreenSize: number;
  104972. /**
  104973. * Define the vertical screen size.
  104974. */
  104975. vScreenSize: number;
  104976. /**
  104977. * Define the vertical screen center position.
  104978. */
  104979. vScreenCenter: number;
  104980. /**
  104981. * Define the distance of the eyes to the screen.
  104982. */
  104983. eyeToScreenDistance: number;
  104984. /**
  104985. * Define the distance between both lenses
  104986. */
  104987. lensSeparationDistance: number;
  104988. /**
  104989. * Define the distance between both viewer's eyes.
  104990. */
  104991. interpupillaryDistance: number;
  104992. /**
  104993. * Define the distortion factor of the VR postprocess.
  104994. * Please, touch with care.
  104995. */
  104996. distortionK: number[];
  104997. /**
  104998. * Define the chromatic aberration correction factors for the VR post process.
  104999. */
  105000. chromaAbCorrection: number[];
  105001. /**
  105002. * Define the scale factor of the post process.
  105003. * The smaller the better but the slower.
  105004. */
  105005. postProcessScaleFactor: number;
  105006. /**
  105007. * Define an offset for the lens center.
  105008. */
  105009. lensCenterOffset: number;
  105010. /**
  105011. * Define if the current vr camera should compensate the distortion of the lense or not.
  105012. */
  105013. compensateDistortion: boolean;
  105014. /**
  105015. * Defines if multiview should be enabled when rendering (Default: false)
  105016. */
  105017. multiviewEnabled: boolean;
  105018. /**
  105019. * Gets the rendering aspect ratio based on the provided resolutions.
  105020. */
  105021. readonly aspectRatio: number;
  105022. /**
  105023. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105024. */
  105025. readonly aspectRatioFov: number;
  105026. /**
  105027. * @hidden
  105028. */
  105029. readonly leftHMatrix: Matrix;
  105030. /**
  105031. * @hidden
  105032. */
  105033. readonly rightHMatrix: Matrix;
  105034. /**
  105035. * @hidden
  105036. */
  105037. readonly leftPreViewMatrix: Matrix;
  105038. /**
  105039. * @hidden
  105040. */
  105041. readonly rightPreViewMatrix: Matrix;
  105042. /**
  105043. * Get the default VRMetrics based on the most generic setup.
  105044. * @returns the default vr metrics
  105045. */
  105046. static GetDefault(): VRCameraMetrics;
  105047. }
  105048. }
  105049. declare module BABYLON {
  105050. /** @hidden */
  105051. export var vrDistortionCorrectionPixelShader: {
  105052. name: string;
  105053. shader: string;
  105054. };
  105055. }
  105056. declare module BABYLON {
  105057. /**
  105058. * VRDistortionCorrectionPostProcess used for mobile VR
  105059. */
  105060. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105061. private _isRightEye;
  105062. private _distortionFactors;
  105063. private _postProcessScaleFactor;
  105064. private _lensCenterOffset;
  105065. private _scaleIn;
  105066. private _scaleFactor;
  105067. private _lensCenter;
  105068. /**
  105069. * Initializes the VRDistortionCorrectionPostProcess
  105070. * @param name The name of the effect.
  105071. * @param camera The camera to apply the render pass to.
  105072. * @param isRightEye If this is for the right eye distortion
  105073. * @param vrMetrics All the required metrics for the VR camera
  105074. */
  105075. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105076. }
  105077. }
  105078. declare module BABYLON {
  105079. /**
  105080. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105081. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105082. */
  105083. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105084. /**
  105085. * Creates a new VRDeviceOrientationArcRotateCamera
  105086. * @param name defines camera name
  105087. * @param alpha defines the camera rotation along the logitudinal axis
  105088. * @param beta defines the camera rotation along the latitudinal axis
  105089. * @param radius defines the camera distance from its target
  105090. * @param target defines the camera target
  105091. * @param scene defines the scene the camera belongs to
  105092. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105093. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105094. */
  105095. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105096. /**
  105097. * Gets camera class name
  105098. * @returns VRDeviceOrientationArcRotateCamera
  105099. */
  105100. getClassName(): string;
  105101. }
  105102. }
  105103. declare module BABYLON {
  105104. /**
  105105. * Camera used to simulate VR rendering (based on FreeCamera)
  105106. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105107. */
  105108. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105109. /**
  105110. * Creates a new VRDeviceOrientationFreeCamera
  105111. * @param name defines camera name
  105112. * @param position defines the start position of the camera
  105113. * @param scene defines the scene the camera belongs to
  105114. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105115. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105116. */
  105117. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105118. /**
  105119. * Gets camera class name
  105120. * @returns VRDeviceOrientationFreeCamera
  105121. */
  105122. getClassName(): string;
  105123. }
  105124. }
  105125. declare module BABYLON {
  105126. /**
  105127. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105128. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105129. */
  105130. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105131. /**
  105132. * Creates a new VRDeviceOrientationGamepadCamera
  105133. * @param name defines camera name
  105134. * @param position defines the start position of the camera
  105135. * @param scene defines the scene the camera belongs to
  105136. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105137. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105138. */
  105139. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105140. /**
  105141. * Gets camera class name
  105142. * @returns VRDeviceOrientationGamepadCamera
  105143. */
  105144. getClassName(): string;
  105145. }
  105146. }
  105147. declare module BABYLON {
  105148. /**
  105149. * Base class of materials working in push mode in babylon JS
  105150. * @hidden
  105151. */
  105152. export class PushMaterial extends Material {
  105153. protected _activeEffect: Effect;
  105154. protected _normalMatrix: Matrix;
  105155. /**
  105156. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105157. * This means that the material can keep using a previous shader while a new one is being compiled.
  105158. * This is mostly used when shader parallel compilation is supported (true by default)
  105159. */
  105160. allowShaderHotSwapping: boolean;
  105161. constructor(name: string, scene: Scene);
  105162. getEffect(): Effect;
  105163. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105164. /**
  105165. * Binds the given world matrix to the active effect
  105166. *
  105167. * @param world the matrix to bind
  105168. */
  105169. bindOnlyWorldMatrix(world: Matrix): void;
  105170. /**
  105171. * Binds the given normal matrix to the active effect
  105172. *
  105173. * @param normalMatrix the matrix to bind
  105174. */
  105175. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105176. bind(world: Matrix, mesh?: Mesh): void;
  105177. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105178. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105179. }
  105180. }
  105181. declare module BABYLON {
  105182. /**
  105183. * This groups all the flags used to control the materials channel.
  105184. */
  105185. export class MaterialFlags {
  105186. private static _DiffuseTextureEnabled;
  105187. /**
  105188. * Are diffuse textures enabled in the application.
  105189. */
  105190. static DiffuseTextureEnabled: boolean;
  105191. private static _AmbientTextureEnabled;
  105192. /**
  105193. * Are ambient textures enabled in the application.
  105194. */
  105195. static AmbientTextureEnabled: boolean;
  105196. private static _OpacityTextureEnabled;
  105197. /**
  105198. * Are opacity textures enabled in the application.
  105199. */
  105200. static OpacityTextureEnabled: boolean;
  105201. private static _ReflectionTextureEnabled;
  105202. /**
  105203. * Are reflection textures enabled in the application.
  105204. */
  105205. static ReflectionTextureEnabled: boolean;
  105206. private static _EmissiveTextureEnabled;
  105207. /**
  105208. * Are emissive textures enabled in the application.
  105209. */
  105210. static EmissiveTextureEnabled: boolean;
  105211. private static _SpecularTextureEnabled;
  105212. /**
  105213. * Are specular textures enabled in the application.
  105214. */
  105215. static SpecularTextureEnabled: boolean;
  105216. private static _BumpTextureEnabled;
  105217. /**
  105218. * Are bump textures enabled in the application.
  105219. */
  105220. static BumpTextureEnabled: boolean;
  105221. private static _LightmapTextureEnabled;
  105222. /**
  105223. * Are lightmap textures enabled in the application.
  105224. */
  105225. static LightmapTextureEnabled: boolean;
  105226. private static _RefractionTextureEnabled;
  105227. /**
  105228. * Are refraction textures enabled in the application.
  105229. */
  105230. static RefractionTextureEnabled: boolean;
  105231. private static _ColorGradingTextureEnabled;
  105232. /**
  105233. * Are color grading textures enabled in the application.
  105234. */
  105235. static ColorGradingTextureEnabled: boolean;
  105236. private static _FresnelEnabled;
  105237. /**
  105238. * Are fresnels enabled in the application.
  105239. */
  105240. static FresnelEnabled: boolean;
  105241. private static _ClearCoatTextureEnabled;
  105242. /**
  105243. * Are clear coat textures enabled in the application.
  105244. */
  105245. static ClearCoatTextureEnabled: boolean;
  105246. private static _ClearCoatBumpTextureEnabled;
  105247. /**
  105248. * Are clear coat bump textures enabled in the application.
  105249. */
  105250. static ClearCoatBumpTextureEnabled: boolean;
  105251. private static _ClearCoatTintTextureEnabled;
  105252. /**
  105253. * Are clear coat tint textures enabled in the application.
  105254. */
  105255. static ClearCoatTintTextureEnabled: boolean;
  105256. private static _SheenTextureEnabled;
  105257. /**
  105258. * Are sheen textures enabled in the application.
  105259. */
  105260. static SheenTextureEnabled: boolean;
  105261. private static _AnisotropicTextureEnabled;
  105262. /**
  105263. * Are anisotropic textures enabled in the application.
  105264. */
  105265. static AnisotropicTextureEnabled: boolean;
  105266. private static _ThicknessTextureEnabled;
  105267. /**
  105268. * Are thickness textures enabled in the application.
  105269. */
  105270. static ThicknessTextureEnabled: boolean;
  105271. }
  105272. }
  105273. declare module BABYLON {
  105274. /** @hidden */
  105275. export var defaultFragmentDeclaration: {
  105276. name: string;
  105277. shader: string;
  105278. };
  105279. }
  105280. declare module BABYLON {
  105281. /** @hidden */
  105282. export var defaultUboDeclaration: {
  105283. name: string;
  105284. shader: string;
  105285. };
  105286. }
  105287. declare module BABYLON {
  105288. /** @hidden */
  105289. export var lightFragmentDeclaration: {
  105290. name: string;
  105291. shader: string;
  105292. };
  105293. }
  105294. declare module BABYLON {
  105295. /** @hidden */
  105296. export var lightUboDeclaration: {
  105297. name: string;
  105298. shader: string;
  105299. };
  105300. }
  105301. declare module BABYLON {
  105302. /** @hidden */
  105303. export var lightsFragmentFunctions: {
  105304. name: string;
  105305. shader: string;
  105306. };
  105307. }
  105308. declare module BABYLON {
  105309. /** @hidden */
  105310. export var shadowsFragmentFunctions: {
  105311. name: string;
  105312. shader: string;
  105313. };
  105314. }
  105315. declare module BABYLON {
  105316. /** @hidden */
  105317. export var fresnelFunction: {
  105318. name: string;
  105319. shader: string;
  105320. };
  105321. }
  105322. declare module BABYLON {
  105323. /** @hidden */
  105324. export var reflectionFunction: {
  105325. name: string;
  105326. shader: string;
  105327. };
  105328. }
  105329. declare module BABYLON {
  105330. /** @hidden */
  105331. export var bumpFragmentFunctions: {
  105332. name: string;
  105333. shader: string;
  105334. };
  105335. }
  105336. declare module BABYLON {
  105337. /** @hidden */
  105338. export var logDepthDeclaration: {
  105339. name: string;
  105340. shader: string;
  105341. };
  105342. }
  105343. declare module BABYLON {
  105344. /** @hidden */
  105345. export var bumpFragment: {
  105346. name: string;
  105347. shader: string;
  105348. };
  105349. }
  105350. declare module BABYLON {
  105351. /** @hidden */
  105352. export var depthPrePass: {
  105353. name: string;
  105354. shader: string;
  105355. };
  105356. }
  105357. declare module BABYLON {
  105358. /** @hidden */
  105359. export var lightFragment: {
  105360. name: string;
  105361. shader: string;
  105362. };
  105363. }
  105364. declare module BABYLON {
  105365. /** @hidden */
  105366. export var logDepthFragment: {
  105367. name: string;
  105368. shader: string;
  105369. };
  105370. }
  105371. declare module BABYLON {
  105372. /** @hidden */
  105373. export var defaultPixelShader: {
  105374. name: string;
  105375. shader: string;
  105376. };
  105377. }
  105378. declare module BABYLON {
  105379. /** @hidden */
  105380. export var defaultVertexDeclaration: {
  105381. name: string;
  105382. shader: string;
  105383. };
  105384. }
  105385. declare module BABYLON {
  105386. /** @hidden */
  105387. export var bumpVertexDeclaration: {
  105388. name: string;
  105389. shader: string;
  105390. };
  105391. }
  105392. declare module BABYLON {
  105393. /** @hidden */
  105394. export var bumpVertex: {
  105395. name: string;
  105396. shader: string;
  105397. };
  105398. }
  105399. declare module BABYLON {
  105400. /** @hidden */
  105401. export var fogVertex: {
  105402. name: string;
  105403. shader: string;
  105404. };
  105405. }
  105406. declare module BABYLON {
  105407. /** @hidden */
  105408. export var shadowsVertex: {
  105409. name: string;
  105410. shader: string;
  105411. };
  105412. }
  105413. declare module BABYLON {
  105414. /** @hidden */
  105415. export var pointCloudVertex: {
  105416. name: string;
  105417. shader: string;
  105418. };
  105419. }
  105420. declare module BABYLON {
  105421. /** @hidden */
  105422. export var logDepthVertex: {
  105423. name: string;
  105424. shader: string;
  105425. };
  105426. }
  105427. declare module BABYLON {
  105428. /** @hidden */
  105429. export var defaultVertexShader: {
  105430. name: string;
  105431. shader: string;
  105432. };
  105433. }
  105434. declare module BABYLON {
  105435. /** @hidden */
  105436. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105437. MAINUV1: boolean;
  105438. MAINUV2: boolean;
  105439. DIFFUSE: boolean;
  105440. DIFFUSEDIRECTUV: number;
  105441. AMBIENT: boolean;
  105442. AMBIENTDIRECTUV: number;
  105443. OPACITY: boolean;
  105444. OPACITYDIRECTUV: number;
  105445. OPACITYRGB: boolean;
  105446. REFLECTION: boolean;
  105447. EMISSIVE: boolean;
  105448. EMISSIVEDIRECTUV: number;
  105449. SPECULAR: boolean;
  105450. SPECULARDIRECTUV: number;
  105451. BUMP: boolean;
  105452. BUMPDIRECTUV: number;
  105453. PARALLAX: boolean;
  105454. PARALLAXOCCLUSION: boolean;
  105455. SPECULAROVERALPHA: boolean;
  105456. CLIPPLANE: boolean;
  105457. CLIPPLANE2: boolean;
  105458. CLIPPLANE3: boolean;
  105459. CLIPPLANE4: boolean;
  105460. ALPHATEST: boolean;
  105461. DEPTHPREPASS: boolean;
  105462. ALPHAFROMDIFFUSE: boolean;
  105463. POINTSIZE: boolean;
  105464. FOG: boolean;
  105465. SPECULARTERM: boolean;
  105466. DIFFUSEFRESNEL: boolean;
  105467. OPACITYFRESNEL: boolean;
  105468. REFLECTIONFRESNEL: boolean;
  105469. REFRACTIONFRESNEL: boolean;
  105470. EMISSIVEFRESNEL: boolean;
  105471. FRESNEL: boolean;
  105472. NORMAL: boolean;
  105473. UV1: boolean;
  105474. UV2: boolean;
  105475. VERTEXCOLOR: boolean;
  105476. VERTEXALPHA: boolean;
  105477. NUM_BONE_INFLUENCERS: number;
  105478. BonesPerMesh: number;
  105479. BONETEXTURE: boolean;
  105480. INSTANCES: boolean;
  105481. GLOSSINESS: boolean;
  105482. ROUGHNESS: boolean;
  105483. EMISSIVEASILLUMINATION: boolean;
  105484. LINKEMISSIVEWITHDIFFUSE: boolean;
  105485. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105486. LIGHTMAP: boolean;
  105487. LIGHTMAPDIRECTUV: number;
  105488. OBJECTSPACE_NORMALMAP: boolean;
  105489. USELIGHTMAPASSHADOWMAP: boolean;
  105490. REFLECTIONMAP_3D: boolean;
  105491. REFLECTIONMAP_SPHERICAL: boolean;
  105492. REFLECTIONMAP_PLANAR: boolean;
  105493. REFLECTIONMAP_CUBIC: boolean;
  105494. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105495. REFLECTIONMAP_PROJECTION: boolean;
  105496. REFLECTIONMAP_SKYBOX: boolean;
  105497. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105498. REFLECTIONMAP_EXPLICIT: boolean;
  105499. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105500. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105501. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105502. INVERTCUBICMAP: boolean;
  105503. LOGARITHMICDEPTH: boolean;
  105504. REFRACTION: boolean;
  105505. REFRACTIONMAP_3D: boolean;
  105506. REFLECTIONOVERALPHA: boolean;
  105507. TWOSIDEDLIGHTING: boolean;
  105508. SHADOWFLOAT: boolean;
  105509. MORPHTARGETS: boolean;
  105510. MORPHTARGETS_NORMAL: boolean;
  105511. MORPHTARGETS_TANGENT: boolean;
  105512. MORPHTARGETS_UV: boolean;
  105513. NUM_MORPH_INFLUENCERS: number;
  105514. NONUNIFORMSCALING: boolean;
  105515. PREMULTIPLYALPHA: boolean;
  105516. IMAGEPROCESSING: boolean;
  105517. VIGNETTE: boolean;
  105518. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105519. VIGNETTEBLENDMODEOPAQUE: boolean;
  105520. TONEMAPPING: boolean;
  105521. TONEMAPPING_ACES: boolean;
  105522. CONTRAST: boolean;
  105523. COLORCURVES: boolean;
  105524. COLORGRADING: boolean;
  105525. COLORGRADING3D: boolean;
  105526. SAMPLER3DGREENDEPTH: boolean;
  105527. SAMPLER3DBGRMAP: boolean;
  105528. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105529. MULTIVIEW: boolean;
  105530. /**
  105531. * If the reflection texture on this material is in linear color space
  105532. * @hidden
  105533. */
  105534. IS_REFLECTION_LINEAR: boolean;
  105535. /**
  105536. * If the refraction texture on this material is in linear color space
  105537. * @hidden
  105538. */
  105539. IS_REFRACTION_LINEAR: boolean;
  105540. EXPOSURE: boolean;
  105541. constructor();
  105542. setReflectionMode(modeToEnable: string): void;
  105543. }
  105544. /**
  105545. * This is the default material used in Babylon. It is the best trade off between quality
  105546. * and performances.
  105547. * @see http://doc.babylonjs.com/babylon101/materials
  105548. */
  105549. export class StandardMaterial extends PushMaterial {
  105550. private _diffuseTexture;
  105551. /**
  105552. * The basic texture of the material as viewed under a light.
  105553. */
  105554. diffuseTexture: Nullable<BaseTexture>;
  105555. private _ambientTexture;
  105556. /**
  105557. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105558. */
  105559. ambientTexture: Nullable<BaseTexture>;
  105560. private _opacityTexture;
  105561. /**
  105562. * Define the transparency of the material from a texture.
  105563. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105564. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105565. */
  105566. opacityTexture: Nullable<BaseTexture>;
  105567. private _reflectionTexture;
  105568. /**
  105569. * Define the texture used to display the reflection.
  105570. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105571. */
  105572. reflectionTexture: Nullable<BaseTexture>;
  105573. private _emissiveTexture;
  105574. /**
  105575. * Define texture of the material as if self lit.
  105576. * This will be mixed in the final result even in the absence of light.
  105577. */
  105578. emissiveTexture: Nullable<BaseTexture>;
  105579. private _specularTexture;
  105580. /**
  105581. * Define how the color and intensity of the highlight given by the light in the material.
  105582. */
  105583. specularTexture: Nullable<BaseTexture>;
  105584. private _bumpTexture;
  105585. /**
  105586. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105587. * 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.
  105588. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105589. */
  105590. bumpTexture: Nullable<BaseTexture>;
  105591. private _lightmapTexture;
  105592. /**
  105593. * Complex lighting can be computationally expensive to compute at runtime.
  105594. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105595. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105596. */
  105597. lightmapTexture: Nullable<BaseTexture>;
  105598. private _refractionTexture;
  105599. /**
  105600. * Define the texture used to display the refraction.
  105601. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105602. */
  105603. refractionTexture: Nullable<BaseTexture>;
  105604. /**
  105605. * The color of the material lit by the environmental background lighting.
  105606. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105607. */
  105608. ambientColor: Color3;
  105609. /**
  105610. * The basic color of the material as viewed under a light.
  105611. */
  105612. diffuseColor: Color3;
  105613. /**
  105614. * Define how the color and intensity of the highlight given by the light in the material.
  105615. */
  105616. specularColor: Color3;
  105617. /**
  105618. * Define the color of the material as if self lit.
  105619. * This will be mixed in the final result even in the absence of light.
  105620. */
  105621. emissiveColor: Color3;
  105622. /**
  105623. * Defines how sharp are the highlights in the material.
  105624. * The bigger the value the sharper giving a more glossy feeling to the result.
  105625. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105626. */
  105627. specularPower: number;
  105628. private _useAlphaFromDiffuseTexture;
  105629. /**
  105630. * Does the transparency come from the diffuse texture alpha channel.
  105631. */
  105632. useAlphaFromDiffuseTexture: boolean;
  105633. private _useEmissiveAsIllumination;
  105634. /**
  105635. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105636. */
  105637. useEmissiveAsIllumination: boolean;
  105638. private _linkEmissiveWithDiffuse;
  105639. /**
  105640. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105641. * the emissive level when the final color is close to one.
  105642. */
  105643. linkEmissiveWithDiffuse: boolean;
  105644. private _useSpecularOverAlpha;
  105645. /**
  105646. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105647. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105648. */
  105649. useSpecularOverAlpha: boolean;
  105650. private _useReflectionOverAlpha;
  105651. /**
  105652. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105653. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105654. */
  105655. useReflectionOverAlpha: boolean;
  105656. private _disableLighting;
  105657. /**
  105658. * Does lights from the scene impacts this material.
  105659. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105660. */
  105661. disableLighting: boolean;
  105662. private _useObjectSpaceNormalMap;
  105663. /**
  105664. * Allows using an object space normal map (instead of tangent space).
  105665. */
  105666. useObjectSpaceNormalMap: boolean;
  105667. private _useParallax;
  105668. /**
  105669. * Is parallax enabled or not.
  105670. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105671. */
  105672. useParallax: boolean;
  105673. private _useParallaxOcclusion;
  105674. /**
  105675. * Is parallax occlusion enabled or not.
  105676. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105677. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105678. */
  105679. useParallaxOcclusion: boolean;
  105680. /**
  105681. * 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.
  105682. */
  105683. parallaxScaleBias: number;
  105684. private _roughness;
  105685. /**
  105686. * Helps to define how blurry the reflections should appears in the material.
  105687. */
  105688. roughness: number;
  105689. /**
  105690. * In case of refraction, define the value of the index of refraction.
  105691. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105692. */
  105693. indexOfRefraction: number;
  105694. /**
  105695. * Invert the refraction texture alongside the y axis.
  105696. * It can be useful with procedural textures or probe for instance.
  105697. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105698. */
  105699. invertRefractionY: boolean;
  105700. /**
  105701. * Defines the alpha limits in alpha test mode.
  105702. */
  105703. alphaCutOff: number;
  105704. private _useLightmapAsShadowmap;
  105705. /**
  105706. * In case of light mapping, define whether the map contains light or shadow informations.
  105707. */
  105708. useLightmapAsShadowmap: boolean;
  105709. private _diffuseFresnelParameters;
  105710. /**
  105711. * Define the diffuse fresnel parameters of the material.
  105712. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105713. */
  105714. diffuseFresnelParameters: FresnelParameters;
  105715. private _opacityFresnelParameters;
  105716. /**
  105717. * Define the opacity fresnel parameters of the material.
  105718. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105719. */
  105720. opacityFresnelParameters: FresnelParameters;
  105721. private _reflectionFresnelParameters;
  105722. /**
  105723. * Define the reflection fresnel parameters of the material.
  105724. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105725. */
  105726. reflectionFresnelParameters: FresnelParameters;
  105727. private _refractionFresnelParameters;
  105728. /**
  105729. * Define the refraction fresnel parameters of the material.
  105730. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105731. */
  105732. refractionFresnelParameters: FresnelParameters;
  105733. private _emissiveFresnelParameters;
  105734. /**
  105735. * Define the emissive fresnel parameters of the material.
  105736. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105737. */
  105738. emissiveFresnelParameters: FresnelParameters;
  105739. private _useReflectionFresnelFromSpecular;
  105740. /**
  105741. * If true automatically deducts the fresnels values from the material specularity.
  105742. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105743. */
  105744. useReflectionFresnelFromSpecular: boolean;
  105745. private _useGlossinessFromSpecularMapAlpha;
  105746. /**
  105747. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105748. */
  105749. useGlossinessFromSpecularMapAlpha: boolean;
  105750. private _maxSimultaneousLights;
  105751. /**
  105752. * Defines the maximum number of lights that can be used in the material
  105753. */
  105754. maxSimultaneousLights: number;
  105755. private _invertNormalMapX;
  105756. /**
  105757. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105758. */
  105759. invertNormalMapX: boolean;
  105760. private _invertNormalMapY;
  105761. /**
  105762. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105763. */
  105764. invertNormalMapY: boolean;
  105765. private _twoSidedLighting;
  105766. /**
  105767. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105768. */
  105769. twoSidedLighting: boolean;
  105770. /**
  105771. * Default configuration related to image processing available in the standard Material.
  105772. */
  105773. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105774. /**
  105775. * Gets the image processing configuration used either in this material.
  105776. */
  105777. /**
  105778. * Sets the Default image processing configuration used either in the this material.
  105779. *
  105780. * If sets to null, the scene one is in use.
  105781. */
  105782. imageProcessingConfiguration: ImageProcessingConfiguration;
  105783. /**
  105784. * Keep track of the image processing observer to allow dispose and replace.
  105785. */
  105786. private _imageProcessingObserver;
  105787. /**
  105788. * Attaches a new image processing configuration to the Standard Material.
  105789. * @param configuration
  105790. */
  105791. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105792. /**
  105793. * Gets wether the color curves effect is enabled.
  105794. */
  105795. /**
  105796. * Sets wether the color curves effect is enabled.
  105797. */
  105798. cameraColorCurvesEnabled: boolean;
  105799. /**
  105800. * Gets wether the color grading effect is enabled.
  105801. */
  105802. /**
  105803. * Gets wether the color grading effect is enabled.
  105804. */
  105805. cameraColorGradingEnabled: boolean;
  105806. /**
  105807. * Gets wether tonemapping is enabled or not.
  105808. */
  105809. /**
  105810. * Sets wether tonemapping is enabled or not
  105811. */
  105812. cameraToneMappingEnabled: boolean;
  105813. /**
  105814. * The camera exposure used on this material.
  105815. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105816. * This corresponds to a photographic exposure.
  105817. */
  105818. /**
  105819. * The camera exposure used on this material.
  105820. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105821. * This corresponds to a photographic exposure.
  105822. */
  105823. cameraExposure: number;
  105824. /**
  105825. * Gets The camera contrast used on this material.
  105826. */
  105827. /**
  105828. * Sets The camera contrast used on this material.
  105829. */
  105830. cameraContrast: number;
  105831. /**
  105832. * Gets the Color Grading 2D Lookup Texture.
  105833. */
  105834. /**
  105835. * Sets the Color Grading 2D Lookup Texture.
  105836. */
  105837. cameraColorGradingTexture: Nullable<BaseTexture>;
  105838. /**
  105839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105841. * 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;
  105842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105843. */
  105844. /**
  105845. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105846. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105847. * 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;
  105848. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105849. */
  105850. cameraColorCurves: Nullable<ColorCurves>;
  105851. /**
  105852. * Custom callback helping to override the default shader used in the material.
  105853. */
  105854. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  105855. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105856. protected _worldViewProjectionMatrix: Matrix;
  105857. protected _globalAmbientColor: Color3;
  105858. protected _useLogarithmicDepth: boolean;
  105859. protected _rebuildInParallel: boolean;
  105860. /**
  105861. * Instantiates a new standard material.
  105862. * This is the default material used in Babylon. It is the best trade off between quality
  105863. * and performances.
  105864. * @see http://doc.babylonjs.com/babylon101/materials
  105865. * @param name Define the name of the material in the scene
  105866. * @param scene Define the scene the material belong to
  105867. */
  105868. constructor(name: string, scene: Scene);
  105869. /**
  105870. * Gets a boolean indicating that current material needs to register RTT
  105871. */
  105872. readonly hasRenderTargetTextures: boolean;
  105873. /**
  105874. * Gets the current class name of the material e.g. "StandardMaterial"
  105875. * Mainly use in serialization.
  105876. * @returns the class name
  105877. */
  105878. getClassName(): string;
  105879. /**
  105880. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105881. * You can try switching to logarithmic depth.
  105882. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105883. */
  105884. useLogarithmicDepth: boolean;
  105885. /**
  105886. * Specifies if the material will require alpha blending
  105887. * @returns a boolean specifying if alpha blending is needed
  105888. */
  105889. needAlphaBlending(): boolean;
  105890. /**
  105891. * Specifies if this material should be rendered in alpha test mode
  105892. * @returns a boolean specifying if an alpha test is needed.
  105893. */
  105894. needAlphaTesting(): boolean;
  105895. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105896. /**
  105897. * Get the texture used for alpha test purpose.
  105898. * @returns the diffuse texture in case of the standard material.
  105899. */
  105900. getAlphaTestTexture(): Nullable<BaseTexture>;
  105901. /**
  105902. * Get if the submesh is ready to be used and all its information available.
  105903. * Child classes can use it to update shaders
  105904. * @param mesh defines the mesh to check
  105905. * @param subMesh defines which submesh to check
  105906. * @param useInstances specifies that instances should be used
  105907. * @returns a boolean indicating that the submesh is ready or not
  105908. */
  105909. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105910. /**
  105911. * Builds the material UBO layouts.
  105912. * Used internally during the effect preparation.
  105913. */
  105914. buildUniformLayout(): void;
  105915. /**
  105916. * Unbinds the material from the mesh
  105917. */
  105918. unbind(): void;
  105919. /**
  105920. * Binds the submesh to this material by preparing the effect and shader to draw
  105921. * @param world defines the world transformation matrix
  105922. * @param mesh defines the mesh containing the submesh
  105923. * @param subMesh defines the submesh to bind the material to
  105924. */
  105925. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105926. /**
  105927. * Get the list of animatables in the material.
  105928. * @returns the list of animatables object used in the material
  105929. */
  105930. getAnimatables(): IAnimatable[];
  105931. /**
  105932. * Gets the active textures from the material
  105933. * @returns an array of textures
  105934. */
  105935. getActiveTextures(): BaseTexture[];
  105936. /**
  105937. * Specifies if the material uses a texture
  105938. * @param texture defines the texture to check against the material
  105939. * @returns a boolean specifying if the material uses the texture
  105940. */
  105941. hasTexture(texture: BaseTexture): boolean;
  105942. /**
  105943. * Disposes the material
  105944. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105945. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105946. */
  105947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105948. /**
  105949. * Makes a duplicate of the material, and gives it a new name
  105950. * @param name defines the new name for the duplicated material
  105951. * @returns the cloned material
  105952. */
  105953. clone(name: string): StandardMaterial;
  105954. /**
  105955. * Serializes this material in a JSON representation
  105956. * @returns the serialized material object
  105957. */
  105958. serialize(): any;
  105959. /**
  105960. * Creates a standard material from parsed material data
  105961. * @param source defines the JSON representation of the material
  105962. * @param scene defines the hosting scene
  105963. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105964. * @returns a new standard material
  105965. */
  105966. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105967. /**
  105968. * Are diffuse textures enabled in the application.
  105969. */
  105970. static DiffuseTextureEnabled: boolean;
  105971. /**
  105972. * Are ambient textures enabled in the application.
  105973. */
  105974. static AmbientTextureEnabled: boolean;
  105975. /**
  105976. * Are opacity textures enabled in the application.
  105977. */
  105978. static OpacityTextureEnabled: boolean;
  105979. /**
  105980. * Are reflection textures enabled in the application.
  105981. */
  105982. static ReflectionTextureEnabled: boolean;
  105983. /**
  105984. * Are emissive textures enabled in the application.
  105985. */
  105986. static EmissiveTextureEnabled: boolean;
  105987. /**
  105988. * Are specular textures enabled in the application.
  105989. */
  105990. static SpecularTextureEnabled: boolean;
  105991. /**
  105992. * Are bump textures enabled in the application.
  105993. */
  105994. static BumpTextureEnabled: boolean;
  105995. /**
  105996. * Are lightmap textures enabled in the application.
  105997. */
  105998. static LightmapTextureEnabled: boolean;
  105999. /**
  106000. * Are refraction textures enabled in the application.
  106001. */
  106002. static RefractionTextureEnabled: boolean;
  106003. /**
  106004. * Are color grading textures enabled in the application.
  106005. */
  106006. static ColorGradingTextureEnabled: boolean;
  106007. /**
  106008. * Are fresnels enabled in the application.
  106009. */
  106010. static FresnelEnabled: boolean;
  106011. }
  106012. }
  106013. declare module BABYLON {
  106014. /**
  106015. * A class extending Texture allowing drawing on a texture
  106016. * @see http://doc.babylonjs.com/how_to/dynamictexture
  106017. */
  106018. export class DynamicTexture extends Texture {
  106019. private _generateMipMaps;
  106020. private _canvas;
  106021. private _context;
  106022. private _engine;
  106023. /**
  106024. * Creates a DynamicTexture
  106025. * @param name defines the name of the texture
  106026. * @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
  106027. * @param scene defines the scene where you want the texture
  106028. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  106029. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  106030. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  106031. */
  106032. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  106033. /**
  106034. * Get the current class name of the texture useful for serialization or dynamic coding.
  106035. * @returns "DynamicTexture"
  106036. */
  106037. getClassName(): string;
  106038. /**
  106039. * Gets the current state of canRescale
  106040. */
  106041. readonly canRescale: boolean;
  106042. private _recreate;
  106043. /**
  106044. * Scales the texture
  106045. * @param ratio the scale factor to apply to both width and height
  106046. */
  106047. scale(ratio: number): void;
  106048. /**
  106049. * Resizes the texture
  106050. * @param width the new width
  106051. * @param height the new height
  106052. */
  106053. scaleTo(width: number, height: number): void;
  106054. /**
  106055. * Gets the context of the canvas used by the texture
  106056. * @returns the canvas context of the dynamic texture
  106057. */
  106058. getContext(): CanvasRenderingContext2D;
  106059. /**
  106060. * Clears the texture
  106061. */
  106062. clear(): void;
  106063. /**
  106064. * Updates the texture
  106065. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  106066. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  106067. */
  106068. update(invertY?: boolean, premulAlpha?: boolean): void;
  106069. /**
  106070. * Draws text onto the texture
  106071. * @param text defines the text to be drawn
  106072. * @param x defines the placement of the text from the left
  106073. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  106074. * @param font defines the font to be used with font-style, font-size, font-name
  106075. * @param color defines the color used for the text
  106076. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  106077. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  106078. * @param update defines whether texture is immediately update (default is true)
  106079. */
  106080. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  106081. /**
  106082. * Clones the texture
  106083. * @returns the clone of the texture.
  106084. */
  106085. clone(): DynamicTexture;
  106086. /**
  106087. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  106088. * @returns a serialized dynamic texture object
  106089. */
  106090. serialize(): any;
  106091. /** @hidden */
  106092. _rebuild(): void;
  106093. }
  106094. }
  106095. declare module BABYLON {
  106096. /** @hidden */
  106097. export var imageProcessingPixelShader: {
  106098. name: string;
  106099. shader: string;
  106100. };
  106101. }
  106102. declare module BABYLON {
  106103. /**
  106104. * ImageProcessingPostProcess
  106105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106106. */
  106107. export class ImageProcessingPostProcess extends PostProcess {
  106108. /**
  106109. * Default configuration related to image processing available in the PBR Material.
  106110. */
  106111. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106112. /**
  106113. * Gets the image processing configuration used either in this material.
  106114. */
  106115. /**
  106116. * Sets the Default image processing configuration used either in the this material.
  106117. *
  106118. * If sets to null, the scene one is in use.
  106119. */
  106120. imageProcessingConfiguration: ImageProcessingConfiguration;
  106121. /**
  106122. * Keep track of the image processing observer to allow dispose and replace.
  106123. */
  106124. private _imageProcessingObserver;
  106125. /**
  106126. * Attaches a new image processing configuration to the PBR Material.
  106127. * @param configuration
  106128. */
  106129. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106130. /**
  106131. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106132. */
  106133. /**
  106134. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106135. */
  106136. colorCurves: Nullable<ColorCurves>;
  106137. /**
  106138. * Gets wether the color curves effect is enabled.
  106139. */
  106140. /**
  106141. * Sets wether the color curves effect is enabled.
  106142. */
  106143. colorCurvesEnabled: boolean;
  106144. /**
  106145. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106146. */
  106147. /**
  106148. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106149. */
  106150. colorGradingTexture: Nullable<BaseTexture>;
  106151. /**
  106152. * Gets wether the color grading effect is enabled.
  106153. */
  106154. /**
  106155. * Gets wether the color grading effect is enabled.
  106156. */
  106157. colorGradingEnabled: boolean;
  106158. /**
  106159. * Gets exposure used in the effect.
  106160. */
  106161. /**
  106162. * Sets exposure used in the effect.
  106163. */
  106164. exposure: number;
  106165. /**
  106166. * Gets wether tonemapping is enabled or not.
  106167. */
  106168. /**
  106169. * Sets wether tonemapping is enabled or not
  106170. */
  106171. toneMappingEnabled: boolean;
  106172. /**
  106173. * Gets the type of tone mapping effect.
  106174. */
  106175. /**
  106176. * Sets the type of tone mapping effect.
  106177. */
  106178. toneMappingType: number;
  106179. /**
  106180. * Gets contrast used in the effect.
  106181. */
  106182. /**
  106183. * Sets contrast used in the effect.
  106184. */
  106185. contrast: number;
  106186. /**
  106187. * Gets Vignette stretch size.
  106188. */
  106189. /**
  106190. * Sets Vignette stretch size.
  106191. */
  106192. vignetteStretch: number;
  106193. /**
  106194. * Gets Vignette centre X Offset.
  106195. */
  106196. /**
  106197. * Sets Vignette centre X Offset.
  106198. */
  106199. vignetteCentreX: number;
  106200. /**
  106201. * Gets Vignette centre Y Offset.
  106202. */
  106203. /**
  106204. * Sets Vignette centre Y Offset.
  106205. */
  106206. vignetteCentreY: number;
  106207. /**
  106208. * Gets Vignette weight or intensity of the vignette effect.
  106209. */
  106210. /**
  106211. * Sets Vignette weight or intensity of the vignette effect.
  106212. */
  106213. vignetteWeight: number;
  106214. /**
  106215. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106216. * if vignetteEnabled is set to true.
  106217. */
  106218. /**
  106219. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106220. * if vignetteEnabled is set to true.
  106221. */
  106222. vignetteColor: Color4;
  106223. /**
  106224. * Gets Camera field of view used by the Vignette effect.
  106225. */
  106226. /**
  106227. * Sets Camera field of view used by the Vignette effect.
  106228. */
  106229. vignetteCameraFov: number;
  106230. /**
  106231. * Gets the vignette blend mode allowing different kind of effect.
  106232. */
  106233. /**
  106234. * Sets the vignette blend mode allowing different kind of effect.
  106235. */
  106236. vignetteBlendMode: number;
  106237. /**
  106238. * Gets wether the vignette effect is enabled.
  106239. */
  106240. /**
  106241. * Sets wether the vignette effect is enabled.
  106242. */
  106243. vignetteEnabled: boolean;
  106244. private _fromLinearSpace;
  106245. /**
  106246. * Gets wether the input of the processing is in Gamma or Linear Space.
  106247. */
  106248. /**
  106249. * Sets wether the input of the processing is in Gamma or Linear Space.
  106250. */
  106251. fromLinearSpace: boolean;
  106252. /**
  106253. * Defines cache preventing GC.
  106254. */
  106255. private _defines;
  106256. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106257. /**
  106258. * "ImageProcessingPostProcess"
  106259. * @returns "ImageProcessingPostProcess"
  106260. */
  106261. getClassName(): string;
  106262. protected _updateParameters(): void;
  106263. dispose(camera?: Camera): void;
  106264. }
  106265. }
  106266. declare module BABYLON {
  106267. /**
  106268. * Class containing static functions to help procedurally build meshes
  106269. */
  106270. export class GroundBuilder {
  106271. /**
  106272. * Creates a ground mesh
  106273. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106274. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106276. * @param name defines the name of the mesh
  106277. * @param options defines the options used to create the mesh
  106278. * @param scene defines the hosting scene
  106279. * @returns the ground mesh
  106280. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106281. */
  106282. static CreateGround(name: string, options: {
  106283. width?: number;
  106284. height?: number;
  106285. subdivisions?: number;
  106286. subdivisionsX?: number;
  106287. subdivisionsY?: number;
  106288. updatable?: boolean;
  106289. }, scene: any): Mesh;
  106290. /**
  106291. * Creates a tiled ground mesh
  106292. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106293. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106294. * * 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
  106295. * * 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
  106296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106297. * @param name defines the name of the mesh
  106298. * @param options defines the options used to create the mesh
  106299. * @param scene defines the hosting scene
  106300. * @returns the tiled ground mesh
  106301. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106302. */
  106303. static CreateTiledGround(name: string, options: {
  106304. xmin: number;
  106305. zmin: number;
  106306. xmax: number;
  106307. zmax: number;
  106308. subdivisions?: {
  106309. w: number;
  106310. h: number;
  106311. };
  106312. precision?: {
  106313. w: number;
  106314. h: number;
  106315. };
  106316. updatable?: boolean;
  106317. }, scene?: Nullable<Scene>): Mesh;
  106318. /**
  106319. * Creates a ground mesh from a height map
  106320. * * The parameter `url` sets the URL of the height map image resource.
  106321. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106322. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106323. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106324. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106325. * * 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.
  106326. * * 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).
  106327. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106329. * @param name defines the name of the mesh
  106330. * @param url defines the url to the height map
  106331. * @param options defines the options used to create the mesh
  106332. * @param scene defines the hosting scene
  106333. * @returns the ground mesh
  106334. * @see https://doc.babylonjs.com/babylon101/height_map
  106335. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106336. */
  106337. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106338. width?: number;
  106339. height?: number;
  106340. subdivisions?: number;
  106341. minHeight?: number;
  106342. maxHeight?: number;
  106343. colorFilter?: Color3;
  106344. alphaFilter?: number;
  106345. updatable?: boolean;
  106346. onReady?: (mesh: GroundMesh) => void;
  106347. }, scene?: Nullable<Scene>): GroundMesh;
  106348. }
  106349. }
  106350. declare module BABYLON {
  106351. /**
  106352. * Class containing static functions to help procedurally build meshes
  106353. */
  106354. export class TorusBuilder {
  106355. /**
  106356. * Creates a torus mesh
  106357. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106358. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106359. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106361. * * 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
  106362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106363. * @param name defines the name of the mesh
  106364. * @param options defines the options used to create the mesh
  106365. * @param scene defines the hosting scene
  106366. * @returns the torus mesh
  106367. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106368. */
  106369. static CreateTorus(name: string, options: {
  106370. diameter?: number;
  106371. thickness?: number;
  106372. tessellation?: number;
  106373. updatable?: boolean;
  106374. sideOrientation?: number;
  106375. frontUVs?: Vector4;
  106376. backUVs?: Vector4;
  106377. }, scene: any): Mesh;
  106378. }
  106379. }
  106380. declare module BABYLON {
  106381. /**
  106382. * Class containing static functions to help procedurally build meshes
  106383. */
  106384. export class CylinderBuilder {
  106385. /**
  106386. * Creates a cylinder or a cone mesh
  106387. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106388. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106389. * * 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.
  106390. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106391. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106392. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106393. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106394. * * 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).
  106395. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106396. * * 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).
  106397. * * 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
  106398. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106399. * * 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
  106400. * * 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.
  106401. * * If `enclose` is false, a ring surface is one element.
  106402. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106403. * * 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
  106404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106405. * * 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
  106406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106407. * @param name defines the name of the mesh
  106408. * @param options defines the options used to create the mesh
  106409. * @param scene defines the hosting scene
  106410. * @returns the cylinder mesh
  106411. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106412. */
  106413. static CreateCylinder(name: string, options: {
  106414. height?: number;
  106415. diameterTop?: number;
  106416. diameterBottom?: number;
  106417. diameter?: number;
  106418. tessellation?: number;
  106419. subdivisions?: number;
  106420. arc?: number;
  106421. faceColors?: Color4[];
  106422. faceUV?: Vector4[];
  106423. updatable?: boolean;
  106424. hasRings?: boolean;
  106425. enclose?: boolean;
  106426. cap?: number;
  106427. sideOrientation?: number;
  106428. frontUVs?: Vector4;
  106429. backUVs?: Vector4;
  106430. }, scene: any): Mesh;
  106431. }
  106432. }
  106433. declare module BABYLON {
  106434. /**
  106435. * Options to modify the vr teleportation behavior.
  106436. */
  106437. export interface VRTeleportationOptions {
  106438. /**
  106439. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106440. */
  106441. floorMeshName?: string;
  106442. /**
  106443. * A list of meshes to be used as the teleportation floor. (default: empty)
  106444. */
  106445. floorMeshes?: Mesh[];
  106446. }
  106447. /**
  106448. * Options to modify the vr experience helper's behavior.
  106449. */
  106450. export interface VRExperienceHelperOptions extends WebVROptions {
  106451. /**
  106452. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106453. */
  106454. createDeviceOrientationCamera?: boolean;
  106455. /**
  106456. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106457. */
  106458. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106459. /**
  106460. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106461. */
  106462. laserToggle?: boolean;
  106463. /**
  106464. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106465. */
  106466. floorMeshes?: Mesh[];
  106467. /**
  106468. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106469. */
  106470. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106471. }
  106472. /**
  106473. * Event containing information after VR has been entered
  106474. */
  106475. export class OnAfterEnteringVRObservableEvent {
  106476. /**
  106477. * If entering vr was successful
  106478. */
  106479. success: boolean;
  106480. }
  106481. /**
  106482. * Helps to quickly add VR support to an existing scene.
  106483. * See http://doc.babylonjs.com/how_to/webvr_helper
  106484. */
  106485. export class VRExperienceHelper {
  106486. /** Options to modify the vr experience helper's behavior. */
  106487. webVROptions: VRExperienceHelperOptions;
  106488. private _scene;
  106489. private _position;
  106490. private _btnVR;
  106491. private _btnVRDisplayed;
  106492. private _webVRsupported;
  106493. private _webVRready;
  106494. private _webVRrequesting;
  106495. private _webVRpresenting;
  106496. private _hasEnteredVR;
  106497. private _fullscreenVRpresenting;
  106498. private _canvas;
  106499. private _webVRCamera;
  106500. private _vrDeviceOrientationCamera;
  106501. private _deviceOrientationCamera;
  106502. private _existingCamera;
  106503. private _onKeyDown;
  106504. private _onVrDisplayPresentChange;
  106505. private _onVRDisplayChanged;
  106506. private _onVRRequestPresentStart;
  106507. private _onVRRequestPresentComplete;
  106508. /**
  106509. * 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)
  106510. */
  106511. enableGazeEvenWhenNoPointerLock: boolean;
  106512. /**
  106513. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106514. */
  106515. exitVROnDoubleTap: boolean;
  106516. /**
  106517. * Observable raised right before entering VR.
  106518. */
  106519. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106520. /**
  106521. * Observable raised when entering VR has completed.
  106522. */
  106523. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106524. /**
  106525. * Observable raised when exiting VR.
  106526. */
  106527. onExitingVRObservable: Observable<VRExperienceHelper>;
  106528. /**
  106529. * Observable raised when controller mesh is loaded.
  106530. */
  106531. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106532. /** Return this.onEnteringVRObservable
  106533. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106534. */
  106535. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106536. /** Return this.onExitingVRObservable
  106537. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106538. */
  106539. readonly onExitingVR: Observable<VRExperienceHelper>;
  106540. /** Return this.onControllerMeshLoadedObservable
  106541. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106542. */
  106543. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106544. private _rayLength;
  106545. private _useCustomVRButton;
  106546. private _teleportationRequested;
  106547. private _teleportActive;
  106548. private _floorMeshName;
  106549. private _floorMeshesCollection;
  106550. private _rotationAllowed;
  106551. private _teleportBackwardsVector;
  106552. private _teleportationTarget;
  106553. private _isDefaultTeleportationTarget;
  106554. private _postProcessMove;
  106555. private _teleportationFillColor;
  106556. private _teleportationBorderColor;
  106557. private _rotationAngle;
  106558. private _haloCenter;
  106559. private _cameraGazer;
  106560. private _padSensibilityUp;
  106561. private _padSensibilityDown;
  106562. private _leftController;
  106563. private _rightController;
  106564. /**
  106565. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106566. */
  106567. onNewMeshSelected: Observable<AbstractMesh>;
  106568. /**
  106569. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106570. * This observable will provide the mesh and the controller used to select the mesh
  106571. */
  106572. onMeshSelectedWithController: Observable<{
  106573. mesh: AbstractMesh;
  106574. controller: WebVRController;
  106575. }>;
  106576. /**
  106577. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106578. */
  106579. onNewMeshPicked: Observable<PickingInfo>;
  106580. private _circleEase;
  106581. /**
  106582. * Observable raised before camera teleportation
  106583. */
  106584. onBeforeCameraTeleport: Observable<Vector3>;
  106585. /**
  106586. * Observable raised after camera teleportation
  106587. */
  106588. onAfterCameraTeleport: Observable<Vector3>;
  106589. /**
  106590. * Observable raised when current selected mesh gets unselected
  106591. */
  106592. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106593. private _raySelectionPredicate;
  106594. /**
  106595. * To be optionaly changed by user to define custom ray selection
  106596. */
  106597. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106598. /**
  106599. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106600. */
  106601. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106602. /**
  106603. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106604. */
  106605. teleportationEnabled: boolean;
  106606. private _defaultHeight;
  106607. private _teleportationInitialized;
  106608. private _interactionsEnabled;
  106609. private _interactionsRequested;
  106610. private _displayGaze;
  106611. private _displayLaserPointer;
  106612. /**
  106613. * The mesh used to display where the user is going to teleport.
  106614. */
  106615. /**
  106616. * Sets the mesh to be used to display where the user is going to teleport.
  106617. */
  106618. teleportationTarget: Mesh;
  106619. /**
  106620. * 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
  106621. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106622. * See http://doc.babylonjs.com/resources/baking_transformations
  106623. */
  106624. gazeTrackerMesh: Mesh;
  106625. /**
  106626. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106627. */
  106628. updateGazeTrackerScale: boolean;
  106629. /**
  106630. * If the gaze trackers color should be updated when selecting meshes
  106631. */
  106632. updateGazeTrackerColor: boolean;
  106633. /**
  106634. * If the controller laser color should be updated when selecting meshes
  106635. */
  106636. updateControllerLaserColor: boolean;
  106637. /**
  106638. * The gaze tracking mesh corresponding to the left controller
  106639. */
  106640. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106641. /**
  106642. * The gaze tracking mesh corresponding to the right controller
  106643. */
  106644. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106645. /**
  106646. * If the ray of the gaze should be displayed.
  106647. */
  106648. /**
  106649. * Sets if the ray of the gaze should be displayed.
  106650. */
  106651. displayGaze: boolean;
  106652. /**
  106653. * If the ray of the LaserPointer should be displayed.
  106654. */
  106655. /**
  106656. * Sets if the ray of the LaserPointer should be displayed.
  106657. */
  106658. displayLaserPointer: boolean;
  106659. /**
  106660. * The deviceOrientationCamera used as the camera when not in VR.
  106661. */
  106662. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106663. /**
  106664. * Based on the current WebVR support, returns the current VR camera used.
  106665. */
  106666. readonly currentVRCamera: Nullable<Camera>;
  106667. /**
  106668. * The webVRCamera which is used when in VR.
  106669. */
  106670. readonly webVRCamera: WebVRFreeCamera;
  106671. /**
  106672. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106673. */
  106674. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106675. /**
  106676. * The html button that is used to trigger entering into VR.
  106677. */
  106678. readonly vrButton: Nullable<HTMLButtonElement>;
  106679. private readonly _teleportationRequestInitiated;
  106680. /**
  106681. * Defines wether or not Pointer lock should be requested when switching to
  106682. * full screen.
  106683. */
  106684. requestPointerLockOnFullScreen: boolean;
  106685. /**
  106686. * Instantiates a VRExperienceHelper.
  106687. * Helps to quickly add VR support to an existing scene.
  106688. * @param scene The scene the VRExperienceHelper belongs to.
  106689. * @param webVROptions Options to modify the vr experience helper's behavior.
  106690. */
  106691. constructor(scene: Scene,
  106692. /** Options to modify the vr experience helper's behavior. */
  106693. webVROptions?: VRExperienceHelperOptions);
  106694. private _onDefaultMeshLoaded;
  106695. private _onResize;
  106696. private _onFullscreenChange;
  106697. /**
  106698. * Gets a value indicating if we are currently in VR mode.
  106699. */
  106700. readonly isInVRMode: boolean;
  106701. private onVrDisplayPresentChange;
  106702. private onVRDisplayChanged;
  106703. private moveButtonToBottomRight;
  106704. private displayVRButton;
  106705. private updateButtonVisibility;
  106706. private _cachedAngularSensibility;
  106707. /**
  106708. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106709. * Otherwise, will use the fullscreen API.
  106710. */
  106711. enterVR(): void;
  106712. /**
  106713. * Attempt to exit VR, or fullscreen.
  106714. */
  106715. exitVR(): void;
  106716. /**
  106717. * The position of the vr experience helper.
  106718. */
  106719. /**
  106720. * Sets the position of the vr experience helper.
  106721. */
  106722. position: Vector3;
  106723. /**
  106724. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106725. */
  106726. enableInteractions(): void;
  106727. private readonly _noControllerIsActive;
  106728. private beforeRender;
  106729. private _isTeleportationFloor;
  106730. /**
  106731. * Adds a floor mesh to be used for teleportation.
  106732. * @param floorMesh the mesh to be used for teleportation.
  106733. */
  106734. addFloorMesh(floorMesh: Mesh): void;
  106735. /**
  106736. * Removes a floor mesh from being used for teleportation.
  106737. * @param floorMesh the mesh to be removed.
  106738. */
  106739. removeFloorMesh(floorMesh: Mesh): void;
  106740. /**
  106741. * Enables interactions and teleportation using the VR controllers and gaze.
  106742. * @param vrTeleportationOptions options to modify teleportation behavior.
  106743. */
  106744. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106745. private _onNewGamepadConnected;
  106746. private _tryEnableInteractionOnController;
  106747. private _onNewGamepadDisconnected;
  106748. private _enableInteractionOnController;
  106749. private _checkTeleportWithRay;
  106750. private _checkRotate;
  106751. private _checkTeleportBackwards;
  106752. private _enableTeleportationOnController;
  106753. private _createTeleportationCircles;
  106754. private _displayTeleportationTarget;
  106755. private _hideTeleportationTarget;
  106756. private _rotateCamera;
  106757. private _moveTeleportationSelectorTo;
  106758. private _workingVector;
  106759. private _workingQuaternion;
  106760. private _workingMatrix;
  106761. /**
  106762. * Teleports the users feet to the desired location
  106763. * @param location The location where the user's feet should be placed
  106764. */
  106765. teleportCamera(location: Vector3): void;
  106766. private _convertNormalToDirectionOfRay;
  106767. private _castRayAndSelectObject;
  106768. private _notifySelectedMeshUnselected;
  106769. /**
  106770. * Sets the color of the laser ray from the vr controllers.
  106771. * @param color new color for the ray.
  106772. */
  106773. changeLaserColor(color: Color3): void;
  106774. /**
  106775. * Sets the color of the ray from the vr headsets gaze.
  106776. * @param color new color for the ray.
  106777. */
  106778. changeGazeColor(color: Color3): void;
  106779. /**
  106780. * Exits VR and disposes of the vr experience helper
  106781. */
  106782. dispose(): void;
  106783. /**
  106784. * Gets the name of the VRExperienceHelper class
  106785. * @returns "VRExperienceHelper"
  106786. */
  106787. getClassName(): string;
  106788. }
  106789. }
  106790. declare module BABYLON {
  106791. /**
  106792. * Manages an XRSession to work with Babylon's engine
  106793. * @see https://doc.babylonjs.com/how_to/webxr
  106794. */
  106795. export class WebXRSessionManager implements IDisposable {
  106796. private scene;
  106797. /**
  106798. * Fires every time a new xrFrame arrives which can be used to update the camera
  106799. */
  106800. onXRFrameObservable: Observable<any>;
  106801. /**
  106802. * Fires when the xr session is ended either by the device or manually done
  106803. */
  106804. onXRSessionEnded: Observable<any>;
  106805. /**
  106806. * Underlying xr session
  106807. */
  106808. session: XRSession;
  106809. /**
  106810. * Type of reference space used when creating the session
  106811. */
  106812. referenceSpace: XRReferenceSpace;
  106813. /** @hidden */
  106814. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  106815. /**
  106816. * Current XR frame
  106817. */
  106818. currentFrame: Nullable<XRFrame>;
  106819. private _xrNavigator;
  106820. private baseLayer;
  106821. /**
  106822. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  106823. * @param scene The scene which the session should be created for
  106824. */
  106825. constructor(scene: Scene);
  106826. /**
  106827. * Initializes the manager
  106828. * After initialization enterXR can be called to start an XR session
  106829. * @returns Promise which resolves after it is initialized
  106830. */
  106831. initializeAsync(): Promise<void>;
  106832. /**
  106833. * Initializes an xr session
  106834. * @param xrSessionMode mode to initialize
  106835. * @returns a promise which will resolve once the session has been initialized
  106836. */
  106837. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  106838. /**
  106839. * Sets the reference space on the xr session
  106840. * @param referenceSpace space to set
  106841. * @returns a promise that will resolve once the reference space has been set
  106842. */
  106843. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  106844. /**
  106845. * Updates the render state of the session
  106846. * @param state state to set
  106847. * @returns a promise that resolves once the render state has been updated
  106848. */
  106849. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  106850. /**
  106851. * Starts rendering to the xr layer
  106852. * @returns a promise that will resolve once rendering has started
  106853. */
  106854. startRenderingToXRAsync(): Promise<void>;
  106855. /**
  106856. * Stops the xrSession and restores the renderloop
  106857. * @returns Promise which resolves after it exits XR
  106858. */
  106859. exitXRAsync(): Promise<unknown>;
  106860. /**
  106861. * Checks if a session would be supported for the creation options specified
  106862. * @param sessionMode session mode to check if supported eg. immersive-vr
  106863. * @returns true if supported
  106864. */
  106865. supportsSessionAsync(sessionMode: XRSessionMode): any;
  106866. /**
  106867. * @hidden
  106868. * Converts the render layer of xrSession to a render target
  106869. * @param session session to create render target for
  106870. * @param scene scene the new render target should be created for
  106871. */
  106872. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  106873. /**
  106874. * Disposes of the session manager
  106875. */
  106876. dispose(): void;
  106877. }
  106878. }
  106879. declare module BABYLON {
  106880. /**
  106881. * WebXR Camera which holds the views for the xrSession
  106882. * @see https://doc.babylonjs.com/how_to/webxr
  106883. */
  106884. export class WebXRCamera extends FreeCamera {
  106885. private static _TmpMatrix;
  106886. /**
  106887. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  106888. * @param name the name of the camera
  106889. * @param scene the scene to add the camera to
  106890. */
  106891. constructor(name: string, scene: Scene);
  106892. private _updateNumberOfRigCameras;
  106893. /** @hidden */
  106894. _updateForDualEyeDebugging(pupilDistance?: number): void;
  106895. /**
  106896. * Updates the cameras position from the current pose information of the XR session
  106897. * @param xrSessionManager the session containing pose information
  106898. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  106899. */
  106900. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  106901. }
  106902. }
  106903. declare module BABYLON {
  106904. /**
  106905. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  106906. */
  106907. export class WebXRManagedOutputCanvas implements IDisposable {
  106908. private helper;
  106909. private _canvas;
  106910. /**
  106911. * xrpresent context of the canvas which can be used to display/mirror xr content
  106912. */
  106913. canvasContext: WebGLRenderingContext;
  106914. /**
  106915. * xr layer for the canvas
  106916. */
  106917. xrLayer: Nullable<XRWebGLLayer>;
  106918. /**
  106919. * Initializes the xr layer for the session
  106920. * @param xrSession xr session
  106921. * @returns a promise that will resolve once the XR Layer has been created
  106922. */
  106923. initializeXRLayerAsync(xrSession: any): any;
  106924. /**
  106925. * Initializes the canvas to be added/removed upon entering/exiting xr
  106926. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  106927. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  106928. */
  106929. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  106930. /**
  106931. * Disposes of the object
  106932. */
  106933. dispose(): void;
  106934. private _setManagedOutputCanvas;
  106935. private _addCanvas;
  106936. private _removeCanvas;
  106937. }
  106938. }
  106939. declare module BABYLON {
  106940. /**
  106941. * States of the webXR experience
  106942. */
  106943. export enum WebXRState {
  106944. /**
  106945. * Transitioning to being in XR mode
  106946. */
  106947. ENTERING_XR = 0,
  106948. /**
  106949. * Transitioning to non XR mode
  106950. */
  106951. EXITING_XR = 1,
  106952. /**
  106953. * In XR mode and presenting
  106954. */
  106955. IN_XR = 2,
  106956. /**
  106957. * Not entered XR mode
  106958. */
  106959. NOT_IN_XR = 3
  106960. }
  106961. /**
  106962. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  106963. * @see https://doc.babylonjs.com/how_to/webxr
  106964. */
  106965. export class WebXRExperienceHelper implements IDisposable {
  106966. private scene;
  106967. /**
  106968. * 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
  106969. */
  106970. container: AbstractMesh;
  106971. /**
  106972. * Camera used to render xr content
  106973. */
  106974. camera: WebXRCamera;
  106975. /**
  106976. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  106977. */
  106978. state: WebXRState;
  106979. private _setState;
  106980. private static _TmpVector;
  106981. /**
  106982. * Fires when the state of the experience helper has changed
  106983. */
  106984. onStateChangedObservable: Observable<WebXRState>;
  106985. /** Session manager used to keep track of xr session */
  106986. sessionManager: WebXRSessionManager;
  106987. private _nonVRCamera;
  106988. private _originalSceneAutoClear;
  106989. private _supported;
  106990. /**
  106991. * Creates the experience helper
  106992. * @param scene the scene to attach the experience helper to
  106993. * @returns a promise for the experience helper
  106994. */
  106995. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  106996. /**
  106997. * Creates a WebXRExperienceHelper
  106998. * @param scene The scene the helper should be created in
  106999. */
  107000. private constructor();
  107001. /**
  107002. * Exits XR mode and returns the scene to its original state
  107003. * @returns promise that resolves after xr mode has exited
  107004. */
  107005. exitXRAsync(): Promise<unknown>;
  107006. /**
  107007. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107008. * @param sessionCreationOptions options for the XR session
  107009. * @param referenceSpaceType frame of reference of the XR session
  107010. * @param outputCanvas the output canvas that will be used to enter XR mode
  107011. * @returns promise that resolves after xr mode has entered
  107012. */
  107013. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107014. /**
  107015. * Updates the global position of the camera by moving the camera's container
  107016. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107017. * @param position The desired global position of the camera
  107018. */
  107019. setPositionOfCameraUsingContainer(position: Vector3): void;
  107020. /**
  107021. * Rotates the xr camera by rotating the camera's container around the camera's position
  107022. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107023. * @param rotation the desired quaternion rotation to apply to the camera
  107024. */
  107025. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107026. /**
  107027. * Disposes of the experience helper
  107028. */
  107029. dispose(): void;
  107030. }
  107031. }
  107032. declare module BABYLON {
  107033. /**
  107034. * Button which can be used to enter a different mode of XR
  107035. */
  107036. export class WebXREnterExitUIButton {
  107037. /** button element */
  107038. element: HTMLElement;
  107039. /** XR initialization options for the button */
  107040. sessionMode: XRSessionMode;
  107041. /** Reference space type */
  107042. referenceSpaceType: XRReferenceSpaceType;
  107043. /**
  107044. * Creates a WebXREnterExitUIButton
  107045. * @param element button element
  107046. * @param sessionMode XR initialization session mode
  107047. * @param referenceSpaceType the type of reference space to be used
  107048. */
  107049. constructor(
  107050. /** button element */
  107051. element: HTMLElement,
  107052. /** XR initialization options for the button */
  107053. sessionMode: XRSessionMode,
  107054. /** Reference space type */
  107055. referenceSpaceType: XRReferenceSpaceType);
  107056. /**
  107057. * Overwritable function which can be used to update the button's visuals when the state changes
  107058. * @param activeButton the current active button in the UI
  107059. */
  107060. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107061. }
  107062. /**
  107063. * Options to create the webXR UI
  107064. */
  107065. export class WebXREnterExitUIOptions {
  107066. /**
  107067. * Context to enter xr with
  107068. */
  107069. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107070. /**
  107071. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107072. */
  107073. customButtons?: Array<WebXREnterExitUIButton>;
  107074. }
  107075. /**
  107076. * UI to allow the user to enter/exit XR mode
  107077. */
  107078. export class WebXREnterExitUI implements IDisposable {
  107079. private scene;
  107080. private _overlay;
  107081. private _buttons;
  107082. private _activeButton;
  107083. /**
  107084. * Fired every time the active button is changed.
  107085. *
  107086. * When xr is entered via a button that launches xr that button will be the callback parameter
  107087. *
  107088. * When exiting xr the callback parameter will be null)
  107089. */
  107090. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107091. /**
  107092. * Creates UI to allow the user to enter/exit XR mode
  107093. * @param scene the scene to add the ui to
  107094. * @param helper the xr experience helper to enter/exit xr with
  107095. * @param options options to configure the UI
  107096. * @returns the created ui
  107097. */
  107098. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107099. private constructor();
  107100. private _updateButtons;
  107101. /**
  107102. * Disposes of the object
  107103. */
  107104. dispose(): void;
  107105. }
  107106. }
  107107. declare module BABYLON {
  107108. /**
  107109. * Represents an XR input
  107110. */
  107111. export class WebXRController {
  107112. private scene;
  107113. /** The underlying input source for the controller */
  107114. inputSource: XRInputSource;
  107115. private parentContainer;
  107116. /**
  107117. * 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
  107118. */
  107119. grip?: AbstractMesh;
  107120. /**
  107121. * Pointer which can be used to select objects or attach a visible laser to
  107122. */
  107123. pointer: AbstractMesh;
  107124. /**
  107125. * Event that fires when the controller is removed/disposed
  107126. */
  107127. onDisposeObservable: Observable<{}>;
  107128. private _tmpMatrix;
  107129. private _tmpQuaternion;
  107130. private _tmpVector;
  107131. /**
  107132. * Creates the controller
  107133. * @see https://doc.babylonjs.com/how_to/webxr
  107134. * @param scene the scene which the controller should be associated to
  107135. * @param inputSource the underlying input source for the controller
  107136. * @param parentContainer parent that the controller meshes should be children of
  107137. */
  107138. constructor(scene: Scene,
  107139. /** The underlying input source for the controller */
  107140. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107141. /**
  107142. * Updates the controller pose based on the given XRFrame
  107143. * @param xrFrame xr frame to update the pose with
  107144. * @param referenceSpace reference space to use
  107145. */
  107146. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107147. /**
  107148. * Gets a world space ray coming from the controller
  107149. * @param result the resulting ray
  107150. */
  107151. getWorldPointerRayToRef(result: Ray): void;
  107152. /**
  107153. * Disposes of the object
  107154. */
  107155. dispose(): void;
  107156. }
  107157. }
  107158. declare module BABYLON {
  107159. /**
  107160. * XR input used to track XR inputs such as controllers/rays
  107161. */
  107162. export class WebXRInput implements IDisposable {
  107163. /**
  107164. * Base experience the input listens to
  107165. */
  107166. baseExperience: WebXRExperienceHelper;
  107167. /**
  107168. * XR controllers being tracked
  107169. */
  107170. controllers: Array<WebXRController>;
  107171. private _frameObserver;
  107172. private _stateObserver;
  107173. /**
  107174. * Event when a controller has been connected/added
  107175. */
  107176. onControllerAddedObservable: Observable<WebXRController>;
  107177. /**
  107178. * Event when a controller has been removed/disconnected
  107179. */
  107180. onControllerRemovedObservable: Observable<WebXRController>;
  107181. /**
  107182. * Initializes the WebXRInput
  107183. * @param baseExperience experience helper which the input should be created for
  107184. */
  107185. constructor(
  107186. /**
  107187. * Base experience the input listens to
  107188. */
  107189. baseExperience: WebXRExperienceHelper);
  107190. private _onInputSourcesChange;
  107191. private _addAndRemoveControllers;
  107192. /**
  107193. * Disposes of the object
  107194. */
  107195. dispose(): void;
  107196. }
  107197. }
  107198. declare module BABYLON {
  107199. /**
  107200. * Enables teleportation
  107201. */
  107202. export class WebXRControllerTeleportation {
  107203. private _teleportationFillColor;
  107204. private _teleportationBorderColor;
  107205. private _tmpRay;
  107206. private _tmpVector;
  107207. /**
  107208. * Creates a WebXRControllerTeleportation
  107209. * @param input input manager to add teleportation to
  107210. * @param floorMeshes floormeshes which can be teleported to
  107211. */
  107212. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107213. }
  107214. }
  107215. declare module BABYLON {
  107216. /**
  107217. * Handles pointer input automatically for the pointer of XR controllers
  107218. */
  107219. export class WebXRControllerPointerSelection {
  107220. private static _idCounter;
  107221. private _tmpRay;
  107222. /**
  107223. * Creates a WebXRControllerPointerSelection
  107224. * @param input input manager to setup pointer selection
  107225. */
  107226. constructor(input: WebXRInput);
  107227. private _convertNormalToDirectionOfRay;
  107228. private _updatePointerDistance;
  107229. }
  107230. }
  107231. declare module BABYLON {
  107232. /**
  107233. * Class used to represent data loading progression
  107234. */
  107235. export class SceneLoaderProgressEvent {
  107236. /** defines if data length to load can be evaluated */
  107237. readonly lengthComputable: boolean;
  107238. /** defines the loaded data length */
  107239. readonly loaded: number;
  107240. /** defines the data length to load */
  107241. readonly total: number;
  107242. /**
  107243. * Create a new progress event
  107244. * @param lengthComputable defines if data length to load can be evaluated
  107245. * @param loaded defines the loaded data length
  107246. * @param total defines the data length to load
  107247. */
  107248. constructor(
  107249. /** defines if data length to load can be evaluated */
  107250. lengthComputable: boolean,
  107251. /** defines the loaded data length */
  107252. loaded: number,
  107253. /** defines the data length to load */
  107254. total: number);
  107255. /**
  107256. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107257. * @param event defines the source event
  107258. * @returns a new SceneLoaderProgressEvent
  107259. */
  107260. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107261. }
  107262. /**
  107263. * Interface used by SceneLoader plugins to define supported file extensions
  107264. */
  107265. export interface ISceneLoaderPluginExtensions {
  107266. /**
  107267. * Defines the list of supported extensions
  107268. */
  107269. [extension: string]: {
  107270. isBinary: boolean;
  107271. };
  107272. }
  107273. /**
  107274. * Interface used by SceneLoader plugin factory
  107275. */
  107276. export interface ISceneLoaderPluginFactory {
  107277. /**
  107278. * Defines the name of the factory
  107279. */
  107280. name: string;
  107281. /**
  107282. * Function called to create a new plugin
  107283. * @return the new plugin
  107284. */
  107285. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107286. /**
  107287. * Boolean indicating if the plugin can direct load specific data
  107288. */
  107289. canDirectLoad?: (data: string) => boolean;
  107290. }
  107291. /**
  107292. * Interface used to define a SceneLoader plugin
  107293. */
  107294. export interface ISceneLoaderPlugin {
  107295. /**
  107296. * The friendly name of this plugin.
  107297. */
  107298. name: string;
  107299. /**
  107300. * The file extensions supported by this plugin.
  107301. */
  107302. extensions: string | ISceneLoaderPluginExtensions;
  107303. /**
  107304. * Import meshes into a scene.
  107305. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107306. * @param scene The scene to import into
  107307. * @param data The data to import
  107308. * @param rootUrl The root url for scene and resources
  107309. * @param meshes The meshes array to import into
  107310. * @param particleSystems The particle systems array to import into
  107311. * @param skeletons The skeletons array to import into
  107312. * @param onError The callback when import fails
  107313. * @returns True if successful or false otherwise
  107314. */
  107315. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107316. /**
  107317. * Load into a scene.
  107318. * @param scene The scene to load into
  107319. * @param data The data to import
  107320. * @param rootUrl The root url for scene and resources
  107321. * @param onError The callback when import fails
  107322. * @returns true if successful or false otherwise
  107323. */
  107324. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107325. /**
  107326. * The callback that returns true if the data can be directly loaded.
  107327. */
  107328. canDirectLoad?: (data: string) => boolean;
  107329. /**
  107330. * The callback that allows custom handling of the root url based on the response url.
  107331. */
  107332. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107333. /**
  107334. * Load into an asset container.
  107335. * @param scene The scene to load into
  107336. * @param data The data to import
  107337. * @param rootUrl The root url for scene and resources
  107338. * @param onError The callback when import fails
  107339. * @returns The loaded asset container
  107340. */
  107341. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107342. }
  107343. /**
  107344. * Interface used to define an async SceneLoader plugin
  107345. */
  107346. export interface ISceneLoaderPluginAsync {
  107347. /**
  107348. * The friendly name of this plugin.
  107349. */
  107350. name: string;
  107351. /**
  107352. * The file extensions supported by this plugin.
  107353. */
  107354. extensions: string | ISceneLoaderPluginExtensions;
  107355. /**
  107356. * Import meshes into a scene.
  107357. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107358. * @param scene The scene to import into
  107359. * @param data The data to import
  107360. * @param rootUrl The root url for scene and resources
  107361. * @param onProgress The callback when the load progresses
  107362. * @param fileName Defines the name of the file to load
  107363. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107364. */
  107365. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107366. meshes: AbstractMesh[];
  107367. particleSystems: IParticleSystem[];
  107368. skeletons: Skeleton[];
  107369. animationGroups: AnimationGroup[];
  107370. }>;
  107371. /**
  107372. * Load into a scene.
  107373. * @param scene The scene to load into
  107374. * @param data The data to import
  107375. * @param rootUrl The root url for scene and resources
  107376. * @param onProgress The callback when the load progresses
  107377. * @param fileName Defines the name of the file to load
  107378. * @returns Nothing
  107379. */
  107380. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107381. /**
  107382. * The callback that returns true if the data can be directly loaded.
  107383. */
  107384. canDirectLoad?: (data: string) => boolean;
  107385. /**
  107386. * The callback that allows custom handling of the root url based on the response url.
  107387. */
  107388. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107389. /**
  107390. * Load into an asset container.
  107391. * @param scene The scene to load into
  107392. * @param data The data to import
  107393. * @param rootUrl The root url for scene and resources
  107394. * @param onProgress The callback when the load progresses
  107395. * @param fileName Defines the name of the file to load
  107396. * @returns The loaded asset container
  107397. */
  107398. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107399. }
  107400. /**
  107401. * Class used to load scene from various file formats using registered plugins
  107402. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107403. */
  107404. export class SceneLoader {
  107405. /**
  107406. * No logging while loading
  107407. */
  107408. static readonly NO_LOGGING: number;
  107409. /**
  107410. * Minimal logging while loading
  107411. */
  107412. static readonly MINIMAL_LOGGING: number;
  107413. /**
  107414. * Summary logging while loading
  107415. */
  107416. static readonly SUMMARY_LOGGING: number;
  107417. /**
  107418. * Detailled logging while loading
  107419. */
  107420. static readonly DETAILED_LOGGING: number;
  107421. /**
  107422. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107423. */
  107424. static ForceFullSceneLoadingForIncremental: boolean;
  107425. /**
  107426. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107427. */
  107428. static ShowLoadingScreen: boolean;
  107429. /**
  107430. * Defines the current logging level (while loading the scene)
  107431. * @ignorenaming
  107432. */
  107433. static loggingLevel: number;
  107434. /**
  107435. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107436. */
  107437. static CleanBoneMatrixWeights: boolean;
  107438. /**
  107439. * Event raised when a plugin is used to load a scene
  107440. */
  107441. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107442. private static _registeredPlugins;
  107443. private static _getDefaultPlugin;
  107444. private static _getPluginForExtension;
  107445. private static _getPluginForDirectLoad;
  107446. private static _getPluginForFilename;
  107447. private static _getDirectLoad;
  107448. private static _loadData;
  107449. private static _getFileInfo;
  107450. /**
  107451. * Gets a plugin that can load the given extension
  107452. * @param extension defines the extension to load
  107453. * @returns a plugin or null if none works
  107454. */
  107455. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107456. /**
  107457. * Gets a boolean indicating that the given extension can be loaded
  107458. * @param extension defines the extension to load
  107459. * @returns true if the extension is supported
  107460. */
  107461. static IsPluginForExtensionAvailable(extension: string): boolean;
  107462. /**
  107463. * Adds a new plugin to the list of registered plugins
  107464. * @param plugin defines the plugin to add
  107465. */
  107466. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107467. /**
  107468. * Import meshes into a scene
  107469. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107470. * @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)
  107471. * @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)
  107472. * @param scene the instance of BABYLON.Scene to append to
  107473. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107474. * @param onProgress a callback with a progress event for each file being loaded
  107475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107476. * @param pluginExtension the extension used to determine the plugin
  107477. * @returns The loaded plugin
  107478. */
  107479. 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>;
  107480. /**
  107481. * Import meshes into a scene
  107482. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107483. * @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)
  107484. * @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)
  107485. * @param scene the instance of BABYLON.Scene to append to
  107486. * @param onProgress a callback with a progress event for each file being loaded
  107487. * @param pluginExtension the extension used to determine the plugin
  107488. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107489. */
  107490. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107491. meshes: AbstractMesh[];
  107492. particleSystems: IParticleSystem[];
  107493. skeletons: Skeleton[];
  107494. animationGroups: AnimationGroup[];
  107495. }>;
  107496. /**
  107497. * Load a scene
  107498. * @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)
  107499. * @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)
  107500. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107501. * @param onSuccess a callback with the scene when import succeeds
  107502. * @param onProgress a callback with a progress event for each file being loaded
  107503. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107504. * @param pluginExtension the extension used to determine the plugin
  107505. * @returns The loaded plugin
  107506. */
  107507. 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>;
  107508. /**
  107509. * Load a scene
  107510. * @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)
  107511. * @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)
  107512. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107513. * @param onProgress a callback with a progress event for each file being loaded
  107514. * @param pluginExtension the extension used to determine the plugin
  107515. * @returns The loaded scene
  107516. */
  107517. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107518. /**
  107519. * Append a scene
  107520. * @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)
  107521. * @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)
  107522. * @param scene is the instance of BABYLON.Scene to append to
  107523. * @param onSuccess a callback with the scene when import succeeds
  107524. * @param onProgress a callback with a progress event for each file being loaded
  107525. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107526. * @param pluginExtension the extension used to determine the plugin
  107527. * @returns The loaded plugin
  107528. */
  107529. 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>;
  107530. /**
  107531. * Append a scene
  107532. * @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)
  107533. * @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)
  107534. * @param scene is the instance of BABYLON.Scene to append to
  107535. * @param onProgress a callback with a progress event for each file being loaded
  107536. * @param pluginExtension the extension used to determine the plugin
  107537. * @returns The given scene
  107538. */
  107539. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107540. /**
  107541. * Load a scene into an asset container
  107542. * @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)
  107543. * @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)
  107544. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107545. * @param onSuccess a callback with the scene when import succeeds
  107546. * @param onProgress a callback with a progress event for each file being loaded
  107547. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107548. * @param pluginExtension the extension used to determine the plugin
  107549. * @returns The loaded plugin
  107550. */
  107551. 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>;
  107552. /**
  107553. * Load a scene into an asset container
  107554. * @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)
  107555. * @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)
  107556. * @param scene is the instance of Scene to append to
  107557. * @param onProgress a callback with a progress event for each file being loaded
  107558. * @param pluginExtension the extension used to determine the plugin
  107559. * @returns The loaded asset container
  107560. */
  107561. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107562. }
  107563. }
  107564. declare module BABYLON {
  107565. /**
  107566. * Generic Controller
  107567. */
  107568. export class GenericController extends WebVRController {
  107569. /**
  107570. * Base Url for the controller model.
  107571. */
  107572. static readonly MODEL_BASE_URL: string;
  107573. /**
  107574. * File name for the controller model.
  107575. */
  107576. static readonly MODEL_FILENAME: string;
  107577. /**
  107578. * Creates a new GenericController from a gamepad
  107579. * @param vrGamepad the gamepad that the controller should be created from
  107580. */
  107581. constructor(vrGamepad: any);
  107582. /**
  107583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107584. * @param scene scene in which to add meshes
  107585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107586. */
  107587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107588. /**
  107589. * Called once for each button that changed state since the last frame
  107590. * @param buttonIdx Which button index changed
  107591. * @param state New state of the button
  107592. * @param changes Which properties on the state changed since last frame
  107593. */
  107594. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107595. }
  107596. }
  107597. declare module BABYLON {
  107598. /**
  107599. * Defines the WindowsMotionController object that the state of the windows motion controller
  107600. */
  107601. export class WindowsMotionController extends WebVRController {
  107602. /**
  107603. * The base url used to load the left and right controller models
  107604. */
  107605. static MODEL_BASE_URL: string;
  107606. /**
  107607. * The name of the left controller model file
  107608. */
  107609. static MODEL_LEFT_FILENAME: string;
  107610. /**
  107611. * The name of the right controller model file
  107612. */
  107613. static MODEL_RIGHT_FILENAME: string;
  107614. /**
  107615. * The controller name prefix for this controller type
  107616. */
  107617. static readonly GAMEPAD_ID_PREFIX: string;
  107618. /**
  107619. * The controller id pattern for this controller type
  107620. */
  107621. private static readonly GAMEPAD_ID_PATTERN;
  107622. private _loadedMeshInfo;
  107623. private readonly _mapping;
  107624. /**
  107625. * Fired when the trackpad on this controller is clicked
  107626. */
  107627. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107628. /**
  107629. * Fired when the trackpad on this controller is modified
  107630. */
  107631. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107632. /**
  107633. * The current x and y values of this controller's trackpad
  107634. */
  107635. trackpad: StickValues;
  107636. /**
  107637. * Creates a new WindowsMotionController from a gamepad
  107638. * @param vrGamepad the gamepad that the controller should be created from
  107639. */
  107640. constructor(vrGamepad: any);
  107641. /**
  107642. * Fired when the trigger on this controller is modified
  107643. */
  107644. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107645. /**
  107646. * Fired when the menu button on this controller is modified
  107647. */
  107648. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107649. /**
  107650. * Fired when the grip button on this controller is modified
  107651. */
  107652. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107653. /**
  107654. * Fired when the thumbstick button on this controller is modified
  107655. */
  107656. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107657. /**
  107658. * Fired when the touchpad button on this controller is modified
  107659. */
  107660. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107661. /**
  107662. * Fired when the touchpad values on this controller are modified
  107663. */
  107664. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107665. private _updateTrackpad;
  107666. /**
  107667. * Called once per frame by the engine.
  107668. */
  107669. update(): void;
  107670. /**
  107671. * Called once for each button that changed state since the last frame
  107672. * @param buttonIdx Which button index changed
  107673. * @param state New state of the button
  107674. * @param changes Which properties on the state changed since last frame
  107675. */
  107676. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107677. /**
  107678. * Moves the buttons on the controller mesh based on their current state
  107679. * @param buttonName the name of the button to move
  107680. * @param buttonValue the value of the button which determines the buttons new position
  107681. */
  107682. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107683. /**
  107684. * Moves the axis on the controller mesh based on its current state
  107685. * @param axis the index of the axis
  107686. * @param axisValue the value of the axis which determines the meshes new position
  107687. * @hidden
  107688. */
  107689. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107690. /**
  107691. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107692. * @param scene scene in which to add meshes
  107693. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107694. */
  107695. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107696. /**
  107697. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107698. * can be transformed by button presses and axes values, based on this._mapping.
  107699. *
  107700. * @param scene scene in which the meshes exist
  107701. * @param meshes list of meshes that make up the controller model to process
  107702. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107703. */
  107704. private processModel;
  107705. private createMeshInfo;
  107706. /**
  107707. * Gets the ray of the controller in the direction the controller is pointing
  107708. * @param length the length the resulting ray should be
  107709. * @returns a ray in the direction the controller is pointing
  107710. */
  107711. getForwardRay(length?: number): Ray;
  107712. /**
  107713. * Disposes of the controller
  107714. */
  107715. dispose(): void;
  107716. }
  107717. }
  107718. declare module BABYLON {
  107719. /**
  107720. * Oculus Touch Controller
  107721. */
  107722. export class OculusTouchController extends WebVRController {
  107723. /**
  107724. * Base Url for the controller model.
  107725. */
  107726. static MODEL_BASE_URL: string;
  107727. /**
  107728. * File name for the left controller model.
  107729. */
  107730. static MODEL_LEFT_FILENAME: string;
  107731. /**
  107732. * File name for the right controller model.
  107733. */
  107734. static MODEL_RIGHT_FILENAME: string;
  107735. /**
  107736. * Base Url for the Quest controller model.
  107737. */
  107738. static QUEST_MODEL_BASE_URL: string;
  107739. /**
  107740. * @hidden
  107741. * If the controllers are running on a device that needs the updated Quest controller models
  107742. */
  107743. static _IsQuest: boolean;
  107744. /**
  107745. * Fired when the secondary trigger on this controller is modified
  107746. */
  107747. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107748. /**
  107749. * Fired when the thumb rest on this controller is modified
  107750. */
  107751. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107752. /**
  107753. * Creates a new OculusTouchController from a gamepad
  107754. * @param vrGamepad the gamepad that the controller should be created from
  107755. */
  107756. constructor(vrGamepad: any);
  107757. /**
  107758. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107759. * @param scene scene in which to add meshes
  107760. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107761. */
  107762. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107763. /**
  107764. * Fired when the A button on this controller is modified
  107765. */
  107766. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107767. /**
  107768. * Fired when the B button on this controller is modified
  107769. */
  107770. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107771. /**
  107772. * Fired when the X button on this controller is modified
  107773. */
  107774. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107775. /**
  107776. * Fired when the Y button on this controller is modified
  107777. */
  107778. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107779. /**
  107780. * Called once for each button that changed state since the last frame
  107781. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107782. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107783. * 2) secondary trigger (same)
  107784. * 3) A (right) X (left), touch, pressed = value
  107785. * 4) B / Y
  107786. * 5) thumb rest
  107787. * @param buttonIdx Which button index changed
  107788. * @param state New state of the button
  107789. * @param changes Which properties on the state changed since last frame
  107790. */
  107791. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107792. }
  107793. }
  107794. declare module BABYLON {
  107795. /**
  107796. * Vive Controller
  107797. */
  107798. export class ViveController extends WebVRController {
  107799. /**
  107800. * Base Url for the controller model.
  107801. */
  107802. static MODEL_BASE_URL: string;
  107803. /**
  107804. * File name for the controller model.
  107805. */
  107806. static MODEL_FILENAME: string;
  107807. /**
  107808. * Creates a new ViveController from a gamepad
  107809. * @param vrGamepad the gamepad that the controller should be created from
  107810. */
  107811. constructor(vrGamepad: any);
  107812. /**
  107813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107814. * @param scene scene in which to add meshes
  107815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107816. */
  107817. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107818. /**
  107819. * Fired when the left button on this controller is modified
  107820. */
  107821. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107822. /**
  107823. * Fired when the right button on this controller is modified
  107824. */
  107825. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107826. /**
  107827. * Fired when the menu button on this controller is modified
  107828. */
  107829. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107830. /**
  107831. * Called once for each button that changed state since the last frame
  107832. * Vive mapping:
  107833. * 0: touchpad
  107834. * 1: trigger
  107835. * 2: left AND right buttons
  107836. * 3: menu button
  107837. * @param buttonIdx Which button index changed
  107838. * @param state New state of the button
  107839. * @param changes Which properties on the state changed since last frame
  107840. */
  107841. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107842. }
  107843. }
  107844. declare module BABYLON {
  107845. /**
  107846. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  107847. */
  107848. export class WebXRControllerModelLoader {
  107849. /**
  107850. * Creates the WebXRControllerModelLoader
  107851. * @param input xr input that creates the controllers
  107852. */
  107853. constructor(input: WebXRInput);
  107854. }
  107855. }
  107856. declare module BABYLON {
  107857. /**
  107858. * Contains an array of blocks representing the octree
  107859. */
  107860. export interface IOctreeContainer<T> {
  107861. /**
  107862. * Blocks within the octree
  107863. */
  107864. blocks: Array<OctreeBlock<T>>;
  107865. }
  107866. /**
  107867. * Class used to store a cell in an octree
  107868. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107869. */
  107870. export class OctreeBlock<T> {
  107871. /**
  107872. * Gets the content of the current block
  107873. */
  107874. entries: T[];
  107875. /**
  107876. * Gets the list of block children
  107877. */
  107878. blocks: Array<OctreeBlock<T>>;
  107879. private _depth;
  107880. private _maxDepth;
  107881. private _capacity;
  107882. private _minPoint;
  107883. private _maxPoint;
  107884. private _boundingVectors;
  107885. private _creationFunc;
  107886. /**
  107887. * Creates a new block
  107888. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  107889. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  107890. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107891. * @param depth defines the current depth of this block in the octree
  107892. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  107893. * @param creationFunc defines a callback to call when an element is added to the block
  107894. */
  107895. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  107896. /**
  107897. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  107898. */
  107899. readonly capacity: number;
  107900. /**
  107901. * Gets the minimum vector (in world space) of the block's bounding box
  107902. */
  107903. readonly minPoint: Vector3;
  107904. /**
  107905. * Gets the maximum vector (in world space) of the block's bounding box
  107906. */
  107907. readonly maxPoint: Vector3;
  107908. /**
  107909. * Add a new element to this block
  107910. * @param entry defines the element to add
  107911. */
  107912. addEntry(entry: T): void;
  107913. /**
  107914. * Remove an element from this block
  107915. * @param entry defines the element to remove
  107916. */
  107917. removeEntry(entry: T): void;
  107918. /**
  107919. * Add an array of elements to this block
  107920. * @param entries defines the array of elements to add
  107921. */
  107922. addEntries(entries: T[]): void;
  107923. /**
  107924. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  107925. * @param frustumPlanes defines the frustum planes to test
  107926. * @param selection defines the array to store current content if selection is positive
  107927. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107928. */
  107929. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107930. /**
  107931. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  107932. * @param sphereCenter defines the bounding sphere center
  107933. * @param sphereRadius defines the bounding sphere radius
  107934. * @param selection defines the array to store current content if selection is positive
  107935. * @param allowDuplicate defines if the selection array can contains duplicated entries
  107936. */
  107937. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  107938. /**
  107939. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  107940. * @param ray defines the ray to test with
  107941. * @param selection defines the array to store current content if selection is positive
  107942. */
  107943. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  107944. /**
  107945. * Subdivide the content into child blocks (this block will then be empty)
  107946. */
  107947. createInnerBlocks(): void;
  107948. /**
  107949. * @hidden
  107950. */
  107951. 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;
  107952. }
  107953. }
  107954. declare module BABYLON {
  107955. /**
  107956. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  107957. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107958. */
  107959. export class Octree<T> {
  107960. /** 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.) */
  107961. maxDepth: number;
  107962. /**
  107963. * Blocks within the octree containing objects
  107964. */
  107965. blocks: Array<OctreeBlock<T>>;
  107966. /**
  107967. * Content stored in the octree
  107968. */
  107969. dynamicContent: T[];
  107970. private _maxBlockCapacity;
  107971. private _selectionContent;
  107972. private _creationFunc;
  107973. /**
  107974. * Creates a octree
  107975. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  107976. * @param creationFunc function to be used to instatiate the octree
  107977. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  107978. * @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.)
  107979. */
  107980. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  107981. /** 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.) */
  107982. maxDepth?: number);
  107983. /**
  107984. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  107985. * @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);
  107986. * @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);
  107987. * @param entries meshes to be added to the octree blocks
  107988. */
  107989. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  107990. /**
  107991. * Adds a mesh to the octree
  107992. * @param entry Mesh to add to the octree
  107993. */
  107994. addMesh(entry: T): void;
  107995. /**
  107996. * Remove an element from the octree
  107997. * @param entry defines the element to remove
  107998. */
  107999. removeMesh(entry: T): void;
  108000. /**
  108001. * Selects an array of meshes within the frustum
  108002. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108003. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108004. * @returns array of meshes within the frustum
  108005. */
  108006. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108007. /**
  108008. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108009. * @param sphereCenter defines the bounding sphere center
  108010. * @param sphereRadius defines the bounding sphere radius
  108011. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108012. * @returns an array of objects that intersect the sphere
  108013. */
  108014. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108015. /**
  108016. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108017. * @param ray defines the ray to test with
  108018. * @returns array of intersected objects
  108019. */
  108020. intersectsRay(ray: Ray): SmartArray<T>;
  108021. /**
  108022. * Adds a mesh into the octree block if it intersects the block
  108023. */
  108024. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108025. /**
  108026. * Adds a submesh into the octree block if it intersects the block
  108027. */
  108028. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108029. }
  108030. }
  108031. declare module BABYLON {
  108032. interface Scene {
  108033. /**
  108034. * @hidden
  108035. * Backing Filed
  108036. */
  108037. _selectionOctree: Octree<AbstractMesh>;
  108038. /**
  108039. * Gets the octree used to boost mesh selection (picking)
  108040. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108041. */
  108042. selectionOctree: Octree<AbstractMesh>;
  108043. /**
  108044. * Creates or updates the octree used to boost selection (picking)
  108045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108046. * @param maxCapacity defines the maximum capacity per leaf
  108047. * @param maxDepth defines the maximum depth of the octree
  108048. * @returns an octree of AbstractMesh
  108049. */
  108050. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108051. }
  108052. interface AbstractMesh {
  108053. /**
  108054. * @hidden
  108055. * Backing Field
  108056. */
  108057. _submeshesOctree: Octree<SubMesh>;
  108058. /**
  108059. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108060. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108061. * @param maxCapacity defines the maximum size of each block (64 by default)
  108062. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108063. * @returns the new octree
  108064. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108066. */
  108067. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108068. }
  108069. /**
  108070. * Defines the octree scene component responsible to manage any octrees
  108071. * in a given scene.
  108072. */
  108073. export class OctreeSceneComponent {
  108074. /**
  108075. * The component name help to identify the component in the list of scene components.
  108076. */
  108077. readonly name: string;
  108078. /**
  108079. * The scene the component belongs to.
  108080. */
  108081. scene: Scene;
  108082. /**
  108083. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108084. */
  108085. readonly checksIsEnabled: boolean;
  108086. /**
  108087. * Creates a new instance of the component for the given scene
  108088. * @param scene Defines the scene to register the component in
  108089. */
  108090. constructor(scene: Scene);
  108091. /**
  108092. * Registers the component in a given scene
  108093. */
  108094. register(): void;
  108095. /**
  108096. * Return the list of active meshes
  108097. * @returns the list of active meshes
  108098. */
  108099. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108100. /**
  108101. * Return the list of active sub meshes
  108102. * @param mesh The mesh to get the candidates sub meshes from
  108103. * @returns the list of active sub meshes
  108104. */
  108105. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108106. private _tempRay;
  108107. /**
  108108. * Return the list of sub meshes intersecting with a given local ray
  108109. * @param mesh defines the mesh to find the submesh for
  108110. * @param localRay defines the ray in local space
  108111. * @returns the list of intersecting sub meshes
  108112. */
  108113. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108114. /**
  108115. * Return the list of sub meshes colliding with a collider
  108116. * @param mesh defines the mesh to find the submesh for
  108117. * @param collider defines the collider to evaluate the collision against
  108118. * @returns the list of colliding sub meshes
  108119. */
  108120. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108121. /**
  108122. * Rebuilds the elements related to this component in case of
  108123. * context lost for instance.
  108124. */
  108125. rebuild(): void;
  108126. /**
  108127. * Disposes the component and the associated ressources.
  108128. */
  108129. dispose(): void;
  108130. }
  108131. }
  108132. declare module BABYLON {
  108133. /**
  108134. * Renders a layer on top of an existing scene
  108135. */
  108136. export class UtilityLayerRenderer implements IDisposable {
  108137. /** the original scene that will be rendered on top of */
  108138. originalScene: Scene;
  108139. private _pointerCaptures;
  108140. private _lastPointerEvents;
  108141. private static _DefaultUtilityLayer;
  108142. private static _DefaultKeepDepthUtilityLayer;
  108143. private _sharedGizmoLight;
  108144. private _renderCamera;
  108145. /**
  108146. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108147. * @returns the camera that is used when rendering the utility layer
  108148. */
  108149. getRenderCamera(): Nullable<Camera>;
  108150. /**
  108151. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108152. * @param cam the camera that should be used when rendering the utility layer
  108153. */
  108154. setRenderCamera(cam: Nullable<Camera>): void;
  108155. /**
  108156. * @hidden
  108157. * Light which used by gizmos to get light shading
  108158. */
  108159. _getSharedGizmoLight(): HemisphericLight;
  108160. /**
  108161. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108162. */
  108163. pickUtilitySceneFirst: boolean;
  108164. /**
  108165. * 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)
  108166. */
  108167. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108168. /**
  108169. * 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)
  108170. */
  108171. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108172. /**
  108173. * The scene that is rendered on top of the original scene
  108174. */
  108175. utilityLayerScene: Scene;
  108176. /**
  108177. * If the utility layer should automatically be rendered on top of existing scene
  108178. */
  108179. shouldRender: boolean;
  108180. /**
  108181. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108182. */
  108183. onlyCheckPointerDownEvents: boolean;
  108184. /**
  108185. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108186. */
  108187. processAllEvents: boolean;
  108188. /**
  108189. * Observable raised when the pointer move from the utility layer scene to the main scene
  108190. */
  108191. onPointerOutObservable: Observable<number>;
  108192. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108193. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108194. private _afterRenderObserver;
  108195. private _sceneDisposeObserver;
  108196. private _originalPointerObserver;
  108197. /**
  108198. * Instantiates a UtilityLayerRenderer
  108199. * @param originalScene the original scene that will be rendered on top of
  108200. * @param handleEvents boolean indicating if the utility layer should handle events
  108201. */
  108202. constructor(
  108203. /** the original scene that will be rendered on top of */
  108204. originalScene: Scene, handleEvents?: boolean);
  108205. private _notifyObservers;
  108206. /**
  108207. * Renders the utility layers scene on top of the original scene
  108208. */
  108209. render(): void;
  108210. /**
  108211. * Disposes of the renderer
  108212. */
  108213. dispose(): void;
  108214. private _updateCamera;
  108215. }
  108216. }
  108217. declare module BABYLON {
  108218. /**
  108219. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108220. */
  108221. export class Gizmo implements IDisposable {
  108222. /** The utility layer the gizmo will be added to */
  108223. gizmoLayer: UtilityLayerRenderer;
  108224. /**
  108225. * The root mesh of the gizmo
  108226. */
  108227. _rootMesh: Mesh;
  108228. private _attachedMesh;
  108229. /**
  108230. * Ratio for the scale of the gizmo (Default: 1)
  108231. */
  108232. scaleRatio: number;
  108233. /**
  108234. * If a custom mesh has been set (Default: false)
  108235. */
  108236. protected _customMeshSet: boolean;
  108237. /**
  108238. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108239. * * When set, interactions will be enabled
  108240. */
  108241. attachedMesh: Nullable<AbstractMesh>;
  108242. /**
  108243. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108244. * @param mesh The mesh to replace the default mesh of the gizmo
  108245. */
  108246. setCustomMesh(mesh: Mesh): void;
  108247. /**
  108248. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108249. */
  108250. updateGizmoRotationToMatchAttachedMesh: boolean;
  108251. /**
  108252. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108253. */
  108254. updateGizmoPositionToMatchAttachedMesh: boolean;
  108255. /**
  108256. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108257. */
  108258. updateScale: boolean;
  108259. protected _interactionsEnabled: boolean;
  108260. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108261. private _beforeRenderObserver;
  108262. private _tempVector;
  108263. /**
  108264. * Creates a gizmo
  108265. * @param gizmoLayer The utility layer the gizmo will be added to
  108266. */
  108267. constructor(
  108268. /** The utility layer the gizmo will be added to */
  108269. gizmoLayer?: UtilityLayerRenderer);
  108270. /**
  108271. * Updates the gizmo to match the attached mesh's position/rotation
  108272. */
  108273. protected _update(): void;
  108274. /**
  108275. * Disposes of the gizmo
  108276. */
  108277. dispose(): void;
  108278. }
  108279. }
  108280. declare module BABYLON {
  108281. /**
  108282. * Single plane drag gizmo
  108283. */
  108284. export class PlaneDragGizmo extends Gizmo {
  108285. /**
  108286. * Drag behavior responsible for the gizmos dragging interactions
  108287. */
  108288. dragBehavior: PointerDragBehavior;
  108289. private _pointerObserver;
  108290. /**
  108291. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108292. */
  108293. snapDistance: number;
  108294. /**
  108295. * Event that fires each time the gizmo snaps to a new location.
  108296. * * snapDistance is the the change in distance
  108297. */
  108298. onSnapObservable: Observable<{
  108299. snapDistance: number;
  108300. }>;
  108301. private _plane;
  108302. private _coloredMaterial;
  108303. private _hoverMaterial;
  108304. private _isEnabled;
  108305. private _parent;
  108306. /** @hidden */
  108307. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108308. /** @hidden */
  108309. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108310. /**
  108311. * Creates a PlaneDragGizmo
  108312. * @param gizmoLayer The utility layer the gizmo will be added to
  108313. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108314. * @param color The color of the gizmo
  108315. */
  108316. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108317. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108318. /**
  108319. * If the gizmo is enabled
  108320. */
  108321. isEnabled: boolean;
  108322. /**
  108323. * Disposes of the gizmo
  108324. */
  108325. dispose(): void;
  108326. }
  108327. }
  108328. declare module BABYLON {
  108329. /**
  108330. * Gizmo that enables dragging a mesh along 3 axis
  108331. */
  108332. export class PositionGizmo extends Gizmo {
  108333. /**
  108334. * Internal gizmo used for interactions on the x axis
  108335. */
  108336. xGizmo: AxisDragGizmo;
  108337. /**
  108338. * Internal gizmo used for interactions on the y axis
  108339. */
  108340. yGizmo: AxisDragGizmo;
  108341. /**
  108342. * Internal gizmo used for interactions on the z axis
  108343. */
  108344. zGizmo: AxisDragGizmo;
  108345. /**
  108346. * Internal gizmo used for interactions on the yz plane
  108347. */
  108348. xPlaneGizmo: PlaneDragGizmo;
  108349. /**
  108350. * Internal gizmo used for interactions on the xz plane
  108351. */
  108352. yPlaneGizmo: PlaneDragGizmo;
  108353. /**
  108354. * Internal gizmo used for interactions on the xy plane
  108355. */
  108356. zPlaneGizmo: PlaneDragGizmo;
  108357. /**
  108358. * private variables
  108359. */
  108360. private _meshAttached;
  108361. private _updateGizmoRotationToMatchAttachedMesh;
  108362. private _snapDistance;
  108363. private _scaleRatio;
  108364. /** Fires an event when any of it's sub gizmos are dragged */
  108365. onDragStartObservable: Observable<unknown>;
  108366. /** Fires an event when any of it's sub gizmos are released from dragging */
  108367. onDragEndObservable: Observable<unknown>;
  108368. /**
  108369. * If set to true, planar drag is enabled
  108370. */
  108371. private _planarGizmoEnabled;
  108372. attachedMesh: Nullable<AbstractMesh>;
  108373. /**
  108374. * Creates a PositionGizmo
  108375. * @param gizmoLayer The utility layer the gizmo will be added to
  108376. */
  108377. constructor(gizmoLayer?: UtilityLayerRenderer);
  108378. /**
  108379. * If the planar drag gizmo is enabled
  108380. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108381. */
  108382. planarGizmoEnabled: boolean;
  108383. updateGizmoRotationToMatchAttachedMesh: boolean;
  108384. /**
  108385. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108386. */
  108387. snapDistance: number;
  108388. /**
  108389. * Ratio for the scale of the gizmo (Default: 1)
  108390. */
  108391. scaleRatio: number;
  108392. /**
  108393. * Disposes of the gizmo
  108394. */
  108395. dispose(): void;
  108396. /**
  108397. * CustomMeshes are not supported by this gizmo
  108398. * @param mesh The mesh to replace the default mesh of the gizmo
  108399. */
  108400. setCustomMesh(mesh: Mesh): void;
  108401. }
  108402. }
  108403. declare module BABYLON {
  108404. /**
  108405. * Single axis drag gizmo
  108406. */
  108407. export class AxisDragGizmo extends Gizmo {
  108408. /**
  108409. * Drag behavior responsible for the gizmos dragging interactions
  108410. */
  108411. dragBehavior: PointerDragBehavior;
  108412. private _pointerObserver;
  108413. /**
  108414. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108415. */
  108416. snapDistance: number;
  108417. /**
  108418. * Event that fires each time the gizmo snaps to a new location.
  108419. * * snapDistance is the the change in distance
  108420. */
  108421. onSnapObservable: Observable<{
  108422. snapDistance: number;
  108423. }>;
  108424. private _isEnabled;
  108425. private _parent;
  108426. private _arrow;
  108427. private _coloredMaterial;
  108428. private _hoverMaterial;
  108429. /** @hidden */
  108430. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108431. /** @hidden */
  108432. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108433. /**
  108434. * Creates an AxisDragGizmo
  108435. * @param gizmoLayer The utility layer the gizmo will be added to
  108436. * @param dragAxis The axis which the gizmo will be able to drag on
  108437. * @param color The color of the gizmo
  108438. */
  108439. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108440. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108441. /**
  108442. * If the gizmo is enabled
  108443. */
  108444. isEnabled: boolean;
  108445. /**
  108446. * Disposes of the gizmo
  108447. */
  108448. dispose(): void;
  108449. }
  108450. }
  108451. declare module BABYLON.Debug {
  108452. /**
  108453. * The Axes viewer will show 3 axes in a specific point in space
  108454. */
  108455. export class AxesViewer {
  108456. private _xAxis;
  108457. private _yAxis;
  108458. private _zAxis;
  108459. private _scaleLinesFactor;
  108460. private _instanced;
  108461. /**
  108462. * Gets the hosting scene
  108463. */
  108464. scene: Scene;
  108465. /**
  108466. * Gets or sets a number used to scale line length
  108467. */
  108468. scaleLines: number;
  108469. /** Gets the node hierarchy used to render x-axis */
  108470. readonly xAxis: TransformNode;
  108471. /** Gets the node hierarchy used to render y-axis */
  108472. readonly yAxis: TransformNode;
  108473. /** Gets the node hierarchy used to render z-axis */
  108474. readonly zAxis: TransformNode;
  108475. /**
  108476. * Creates a new AxesViewer
  108477. * @param scene defines the hosting scene
  108478. * @param scaleLines defines a number used to scale line length (1 by default)
  108479. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108480. * @param xAxis defines the node hierarchy used to render the x-axis
  108481. * @param yAxis defines the node hierarchy used to render the y-axis
  108482. * @param zAxis defines the node hierarchy used to render the z-axis
  108483. */
  108484. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108485. /**
  108486. * Force the viewer to update
  108487. * @param position defines the position of the viewer
  108488. * @param xaxis defines the x axis of the viewer
  108489. * @param yaxis defines the y axis of the viewer
  108490. * @param zaxis defines the z axis of the viewer
  108491. */
  108492. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108493. /**
  108494. * Creates an instance of this axes viewer.
  108495. * @returns a new axes viewer with instanced meshes
  108496. */
  108497. createInstance(): AxesViewer;
  108498. /** Releases resources */
  108499. dispose(): void;
  108500. private static _SetRenderingGroupId;
  108501. }
  108502. }
  108503. declare module BABYLON.Debug {
  108504. /**
  108505. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108506. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108507. */
  108508. export class BoneAxesViewer extends AxesViewer {
  108509. /**
  108510. * Gets or sets the target mesh where to display the axes viewer
  108511. */
  108512. mesh: Nullable<Mesh>;
  108513. /**
  108514. * Gets or sets the target bone where to display the axes viewer
  108515. */
  108516. bone: Nullable<Bone>;
  108517. /** Gets current position */
  108518. pos: Vector3;
  108519. /** Gets direction of X axis */
  108520. xaxis: Vector3;
  108521. /** Gets direction of Y axis */
  108522. yaxis: Vector3;
  108523. /** Gets direction of Z axis */
  108524. zaxis: Vector3;
  108525. /**
  108526. * Creates a new BoneAxesViewer
  108527. * @param scene defines the hosting scene
  108528. * @param bone defines the target bone
  108529. * @param mesh defines the target mesh
  108530. * @param scaleLines defines a scaling factor for line length (1 by default)
  108531. */
  108532. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108533. /**
  108534. * Force the viewer to update
  108535. */
  108536. update(): void;
  108537. /** Releases resources */
  108538. dispose(): void;
  108539. }
  108540. }
  108541. declare module BABYLON {
  108542. /**
  108543. * Interface used to define scene explorer extensibility option
  108544. */
  108545. export interface IExplorerExtensibilityOption {
  108546. /**
  108547. * Define the option label
  108548. */
  108549. label: string;
  108550. /**
  108551. * Defines the action to execute on click
  108552. */
  108553. action: (entity: any) => void;
  108554. }
  108555. /**
  108556. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108557. */
  108558. export interface IExplorerExtensibilityGroup {
  108559. /**
  108560. * Defines a predicate to test if a given type mut be extended
  108561. */
  108562. predicate: (entity: any) => boolean;
  108563. /**
  108564. * Gets the list of options added to a type
  108565. */
  108566. entries: IExplorerExtensibilityOption[];
  108567. }
  108568. /**
  108569. * Interface used to define the options to use to create the Inspector
  108570. */
  108571. export interface IInspectorOptions {
  108572. /**
  108573. * Display in overlay mode (default: false)
  108574. */
  108575. overlay?: boolean;
  108576. /**
  108577. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108578. */
  108579. globalRoot?: HTMLElement;
  108580. /**
  108581. * Display the Scene explorer
  108582. */
  108583. showExplorer?: boolean;
  108584. /**
  108585. * Display the property inspector
  108586. */
  108587. showInspector?: boolean;
  108588. /**
  108589. * Display in embed mode (both panes on the right)
  108590. */
  108591. embedMode?: boolean;
  108592. /**
  108593. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108594. */
  108595. handleResize?: boolean;
  108596. /**
  108597. * Allow the panes to popup (default: true)
  108598. */
  108599. enablePopup?: boolean;
  108600. /**
  108601. * Allow the panes to be closed by users (default: true)
  108602. */
  108603. enableClose?: boolean;
  108604. /**
  108605. * Optional list of extensibility entries
  108606. */
  108607. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108608. /**
  108609. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108610. */
  108611. inspectorURL?: string;
  108612. }
  108613. interface Scene {
  108614. /**
  108615. * @hidden
  108616. * Backing field
  108617. */
  108618. _debugLayer: DebugLayer;
  108619. /**
  108620. * Gets the debug layer (aka Inspector) associated with the scene
  108621. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108622. */
  108623. debugLayer: DebugLayer;
  108624. }
  108625. /**
  108626. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108627. * what is happening in your scene
  108628. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108629. */
  108630. export class DebugLayer {
  108631. /**
  108632. * Define the url to get the inspector script from.
  108633. * By default it uses the babylonjs CDN.
  108634. * @ignoreNaming
  108635. */
  108636. static InspectorURL: string;
  108637. private _scene;
  108638. private BJSINSPECTOR;
  108639. private _onPropertyChangedObservable?;
  108640. /**
  108641. * Observable triggered when a property is changed through the inspector.
  108642. */
  108643. readonly onPropertyChangedObservable: any;
  108644. /**
  108645. * Instantiates a new debug layer.
  108646. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108647. * what is happening in your scene
  108648. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108649. * @param scene Defines the scene to inspect
  108650. */
  108651. constructor(scene: Scene);
  108652. /** Creates the inspector window. */
  108653. private _createInspector;
  108654. /**
  108655. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108656. * @param entity defines the entity to select
  108657. * @param lineContainerTitle defines the specific block to highlight
  108658. */
  108659. select(entity: any, lineContainerTitle?: string): void;
  108660. /** Get the inspector from bundle or global */
  108661. private _getGlobalInspector;
  108662. /**
  108663. * Get if the inspector is visible or not.
  108664. * @returns true if visible otherwise, false
  108665. */
  108666. isVisible(): boolean;
  108667. /**
  108668. * Hide the inspector and close its window.
  108669. */
  108670. hide(): void;
  108671. /**
  108672. * Launch the debugLayer.
  108673. * @param config Define the configuration of the inspector
  108674. * @return a promise fulfilled when the debug layer is visible
  108675. */
  108676. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108677. }
  108678. }
  108679. declare module BABYLON {
  108680. /**
  108681. * Class containing static functions to help procedurally build meshes
  108682. */
  108683. export class BoxBuilder {
  108684. /**
  108685. * Creates a box mesh
  108686. * * The parameter `size` sets the size (float) of each box side (default 1)
  108687. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108688. * * 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)
  108689. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108691. * * 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
  108692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108693. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108694. * @param name defines the name of the mesh
  108695. * @param options defines the options used to create the mesh
  108696. * @param scene defines the hosting scene
  108697. * @returns the box mesh
  108698. */
  108699. static CreateBox(name: string, options: {
  108700. size?: number;
  108701. width?: number;
  108702. height?: number;
  108703. depth?: number;
  108704. faceUV?: Vector4[];
  108705. faceColors?: Color4[];
  108706. sideOrientation?: number;
  108707. frontUVs?: Vector4;
  108708. backUVs?: Vector4;
  108709. wrap?: boolean;
  108710. topBaseAt?: number;
  108711. bottomBaseAt?: number;
  108712. updatable?: boolean;
  108713. }, scene?: Nullable<Scene>): Mesh;
  108714. }
  108715. }
  108716. declare module BABYLON {
  108717. /**
  108718. * Class containing static functions to help procedurally build meshes
  108719. */
  108720. export class SphereBuilder {
  108721. /**
  108722. * Creates a sphere mesh
  108723. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108724. * * 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`)
  108725. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108726. * * 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
  108727. * * 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)
  108728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108729. * * 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
  108730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108731. * @param name defines the name of the mesh
  108732. * @param options defines the options used to create the mesh
  108733. * @param scene defines the hosting scene
  108734. * @returns the sphere mesh
  108735. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108736. */
  108737. static CreateSphere(name: string, options: {
  108738. segments?: number;
  108739. diameter?: number;
  108740. diameterX?: number;
  108741. diameterY?: number;
  108742. diameterZ?: number;
  108743. arc?: number;
  108744. slice?: number;
  108745. sideOrientation?: number;
  108746. frontUVs?: Vector4;
  108747. backUVs?: Vector4;
  108748. updatable?: boolean;
  108749. }, scene?: Nullable<Scene>): Mesh;
  108750. }
  108751. }
  108752. declare module BABYLON.Debug {
  108753. /**
  108754. * Used to show the physics impostor around the specific mesh
  108755. */
  108756. export class PhysicsViewer {
  108757. /** @hidden */
  108758. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108759. /** @hidden */
  108760. protected _meshes: Array<Nullable<AbstractMesh>>;
  108761. /** @hidden */
  108762. protected _scene: Nullable<Scene>;
  108763. /** @hidden */
  108764. protected _numMeshes: number;
  108765. /** @hidden */
  108766. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108767. private _renderFunction;
  108768. private _utilityLayer;
  108769. private _debugBoxMesh;
  108770. private _debugSphereMesh;
  108771. private _debugCylinderMesh;
  108772. private _debugMaterial;
  108773. private _debugMeshMeshes;
  108774. /**
  108775. * Creates a new PhysicsViewer
  108776. * @param scene defines the hosting scene
  108777. */
  108778. constructor(scene: Scene);
  108779. /** @hidden */
  108780. protected _updateDebugMeshes(): void;
  108781. /**
  108782. * Renders a specified physic impostor
  108783. * @param impostor defines the impostor to render
  108784. * @param targetMesh defines the mesh represented by the impostor
  108785. * @returns the new debug mesh used to render the impostor
  108786. */
  108787. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108788. /**
  108789. * Hides a specified physic impostor
  108790. * @param impostor defines the impostor to hide
  108791. */
  108792. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108793. private _getDebugMaterial;
  108794. private _getDebugBoxMesh;
  108795. private _getDebugSphereMesh;
  108796. private _getDebugCylinderMesh;
  108797. private _getDebugMeshMesh;
  108798. private _getDebugMesh;
  108799. /** Releases all resources */
  108800. dispose(): void;
  108801. }
  108802. }
  108803. declare module BABYLON {
  108804. /**
  108805. * Class containing static functions to help procedurally build meshes
  108806. */
  108807. export class LinesBuilder {
  108808. /**
  108809. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  108810. * * 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
  108811. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  108812. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  108813. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  108814. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  108815. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  108816. * * 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
  108817. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  108818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  108820. * @param name defines the name of the new line system
  108821. * @param options defines the options used to create the line system
  108822. * @param scene defines the hosting scene
  108823. * @returns a new line system mesh
  108824. */
  108825. static CreateLineSystem(name: string, options: {
  108826. lines: Vector3[][];
  108827. updatable?: boolean;
  108828. instance?: Nullable<LinesMesh>;
  108829. colors?: Nullable<Color4[][]>;
  108830. useVertexAlpha?: boolean;
  108831. }, scene: Nullable<Scene>): LinesMesh;
  108832. /**
  108833. * Creates a line mesh
  108834. * 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
  108835. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108836. * * The parameter `points` is an array successive Vector3
  108837. * * 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
  108838. * * The optional parameter `colors` is an array of successive Color4, one per line point
  108839. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  108840. * * When updating an instance, remember that only point positions can change, not the number of points
  108841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108842. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  108843. * @param name defines the name of the new line system
  108844. * @param options defines the options used to create the line system
  108845. * @param scene defines the hosting scene
  108846. * @returns a new line mesh
  108847. */
  108848. static CreateLines(name: string, options: {
  108849. points: Vector3[];
  108850. updatable?: boolean;
  108851. instance?: Nullable<LinesMesh>;
  108852. colors?: Color4[];
  108853. useVertexAlpha?: boolean;
  108854. }, scene?: Nullable<Scene>): LinesMesh;
  108855. /**
  108856. * Creates a dashed line mesh
  108857. * * 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
  108858. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  108859. * * The parameter `points` is an array successive Vector3
  108860. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  108861. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  108862. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108863. * * 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
  108864. * * When updating an instance, remember that only point positions can change, not the number of points
  108865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108866. * @param name defines the name of the mesh
  108867. * @param options defines the options used to create the mesh
  108868. * @param scene defines the hosting scene
  108869. * @returns the dashed line mesh
  108870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  108871. */
  108872. static CreateDashedLines(name: string, options: {
  108873. points: Vector3[];
  108874. dashSize?: number;
  108875. gapSize?: number;
  108876. dashNb?: number;
  108877. updatable?: boolean;
  108878. instance?: LinesMesh;
  108879. }, scene?: Nullable<Scene>): LinesMesh;
  108880. }
  108881. }
  108882. declare module BABYLON {
  108883. /**
  108884. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108885. * in order to better appreciate the issue one might have.
  108886. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108887. */
  108888. export class RayHelper {
  108889. /**
  108890. * Defines the ray we are currently tryin to visualize.
  108891. */
  108892. ray: Nullable<Ray>;
  108893. private _renderPoints;
  108894. private _renderLine;
  108895. private _renderFunction;
  108896. private _scene;
  108897. private _updateToMeshFunction;
  108898. private _attachedToMesh;
  108899. private _meshSpaceDirection;
  108900. private _meshSpaceOrigin;
  108901. /**
  108902. * Helper function to create a colored helper in a scene in one line.
  108903. * @param ray Defines the ray we are currently tryin to visualize
  108904. * @param scene Defines the scene the ray is used in
  108905. * @param color Defines the color we want to see the ray in
  108906. * @returns The newly created ray helper.
  108907. */
  108908. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  108909. /**
  108910. * Instantiate a new ray helper.
  108911. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  108912. * in order to better appreciate the issue one might have.
  108913. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  108914. * @param ray Defines the ray we are currently tryin to visualize
  108915. */
  108916. constructor(ray: Ray);
  108917. /**
  108918. * Shows the ray we are willing to debug.
  108919. * @param scene Defines the scene the ray needs to be rendered in
  108920. * @param color Defines the color the ray needs to be rendered in
  108921. */
  108922. show(scene: Scene, color?: Color3): void;
  108923. /**
  108924. * Hides the ray we are debugging.
  108925. */
  108926. hide(): void;
  108927. private _render;
  108928. /**
  108929. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  108930. * @param mesh Defines the mesh we want the helper attached to
  108931. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  108932. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  108933. * @param length Defines the length of the ray
  108934. */
  108935. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  108936. /**
  108937. * Detach the ray helper from the mesh it has previously been attached to.
  108938. */
  108939. detachFromMesh(): void;
  108940. private _updateToMesh;
  108941. /**
  108942. * Dispose the helper and release its associated resources.
  108943. */
  108944. dispose(): void;
  108945. }
  108946. }
  108947. declare module BABYLON.Debug {
  108948. /**
  108949. * Class used to render a debug view of a given skeleton
  108950. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  108951. */
  108952. export class SkeletonViewer {
  108953. /** defines the skeleton to render */
  108954. skeleton: Skeleton;
  108955. /** defines the mesh attached to the skeleton */
  108956. mesh: AbstractMesh;
  108957. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108958. autoUpdateBonesMatrices: boolean;
  108959. /** defines the rendering group id to use with the viewer */
  108960. renderingGroupId: number;
  108961. /** Gets or sets the color used to render the skeleton */
  108962. color: Color3;
  108963. private _scene;
  108964. private _debugLines;
  108965. private _debugMesh;
  108966. private _isEnabled;
  108967. private _renderFunction;
  108968. private _utilityLayer;
  108969. /**
  108970. * Returns the mesh used to render the bones
  108971. */
  108972. readonly debugMesh: Nullable<LinesMesh>;
  108973. /**
  108974. * Creates a new SkeletonViewer
  108975. * @param skeleton defines the skeleton to render
  108976. * @param mesh defines the mesh attached to the skeleton
  108977. * @param scene defines the hosting scene
  108978. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  108979. * @param renderingGroupId defines the rendering group id to use with the viewer
  108980. */
  108981. constructor(
  108982. /** defines the skeleton to render */
  108983. skeleton: Skeleton,
  108984. /** defines the mesh attached to the skeleton */
  108985. mesh: AbstractMesh, scene: Scene,
  108986. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  108987. autoUpdateBonesMatrices?: boolean,
  108988. /** defines the rendering group id to use with the viewer */
  108989. renderingGroupId?: number);
  108990. /** Gets or sets a boolean indicating if the viewer is enabled */
  108991. isEnabled: boolean;
  108992. private _getBonePosition;
  108993. private _getLinesForBonesWithLength;
  108994. private _getLinesForBonesNoLength;
  108995. /** Update the viewer to sync with current skeleton state */
  108996. update(): void;
  108997. /** Release associated resources */
  108998. dispose(): void;
  108999. }
  109000. }
  109001. declare module BABYLON {
  109002. /**
  109003. * Options to create the null engine
  109004. */
  109005. export class NullEngineOptions {
  109006. /**
  109007. * Render width (Default: 512)
  109008. */
  109009. renderWidth: number;
  109010. /**
  109011. * Render height (Default: 256)
  109012. */
  109013. renderHeight: number;
  109014. /**
  109015. * Texture size (Default: 512)
  109016. */
  109017. textureSize: number;
  109018. /**
  109019. * If delta time between frames should be constant
  109020. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109021. */
  109022. deterministicLockstep: boolean;
  109023. /**
  109024. * Maximum about of steps between frames (Default: 4)
  109025. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109026. */
  109027. lockstepMaxSteps: number;
  109028. }
  109029. /**
  109030. * The null engine class provides support for headless version of babylon.js.
  109031. * This can be used in server side scenario or for testing purposes
  109032. */
  109033. export class NullEngine extends Engine {
  109034. private _options;
  109035. /**
  109036. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109037. */
  109038. isDeterministicLockStep(): boolean;
  109039. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109040. getLockstepMaxSteps(): number;
  109041. /**
  109042. * Sets hardware scaling, used to save performance if needed
  109043. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109044. */
  109045. getHardwareScalingLevel(): number;
  109046. constructor(options?: NullEngineOptions);
  109047. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109048. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109049. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109050. getRenderWidth(useScreen?: boolean): number;
  109051. getRenderHeight(useScreen?: boolean): number;
  109052. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109053. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109054. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109055. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109056. bindSamplers(effect: Effect): void;
  109057. enableEffect(effect: Effect): void;
  109058. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109059. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109060. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109061. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109062. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109063. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109064. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109065. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109066. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109067. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109068. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109069. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109070. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109071. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109072. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109073. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109074. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109075. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109076. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109077. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109078. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109079. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109080. bindBuffers(vertexBuffers: {
  109081. [key: string]: VertexBuffer;
  109082. }, indexBuffer: DataBuffer, effect: Effect): void;
  109083. wipeCaches(bruteForce?: boolean): void;
  109084. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109085. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109086. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109087. /** @hidden */
  109088. _createTexture(): WebGLTexture;
  109089. /** @hidden */
  109090. _releaseTexture(texture: InternalTexture): void;
  109091. 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;
  109092. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109093. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109094. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109095. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109096. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109097. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109098. areAllEffectsReady(): boolean;
  109099. /**
  109100. * @hidden
  109101. * Get the current error code of the webGL context
  109102. * @returns the error code
  109103. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109104. */
  109105. getError(): number;
  109106. /** @hidden */
  109107. _getUnpackAlignement(): number;
  109108. /** @hidden */
  109109. _unpackFlipY(value: boolean): void;
  109110. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109111. /**
  109112. * Updates a dynamic vertex buffer.
  109113. * @param vertexBuffer the vertex buffer to update
  109114. * @param data the data used to update the vertex buffer
  109115. * @param byteOffset the byte offset of the data (optional)
  109116. * @param byteLength the byte length of the data (optional)
  109117. */
  109118. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109119. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109120. /** @hidden */
  109121. _bindTexture(channel: number, texture: InternalTexture): void;
  109122. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109123. releaseEffects(): void;
  109124. displayLoadingUI(): void;
  109125. hideLoadingUI(): void;
  109126. /** @hidden */
  109127. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109128. /** @hidden */
  109129. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109130. /** @hidden */
  109131. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109132. /** @hidden */
  109133. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109134. }
  109135. }
  109136. declare module BABYLON {
  109137. /** @hidden */
  109138. export class _OcclusionDataStorage {
  109139. /** @hidden */
  109140. occlusionInternalRetryCounter: number;
  109141. /** @hidden */
  109142. isOcclusionQueryInProgress: boolean;
  109143. /** @hidden */
  109144. isOccluded: boolean;
  109145. /** @hidden */
  109146. occlusionRetryCount: number;
  109147. /** @hidden */
  109148. occlusionType: number;
  109149. /** @hidden */
  109150. occlusionQueryAlgorithmType: number;
  109151. }
  109152. interface Engine {
  109153. /**
  109154. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109155. * @return the new query
  109156. */
  109157. createQuery(): WebGLQuery;
  109158. /**
  109159. * Delete and release a webGL query
  109160. * @param query defines the query to delete
  109161. * @return the current engine
  109162. */
  109163. deleteQuery(query: WebGLQuery): Engine;
  109164. /**
  109165. * Check if a given query has resolved and got its value
  109166. * @param query defines the query to check
  109167. * @returns true if the query got its value
  109168. */
  109169. isQueryResultAvailable(query: WebGLQuery): boolean;
  109170. /**
  109171. * Gets the value of a given query
  109172. * @param query defines the query to check
  109173. * @returns the value of the query
  109174. */
  109175. getQueryResult(query: WebGLQuery): number;
  109176. /**
  109177. * Initiates an occlusion query
  109178. * @param algorithmType defines the algorithm to use
  109179. * @param query defines the query to use
  109180. * @returns the current engine
  109181. * @see http://doc.babylonjs.com/features/occlusionquery
  109182. */
  109183. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109184. /**
  109185. * Ends an occlusion query
  109186. * @see http://doc.babylonjs.com/features/occlusionquery
  109187. * @param algorithmType defines the algorithm to use
  109188. * @returns the current engine
  109189. */
  109190. endOcclusionQuery(algorithmType: number): Engine;
  109191. /**
  109192. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109193. * Please note that only one query can be issued at a time
  109194. * @returns a time token used to track the time span
  109195. */
  109196. startTimeQuery(): Nullable<_TimeToken>;
  109197. /**
  109198. * Ends a time query
  109199. * @param token defines the token used to measure the time span
  109200. * @returns the time spent (in ns)
  109201. */
  109202. endTimeQuery(token: _TimeToken): int;
  109203. /** @hidden */
  109204. _currentNonTimestampToken: Nullable<_TimeToken>;
  109205. /** @hidden */
  109206. _createTimeQuery(): WebGLQuery;
  109207. /** @hidden */
  109208. _deleteTimeQuery(query: WebGLQuery): void;
  109209. /** @hidden */
  109210. _getGlAlgorithmType(algorithmType: number): number;
  109211. /** @hidden */
  109212. _getTimeQueryResult(query: WebGLQuery): any;
  109213. /** @hidden */
  109214. _getTimeQueryAvailability(query: WebGLQuery): any;
  109215. }
  109216. interface AbstractMesh {
  109217. /**
  109218. * Backing filed
  109219. * @hidden
  109220. */
  109221. __occlusionDataStorage: _OcclusionDataStorage;
  109222. /**
  109223. * Access property
  109224. * @hidden
  109225. */
  109226. _occlusionDataStorage: _OcclusionDataStorage;
  109227. /**
  109228. * 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.
  109229. * The default value is -1 which means don't break the query and wait till the result
  109230. * @see http://doc.babylonjs.com/features/occlusionquery
  109231. */
  109232. occlusionRetryCount: number;
  109233. /**
  109234. * 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:
  109235. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109236. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109237. * * 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.
  109238. * @see http://doc.babylonjs.com/features/occlusionquery
  109239. */
  109240. occlusionType: number;
  109241. /**
  109242. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109243. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109244. * * 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.
  109245. * @see http://doc.babylonjs.com/features/occlusionquery
  109246. */
  109247. occlusionQueryAlgorithmType: number;
  109248. /**
  109249. * 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
  109250. * @see http://doc.babylonjs.com/features/occlusionquery
  109251. */
  109252. isOccluded: boolean;
  109253. /**
  109254. * Flag to check the progress status of the query
  109255. * @see http://doc.babylonjs.com/features/occlusionquery
  109256. */
  109257. isOcclusionQueryInProgress: boolean;
  109258. }
  109259. }
  109260. declare module BABYLON {
  109261. /** @hidden */
  109262. export var _forceTransformFeedbackToBundle: boolean;
  109263. interface Engine {
  109264. /**
  109265. * Creates a webGL transform feedback object
  109266. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109267. * @returns the webGL transform feedback object
  109268. */
  109269. createTransformFeedback(): WebGLTransformFeedback;
  109270. /**
  109271. * Delete a webGL transform feedback object
  109272. * @param value defines the webGL transform feedback object to delete
  109273. */
  109274. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109275. /**
  109276. * Bind a webGL transform feedback object to the webgl context
  109277. * @param value defines the webGL transform feedback object to bind
  109278. */
  109279. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109280. /**
  109281. * Begins a transform feedback operation
  109282. * @param usePoints defines if points or triangles must be used
  109283. */
  109284. beginTransformFeedback(usePoints: boolean): void;
  109285. /**
  109286. * Ends a transform feedback operation
  109287. */
  109288. endTransformFeedback(): void;
  109289. /**
  109290. * Specify the varyings to use with transform feedback
  109291. * @param program defines the associated webGL program
  109292. * @param value defines the list of strings representing the varying names
  109293. */
  109294. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109295. /**
  109296. * Bind a webGL buffer for a transform feedback operation
  109297. * @param value defines the webGL buffer to bind
  109298. */
  109299. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109300. }
  109301. }
  109302. declare module BABYLON {
  109303. /**
  109304. * Creation options of the multi render target texture.
  109305. */
  109306. export interface IMultiRenderTargetOptions {
  109307. /**
  109308. * Define if the texture needs to create mip maps after render.
  109309. */
  109310. generateMipMaps?: boolean;
  109311. /**
  109312. * Define the types of all the draw buffers we want to create
  109313. */
  109314. types?: number[];
  109315. /**
  109316. * Define the sampling modes of all the draw buffers we want to create
  109317. */
  109318. samplingModes?: number[];
  109319. /**
  109320. * Define if a depth buffer is required
  109321. */
  109322. generateDepthBuffer?: boolean;
  109323. /**
  109324. * Define if a stencil buffer is required
  109325. */
  109326. generateStencilBuffer?: boolean;
  109327. /**
  109328. * Define if a depth texture is required instead of a depth buffer
  109329. */
  109330. generateDepthTexture?: boolean;
  109331. /**
  109332. * Define the number of desired draw buffers
  109333. */
  109334. textureCount?: number;
  109335. /**
  109336. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109337. */
  109338. doNotChangeAspectRatio?: boolean;
  109339. /**
  109340. * Define the default type of the buffers we are creating
  109341. */
  109342. defaultType?: number;
  109343. }
  109344. /**
  109345. * A multi render target, like a render target provides the ability to render to a texture.
  109346. * Unlike the render target, it can render to several draw buffers in one draw.
  109347. * This is specially interesting in deferred rendering or for any effects requiring more than
  109348. * just one color from a single pass.
  109349. */
  109350. export class MultiRenderTarget extends RenderTargetTexture {
  109351. private _internalTextures;
  109352. private _textures;
  109353. private _multiRenderTargetOptions;
  109354. /**
  109355. * Get if draw buffers are currently supported by the used hardware and browser.
  109356. */
  109357. readonly isSupported: boolean;
  109358. /**
  109359. * Get the list of textures generated by the multi render target.
  109360. */
  109361. readonly textures: Texture[];
  109362. /**
  109363. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109364. */
  109365. readonly depthTexture: Texture;
  109366. /**
  109367. * Set the wrapping mode on U of all the textures we are rendering to.
  109368. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109369. */
  109370. wrapU: number;
  109371. /**
  109372. * Set the wrapping mode on V of all the textures we are rendering to.
  109373. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109374. */
  109375. wrapV: number;
  109376. /**
  109377. * Instantiate a new multi render target texture.
  109378. * A multi render target, like a render target provides the ability to render to a texture.
  109379. * Unlike the render target, it can render to several draw buffers in one draw.
  109380. * This is specially interesting in deferred rendering or for any effects requiring more than
  109381. * just one color from a single pass.
  109382. * @param name Define the name of the texture
  109383. * @param size Define the size of the buffers to render to
  109384. * @param count Define the number of target we are rendering into
  109385. * @param scene Define the scene the texture belongs to
  109386. * @param options Define the options used to create the multi render target
  109387. */
  109388. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109389. /** @hidden */
  109390. _rebuild(): void;
  109391. private _createInternalTextures;
  109392. private _createTextures;
  109393. /**
  109394. * Define the number of samples used if MSAA is enabled.
  109395. */
  109396. samples: number;
  109397. /**
  109398. * Resize all the textures in the multi render target.
  109399. * Be carrefull as it will recreate all the data in the new texture.
  109400. * @param size Define the new size
  109401. */
  109402. resize(size: any): void;
  109403. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109404. /**
  109405. * Dispose the render targets and their associated resources
  109406. */
  109407. dispose(): void;
  109408. /**
  109409. * Release all the underlying texture used as draw buffers.
  109410. */
  109411. releaseInternalTextures(): void;
  109412. }
  109413. }
  109414. declare module BABYLON {
  109415. interface Engine {
  109416. /**
  109417. * Unbind a list of render target textures from the webGL context
  109418. * This is used only when drawBuffer extension or webGL2 are active
  109419. * @param textures defines the render target textures to unbind
  109420. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109421. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109422. */
  109423. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109424. /**
  109425. * Create a multi render target texture
  109426. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109427. * @param size defines the size of the texture
  109428. * @param options defines the creation options
  109429. * @returns the cube texture as an InternalTexture
  109430. */
  109431. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109432. /**
  109433. * Update the sample count for a given multiple render target texture
  109434. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109435. * @param textures defines the textures to update
  109436. * @param samples defines the sample count to set
  109437. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109438. */
  109439. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109440. }
  109441. }
  109442. declare module BABYLON {
  109443. /** @hidden */
  109444. export var rgbdEncodePixelShader: {
  109445. name: string;
  109446. shader: string;
  109447. };
  109448. }
  109449. declare module BABYLON {
  109450. /** @hidden */
  109451. export var rgbdDecodePixelShader: {
  109452. name: string;
  109453. shader: string;
  109454. };
  109455. }
  109456. declare module BABYLON {
  109457. /**
  109458. * Raw texture data and descriptor sufficient for WebGL texture upload
  109459. */
  109460. export interface EnvironmentTextureInfo {
  109461. /**
  109462. * Version of the environment map
  109463. */
  109464. version: number;
  109465. /**
  109466. * Width of image
  109467. */
  109468. width: number;
  109469. /**
  109470. * Irradiance information stored in the file.
  109471. */
  109472. irradiance: any;
  109473. /**
  109474. * Specular information stored in the file.
  109475. */
  109476. specular: any;
  109477. }
  109478. /**
  109479. * Defines One Image in the file. It requires only the position in the file
  109480. * as well as the length.
  109481. */
  109482. interface BufferImageData {
  109483. /**
  109484. * Length of the image data.
  109485. */
  109486. length: number;
  109487. /**
  109488. * Position of the data from the null terminator delimiting the end of the JSON.
  109489. */
  109490. position: number;
  109491. }
  109492. /**
  109493. * Defines the specular data enclosed in the file.
  109494. * This corresponds to the version 1 of the data.
  109495. */
  109496. export interface EnvironmentTextureSpecularInfoV1 {
  109497. /**
  109498. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109499. */
  109500. specularDataPosition?: number;
  109501. /**
  109502. * This contains all the images data needed to reconstruct the cubemap.
  109503. */
  109504. mipmaps: Array<BufferImageData>;
  109505. /**
  109506. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109507. */
  109508. lodGenerationScale: number;
  109509. }
  109510. /**
  109511. * Sets of helpers addressing the serialization and deserialization of environment texture
  109512. * stored in a BabylonJS env file.
  109513. * Those files are usually stored as .env files.
  109514. */
  109515. export class EnvironmentTextureTools {
  109516. /**
  109517. * Magic number identifying the env file.
  109518. */
  109519. private static _MagicBytes;
  109520. /**
  109521. * Gets the environment info from an env file.
  109522. * @param data The array buffer containing the .env bytes.
  109523. * @returns the environment file info (the json header) if successfully parsed.
  109524. */
  109525. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109526. /**
  109527. * Creates an environment texture from a loaded cube texture.
  109528. * @param texture defines the cube texture to convert in env file
  109529. * @return a promise containing the environment data if succesfull.
  109530. */
  109531. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109532. /**
  109533. * Creates a JSON representation of the spherical data.
  109534. * @param texture defines the texture containing the polynomials
  109535. * @return the JSON representation of the spherical info
  109536. */
  109537. private static _CreateEnvTextureIrradiance;
  109538. /**
  109539. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109540. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109541. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109542. * @return the views described by info providing access to the underlying buffer
  109543. */
  109544. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109545. /**
  109546. * Uploads the texture info contained in the env file to the GPU.
  109547. * @param texture defines the internal texture to upload to
  109548. * @param arrayBuffer defines the buffer cotaining the data to load
  109549. * @param info defines the texture info retrieved through the GetEnvInfo method
  109550. * @returns a promise
  109551. */
  109552. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109553. /**
  109554. * Uploads the levels of image data to the GPU.
  109555. * @param texture defines the internal texture to upload to
  109556. * @param imageData defines the array buffer views of image data [mipmap][face]
  109557. * @returns a promise
  109558. */
  109559. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109560. /**
  109561. * Uploads spherical polynomials information to the texture.
  109562. * @param texture defines the texture we are trying to upload the information to
  109563. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109564. */
  109565. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109566. /** @hidden */
  109567. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109568. }
  109569. }
  109570. declare module BABYLON {
  109571. /**
  109572. * Contains position and normal vectors for a vertex
  109573. */
  109574. export class PositionNormalVertex {
  109575. /** the position of the vertex (defaut: 0,0,0) */
  109576. position: Vector3;
  109577. /** the normal of the vertex (defaut: 0,1,0) */
  109578. normal: Vector3;
  109579. /**
  109580. * Creates a PositionNormalVertex
  109581. * @param position the position of the vertex (defaut: 0,0,0)
  109582. * @param normal the normal of the vertex (defaut: 0,1,0)
  109583. */
  109584. constructor(
  109585. /** the position of the vertex (defaut: 0,0,0) */
  109586. position?: Vector3,
  109587. /** the normal of the vertex (defaut: 0,1,0) */
  109588. normal?: Vector3);
  109589. /**
  109590. * Clones the PositionNormalVertex
  109591. * @returns the cloned PositionNormalVertex
  109592. */
  109593. clone(): PositionNormalVertex;
  109594. }
  109595. /**
  109596. * Contains position, normal and uv vectors for a vertex
  109597. */
  109598. export class PositionNormalTextureVertex {
  109599. /** the position of the vertex (defaut: 0,0,0) */
  109600. position: Vector3;
  109601. /** the normal of the vertex (defaut: 0,1,0) */
  109602. normal: Vector3;
  109603. /** the uv of the vertex (default: 0,0) */
  109604. uv: Vector2;
  109605. /**
  109606. * Creates a PositionNormalTextureVertex
  109607. * @param position the position of the vertex (defaut: 0,0,0)
  109608. * @param normal the normal of the vertex (defaut: 0,1,0)
  109609. * @param uv the uv of the vertex (default: 0,0)
  109610. */
  109611. constructor(
  109612. /** the position of the vertex (defaut: 0,0,0) */
  109613. position?: Vector3,
  109614. /** the normal of the vertex (defaut: 0,1,0) */
  109615. normal?: Vector3,
  109616. /** the uv of the vertex (default: 0,0) */
  109617. uv?: Vector2);
  109618. /**
  109619. * Clones the PositionNormalTextureVertex
  109620. * @returns the cloned PositionNormalTextureVertex
  109621. */
  109622. clone(): PositionNormalTextureVertex;
  109623. }
  109624. }
  109625. declare module BABYLON {
  109626. /** @hidden */
  109627. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109628. private _genericAttributeLocation;
  109629. private _varyingLocationCount;
  109630. private _varyingLocationMap;
  109631. private _replacements;
  109632. private _textureCount;
  109633. private _uniforms;
  109634. lineProcessor(line: string): string;
  109635. attributeProcessor(attribute: string): string;
  109636. varyingProcessor(varying: string, isFragment: boolean): string;
  109637. uniformProcessor(uniform: string): string;
  109638. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109639. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109640. }
  109641. }
  109642. declare module BABYLON {
  109643. /**
  109644. * Container for accessors for natively-stored mesh data buffers.
  109645. */
  109646. class NativeDataBuffer extends DataBuffer {
  109647. /**
  109648. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109649. */
  109650. nativeIndexBuffer?: any;
  109651. /**
  109652. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109653. */
  109654. nativeVertexBuffer?: any;
  109655. }
  109656. /** @hidden */
  109657. export class NativeEngine extends Engine {
  109658. private readonly _native;
  109659. getHardwareScalingLevel(): number;
  109660. constructor();
  109661. /**
  109662. * Can be used to override the current requestAnimationFrame requester.
  109663. * @hidden
  109664. */
  109665. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109666. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109667. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109668. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109669. recordVertexArrayObject(vertexBuffers: {
  109670. [key: string]: VertexBuffer;
  109671. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109672. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109673. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109674. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109675. /**
  109676. * Draw a list of indexed primitives
  109677. * @param fillMode defines the primitive to use
  109678. * @param indexStart defines the starting index
  109679. * @param indexCount defines the number of index to draw
  109680. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109681. */
  109682. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109683. /**
  109684. * Draw a list of unindexed primitives
  109685. * @param fillMode defines the primitive to use
  109686. * @param verticesStart defines the index of first vertex to draw
  109687. * @param verticesCount defines the count of vertices to draw
  109688. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109689. */
  109690. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109691. createPipelineContext(): IPipelineContext;
  109692. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109693. /** @hidden */
  109694. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109695. /** @hidden */
  109696. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109697. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109698. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109699. protected _setProgram(program: WebGLProgram): void;
  109700. _releaseEffect(effect: Effect): void;
  109701. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109702. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109703. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109704. bindSamplers(effect: Effect): void;
  109705. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109706. getRenderWidth(useScreen?: boolean): number;
  109707. getRenderHeight(useScreen?: boolean): number;
  109708. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109709. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109710. /**
  109711. * Set the z offset to apply to current rendering
  109712. * @param value defines the offset to apply
  109713. */
  109714. setZOffset(value: number): void;
  109715. /**
  109716. * Gets the current value of the zOffset
  109717. * @returns the current zOffset state
  109718. */
  109719. getZOffset(): number;
  109720. /**
  109721. * Enable or disable depth buffering
  109722. * @param enable defines the state to set
  109723. */
  109724. setDepthBuffer(enable: boolean): void;
  109725. /**
  109726. * Gets a boolean indicating if depth writing is enabled
  109727. * @returns the current depth writing state
  109728. */
  109729. getDepthWrite(): boolean;
  109730. /**
  109731. * Enable or disable depth writing
  109732. * @param enable defines the state to set
  109733. */
  109734. setDepthWrite(enable: boolean): void;
  109735. /**
  109736. * Enable or disable color writing
  109737. * @param enable defines the state to set
  109738. */
  109739. setColorWrite(enable: boolean): void;
  109740. /**
  109741. * Gets a boolean indicating if color writing is enabled
  109742. * @returns the current color writing state
  109743. */
  109744. getColorWrite(): boolean;
  109745. /**
  109746. * Sets alpha constants used by some alpha blending modes
  109747. * @param r defines the red component
  109748. * @param g defines the green component
  109749. * @param b defines the blue component
  109750. * @param a defines the alpha component
  109751. */
  109752. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109753. /**
  109754. * Sets the current alpha mode
  109755. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109756. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109757. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109758. */
  109759. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109760. /**
  109761. * Gets the current alpha mode
  109762. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109763. * @returns the current alpha mode
  109764. */
  109765. getAlphaMode(): number;
  109766. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109767. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109768. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109769. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109770. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109771. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109772. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109773. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109774. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109775. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109776. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109777. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109778. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109779. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109780. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109781. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109782. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109783. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109784. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109785. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109786. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  109787. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  109788. wipeCaches(bruteForce?: boolean): void;
  109789. _createTexture(): WebGLTexture;
  109790. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  109791. /**
  109792. * Usually called from BABYLON.Texture.ts.
  109793. * Passed information to create a WebGLTexture
  109794. * @param urlArg defines a value which contains one of the following:
  109795. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  109796. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  109797. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  109798. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  109799. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  109800. * @param scene needed for loading to the correct scene
  109801. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  109802. * @param onLoad optional callback to be called upon successful completion
  109803. * @param onError optional callback to be called upon failure
  109804. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  109805. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  109806. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  109807. * @param forcedExtension defines the extension to use to pick the right loader
  109808. * @returns a InternalTexture for assignment back into BABYLON.Texture
  109809. */
  109810. 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;
  109811. /**
  109812. * Creates a cube texture
  109813. * @param rootUrl defines the url where the files to load is located
  109814. * @param scene defines the current scene
  109815. * @param files defines the list of files to load (1 per face)
  109816. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  109817. * @param onLoad defines an optional callback raised when the texture is loaded
  109818. * @param onError defines an optional callback raised if there is an issue to load the texture
  109819. * @param format defines the format of the data
  109820. * @param forcedExtension defines the extension to use to pick the right loader
  109821. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  109822. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  109823. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  109824. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  109825. * @returns the cube texture as an InternalTexture
  109826. */
  109827. 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;
  109828. private _getSamplingFilter;
  109829. private static _GetNativeTextureFormat;
  109830. createRenderTargetTexture(size: number | {
  109831. width: number;
  109832. height: number;
  109833. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109834. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109835. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109836. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109837. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  109838. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  109839. /**
  109840. * Updates a dynamic vertex buffer.
  109841. * @param vertexBuffer the vertex buffer to update
  109842. * @param data the data used to update the vertex buffer
  109843. * @param byteOffset the byte offset of the data (optional)
  109844. * @param byteLength the byte length of the data (optional)
  109845. */
  109846. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  109847. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  109848. private _updateAnisotropicLevel;
  109849. private _getAddressMode;
  109850. /** @hidden */
  109851. _bindTexture(channel: number, texture: InternalTexture): void;
  109852. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  109853. releaseEffects(): void;
  109854. /** @hidden */
  109855. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109856. /** @hidden */
  109857. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109858. /** @hidden */
  109859. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109860. /** @hidden */
  109861. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109862. }
  109863. }
  109864. declare module BABYLON {
  109865. /**
  109866. * Gather the list of clipboard event types as constants.
  109867. */
  109868. export class ClipboardEventTypes {
  109869. /**
  109870. * The clipboard event is fired when a copy command is active (pressed).
  109871. */
  109872. static readonly COPY: number;
  109873. /**
  109874. * The clipboard event is fired when a cut command is active (pressed).
  109875. */
  109876. static readonly CUT: number;
  109877. /**
  109878. * The clipboard event is fired when a paste command is active (pressed).
  109879. */
  109880. static readonly PASTE: number;
  109881. }
  109882. /**
  109883. * This class is used to store clipboard related info for the onClipboardObservable event.
  109884. */
  109885. export class ClipboardInfo {
  109886. /**
  109887. * Defines the type of event (BABYLON.ClipboardEventTypes)
  109888. */
  109889. type: number;
  109890. /**
  109891. * Defines the related dom event
  109892. */
  109893. event: ClipboardEvent;
  109894. /**
  109895. *Creates an instance of ClipboardInfo.
  109896. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  109897. * @param event Defines the related dom event
  109898. */
  109899. constructor(
  109900. /**
  109901. * Defines the type of event (BABYLON.ClipboardEventTypes)
  109902. */
  109903. type: number,
  109904. /**
  109905. * Defines the related dom event
  109906. */
  109907. event: ClipboardEvent);
  109908. /**
  109909. * Get the clipboard event's type from the keycode.
  109910. * @param keyCode Defines the keyCode for the current keyboard event.
  109911. * @return {number}
  109912. */
  109913. static GetTypeFromCharacter(keyCode: number): number;
  109914. }
  109915. }
  109916. declare module BABYLON {
  109917. /**
  109918. * Google Daydream controller
  109919. */
  109920. export class DaydreamController extends WebVRController {
  109921. /**
  109922. * Base Url for the controller model.
  109923. */
  109924. static MODEL_BASE_URL: string;
  109925. /**
  109926. * File name for the controller model.
  109927. */
  109928. static MODEL_FILENAME: string;
  109929. /**
  109930. * Gamepad Id prefix used to identify Daydream Controller.
  109931. */
  109932. static readonly GAMEPAD_ID_PREFIX: string;
  109933. /**
  109934. * Creates a new DaydreamController from a gamepad
  109935. * @param vrGamepad the gamepad that the controller should be created from
  109936. */
  109937. constructor(vrGamepad: any);
  109938. /**
  109939. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109940. * @param scene scene in which to add meshes
  109941. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109942. */
  109943. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109944. /**
  109945. * Called once for each button that changed state since the last frame
  109946. * @param buttonIdx Which button index changed
  109947. * @param state New state of the button
  109948. * @param changes Which properties on the state changed since last frame
  109949. */
  109950. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109951. }
  109952. }
  109953. declare module BABYLON {
  109954. /**
  109955. * Gear VR Controller
  109956. */
  109957. export class GearVRController extends WebVRController {
  109958. /**
  109959. * Base Url for the controller model.
  109960. */
  109961. static MODEL_BASE_URL: string;
  109962. /**
  109963. * File name for the controller model.
  109964. */
  109965. static MODEL_FILENAME: string;
  109966. /**
  109967. * Gamepad Id prefix used to identify this controller.
  109968. */
  109969. static readonly GAMEPAD_ID_PREFIX: string;
  109970. private readonly _buttonIndexToObservableNameMap;
  109971. /**
  109972. * Creates a new GearVRController from a gamepad
  109973. * @param vrGamepad the gamepad that the controller should be created from
  109974. */
  109975. constructor(vrGamepad: any);
  109976. /**
  109977. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109978. * @param scene scene in which to add meshes
  109979. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109980. */
  109981. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109982. /**
  109983. * Called once for each button that changed state since the last frame
  109984. * @param buttonIdx Which button index changed
  109985. * @param state New state of the button
  109986. * @param changes Which properties on the state changed since last frame
  109987. */
  109988. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109989. }
  109990. }
  109991. declare module BABYLON {
  109992. /**
  109993. * Class containing static functions to help procedurally build meshes
  109994. */
  109995. export class PolyhedronBuilder {
  109996. /**
  109997. * Creates a polyhedron mesh
  109998. * * 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
  109999. * * The parameter `size` (positive float, default 1) sets the polygon size
  110000. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110001. * * 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`
  110002. * * 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
  110003. * * 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)`)
  110004. * * 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
  110005. * * 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
  110006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110007. * * 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
  110008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110009. * @param name defines the name of the mesh
  110010. * @param options defines the options used to create the mesh
  110011. * @param scene defines the hosting scene
  110012. * @returns the polyhedron mesh
  110013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110014. */
  110015. static CreatePolyhedron(name: string, options: {
  110016. type?: number;
  110017. size?: number;
  110018. sizeX?: number;
  110019. sizeY?: number;
  110020. sizeZ?: number;
  110021. custom?: any;
  110022. faceUV?: Vector4[];
  110023. faceColors?: Color4[];
  110024. flat?: boolean;
  110025. updatable?: boolean;
  110026. sideOrientation?: number;
  110027. frontUVs?: Vector4;
  110028. backUVs?: Vector4;
  110029. }, scene?: Nullable<Scene>): Mesh;
  110030. }
  110031. }
  110032. declare module BABYLON {
  110033. /**
  110034. * Gizmo that enables scaling a mesh along 3 axis
  110035. */
  110036. export class ScaleGizmo extends Gizmo {
  110037. /**
  110038. * Internal gizmo used for interactions on the x axis
  110039. */
  110040. xGizmo: AxisScaleGizmo;
  110041. /**
  110042. * Internal gizmo used for interactions on the y axis
  110043. */
  110044. yGizmo: AxisScaleGizmo;
  110045. /**
  110046. * Internal gizmo used for interactions on the z axis
  110047. */
  110048. zGizmo: AxisScaleGizmo;
  110049. /**
  110050. * Internal gizmo used to scale all axis equally
  110051. */
  110052. uniformScaleGizmo: AxisScaleGizmo;
  110053. private _meshAttached;
  110054. private _updateGizmoRotationToMatchAttachedMesh;
  110055. private _snapDistance;
  110056. private _scaleRatio;
  110057. private _uniformScalingMesh;
  110058. private _octahedron;
  110059. /** Fires an event when any of it's sub gizmos are dragged */
  110060. onDragStartObservable: Observable<unknown>;
  110061. /** Fires an event when any of it's sub gizmos are released from dragging */
  110062. onDragEndObservable: Observable<unknown>;
  110063. attachedMesh: Nullable<AbstractMesh>;
  110064. /**
  110065. * Creates a ScaleGizmo
  110066. * @param gizmoLayer The utility layer the gizmo will be added to
  110067. */
  110068. constructor(gizmoLayer?: UtilityLayerRenderer);
  110069. updateGizmoRotationToMatchAttachedMesh: boolean;
  110070. /**
  110071. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110072. */
  110073. snapDistance: number;
  110074. /**
  110075. * Ratio for the scale of the gizmo (Default: 1)
  110076. */
  110077. scaleRatio: number;
  110078. /**
  110079. * Disposes of the gizmo
  110080. */
  110081. dispose(): void;
  110082. }
  110083. }
  110084. declare module BABYLON {
  110085. /**
  110086. * Single axis scale gizmo
  110087. */
  110088. export class AxisScaleGizmo extends Gizmo {
  110089. /**
  110090. * Drag behavior responsible for the gizmos dragging interactions
  110091. */
  110092. dragBehavior: PointerDragBehavior;
  110093. private _pointerObserver;
  110094. /**
  110095. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110096. */
  110097. snapDistance: number;
  110098. /**
  110099. * Event that fires each time the gizmo snaps to a new location.
  110100. * * snapDistance is the the change in distance
  110101. */
  110102. onSnapObservable: Observable<{
  110103. snapDistance: number;
  110104. }>;
  110105. /**
  110106. * If the scaling operation should be done on all axis (default: false)
  110107. */
  110108. uniformScaling: boolean;
  110109. private _isEnabled;
  110110. private _parent;
  110111. private _arrow;
  110112. private _coloredMaterial;
  110113. private _hoverMaterial;
  110114. /**
  110115. * Creates an AxisScaleGizmo
  110116. * @param gizmoLayer The utility layer the gizmo will be added to
  110117. * @param dragAxis The axis which the gizmo will be able to scale on
  110118. * @param color The color of the gizmo
  110119. */
  110120. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110121. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110122. /**
  110123. * If the gizmo is enabled
  110124. */
  110125. isEnabled: boolean;
  110126. /**
  110127. * Disposes of the gizmo
  110128. */
  110129. dispose(): void;
  110130. /**
  110131. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110132. * @param mesh The mesh to replace the default mesh of the gizmo
  110133. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110134. */
  110135. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110136. }
  110137. }
  110138. declare module BABYLON {
  110139. /**
  110140. * Bounding box gizmo
  110141. */
  110142. export class BoundingBoxGizmo extends Gizmo {
  110143. private _lineBoundingBox;
  110144. private _rotateSpheresParent;
  110145. private _scaleBoxesParent;
  110146. private _boundingDimensions;
  110147. private _renderObserver;
  110148. private _pointerObserver;
  110149. private _scaleDragSpeed;
  110150. private _tmpQuaternion;
  110151. private _tmpVector;
  110152. private _tmpRotationMatrix;
  110153. /**
  110154. * 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)
  110155. */
  110156. ignoreChildren: boolean;
  110157. /**
  110158. * 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)
  110159. */
  110160. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110161. /**
  110162. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110163. */
  110164. rotationSphereSize: number;
  110165. /**
  110166. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110167. */
  110168. scaleBoxSize: number;
  110169. /**
  110170. * 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)
  110171. */
  110172. fixedDragMeshScreenSize: boolean;
  110173. /**
  110174. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110175. */
  110176. fixedDragMeshScreenSizeDistanceFactor: number;
  110177. /**
  110178. * Fired when a rotation sphere or scale box is dragged
  110179. */
  110180. onDragStartObservable: Observable<{}>;
  110181. /**
  110182. * Fired when a scale box is dragged
  110183. */
  110184. onScaleBoxDragObservable: Observable<{}>;
  110185. /**
  110186. * Fired when a scale box drag is ended
  110187. */
  110188. onScaleBoxDragEndObservable: Observable<{}>;
  110189. /**
  110190. * Fired when a rotation sphere is dragged
  110191. */
  110192. onRotationSphereDragObservable: Observable<{}>;
  110193. /**
  110194. * Fired when a rotation sphere drag is ended
  110195. */
  110196. onRotationSphereDragEndObservable: Observable<{}>;
  110197. /**
  110198. * 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)
  110199. */
  110200. scalePivot: Nullable<Vector3>;
  110201. /**
  110202. * Mesh used as a pivot to rotate the attached mesh
  110203. */
  110204. private _anchorMesh;
  110205. private _existingMeshScale;
  110206. private _dragMesh;
  110207. private pointerDragBehavior;
  110208. private coloredMaterial;
  110209. private hoverColoredMaterial;
  110210. /**
  110211. * Sets the color of the bounding box gizmo
  110212. * @param color the color to set
  110213. */
  110214. setColor(color: Color3): void;
  110215. /**
  110216. * Creates an BoundingBoxGizmo
  110217. * @param gizmoLayer The utility layer the gizmo will be added to
  110218. * @param color The color of the gizmo
  110219. */
  110220. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110221. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110222. private _selectNode;
  110223. /**
  110224. * Updates the bounding box information for the Gizmo
  110225. */
  110226. updateBoundingBox(): void;
  110227. private _updateRotationSpheres;
  110228. private _updateScaleBoxes;
  110229. /**
  110230. * Enables rotation on the specified axis and disables rotation on the others
  110231. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110232. */
  110233. setEnabledRotationAxis(axis: string): void;
  110234. /**
  110235. * Enables/disables scaling
  110236. * @param enable if scaling should be enabled
  110237. */
  110238. setEnabledScaling(enable: boolean): void;
  110239. private _updateDummy;
  110240. /**
  110241. * Enables a pointer drag behavior on the bounding box of the gizmo
  110242. */
  110243. enableDragBehavior(): void;
  110244. /**
  110245. * Disposes of the gizmo
  110246. */
  110247. dispose(): void;
  110248. /**
  110249. * 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)
  110250. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110251. * @returns the bounding box mesh with the passed in mesh as a child
  110252. */
  110253. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110254. /**
  110255. * CustomMeshes are not supported by this gizmo
  110256. * @param mesh The mesh to replace the default mesh of the gizmo
  110257. */
  110258. setCustomMesh(mesh: Mesh): void;
  110259. }
  110260. }
  110261. declare module BABYLON {
  110262. /**
  110263. * Single plane rotation gizmo
  110264. */
  110265. export class PlaneRotationGizmo extends Gizmo {
  110266. /**
  110267. * Drag behavior responsible for the gizmos dragging interactions
  110268. */
  110269. dragBehavior: PointerDragBehavior;
  110270. private _pointerObserver;
  110271. /**
  110272. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110273. */
  110274. snapDistance: number;
  110275. /**
  110276. * Event that fires each time the gizmo snaps to a new location.
  110277. * * snapDistance is the the change in distance
  110278. */
  110279. onSnapObservable: Observable<{
  110280. snapDistance: number;
  110281. }>;
  110282. private _isEnabled;
  110283. private _parent;
  110284. /**
  110285. * Creates a PlaneRotationGizmo
  110286. * @param gizmoLayer The utility layer the gizmo will be added to
  110287. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110288. * @param color The color of the gizmo
  110289. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110290. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110291. */
  110292. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110293. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110294. /**
  110295. * If the gizmo is enabled
  110296. */
  110297. isEnabled: boolean;
  110298. /**
  110299. * Disposes of the gizmo
  110300. */
  110301. dispose(): void;
  110302. }
  110303. }
  110304. declare module BABYLON {
  110305. /**
  110306. * Gizmo that enables rotating a mesh along 3 axis
  110307. */
  110308. export class RotationGizmo extends Gizmo {
  110309. /**
  110310. * Internal gizmo used for interactions on the x axis
  110311. */
  110312. xGizmo: PlaneRotationGizmo;
  110313. /**
  110314. * Internal gizmo used for interactions on the y axis
  110315. */
  110316. yGizmo: PlaneRotationGizmo;
  110317. /**
  110318. * Internal gizmo used for interactions on the z axis
  110319. */
  110320. zGizmo: PlaneRotationGizmo;
  110321. /** Fires an event when any of it's sub gizmos are dragged */
  110322. onDragStartObservable: Observable<unknown>;
  110323. /** Fires an event when any of it's sub gizmos are released from dragging */
  110324. onDragEndObservable: Observable<unknown>;
  110325. private _meshAttached;
  110326. attachedMesh: Nullable<AbstractMesh>;
  110327. /**
  110328. * Creates a RotationGizmo
  110329. * @param gizmoLayer The utility layer the gizmo will be added to
  110330. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110331. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110332. */
  110333. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110334. updateGizmoRotationToMatchAttachedMesh: boolean;
  110335. /**
  110336. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110337. */
  110338. snapDistance: number;
  110339. /**
  110340. * Ratio for the scale of the gizmo (Default: 1)
  110341. */
  110342. scaleRatio: number;
  110343. /**
  110344. * Disposes of the gizmo
  110345. */
  110346. dispose(): void;
  110347. /**
  110348. * CustomMeshes are not supported by this gizmo
  110349. * @param mesh The mesh to replace the default mesh of the gizmo
  110350. */
  110351. setCustomMesh(mesh: Mesh): void;
  110352. }
  110353. }
  110354. declare module BABYLON {
  110355. /**
  110356. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110357. */
  110358. export class GizmoManager implements IDisposable {
  110359. private scene;
  110360. /**
  110361. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110362. */
  110363. gizmos: {
  110364. positionGizmo: Nullable<PositionGizmo>;
  110365. rotationGizmo: Nullable<RotationGizmo>;
  110366. scaleGizmo: Nullable<ScaleGizmo>;
  110367. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110368. };
  110369. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110370. clearGizmoOnEmptyPointerEvent: boolean;
  110371. /** Fires an event when the manager is attached to a mesh */
  110372. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110373. private _gizmosEnabled;
  110374. private _pointerObserver;
  110375. private _attachedMesh;
  110376. private _boundingBoxColor;
  110377. private _defaultUtilityLayer;
  110378. private _defaultKeepDepthUtilityLayer;
  110379. /**
  110380. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110381. */
  110382. boundingBoxDragBehavior: SixDofDragBehavior;
  110383. /**
  110384. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110385. */
  110386. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110387. /**
  110388. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110389. */
  110390. usePointerToAttachGizmos: boolean;
  110391. /**
  110392. * Utility layer that the bounding box gizmo belongs to
  110393. */
  110394. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110395. /**
  110396. * Utility layer that all gizmos besides bounding box belong to
  110397. */
  110398. readonly utilityLayer: UtilityLayerRenderer;
  110399. /**
  110400. * Instatiates a gizmo manager
  110401. * @param scene the scene to overlay the gizmos on top of
  110402. */
  110403. constructor(scene: Scene);
  110404. /**
  110405. * Attaches a set of gizmos to the specified mesh
  110406. * @param mesh The mesh the gizmo's should be attached to
  110407. */
  110408. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110409. /**
  110410. * If the position gizmo is enabled
  110411. */
  110412. positionGizmoEnabled: boolean;
  110413. /**
  110414. * If the rotation gizmo is enabled
  110415. */
  110416. rotationGizmoEnabled: boolean;
  110417. /**
  110418. * If the scale gizmo is enabled
  110419. */
  110420. scaleGizmoEnabled: boolean;
  110421. /**
  110422. * If the boundingBox gizmo is enabled
  110423. */
  110424. boundingBoxGizmoEnabled: boolean;
  110425. /**
  110426. * Disposes of the gizmo manager
  110427. */
  110428. dispose(): void;
  110429. }
  110430. }
  110431. declare module BABYLON {
  110432. /**
  110433. * A directional light is defined by a direction (what a surprise!).
  110434. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110435. * 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.
  110436. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110437. */
  110438. export class DirectionalLight extends ShadowLight {
  110439. private _shadowFrustumSize;
  110440. /**
  110441. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110442. */
  110443. /**
  110444. * Specifies a fix frustum size for the shadow generation.
  110445. */
  110446. shadowFrustumSize: number;
  110447. private _shadowOrthoScale;
  110448. /**
  110449. * Gets the shadow projection scale against the optimal computed one.
  110450. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110451. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110452. */
  110453. /**
  110454. * Sets the shadow projection scale against the optimal computed one.
  110455. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110456. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110457. */
  110458. shadowOrthoScale: number;
  110459. /**
  110460. * Automatically compute the projection matrix to best fit (including all the casters)
  110461. * on each frame.
  110462. */
  110463. autoUpdateExtends: boolean;
  110464. private _orthoLeft;
  110465. private _orthoRight;
  110466. private _orthoTop;
  110467. private _orthoBottom;
  110468. /**
  110469. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110470. * The directional light is emitted from everywhere in the given direction.
  110471. * It can cast shadows.
  110472. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110473. * @param name The friendly name of the light
  110474. * @param direction The direction of the light
  110475. * @param scene The scene the light belongs to
  110476. */
  110477. constructor(name: string, direction: Vector3, scene: Scene);
  110478. /**
  110479. * Returns the string "DirectionalLight".
  110480. * @return The class name
  110481. */
  110482. getClassName(): string;
  110483. /**
  110484. * Returns the integer 1.
  110485. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110486. */
  110487. getTypeID(): number;
  110488. /**
  110489. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110490. * Returns the DirectionalLight Shadow projection matrix.
  110491. */
  110492. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110493. /**
  110494. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110495. * Returns the DirectionalLight Shadow projection matrix.
  110496. */
  110497. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110498. /**
  110499. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110500. * Returns the DirectionalLight Shadow projection matrix.
  110501. */
  110502. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110503. protected _buildUniformLayout(): void;
  110504. /**
  110505. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110506. * @param effect The effect to update
  110507. * @param lightIndex The index of the light in the effect to update
  110508. * @returns The directional light
  110509. */
  110510. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110511. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110512. /**
  110513. * Gets the minZ used for shadow according to both the scene and the light.
  110514. *
  110515. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110516. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110517. * @param activeCamera The camera we are returning the min for
  110518. * @returns the depth min z
  110519. */
  110520. getDepthMinZ(activeCamera: Camera): number;
  110521. /**
  110522. * Gets the maxZ used for shadow according to both the scene and the light.
  110523. *
  110524. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110525. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110526. * @param activeCamera The camera we are returning the max for
  110527. * @returns the depth max z
  110528. */
  110529. getDepthMaxZ(activeCamera: Camera): number;
  110530. /**
  110531. * Prepares the list of defines specific to the light type.
  110532. * @param defines the list of defines
  110533. * @param lightIndex defines the index of the light for the effect
  110534. */
  110535. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110536. }
  110537. }
  110538. declare module BABYLON {
  110539. /**
  110540. * Class containing static functions to help procedurally build meshes
  110541. */
  110542. export class HemisphereBuilder {
  110543. /**
  110544. * Creates a hemisphere mesh
  110545. * @param name defines the name of the mesh
  110546. * @param options defines the options used to create the mesh
  110547. * @param scene defines the hosting scene
  110548. * @returns the hemisphere mesh
  110549. */
  110550. static CreateHemisphere(name: string, options: {
  110551. segments?: number;
  110552. diameter?: number;
  110553. sideOrientation?: number;
  110554. }, scene: any): Mesh;
  110555. }
  110556. }
  110557. declare module BABYLON {
  110558. /**
  110559. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110560. * These values define a cone of light starting from the position, emitting toward the direction.
  110561. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110562. * and the exponent defines the speed of the decay of the light with distance (reach).
  110563. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110564. */
  110565. export class SpotLight extends ShadowLight {
  110566. private _angle;
  110567. private _innerAngle;
  110568. private _cosHalfAngle;
  110569. private _lightAngleScale;
  110570. private _lightAngleOffset;
  110571. /**
  110572. * Gets the cone angle of the spot light in Radians.
  110573. */
  110574. /**
  110575. * Sets the cone angle of the spot light in Radians.
  110576. */
  110577. angle: number;
  110578. /**
  110579. * Only used in gltf falloff mode, this defines the angle where
  110580. * the directional falloff will start before cutting at angle which could be seen
  110581. * as outer angle.
  110582. */
  110583. /**
  110584. * Only used in gltf falloff mode, this defines the angle where
  110585. * the directional falloff will start before cutting at angle which could be seen
  110586. * as outer angle.
  110587. */
  110588. innerAngle: number;
  110589. private _shadowAngleScale;
  110590. /**
  110591. * Allows scaling the angle of the light for shadow generation only.
  110592. */
  110593. /**
  110594. * Allows scaling the angle of the light for shadow generation only.
  110595. */
  110596. shadowAngleScale: number;
  110597. /**
  110598. * The light decay speed with the distance from the emission spot.
  110599. */
  110600. exponent: number;
  110601. private _projectionTextureMatrix;
  110602. /**
  110603. * Allows reading the projecton texture
  110604. */
  110605. readonly projectionTextureMatrix: Matrix;
  110606. protected _projectionTextureLightNear: number;
  110607. /**
  110608. * Gets the near clip of the Spotlight for texture projection.
  110609. */
  110610. /**
  110611. * Sets the near clip of the Spotlight for texture projection.
  110612. */
  110613. projectionTextureLightNear: number;
  110614. protected _projectionTextureLightFar: number;
  110615. /**
  110616. * Gets the far clip of the Spotlight for texture projection.
  110617. */
  110618. /**
  110619. * Sets the far clip of the Spotlight for texture projection.
  110620. */
  110621. projectionTextureLightFar: number;
  110622. protected _projectionTextureUpDirection: Vector3;
  110623. /**
  110624. * Gets the Up vector of the Spotlight for texture projection.
  110625. */
  110626. /**
  110627. * Sets the Up vector of the Spotlight for texture projection.
  110628. */
  110629. projectionTextureUpDirection: Vector3;
  110630. private _projectionTexture;
  110631. /**
  110632. * Gets the projection texture of the light.
  110633. */
  110634. /**
  110635. * Sets the projection texture of the light.
  110636. */
  110637. projectionTexture: Nullable<BaseTexture>;
  110638. private _projectionTextureViewLightDirty;
  110639. private _projectionTextureProjectionLightDirty;
  110640. private _projectionTextureDirty;
  110641. private _projectionTextureViewTargetVector;
  110642. private _projectionTextureViewLightMatrix;
  110643. private _projectionTextureProjectionLightMatrix;
  110644. private _projectionTextureScalingMatrix;
  110645. /**
  110646. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110647. * It can cast shadows.
  110648. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110649. * @param name The light friendly name
  110650. * @param position The position of the spot light in the scene
  110651. * @param direction The direction of the light in the scene
  110652. * @param angle The cone angle of the light in Radians
  110653. * @param exponent The light decay speed with the distance from the emission spot
  110654. * @param scene The scene the lights belongs to
  110655. */
  110656. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110657. /**
  110658. * Returns the string "SpotLight".
  110659. * @returns the class name
  110660. */
  110661. getClassName(): string;
  110662. /**
  110663. * Returns the integer 2.
  110664. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110665. */
  110666. getTypeID(): number;
  110667. /**
  110668. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110669. */
  110670. protected _setDirection(value: Vector3): void;
  110671. /**
  110672. * Overrides the position setter to recompute the projection texture view light Matrix.
  110673. */
  110674. protected _setPosition(value: Vector3): void;
  110675. /**
  110676. * 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.
  110677. * Returns the SpotLight.
  110678. */
  110679. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110680. protected _computeProjectionTextureViewLightMatrix(): void;
  110681. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110682. /**
  110683. * Main function for light texture projection matrix computing.
  110684. */
  110685. protected _computeProjectionTextureMatrix(): void;
  110686. protected _buildUniformLayout(): void;
  110687. private _computeAngleValues;
  110688. /**
  110689. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110690. * @param effect The effect to update
  110691. * @param lightIndex The index of the light in the effect to update
  110692. * @returns The spot light
  110693. */
  110694. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110695. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110696. /**
  110697. * Disposes the light and the associated resources.
  110698. */
  110699. dispose(): void;
  110700. /**
  110701. * Prepares the list of defines specific to the light type.
  110702. * @param defines the list of defines
  110703. * @param lightIndex defines the index of the light for the effect
  110704. */
  110705. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110706. }
  110707. }
  110708. declare module BABYLON {
  110709. /**
  110710. * Gizmo that enables viewing a light
  110711. */
  110712. export class LightGizmo extends Gizmo {
  110713. private _lightMesh;
  110714. private _material;
  110715. private cachedPosition;
  110716. private cachedForward;
  110717. /**
  110718. * Creates a LightGizmo
  110719. * @param gizmoLayer The utility layer the gizmo will be added to
  110720. */
  110721. constructor(gizmoLayer?: UtilityLayerRenderer);
  110722. private _light;
  110723. /**
  110724. * The light that the gizmo is attached to
  110725. */
  110726. light: Nullable<Light>;
  110727. /**
  110728. * Gets the material used to render the light gizmo
  110729. */
  110730. readonly material: StandardMaterial;
  110731. /**
  110732. * @hidden
  110733. * Updates the gizmo to match the attached mesh's position/rotation
  110734. */
  110735. protected _update(): void;
  110736. private static _Scale;
  110737. /**
  110738. * Creates the lines for a light mesh
  110739. */
  110740. private static _createLightLines;
  110741. /**
  110742. * Disposes of the light gizmo
  110743. */
  110744. dispose(): void;
  110745. private static _CreateHemisphericLightMesh;
  110746. private static _CreatePointLightMesh;
  110747. private static _CreateSpotLightMesh;
  110748. private static _CreateDirectionalLightMesh;
  110749. }
  110750. }
  110751. declare module BABYLON {
  110752. /** @hidden */
  110753. export var backgroundFragmentDeclaration: {
  110754. name: string;
  110755. shader: string;
  110756. };
  110757. }
  110758. declare module BABYLON {
  110759. /** @hidden */
  110760. export var backgroundUboDeclaration: {
  110761. name: string;
  110762. shader: string;
  110763. };
  110764. }
  110765. declare module BABYLON {
  110766. /** @hidden */
  110767. export var backgroundPixelShader: {
  110768. name: string;
  110769. shader: string;
  110770. };
  110771. }
  110772. declare module BABYLON {
  110773. /** @hidden */
  110774. export var backgroundVertexDeclaration: {
  110775. name: string;
  110776. shader: string;
  110777. };
  110778. }
  110779. declare module BABYLON {
  110780. /** @hidden */
  110781. export var backgroundVertexShader: {
  110782. name: string;
  110783. shader: string;
  110784. };
  110785. }
  110786. declare module BABYLON {
  110787. /**
  110788. * Background material used to create an efficient environement around your scene.
  110789. */
  110790. export class BackgroundMaterial extends PushMaterial {
  110791. /**
  110792. * Standard reflectance value at parallel view angle.
  110793. */
  110794. static StandardReflectance0: number;
  110795. /**
  110796. * Standard reflectance value at grazing angle.
  110797. */
  110798. static StandardReflectance90: number;
  110799. protected _primaryColor: Color3;
  110800. /**
  110801. * Key light Color (multiply against the environement texture)
  110802. */
  110803. primaryColor: Color3;
  110804. protected __perceptualColor: Nullable<Color3>;
  110805. /**
  110806. * Experimental Internal Use Only.
  110807. *
  110808. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  110809. * This acts as a helper to set the primary color to a more "human friendly" value.
  110810. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  110811. * output color as close as possible from the chosen value.
  110812. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  110813. * part of lighting setup.)
  110814. */
  110815. _perceptualColor: Nullable<Color3>;
  110816. protected _primaryColorShadowLevel: float;
  110817. /**
  110818. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  110819. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  110820. */
  110821. primaryColorShadowLevel: float;
  110822. protected _primaryColorHighlightLevel: float;
  110823. /**
  110824. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  110825. * The primary color is used at the level chosen to define what the white area would look.
  110826. */
  110827. primaryColorHighlightLevel: float;
  110828. protected _reflectionTexture: Nullable<BaseTexture>;
  110829. /**
  110830. * Reflection Texture used in the material.
  110831. * Should be author in a specific way for the best result (refer to the documentation).
  110832. */
  110833. reflectionTexture: Nullable<BaseTexture>;
  110834. protected _reflectionBlur: float;
  110835. /**
  110836. * Reflection Texture level of blur.
  110837. *
  110838. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  110839. * texture twice.
  110840. */
  110841. reflectionBlur: float;
  110842. protected _diffuseTexture: Nullable<BaseTexture>;
  110843. /**
  110844. * Diffuse Texture used in the material.
  110845. * Should be author in a specific way for the best result (refer to the documentation).
  110846. */
  110847. diffuseTexture: Nullable<BaseTexture>;
  110848. protected _shadowLights: Nullable<IShadowLight[]>;
  110849. /**
  110850. * Specify the list of lights casting shadow on the material.
  110851. * All scene shadow lights will be included if null.
  110852. */
  110853. shadowLights: Nullable<IShadowLight[]>;
  110854. protected _shadowLevel: float;
  110855. /**
  110856. * Helps adjusting the shadow to a softer level if required.
  110857. * 0 means black shadows and 1 means no shadows.
  110858. */
  110859. shadowLevel: float;
  110860. protected _sceneCenter: Vector3;
  110861. /**
  110862. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  110863. * It is usually zero but might be interesting to modify according to your setup.
  110864. */
  110865. sceneCenter: Vector3;
  110866. protected _opacityFresnel: boolean;
  110867. /**
  110868. * This helps specifying that the material is falling off to the sky box at grazing angle.
  110869. * This helps ensuring a nice transition when the camera goes under the ground.
  110870. */
  110871. opacityFresnel: boolean;
  110872. protected _reflectionFresnel: boolean;
  110873. /**
  110874. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  110875. * This helps adding a mirror texture on the ground.
  110876. */
  110877. reflectionFresnel: boolean;
  110878. protected _reflectionFalloffDistance: number;
  110879. /**
  110880. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  110881. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  110882. */
  110883. reflectionFalloffDistance: number;
  110884. protected _reflectionAmount: number;
  110885. /**
  110886. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  110887. */
  110888. reflectionAmount: number;
  110889. protected _reflectionReflectance0: number;
  110890. /**
  110891. * This specifies the weight of the reflection at grazing angle.
  110892. */
  110893. reflectionReflectance0: number;
  110894. protected _reflectionReflectance90: number;
  110895. /**
  110896. * This specifies the weight of the reflection at a perpendicular point of view.
  110897. */
  110898. reflectionReflectance90: number;
  110899. /**
  110900. * Sets the reflection reflectance fresnel values according to the default standard
  110901. * empirically know to work well :-)
  110902. */
  110903. reflectionStandardFresnelWeight: number;
  110904. protected _useRGBColor: boolean;
  110905. /**
  110906. * Helps to directly use the maps channels instead of their level.
  110907. */
  110908. useRGBColor: boolean;
  110909. protected _enableNoise: boolean;
  110910. /**
  110911. * This helps reducing the banding effect that could occur on the background.
  110912. */
  110913. enableNoise: boolean;
  110914. /**
  110915. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  110916. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  110917. * Recommended to be keep at 1.0 except for special cases.
  110918. */
  110919. fovMultiplier: number;
  110920. private _fovMultiplier;
  110921. /**
  110922. * Enable the FOV adjustment feature controlled by fovMultiplier.
  110923. */
  110924. useEquirectangularFOV: boolean;
  110925. private _maxSimultaneousLights;
  110926. /**
  110927. * Number of Simultaneous lights allowed on the material.
  110928. */
  110929. maxSimultaneousLights: int;
  110930. /**
  110931. * Default configuration related to image processing available in the Background Material.
  110932. */
  110933. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110934. /**
  110935. * Keep track of the image processing observer to allow dispose and replace.
  110936. */
  110937. private _imageProcessingObserver;
  110938. /**
  110939. * Attaches a new image processing configuration to the PBR Material.
  110940. * @param configuration (if null the scene configuration will be use)
  110941. */
  110942. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110943. /**
  110944. * Gets the image processing configuration used either in this material.
  110945. */
  110946. /**
  110947. * Sets the Default image processing configuration used either in the this material.
  110948. *
  110949. * If sets to null, the scene one is in use.
  110950. */
  110951. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  110952. /**
  110953. * Gets wether the color curves effect is enabled.
  110954. */
  110955. /**
  110956. * Sets wether the color curves effect is enabled.
  110957. */
  110958. cameraColorCurvesEnabled: boolean;
  110959. /**
  110960. * Gets wether the color grading effect is enabled.
  110961. */
  110962. /**
  110963. * Gets wether the color grading effect is enabled.
  110964. */
  110965. cameraColorGradingEnabled: boolean;
  110966. /**
  110967. * Gets wether tonemapping is enabled or not.
  110968. */
  110969. /**
  110970. * Sets wether tonemapping is enabled or not
  110971. */
  110972. cameraToneMappingEnabled: boolean;
  110973. /**
  110974. * The camera exposure used on this material.
  110975. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110976. * This corresponds to a photographic exposure.
  110977. */
  110978. /**
  110979. * The camera exposure used on this material.
  110980. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110981. * This corresponds to a photographic exposure.
  110982. */
  110983. cameraExposure: float;
  110984. /**
  110985. * Gets The camera contrast used on this material.
  110986. */
  110987. /**
  110988. * Sets The camera contrast used on this material.
  110989. */
  110990. cameraContrast: float;
  110991. /**
  110992. * Gets the Color Grading 2D Lookup Texture.
  110993. */
  110994. /**
  110995. * Sets the Color Grading 2D Lookup Texture.
  110996. */
  110997. cameraColorGradingTexture: Nullable<BaseTexture>;
  110998. /**
  110999. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111000. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111001. * 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;
  111002. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111003. */
  111004. /**
  111005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111007. * 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;
  111008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111009. */
  111010. cameraColorCurves: Nullable<ColorCurves>;
  111011. /**
  111012. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111013. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111014. */
  111015. switchToBGR: boolean;
  111016. private _renderTargets;
  111017. private _reflectionControls;
  111018. private _white;
  111019. private _primaryShadowColor;
  111020. private _primaryHighlightColor;
  111021. /**
  111022. * Instantiates a Background Material in the given scene
  111023. * @param name The friendly name of the material
  111024. * @param scene The scene to add the material to
  111025. */
  111026. constructor(name: string, scene: Scene);
  111027. /**
  111028. * Gets a boolean indicating that current material needs to register RTT
  111029. */
  111030. readonly hasRenderTargetTextures: boolean;
  111031. /**
  111032. * The entire material has been created in order to prevent overdraw.
  111033. * @returns false
  111034. */
  111035. needAlphaTesting(): boolean;
  111036. /**
  111037. * The entire material has been created in order to prevent overdraw.
  111038. * @returns true if blending is enable
  111039. */
  111040. needAlphaBlending(): boolean;
  111041. /**
  111042. * Checks wether the material is ready to be rendered for a given mesh.
  111043. * @param mesh The mesh to render
  111044. * @param subMesh The submesh to check against
  111045. * @param useInstances Specify wether or not the material is used with instances
  111046. * @returns true if all the dependencies are ready (Textures, Effects...)
  111047. */
  111048. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111049. /**
  111050. * Compute the primary color according to the chosen perceptual color.
  111051. */
  111052. private _computePrimaryColorFromPerceptualColor;
  111053. /**
  111054. * Compute the highlights and shadow colors according to their chosen levels.
  111055. */
  111056. private _computePrimaryColors;
  111057. /**
  111058. * Build the uniform buffer used in the material.
  111059. */
  111060. buildUniformLayout(): void;
  111061. /**
  111062. * Unbind the material.
  111063. */
  111064. unbind(): void;
  111065. /**
  111066. * Bind only the world matrix to the material.
  111067. * @param world The world matrix to bind.
  111068. */
  111069. bindOnlyWorldMatrix(world: Matrix): void;
  111070. /**
  111071. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111072. * @param world The world matrix to bind.
  111073. * @param subMesh The submesh to bind for.
  111074. */
  111075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111076. /**
  111077. * Checks to see if a texture is used in the material.
  111078. * @param texture - Base texture to use.
  111079. * @returns - Boolean specifying if a texture is used in the material.
  111080. */
  111081. hasTexture(texture: BaseTexture): boolean;
  111082. /**
  111083. * Dispose the material.
  111084. * @param forceDisposeEffect Force disposal of the associated effect.
  111085. * @param forceDisposeTextures Force disposal of the associated textures.
  111086. */
  111087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111088. /**
  111089. * Clones the material.
  111090. * @param name The cloned name.
  111091. * @returns The cloned material.
  111092. */
  111093. clone(name: string): BackgroundMaterial;
  111094. /**
  111095. * Serializes the current material to its JSON representation.
  111096. * @returns The JSON representation.
  111097. */
  111098. serialize(): any;
  111099. /**
  111100. * Gets the class name of the material
  111101. * @returns "BackgroundMaterial"
  111102. */
  111103. getClassName(): string;
  111104. /**
  111105. * Parse a JSON input to create back a background material.
  111106. * @param source The JSON data to parse
  111107. * @param scene The scene to create the parsed material in
  111108. * @param rootUrl The root url of the assets the material depends upon
  111109. * @returns the instantiated BackgroundMaterial.
  111110. */
  111111. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111112. }
  111113. }
  111114. declare module BABYLON {
  111115. /**
  111116. * Represents the different options available during the creation of
  111117. * a Environment helper.
  111118. *
  111119. * This can control the default ground, skybox and image processing setup of your scene.
  111120. */
  111121. export interface IEnvironmentHelperOptions {
  111122. /**
  111123. * Specifies wether or not to create a ground.
  111124. * True by default.
  111125. */
  111126. createGround: boolean;
  111127. /**
  111128. * Specifies the ground size.
  111129. * 15 by default.
  111130. */
  111131. groundSize: number;
  111132. /**
  111133. * The texture used on the ground for the main color.
  111134. * Comes from the BabylonJS CDN by default.
  111135. *
  111136. * Remarks: Can be either a texture or a url.
  111137. */
  111138. groundTexture: string | BaseTexture;
  111139. /**
  111140. * The color mixed in the ground texture by default.
  111141. * BabylonJS clearColor by default.
  111142. */
  111143. groundColor: Color3;
  111144. /**
  111145. * Specifies the ground opacity.
  111146. * 1 by default.
  111147. */
  111148. groundOpacity: number;
  111149. /**
  111150. * Enables the ground to receive shadows.
  111151. * True by default.
  111152. */
  111153. enableGroundShadow: boolean;
  111154. /**
  111155. * Helps preventing the shadow to be fully black on the ground.
  111156. * 0.5 by default.
  111157. */
  111158. groundShadowLevel: number;
  111159. /**
  111160. * Creates a mirror texture attach to the ground.
  111161. * false by default.
  111162. */
  111163. enableGroundMirror: boolean;
  111164. /**
  111165. * Specifies the ground mirror size ratio.
  111166. * 0.3 by default as the default kernel is 64.
  111167. */
  111168. groundMirrorSizeRatio: number;
  111169. /**
  111170. * Specifies the ground mirror blur kernel size.
  111171. * 64 by default.
  111172. */
  111173. groundMirrorBlurKernel: number;
  111174. /**
  111175. * Specifies the ground mirror visibility amount.
  111176. * 1 by default
  111177. */
  111178. groundMirrorAmount: number;
  111179. /**
  111180. * Specifies the ground mirror reflectance weight.
  111181. * This uses the standard weight of the background material to setup the fresnel effect
  111182. * of the mirror.
  111183. * 1 by default.
  111184. */
  111185. groundMirrorFresnelWeight: number;
  111186. /**
  111187. * Specifies the ground mirror Falloff distance.
  111188. * This can helps reducing the size of the reflection.
  111189. * 0 by Default.
  111190. */
  111191. groundMirrorFallOffDistance: number;
  111192. /**
  111193. * Specifies the ground mirror texture type.
  111194. * Unsigned Int by Default.
  111195. */
  111196. groundMirrorTextureType: number;
  111197. /**
  111198. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111199. * the shown objects.
  111200. */
  111201. groundYBias: number;
  111202. /**
  111203. * Specifies wether or not to create a skybox.
  111204. * True by default.
  111205. */
  111206. createSkybox: boolean;
  111207. /**
  111208. * Specifies the skybox size.
  111209. * 20 by default.
  111210. */
  111211. skyboxSize: number;
  111212. /**
  111213. * The texture used on the skybox for the main color.
  111214. * Comes from the BabylonJS CDN by default.
  111215. *
  111216. * Remarks: Can be either a texture or a url.
  111217. */
  111218. skyboxTexture: string | BaseTexture;
  111219. /**
  111220. * The color mixed in the skybox texture by default.
  111221. * BabylonJS clearColor by default.
  111222. */
  111223. skyboxColor: Color3;
  111224. /**
  111225. * The background rotation around the Y axis of the scene.
  111226. * This helps aligning the key lights of your scene with the background.
  111227. * 0 by default.
  111228. */
  111229. backgroundYRotation: number;
  111230. /**
  111231. * Compute automatically the size of the elements to best fit with the scene.
  111232. */
  111233. sizeAuto: boolean;
  111234. /**
  111235. * Default position of the rootMesh if autoSize is not true.
  111236. */
  111237. rootPosition: Vector3;
  111238. /**
  111239. * Sets up the image processing in the scene.
  111240. * true by default.
  111241. */
  111242. setupImageProcessing: boolean;
  111243. /**
  111244. * The texture used as your environment texture in the scene.
  111245. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111246. *
  111247. * Remarks: Can be either a texture or a url.
  111248. */
  111249. environmentTexture: string | BaseTexture;
  111250. /**
  111251. * The value of the exposure to apply to the scene.
  111252. * 0.6 by default if setupImageProcessing is true.
  111253. */
  111254. cameraExposure: number;
  111255. /**
  111256. * The value of the contrast to apply to the scene.
  111257. * 1.6 by default if setupImageProcessing is true.
  111258. */
  111259. cameraContrast: number;
  111260. /**
  111261. * Specifies wether or not tonemapping should be enabled in the scene.
  111262. * true by default if setupImageProcessing is true.
  111263. */
  111264. toneMappingEnabled: boolean;
  111265. }
  111266. /**
  111267. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111268. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111269. * It also helps with the default setup of your imageProcessing configuration.
  111270. */
  111271. export class EnvironmentHelper {
  111272. /**
  111273. * Default ground texture URL.
  111274. */
  111275. private static _groundTextureCDNUrl;
  111276. /**
  111277. * Default skybox texture URL.
  111278. */
  111279. private static _skyboxTextureCDNUrl;
  111280. /**
  111281. * Default environment texture URL.
  111282. */
  111283. private static _environmentTextureCDNUrl;
  111284. /**
  111285. * Creates the default options for the helper.
  111286. */
  111287. private static _getDefaultOptions;
  111288. private _rootMesh;
  111289. /**
  111290. * Gets the root mesh created by the helper.
  111291. */
  111292. readonly rootMesh: Mesh;
  111293. private _skybox;
  111294. /**
  111295. * Gets the skybox created by the helper.
  111296. */
  111297. readonly skybox: Nullable<Mesh>;
  111298. private _skyboxTexture;
  111299. /**
  111300. * Gets the skybox texture created by the helper.
  111301. */
  111302. readonly skyboxTexture: Nullable<BaseTexture>;
  111303. private _skyboxMaterial;
  111304. /**
  111305. * Gets the skybox material created by the helper.
  111306. */
  111307. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111308. private _ground;
  111309. /**
  111310. * Gets the ground mesh created by the helper.
  111311. */
  111312. readonly ground: Nullable<Mesh>;
  111313. private _groundTexture;
  111314. /**
  111315. * Gets the ground texture created by the helper.
  111316. */
  111317. readonly groundTexture: Nullable<BaseTexture>;
  111318. private _groundMirror;
  111319. /**
  111320. * Gets the ground mirror created by the helper.
  111321. */
  111322. readonly groundMirror: Nullable<MirrorTexture>;
  111323. /**
  111324. * Gets the ground mirror render list to helps pushing the meshes
  111325. * you wish in the ground reflection.
  111326. */
  111327. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111328. private _groundMaterial;
  111329. /**
  111330. * Gets the ground material created by the helper.
  111331. */
  111332. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111333. /**
  111334. * Stores the creation options.
  111335. */
  111336. private readonly _scene;
  111337. private _options;
  111338. /**
  111339. * This observable will be notified with any error during the creation of the environment,
  111340. * mainly texture creation errors.
  111341. */
  111342. onErrorObservable: Observable<{
  111343. message?: string;
  111344. exception?: any;
  111345. }>;
  111346. /**
  111347. * constructor
  111348. * @param options Defines the options we want to customize the helper
  111349. * @param scene The scene to add the material to
  111350. */
  111351. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111352. /**
  111353. * Updates the background according to the new options
  111354. * @param options
  111355. */
  111356. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111357. /**
  111358. * Sets the primary color of all the available elements.
  111359. * @param color the main color to affect to the ground and the background
  111360. */
  111361. setMainColor(color: Color3): void;
  111362. /**
  111363. * Setup the image processing according to the specified options.
  111364. */
  111365. private _setupImageProcessing;
  111366. /**
  111367. * Setup the environment texture according to the specified options.
  111368. */
  111369. private _setupEnvironmentTexture;
  111370. /**
  111371. * Setup the background according to the specified options.
  111372. */
  111373. private _setupBackground;
  111374. /**
  111375. * Get the scene sizes according to the setup.
  111376. */
  111377. private _getSceneSize;
  111378. /**
  111379. * Setup the ground according to the specified options.
  111380. */
  111381. private _setupGround;
  111382. /**
  111383. * Setup the ground material according to the specified options.
  111384. */
  111385. private _setupGroundMaterial;
  111386. /**
  111387. * Setup the ground diffuse texture according to the specified options.
  111388. */
  111389. private _setupGroundDiffuseTexture;
  111390. /**
  111391. * Setup the ground mirror texture according to the specified options.
  111392. */
  111393. private _setupGroundMirrorTexture;
  111394. /**
  111395. * Setup the ground to receive the mirror texture.
  111396. */
  111397. private _setupMirrorInGroundMaterial;
  111398. /**
  111399. * Setup the skybox according to the specified options.
  111400. */
  111401. private _setupSkybox;
  111402. /**
  111403. * Setup the skybox material according to the specified options.
  111404. */
  111405. private _setupSkyboxMaterial;
  111406. /**
  111407. * Setup the skybox reflection texture according to the specified options.
  111408. */
  111409. private _setupSkyboxReflectionTexture;
  111410. private _errorHandler;
  111411. /**
  111412. * Dispose all the elements created by the Helper.
  111413. */
  111414. dispose(): void;
  111415. }
  111416. }
  111417. declare module BABYLON {
  111418. /**
  111419. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111420. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111421. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111422. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111423. */
  111424. export class PhotoDome extends TransformNode {
  111425. /**
  111426. * Define the image as a Monoscopic panoramic 360 image.
  111427. */
  111428. static readonly MODE_MONOSCOPIC: number;
  111429. /**
  111430. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111431. */
  111432. static readonly MODE_TOPBOTTOM: number;
  111433. /**
  111434. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111435. */
  111436. static readonly MODE_SIDEBYSIDE: number;
  111437. private _useDirectMapping;
  111438. /**
  111439. * The texture being displayed on the sphere
  111440. */
  111441. protected _photoTexture: Texture;
  111442. /**
  111443. * Gets or sets the texture being displayed on the sphere
  111444. */
  111445. photoTexture: Texture;
  111446. /**
  111447. * Observable raised when an error occured while loading the 360 image
  111448. */
  111449. onLoadErrorObservable: Observable<string>;
  111450. /**
  111451. * The skybox material
  111452. */
  111453. protected _material: BackgroundMaterial;
  111454. /**
  111455. * The surface used for the skybox
  111456. */
  111457. protected _mesh: Mesh;
  111458. /**
  111459. * Gets the mesh used for the skybox.
  111460. */
  111461. readonly mesh: Mesh;
  111462. /**
  111463. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111464. * Also see the options.resolution property.
  111465. */
  111466. fovMultiplier: number;
  111467. private _imageMode;
  111468. /**
  111469. * Gets or set the current video mode for the video. It can be:
  111470. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111471. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111472. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111473. */
  111474. imageMode: number;
  111475. /**
  111476. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111477. * @param name Element's name, child elements will append suffixes for their own names.
  111478. * @param urlsOfPhoto defines the url of the photo to display
  111479. * @param options defines an object containing optional or exposed sub element properties
  111480. * @param onError defines a callback called when an error occured while loading the texture
  111481. */
  111482. constructor(name: string, urlOfPhoto: string, options: {
  111483. resolution?: number;
  111484. size?: number;
  111485. useDirectMapping?: boolean;
  111486. faceForward?: boolean;
  111487. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111488. private _onBeforeCameraRenderObserver;
  111489. private _changeImageMode;
  111490. /**
  111491. * Releases resources associated with this node.
  111492. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111493. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111494. */
  111495. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111496. }
  111497. }
  111498. declare module BABYLON {
  111499. /**
  111500. * Class used to host RGBD texture specific utilities
  111501. */
  111502. export class RGBDTextureTools {
  111503. /**
  111504. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111505. * @param texture the texture to expand.
  111506. */
  111507. static ExpandRGBDTexture(texture: Texture): void;
  111508. }
  111509. }
  111510. declare module BABYLON {
  111511. /**
  111512. * Class used to host texture specific utilities
  111513. */
  111514. export class BRDFTextureTools {
  111515. /**
  111516. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111517. * @param scene defines the hosting scene
  111518. * @returns the environment BRDF texture
  111519. */
  111520. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111521. private static _environmentBRDFBase64Texture;
  111522. }
  111523. }
  111524. declare module BABYLON {
  111525. /**
  111526. * @hidden
  111527. */
  111528. export interface IMaterialClearCoatDefines {
  111529. CLEARCOAT: boolean;
  111530. CLEARCOAT_DEFAULTIOR: boolean;
  111531. CLEARCOAT_TEXTURE: boolean;
  111532. CLEARCOAT_TEXTUREDIRECTUV: number;
  111533. CLEARCOAT_BUMP: boolean;
  111534. CLEARCOAT_BUMPDIRECTUV: number;
  111535. CLEARCOAT_TINT: boolean;
  111536. CLEARCOAT_TINT_TEXTURE: boolean;
  111537. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111538. /** @hidden */
  111539. _areTexturesDirty: boolean;
  111540. }
  111541. /**
  111542. * Define the code related to the clear coat parameters of the pbr material.
  111543. */
  111544. export class PBRClearCoatConfiguration {
  111545. /**
  111546. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111547. * The default fits with a polyurethane material.
  111548. */
  111549. private static readonly _DefaultIndexOfRefraction;
  111550. private _isEnabled;
  111551. /**
  111552. * Defines if the clear coat is enabled in the material.
  111553. */
  111554. isEnabled: boolean;
  111555. /**
  111556. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111557. */
  111558. intensity: number;
  111559. /**
  111560. * Defines the clear coat layer roughness.
  111561. */
  111562. roughness: number;
  111563. private _indexOfRefraction;
  111564. /**
  111565. * Defines the index of refraction of the clear coat.
  111566. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111567. * The default fits with a polyurethane material.
  111568. * Changing the default value is more performance intensive.
  111569. */
  111570. indexOfRefraction: number;
  111571. private _texture;
  111572. /**
  111573. * Stores the clear coat values in a texture.
  111574. */
  111575. texture: Nullable<BaseTexture>;
  111576. private _bumpTexture;
  111577. /**
  111578. * Define the clear coat specific bump texture.
  111579. */
  111580. bumpTexture: Nullable<BaseTexture>;
  111581. private _isTintEnabled;
  111582. /**
  111583. * Defines if the clear coat tint is enabled in the material.
  111584. */
  111585. isTintEnabled: boolean;
  111586. /**
  111587. * Defines the clear coat tint of the material.
  111588. * This is only use if tint is enabled
  111589. */
  111590. tintColor: Color3;
  111591. /**
  111592. * Defines the distance at which the tint color should be found in the
  111593. * clear coat media.
  111594. * This is only use if tint is enabled
  111595. */
  111596. tintColorAtDistance: number;
  111597. /**
  111598. * Defines the clear coat layer thickness.
  111599. * This is only use if tint is enabled
  111600. */
  111601. tintThickness: number;
  111602. private _tintTexture;
  111603. /**
  111604. * Stores the clear tint values in a texture.
  111605. * rgb is tint
  111606. * a is a thickness factor
  111607. */
  111608. tintTexture: Nullable<BaseTexture>;
  111609. /** @hidden */
  111610. private _internalMarkAllSubMeshesAsTexturesDirty;
  111611. /** @hidden */
  111612. _markAllSubMeshesAsTexturesDirty(): void;
  111613. /**
  111614. * Instantiate a new istance of clear coat configuration.
  111615. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111616. */
  111617. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111618. /**
  111619. * Gets wehter the submesh is ready to be used or not.
  111620. * @param defines the list of "defines" to update.
  111621. * @param scene defines the scene the material belongs to.
  111622. * @param engine defines the engine the material belongs to.
  111623. * @param disableBumpMap defines wether the material disables bump or not.
  111624. * @returns - boolean indicating that the submesh is ready or not.
  111625. */
  111626. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111627. /**
  111628. * Checks to see if a texture is used in the material.
  111629. * @param defines the list of "defines" to update.
  111630. * @param scene defines the scene to the material belongs to.
  111631. */
  111632. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111633. /**
  111634. * Binds the material data.
  111635. * @param uniformBuffer defines the Uniform buffer to fill in.
  111636. * @param scene defines the scene the material belongs to.
  111637. * @param engine defines the engine the material belongs to.
  111638. * @param disableBumpMap defines wether the material disables bump or not.
  111639. * @param isFrozen defines wether the material is frozen or not.
  111640. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111641. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111642. */
  111643. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111644. /**
  111645. * Checks to see if a texture is used in the material.
  111646. * @param texture - Base texture to use.
  111647. * @returns - Boolean specifying if a texture is used in the material.
  111648. */
  111649. hasTexture(texture: BaseTexture): boolean;
  111650. /**
  111651. * Returns an array of the actively used textures.
  111652. * @param activeTextures Array of BaseTextures
  111653. */
  111654. getActiveTextures(activeTextures: BaseTexture[]): void;
  111655. /**
  111656. * Returns the animatable textures.
  111657. * @param animatables Array of animatable textures.
  111658. */
  111659. getAnimatables(animatables: IAnimatable[]): void;
  111660. /**
  111661. * Disposes the resources of the material.
  111662. * @param forceDisposeTextures - Forces the disposal of all textures.
  111663. */
  111664. dispose(forceDisposeTextures?: boolean): void;
  111665. /**
  111666. * Get the current class name of the texture useful for serialization or dynamic coding.
  111667. * @returns "PBRClearCoatConfiguration"
  111668. */
  111669. getClassName(): string;
  111670. /**
  111671. * Add fallbacks to the effect fallbacks list.
  111672. * @param defines defines the Base texture to use.
  111673. * @param fallbacks defines the current fallback list.
  111674. * @param currentRank defines the current fallback rank.
  111675. * @returns the new fallback rank.
  111676. */
  111677. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111678. /**
  111679. * Add the required uniforms to the current list.
  111680. * @param uniforms defines the current uniform list.
  111681. */
  111682. static AddUniforms(uniforms: string[]): void;
  111683. /**
  111684. * Add the required samplers to the current list.
  111685. * @param samplers defines the current sampler list.
  111686. */
  111687. static AddSamplers(samplers: string[]): void;
  111688. /**
  111689. * Add the required uniforms to the current buffer.
  111690. * @param uniformBuffer defines the current uniform buffer.
  111691. */
  111692. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111693. /**
  111694. * Makes a duplicate of the current configuration into another one.
  111695. * @param clearCoatConfiguration define the config where to copy the info
  111696. */
  111697. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111698. /**
  111699. * Serializes this clear coat configuration.
  111700. * @returns - An object with the serialized config.
  111701. */
  111702. serialize(): any;
  111703. /**
  111704. * Parses a anisotropy Configuration from a serialized object.
  111705. * @param source - Serialized object.
  111706. * @param scene Defines the scene we are parsing for
  111707. * @param rootUrl Defines the rootUrl to load from
  111708. */
  111709. parse(source: any, scene: Scene, rootUrl: string): void;
  111710. }
  111711. }
  111712. declare module BABYLON {
  111713. /**
  111714. * @hidden
  111715. */
  111716. export interface IMaterialAnisotropicDefines {
  111717. ANISOTROPIC: boolean;
  111718. ANISOTROPIC_TEXTURE: boolean;
  111719. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111720. MAINUV1: boolean;
  111721. _areTexturesDirty: boolean;
  111722. _needUVs: boolean;
  111723. }
  111724. /**
  111725. * Define the code related to the anisotropic parameters of the pbr material.
  111726. */
  111727. export class PBRAnisotropicConfiguration {
  111728. private _isEnabled;
  111729. /**
  111730. * Defines if the anisotropy is enabled in the material.
  111731. */
  111732. isEnabled: boolean;
  111733. /**
  111734. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111735. */
  111736. intensity: number;
  111737. /**
  111738. * Defines if the effect is along the tangents, bitangents or in between.
  111739. * By default, the effect is "strectching" the highlights along the tangents.
  111740. */
  111741. direction: Vector2;
  111742. private _texture;
  111743. /**
  111744. * Stores the anisotropy values in a texture.
  111745. * rg is direction (like normal from -1 to 1)
  111746. * b is a intensity
  111747. */
  111748. texture: Nullable<BaseTexture>;
  111749. /** @hidden */
  111750. private _internalMarkAllSubMeshesAsTexturesDirty;
  111751. /** @hidden */
  111752. _markAllSubMeshesAsTexturesDirty(): void;
  111753. /**
  111754. * Instantiate a new istance of anisotropy configuration.
  111755. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111756. */
  111757. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111758. /**
  111759. * Specifies that the submesh is ready to be used.
  111760. * @param defines the list of "defines" to update.
  111761. * @param scene defines the scene the material belongs to.
  111762. * @returns - boolean indicating that the submesh is ready or not.
  111763. */
  111764. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111765. /**
  111766. * Checks to see if a texture is used in the material.
  111767. * @param defines the list of "defines" to update.
  111768. * @param mesh the mesh we are preparing the defines for.
  111769. * @param scene defines the scene the material belongs to.
  111770. */
  111771. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111772. /**
  111773. * Binds the material data.
  111774. * @param uniformBuffer defines the Uniform buffer to fill in.
  111775. * @param scene defines the scene the material belongs to.
  111776. * @param isFrozen defines wether the material is frozen or not.
  111777. */
  111778. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111779. /**
  111780. * Checks to see if a texture is used in the material.
  111781. * @param texture - Base texture to use.
  111782. * @returns - Boolean specifying if a texture is used in the material.
  111783. */
  111784. hasTexture(texture: BaseTexture): boolean;
  111785. /**
  111786. * Returns an array of the actively used textures.
  111787. * @param activeTextures Array of BaseTextures
  111788. */
  111789. getActiveTextures(activeTextures: BaseTexture[]): void;
  111790. /**
  111791. * Returns the animatable textures.
  111792. * @param animatables Array of animatable textures.
  111793. */
  111794. getAnimatables(animatables: IAnimatable[]): void;
  111795. /**
  111796. * Disposes the resources of the material.
  111797. * @param forceDisposeTextures - Forces the disposal of all textures.
  111798. */
  111799. dispose(forceDisposeTextures?: boolean): void;
  111800. /**
  111801. * Get the current class name of the texture useful for serialization or dynamic coding.
  111802. * @returns "PBRAnisotropicConfiguration"
  111803. */
  111804. getClassName(): string;
  111805. /**
  111806. * Add fallbacks to the effect fallbacks list.
  111807. * @param defines defines the Base texture to use.
  111808. * @param fallbacks defines the current fallback list.
  111809. * @param currentRank defines the current fallback rank.
  111810. * @returns the new fallback rank.
  111811. */
  111812. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111813. /**
  111814. * Add the required uniforms to the current list.
  111815. * @param uniforms defines the current uniform list.
  111816. */
  111817. static AddUniforms(uniforms: string[]): void;
  111818. /**
  111819. * Add the required uniforms to the current buffer.
  111820. * @param uniformBuffer defines the current uniform buffer.
  111821. */
  111822. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111823. /**
  111824. * Add the required samplers to the current list.
  111825. * @param samplers defines the current sampler list.
  111826. */
  111827. static AddSamplers(samplers: string[]): void;
  111828. /**
  111829. * Makes a duplicate of the current configuration into another one.
  111830. * @param anisotropicConfiguration define the config where to copy the info
  111831. */
  111832. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  111833. /**
  111834. * Serializes this anisotropy configuration.
  111835. * @returns - An object with the serialized config.
  111836. */
  111837. serialize(): any;
  111838. /**
  111839. * Parses a anisotropy Configuration from a serialized object.
  111840. * @param source - Serialized object.
  111841. * @param scene Defines the scene we are parsing for
  111842. * @param rootUrl Defines the rootUrl to load from
  111843. */
  111844. parse(source: any, scene: Scene, rootUrl: string): void;
  111845. }
  111846. }
  111847. declare module BABYLON {
  111848. /**
  111849. * @hidden
  111850. */
  111851. export interface IMaterialBRDFDefines {
  111852. BRDF_V_HEIGHT_CORRELATED: boolean;
  111853. MS_BRDF_ENERGY_CONSERVATION: boolean;
  111854. SPHERICAL_HARMONICS: boolean;
  111855. /** @hidden */
  111856. _areMiscDirty: boolean;
  111857. }
  111858. /**
  111859. * Define the code related to the BRDF parameters of the pbr material.
  111860. */
  111861. export class PBRBRDFConfiguration {
  111862. /**
  111863. * Default value used for the energy conservation.
  111864. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  111865. */
  111866. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  111867. /**
  111868. * Default value used for the Smith Visibility Height Correlated mode.
  111869. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  111870. */
  111871. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  111872. /**
  111873. * Default value used for the IBL diffuse part.
  111874. * This can help switching back to the polynomials mode globally which is a tiny bit
  111875. * less GPU intensive at the drawback of a lower quality.
  111876. */
  111877. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  111878. private _useEnergyConservation;
  111879. /**
  111880. * Defines if the material uses energy conservation.
  111881. */
  111882. useEnergyConservation: boolean;
  111883. private _useSmithVisibilityHeightCorrelated;
  111884. /**
  111885. * LEGACY Mode set to false
  111886. * Defines if the material uses height smith correlated visibility term.
  111887. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  111888. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  111889. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  111890. * Not relying on height correlated will also disable energy conservation.
  111891. */
  111892. useSmithVisibilityHeightCorrelated: boolean;
  111893. private _useSphericalHarmonics;
  111894. /**
  111895. * LEGACY Mode set to false
  111896. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  111897. * diffuse part of the IBL.
  111898. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  111899. * to the ground truth.
  111900. */
  111901. useSphericalHarmonics: boolean;
  111902. /** @hidden */
  111903. private _internalMarkAllSubMeshesAsMiscDirty;
  111904. /** @hidden */
  111905. _markAllSubMeshesAsMiscDirty(): void;
  111906. /**
  111907. * Instantiate a new istance of clear coat configuration.
  111908. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  111909. */
  111910. constructor(markAllSubMeshesAsMiscDirty: () => void);
  111911. /**
  111912. * Checks to see if a texture is used in the material.
  111913. * @param defines the list of "defines" to update.
  111914. */
  111915. prepareDefines(defines: IMaterialBRDFDefines): void;
  111916. /**
  111917. * Get the current class name of the texture useful for serialization or dynamic coding.
  111918. * @returns "PBRClearCoatConfiguration"
  111919. */
  111920. getClassName(): string;
  111921. /**
  111922. * Makes a duplicate of the current configuration into another one.
  111923. * @param brdfConfiguration define the config where to copy the info
  111924. */
  111925. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  111926. /**
  111927. * Serializes this BRDF configuration.
  111928. * @returns - An object with the serialized config.
  111929. */
  111930. serialize(): any;
  111931. /**
  111932. * Parses a anisotropy Configuration from a serialized object.
  111933. * @param source - Serialized object.
  111934. * @param scene Defines the scene we are parsing for
  111935. * @param rootUrl Defines the rootUrl to load from
  111936. */
  111937. parse(source: any, scene: Scene, rootUrl: string): void;
  111938. }
  111939. }
  111940. declare module BABYLON {
  111941. /**
  111942. * @hidden
  111943. */
  111944. export interface IMaterialSheenDefines {
  111945. SHEEN: boolean;
  111946. SHEEN_TEXTURE: boolean;
  111947. SHEEN_TEXTUREDIRECTUV: number;
  111948. SHEEN_LINKWITHALBEDO: boolean;
  111949. /** @hidden */
  111950. _areTexturesDirty: boolean;
  111951. }
  111952. /**
  111953. * Define the code related to the Sheen parameters of the pbr material.
  111954. */
  111955. export class PBRSheenConfiguration {
  111956. private _isEnabled;
  111957. /**
  111958. * Defines if the material uses sheen.
  111959. */
  111960. isEnabled: boolean;
  111961. private _linkSheenWithAlbedo;
  111962. /**
  111963. * Defines if the sheen is linked to the sheen color.
  111964. */
  111965. linkSheenWithAlbedo: boolean;
  111966. /**
  111967. * Defines the sheen intensity.
  111968. */
  111969. intensity: number;
  111970. /**
  111971. * Defines the sheen color.
  111972. */
  111973. color: Color3;
  111974. private _texture;
  111975. /**
  111976. * Stores the sheen tint values in a texture.
  111977. * rgb is tint
  111978. * a is a intensity
  111979. */
  111980. texture: Nullable<BaseTexture>;
  111981. /** @hidden */
  111982. private _internalMarkAllSubMeshesAsTexturesDirty;
  111983. /** @hidden */
  111984. _markAllSubMeshesAsTexturesDirty(): void;
  111985. /**
  111986. * Instantiate a new istance of clear coat configuration.
  111987. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111988. */
  111989. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111990. /**
  111991. * Specifies that the submesh is ready to be used.
  111992. * @param defines the list of "defines" to update.
  111993. * @param scene defines the scene the material belongs to.
  111994. * @returns - boolean indicating that the submesh is ready or not.
  111995. */
  111996. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  111997. /**
  111998. * Checks to see if a texture is used in the material.
  111999. * @param defines the list of "defines" to update.
  112000. * @param scene defines the scene the material belongs to.
  112001. */
  112002. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112003. /**
  112004. * Binds the material data.
  112005. * @param uniformBuffer defines the Uniform buffer to fill in.
  112006. * @param scene defines the scene the material belongs to.
  112007. * @param isFrozen defines wether the material is frozen or not.
  112008. */
  112009. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112010. /**
  112011. * Checks to see if a texture is used in the material.
  112012. * @param texture - Base texture to use.
  112013. * @returns - Boolean specifying if a texture is used in the material.
  112014. */
  112015. hasTexture(texture: BaseTexture): boolean;
  112016. /**
  112017. * Returns an array of the actively used textures.
  112018. * @param activeTextures Array of BaseTextures
  112019. */
  112020. getActiveTextures(activeTextures: BaseTexture[]): void;
  112021. /**
  112022. * Returns the animatable textures.
  112023. * @param animatables Array of animatable textures.
  112024. */
  112025. getAnimatables(animatables: IAnimatable[]): void;
  112026. /**
  112027. * Disposes the resources of the material.
  112028. * @param forceDisposeTextures - Forces the disposal of all textures.
  112029. */
  112030. dispose(forceDisposeTextures?: boolean): void;
  112031. /**
  112032. * Get the current class name of the texture useful for serialization or dynamic coding.
  112033. * @returns "PBRSheenConfiguration"
  112034. */
  112035. getClassName(): string;
  112036. /**
  112037. * Add fallbacks to the effect fallbacks list.
  112038. * @param defines defines the Base texture to use.
  112039. * @param fallbacks defines the current fallback list.
  112040. * @param currentRank defines the current fallback rank.
  112041. * @returns the new fallback rank.
  112042. */
  112043. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112044. /**
  112045. * Add the required uniforms to the current list.
  112046. * @param uniforms defines the current uniform list.
  112047. */
  112048. static AddUniforms(uniforms: string[]): void;
  112049. /**
  112050. * Add the required uniforms to the current buffer.
  112051. * @param uniformBuffer defines the current uniform buffer.
  112052. */
  112053. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112054. /**
  112055. * Add the required samplers to the current list.
  112056. * @param samplers defines the current sampler list.
  112057. */
  112058. static AddSamplers(samplers: string[]): void;
  112059. /**
  112060. * Makes a duplicate of the current configuration into another one.
  112061. * @param sheenConfiguration define the config where to copy the info
  112062. */
  112063. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112064. /**
  112065. * Serializes this BRDF configuration.
  112066. * @returns - An object with the serialized config.
  112067. */
  112068. serialize(): any;
  112069. /**
  112070. * Parses a anisotropy Configuration from a serialized object.
  112071. * @param source - Serialized object.
  112072. * @param scene Defines the scene we are parsing for
  112073. * @param rootUrl Defines the rootUrl to load from
  112074. */
  112075. parse(source: any, scene: Scene, rootUrl: string): void;
  112076. }
  112077. }
  112078. declare module BABYLON {
  112079. /**
  112080. * @hidden
  112081. */
  112082. export interface IMaterialSubSurfaceDefines {
  112083. SUBSURFACE: boolean;
  112084. SS_REFRACTION: boolean;
  112085. SS_TRANSLUCENCY: boolean;
  112086. SS_SCATERRING: boolean;
  112087. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112088. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112089. SS_REFRACTIONMAP_3D: boolean;
  112090. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112091. SS_LODINREFRACTIONALPHA: boolean;
  112092. SS_GAMMAREFRACTION: boolean;
  112093. SS_RGBDREFRACTION: boolean;
  112094. SS_LINEARSPECULARREFRACTION: boolean;
  112095. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112096. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112097. /** @hidden */
  112098. _areTexturesDirty: boolean;
  112099. }
  112100. /**
  112101. * Define the code related to the sub surface parameters of the pbr material.
  112102. */
  112103. export class PBRSubSurfaceConfiguration {
  112104. private _isRefractionEnabled;
  112105. /**
  112106. * Defines if the refraction is enabled in the material.
  112107. */
  112108. isRefractionEnabled: boolean;
  112109. private _isTranslucencyEnabled;
  112110. /**
  112111. * Defines if the translucency is enabled in the material.
  112112. */
  112113. isTranslucencyEnabled: boolean;
  112114. private _isScatteringEnabled;
  112115. /**
  112116. * Defines the refraction intensity of the material.
  112117. * The refraction when enabled replaces the Diffuse part of the material.
  112118. * The intensity helps transitionning between diffuse and refraction.
  112119. */
  112120. refractionIntensity: number;
  112121. /**
  112122. * Defines the translucency intensity of the material.
  112123. * When translucency has been enabled, this defines how much of the "translucency"
  112124. * is addded to the diffuse part of the material.
  112125. */
  112126. translucencyIntensity: number;
  112127. /**
  112128. * Defines the scattering intensity of the material.
  112129. * When scattering has been enabled, this defines how much of the "scattered light"
  112130. * is addded to the diffuse part of the material.
  112131. */
  112132. scatteringIntensity: number;
  112133. private _thicknessTexture;
  112134. /**
  112135. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112136. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112137. * 0 would mean minimumThickness
  112138. * 1 would mean maximumThickness
  112139. * The other channels might be use as a mask to vary the different effects intensity.
  112140. */
  112141. thicknessTexture: Nullable<BaseTexture>;
  112142. private _refractionTexture;
  112143. /**
  112144. * Defines the texture to use for refraction.
  112145. */
  112146. refractionTexture: Nullable<BaseTexture>;
  112147. private _indexOfRefraction;
  112148. /**
  112149. * Defines the index of refraction used in the material.
  112150. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112151. */
  112152. indexOfRefraction: number;
  112153. private _invertRefractionY;
  112154. /**
  112155. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112156. */
  112157. invertRefractionY: boolean;
  112158. private _linkRefractionWithTransparency;
  112159. /**
  112160. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112161. * Materials half opaque for instance using refraction could benefit from this control.
  112162. */
  112163. linkRefractionWithTransparency: boolean;
  112164. /**
  112165. * Defines the minimum thickness stored in the thickness map.
  112166. * If no thickness map is defined, this value will be used to simulate thickness.
  112167. */
  112168. minimumThickness: number;
  112169. /**
  112170. * Defines the maximum thickness stored in the thickness map.
  112171. */
  112172. maximumThickness: number;
  112173. /**
  112174. * Defines the volume tint of the material.
  112175. * This is used for both translucency and scattering.
  112176. */
  112177. tintColor: Color3;
  112178. /**
  112179. * Defines the distance at which the tint color should be found in the media.
  112180. * This is used for refraction only.
  112181. */
  112182. tintColorAtDistance: number;
  112183. /**
  112184. * Defines how far each channel transmit through the media.
  112185. * It is defined as a color to simplify it selection.
  112186. */
  112187. diffusionDistance: Color3;
  112188. private _useMaskFromThicknessTexture;
  112189. /**
  112190. * Stores the intensity of the different subsurface effects in the thickness texture.
  112191. * * the green channel is the translucency intensity.
  112192. * * the blue channel is the scattering intensity.
  112193. * * the alpha channel is the refraction intensity.
  112194. */
  112195. useMaskFromThicknessTexture: boolean;
  112196. /** @hidden */
  112197. private _internalMarkAllSubMeshesAsTexturesDirty;
  112198. /** @hidden */
  112199. _markAllSubMeshesAsTexturesDirty(): void;
  112200. /**
  112201. * Instantiate a new istance of sub surface configuration.
  112202. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112203. */
  112204. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112205. /**
  112206. * Gets wehter the submesh is ready to be used or not.
  112207. * @param defines the list of "defines" to update.
  112208. * @param scene defines the scene the material belongs to.
  112209. * @returns - boolean indicating that the submesh is ready or not.
  112210. */
  112211. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112212. /**
  112213. * Checks to see if a texture is used in the material.
  112214. * @param defines the list of "defines" to update.
  112215. * @param scene defines the scene to the material belongs to.
  112216. */
  112217. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112218. /**
  112219. * Binds the material data.
  112220. * @param uniformBuffer defines the Uniform buffer to fill in.
  112221. * @param scene defines the scene the material belongs to.
  112222. * @param engine defines the engine the material belongs to.
  112223. * @param isFrozen defines wether the material is frozen or not.
  112224. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112225. */
  112226. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112227. /**
  112228. * Unbinds the material from the mesh.
  112229. * @param activeEffect defines the effect that should be unbound from.
  112230. * @returns true if unbound, otherwise false
  112231. */
  112232. unbind(activeEffect: Effect): boolean;
  112233. /**
  112234. * Returns the texture used for refraction or null if none is used.
  112235. * @param scene defines the scene the material belongs to.
  112236. * @returns - Refraction texture if present. If no refraction texture and refraction
  112237. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112238. */
  112239. private _getRefractionTexture;
  112240. /**
  112241. * Returns true if alpha blending should be disabled.
  112242. */
  112243. readonly disableAlphaBlending: boolean;
  112244. /**
  112245. * Fills the list of render target textures.
  112246. * @param renderTargets the list of render targets to update
  112247. */
  112248. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112249. /**
  112250. * Checks to see if a texture is used in the material.
  112251. * @param texture - Base texture to use.
  112252. * @returns - Boolean specifying if a texture is used in the material.
  112253. */
  112254. hasTexture(texture: BaseTexture): boolean;
  112255. /**
  112256. * Gets a boolean indicating that current material needs to register RTT
  112257. * @returns true if this uses a render target otherwise false.
  112258. */
  112259. hasRenderTargetTextures(): boolean;
  112260. /**
  112261. * Returns an array of the actively used textures.
  112262. * @param activeTextures Array of BaseTextures
  112263. */
  112264. getActiveTextures(activeTextures: BaseTexture[]): void;
  112265. /**
  112266. * Returns the animatable textures.
  112267. * @param animatables Array of animatable textures.
  112268. */
  112269. getAnimatables(animatables: IAnimatable[]): void;
  112270. /**
  112271. * Disposes the resources of the material.
  112272. * @param forceDisposeTextures - Forces the disposal of all textures.
  112273. */
  112274. dispose(forceDisposeTextures?: boolean): void;
  112275. /**
  112276. * Get the current class name of the texture useful for serialization or dynamic coding.
  112277. * @returns "PBRSubSurfaceConfiguration"
  112278. */
  112279. getClassName(): string;
  112280. /**
  112281. * Add fallbacks to the effect fallbacks list.
  112282. * @param defines defines the Base texture to use.
  112283. * @param fallbacks defines the current fallback list.
  112284. * @param currentRank defines the current fallback rank.
  112285. * @returns the new fallback rank.
  112286. */
  112287. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112288. /**
  112289. * Add the required uniforms to the current list.
  112290. * @param uniforms defines the current uniform list.
  112291. */
  112292. static AddUniforms(uniforms: string[]): void;
  112293. /**
  112294. * Add the required samplers to the current list.
  112295. * @param samplers defines the current sampler list.
  112296. */
  112297. static AddSamplers(samplers: string[]): void;
  112298. /**
  112299. * Add the required uniforms to the current buffer.
  112300. * @param uniformBuffer defines the current uniform buffer.
  112301. */
  112302. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112303. /**
  112304. * Makes a duplicate of the current configuration into another one.
  112305. * @param configuration define the config where to copy the info
  112306. */
  112307. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112308. /**
  112309. * Serializes this Sub Surface configuration.
  112310. * @returns - An object with the serialized config.
  112311. */
  112312. serialize(): any;
  112313. /**
  112314. * Parses a anisotropy Configuration from a serialized object.
  112315. * @param source - Serialized object.
  112316. * @param scene Defines the scene we are parsing for
  112317. * @param rootUrl Defines the rootUrl to load from
  112318. */
  112319. parse(source: any, scene: Scene, rootUrl: string): void;
  112320. }
  112321. }
  112322. declare module BABYLON {
  112323. /** @hidden */
  112324. export var pbrFragmentDeclaration: {
  112325. name: string;
  112326. shader: string;
  112327. };
  112328. }
  112329. declare module BABYLON {
  112330. /** @hidden */
  112331. export var pbrUboDeclaration: {
  112332. name: string;
  112333. shader: string;
  112334. };
  112335. }
  112336. declare module BABYLON {
  112337. /** @hidden */
  112338. export var pbrFragmentExtraDeclaration: {
  112339. name: string;
  112340. shader: string;
  112341. };
  112342. }
  112343. declare module BABYLON {
  112344. /** @hidden */
  112345. export var pbrFragmentSamplersDeclaration: {
  112346. name: string;
  112347. shader: string;
  112348. };
  112349. }
  112350. declare module BABYLON {
  112351. /** @hidden */
  112352. export var pbrHelperFunctions: {
  112353. name: string;
  112354. shader: string;
  112355. };
  112356. }
  112357. declare module BABYLON {
  112358. /** @hidden */
  112359. export var harmonicsFunctions: {
  112360. name: string;
  112361. shader: string;
  112362. };
  112363. }
  112364. declare module BABYLON {
  112365. /** @hidden */
  112366. export var pbrDirectLightingSetupFunctions: {
  112367. name: string;
  112368. shader: string;
  112369. };
  112370. }
  112371. declare module BABYLON {
  112372. /** @hidden */
  112373. export var pbrDirectLightingFalloffFunctions: {
  112374. name: string;
  112375. shader: string;
  112376. };
  112377. }
  112378. declare module BABYLON {
  112379. /** @hidden */
  112380. export var pbrBRDFFunctions: {
  112381. name: string;
  112382. shader: string;
  112383. };
  112384. }
  112385. declare module BABYLON {
  112386. /** @hidden */
  112387. export var pbrDirectLightingFunctions: {
  112388. name: string;
  112389. shader: string;
  112390. };
  112391. }
  112392. declare module BABYLON {
  112393. /** @hidden */
  112394. export var pbrIBLFunctions: {
  112395. name: string;
  112396. shader: string;
  112397. };
  112398. }
  112399. declare module BABYLON {
  112400. /** @hidden */
  112401. export var pbrDebug: {
  112402. name: string;
  112403. shader: string;
  112404. };
  112405. }
  112406. declare module BABYLON {
  112407. /** @hidden */
  112408. export var pbrPixelShader: {
  112409. name: string;
  112410. shader: string;
  112411. };
  112412. }
  112413. declare module BABYLON {
  112414. /** @hidden */
  112415. export var pbrVertexDeclaration: {
  112416. name: string;
  112417. shader: string;
  112418. };
  112419. }
  112420. declare module BABYLON {
  112421. /** @hidden */
  112422. export var pbrVertexShader: {
  112423. name: string;
  112424. shader: string;
  112425. };
  112426. }
  112427. declare module BABYLON {
  112428. /**
  112429. * Manages the defines for the PBR Material.
  112430. * @hidden
  112431. */
  112432. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112433. PBR: boolean;
  112434. MAINUV1: boolean;
  112435. MAINUV2: boolean;
  112436. UV1: boolean;
  112437. UV2: boolean;
  112438. ALBEDO: boolean;
  112439. ALBEDODIRECTUV: number;
  112440. VERTEXCOLOR: boolean;
  112441. AMBIENT: boolean;
  112442. AMBIENTDIRECTUV: number;
  112443. AMBIENTINGRAYSCALE: boolean;
  112444. OPACITY: boolean;
  112445. VERTEXALPHA: boolean;
  112446. OPACITYDIRECTUV: number;
  112447. OPACITYRGB: boolean;
  112448. ALPHATEST: boolean;
  112449. DEPTHPREPASS: boolean;
  112450. ALPHABLEND: boolean;
  112451. ALPHAFROMALBEDO: boolean;
  112452. ALPHATESTVALUE: string;
  112453. SPECULAROVERALPHA: boolean;
  112454. RADIANCEOVERALPHA: boolean;
  112455. ALPHAFRESNEL: boolean;
  112456. LINEARALPHAFRESNEL: boolean;
  112457. PREMULTIPLYALPHA: boolean;
  112458. EMISSIVE: boolean;
  112459. EMISSIVEDIRECTUV: number;
  112460. REFLECTIVITY: boolean;
  112461. REFLECTIVITYDIRECTUV: number;
  112462. SPECULARTERM: boolean;
  112463. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112464. MICROSURFACEAUTOMATIC: boolean;
  112465. LODBASEDMICROSFURACE: boolean;
  112466. MICROSURFACEMAP: boolean;
  112467. MICROSURFACEMAPDIRECTUV: number;
  112468. METALLICWORKFLOW: boolean;
  112469. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112470. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112471. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112472. AOSTOREINMETALMAPRED: boolean;
  112473. ENVIRONMENTBRDF: boolean;
  112474. ENVIRONMENTBRDF_RGBD: boolean;
  112475. NORMAL: boolean;
  112476. TANGENT: boolean;
  112477. BUMP: boolean;
  112478. BUMPDIRECTUV: number;
  112479. OBJECTSPACE_NORMALMAP: boolean;
  112480. PARALLAX: boolean;
  112481. PARALLAXOCCLUSION: boolean;
  112482. NORMALXYSCALE: boolean;
  112483. LIGHTMAP: boolean;
  112484. LIGHTMAPDIRECTUV: number;
  112485. USELIGHTMAPASSHADOWMAP: boolean;
  112486. GAMMALIGHTMAP: boolean;
  112487. RGBDLIGHTMAP: boolean;
  112488. REFLECTION: boolean;
  112489. REFLECTIONMAP_3D: boolean;
  112490. REFLECTIONMAP_SPHERICAL: boolean;
  112491. REFLECTIONMAP_PLANAR: boolean;
  112492. REFLECTIONMAP_CUBIC: boolean;
  112493. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112494. REFLECTIONMAP_PROJECTION: boolean;
  112495. REFLECTIONMAP_SKYBOX: boolean;
  112496. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112497. REFLECTIONMAP_EXPLICIT: boolean;
  112498. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112499. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112500. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112501. INVERTCUBICMAP: boolean;
  112502. USESPHERICALFROMREFLECTIONMAP: boolean;
  112503. USEIRRADIANCEMAP: boolean;
  112504. SPHERICAL_HARMONICS: boolean;
  112505. USESPHERICALINVERTEX: boolean;
  112506. REFLECTIONMAP_OPPOSITEZ: boolean;
  112507. LODINREFLECTIONALPHA: boolean;
  112508. GAMMAREFLECTION: boolean;
  112509. RGBDREFLECTION: boolean;
  112510. LINEARSPECULARREFLECTION: boolean;
  112511. RADIANCEOCCLUSION: boolean;
  112512. HORIZONOCCLUSION: boolean;
  112513. INSTANCES: boolean;
  112514. NUM_BONE_INFLUENCERS: number;
  112515. BonesPerMesh: number;
  112516. BONETEXTURE: boolean;
  112517. NONUNIFORMSCALING: boolean;
  112518. MORPHTARGETS: boolean;
  112519. MORPHTARGETS_NORMAL: boolean;
  112520. MORPHTARGETS_TANGENT: boolean;
  112521. MORPHTARGETS_UV: boolean;
  112522. NUM_MORPH_INFLUENCERS: number;
  112523. IMAGEPROCESSING: boolean;
  112524. VIGNETTE: boolean;
  112525. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112526. VIGNETTEBLENDMODEOPAQUE: boolean;
  112527. TONEMAPPING: boolean;
  112528. TONEMAPPING_ACES: boolean;
  112529. CONTRAST: boolean;
  112530. COLORCURVES: boolean;
  112531. COLORGRADING: boolean;
  112532. COLORGRADING3D: boolean;
  112533. SAMPLER3DGREENDEPTH: boolean;
  112534. SAMPLER3DBGRMAP: boolean;
  112535. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112536. EXPOSURE: boolean;
  112537. MULTIVIEW: boolean;
  112538. USEPHYSICALLIGHTFALLOFF: boolean;
  112539. USEGLTFLIGHTFALLOFF: boolean;
  112540. TWOSIDEDLIGHTING: boolean;
  112541. SHADOWFLOAT: boolean;
  112542. CLIPPLANE: boolean;
  112543. CLIPPLANE2: boolean;
  112544. CLIPPLANE3: boolean;
  112545. CLIPPLANE4: boolean;
  112546. POINTSIZE: boolean;
  112547. FOG: boolean;
  112548. LOGARITHMICDEPTH: boolean;
  112549. FORCENORMALFORWARD: boolean;
  112550. SPECULARAA: boolean;
  112551. CLEARCOAT: boolean;
  112552. CLEARCOAT_DEFAULTIOR: boolean;
  112553. CLEARCOAT_TEXTURE: boolean;
  112554. CLEARCOAT_TEXTUREDIRECTUV: number;
  112555. CLEARCOAT_BUMP: boolean;
  112556. CLEARCOAT_BUMPDIRECTUV: number;
  112557. CLEARCOAT_TINT: boolean;
  112558. CLEARCOAT_TINT_TEXTURE: boolean;
  112559. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112560. ANISOTROPIC: boolean;
  112561. ANISOTROPIC_TEXTURE: boolean;
  112562. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112563. BRDF_V_HEIGHT_CORRELATED: boolean;
  112564. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112565. SHEEN: boolean;
  112566. SHEEN_TEXTURE: boolean;
  112567. SHEEN_TEXTUREDIRECTUV: number;
  112568. SHEEN_LINKWITHALBEDO: boolean;
  112569. SUBSURFACE: boolean;
  112570. SS_REFRACTION: boolean;
  112571. SS_TRANSLUCENCY: boolean;
  112572. SS_SCATERRING: boolean;
  112573. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112574. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112575. SS_REFRACTIONMAP_3D: boolean;
  112576. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112577. SS_LODINREFRACTIONALPHA: boolean;
  112578. SS_GAMMAREFRACTION: boolean;
  112579. SS_RGBDREFRACTION: boolean;
  112580. SS_LINEARSPECULARREFRACTION: boolean;
  112581. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112582. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112583. UNLIT: boolean;
  112584. DEBUGMODE: number;
  112585. /**
  112586. * Initializes the PBR Material defines.
  112587. */
  112588. constructor();
  112589. /**
  112590. * Resets the PBR Material defines.
  112591. */
  112592. reset(): void;
  112593. }
  112594. /**
  112595. * The Physically based material base class of BJS.
  112596. *
  112597. * This offers the main features of a standard PBR material.
  112598. * For more information, please refer to the documentation :
  112599. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112600. */
  112601. export abstract class PBRBaseMaterial extends PushMaterial {
  112602. /**
  112603. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112604. */
  112605. static readonly PBRMATERIAL_OPAQUE: number;
  112606. /**
  112607. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112608. */
  112609. static readonly PBRMATERIAL_ALPHATEST: number;
  112610. /**
  112611. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112612. */
  112613. static readonly PBRMATERIAL_ALPHABLEND: number;
  112614. /**
  112615. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112616. * They are also discarded below the alpha cutoff threshold to improve performances.
  112617. */
  112618. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112619. /**
  112620. * Defines the default value of how much AO map is occluding the analytical lights
  112621. * (point spot...).
  112622. */
  112623. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112624. /**
  112625. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112626. */
  112627. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112628. /**
  112629. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112630. * to enhance interoperability with other engines.
  112631. */
  112632. static readonly LIGHTFALLOFF_GLTF: number;
  112633. /**
  112634. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112635. * to enhance interoperability with other materials.
  112636. */
  112637. static readonly LIGHTFALLOFF_STANDARD: number;
  112638. /**
  112639. * Intensity of the direct lights e.g. the four lights available in your scene.
  112640. * This impacts both the direct diffuse and specular highlights.
  112641. */
  112642. protected _directIntensity: number;
  112643. /**
  112644. * Intensity of the emissive part of the material.
  112645. * This helps controlling the emissive effect without modifying the emissive color.
  112646. */
  112647. protected _emissiveIntensity: number;
  112648. /**
  112649. * Intensity of the environment e.g. how much the environment will light the object
  112650. * either through harmonics for rough material or through the refelction for shiny ones.
  112651. */
  112652. protected _environmentIntensity: number;
  112653. /**
  112654. * This is a special control allowing the reduction of the specular highlights coming from the
  112655. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112656. */
  112657. protected _specularIntensity: number;
  112658. /**
  112659. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112660. */
  112661. private _lightingInfos;
  112662. /**
  112663. * Debug Control allowing disabling the bump map on this material.
  112664. */
  112665. protected _disableBumpMap: boolean;
  112666. /**
  112667. * AKA Diffuse Texture in standard nomenclature.
  112668. */
  112669. protected _albedoTexture: Nullable<BaseTexture>;
  112670. /**
  112671. * AKA Occlusion Texture in other nomenclature.
  112672. */
  112673. protected _ambientTexture: Nullable<BaseTexture>;
  112674. /**
  112675. * AKA Occlusion Texture Intensity in other nomenclature.
  112676. */
  112677. protected _ambientTextureStrength: number;
  112678. /**
  112679. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112680. * 1 means it completely occludes it
  112681. * 0 mean it has no impact
  112682. */
  112683. protected _ambientTextureImpactOnAnalyticalLights: number;
  112684. /**
  112685. * Stores the alpha values in a texture.
  112686. */
  112687. protected _opacityTexture: Nullable<BaseTexture>;
  112688. /**
  112689. * Stores the reflection values in a texture.
  112690. */
  112691. protected _reflectionTexture: Nullable<BaseTexture>;
  112692. /**
  112693. * Stores the emissive values in a texture.
  112694. */
  112695. protected _emissiveTexture: Nullable<BaseTexture>;
  112696. /**
  112697. * AKA Specular texture in other nomenclature.
  112698. */
  112699. protected _reflectivityTexture: Nullable<BaseTexture>;
  112700. /**
  112701. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112702. */
  112703. protected _metallicTexture: Nullable<BaseTexture>;
  112704. /**
  112705. * Specifies the metallic scalar of the metallic/roughness workflow.
  112706. * Can also be used to scale the metalness values of the metallic texture.
  112707. */
  112708. protected _metallic: Nullable<number>;
  112709. /**
  112710. * Specifies the roughness scalar of the metallic/roughness workflow.
  112711. * Can also be used to scale the roughness values of the metallic texture.
  112712. */
  112713. protected _roughness: Nullable<number>;
  112714. /**
  112715. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112716. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112717. */
  112718. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112719. /**
  112720. * Stores surface normal data used to displace a mesh in a texture.
  112721. */
  112722. protected _bumpTexture: Nullable<BaseTexture>;
  112723. /**
  112724. * Stores the pre-calculated light information of a mesh in a texture.
  112725. */
  112726. protected _lightmapTexture: Nullable<BaseTexture>;
  112727. /**
  112728. * The color of a material in ambient lighting.
  112729. */
  112730. protected _ambientColor: Color3;
  112731. /**
  112732. * AKA Diffuse Color in other nomenclature.
  112733. */
  112734. protected _albedoColor: Color3;
  112735. /**
  112736. * AKA Specular Color in other nomenclature.
  112737. */
  112738. protected _reflectivityColor: Color3;
  112739. /**
  112740. * The color applied when light is reflected from a material.
  112741. */
  112742. protected _reflectionColor: Color3;
  112743. /**
  112744. * The color applied when light is emitted from a material.
  112745. */
  112746. protected _emissiveColor: Color3;
  112747. /**
  112748. * AKA Glossiness in other nomenclature.
  112749. */
  112750. protected _microSurface: number;
  112751. /**
  112752. * Specifies that the material will use the light map as a show map.
  112753. */
  112754. protected _useLightmapAsShadowmap: boolean;
  112755. /**
  112756. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112757. * makes the reflect vector face the model (under horizon).
  112758. */
  112759. protected _useHorizonOcclusion: boolean;
  112760. /**
  112761. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112762. * too much the area relying on ambient texture to define their ambient occlusion.
  112763. */
  112764. protected _useRadianceOcclusion: boolean;
  112765. /**
  112766. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112767. */
  112768. protected _useAlphaFromAlbedoTexture: boolean;
  112769. /**
  112770. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  112771. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112772. */
  112773. protected _useSpecularOverAlpha: boolean;
  112774. /**
  112775. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112776. */
  112777. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112778. /**
  112779. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112780. */
  112781. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  112782. /**
  112783. * Specifies if the metallic texture contains the roughness information in its green channel.
  112784. */
  112785. protected _useRoughnessFromMetallicTextureGreen: boolean;
  112786. /**
  112787. * Specifies if the metallic texture contains the metallness information in its blue channel.
  112788. */
  112789. protected _useMetallnessFromMetallicTextureBlue: boolean;
  112790. /**
  112791. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  112792. */
  112793. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  112794. /**
  112795. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  112796. */
  112797. protected _useAmbientInGrayScale: boolean;
  112798. /**
  112799. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  112800. * The material will try to infer what glossiness each pixel should be.
  112801. */
  112802. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  112803. /**
  112804. * Defines the falloff type used in this material.
  112805. * It by default is Physical.
  112806. */
  112807. protected _lightFalloff: number;
  112808. /**
  112809. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  112810. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  112811. */
  112812. protected _useRadianceOverAlpha: boolean;
  112813. /**
  112814. * Allows using an object space normal map (instead of tangent space).
  112815. */
  112816. protected _useObjectSpaceNormalMap: boolean;
  112817. /**
  112818. * Allows using the bump map in parallax mode.
  112819. */
  112820. protected _useParallax: boolean;
  112821. /**
  112822. * Allows using the bump map in parallax occlusion mode.
  112823. */
  112824. protected _useParallaxOcclusion: boolean;
  112825. /**
  112826. * Controls the scale bias of the parallax mode.
  112827. */
  112828. protected _parallaxScaleBias: number;
  112829. /**
  112830. * If sets to true, disables all the lights affecting the material.
  112831. */
  112832. protected _disableLighting: boolean;
  112833. /**
  112834. * Number of Simultaneous lights allowed on the material.
  112835. */
  112836. protected _maxSimultaneousLights: number;
  112837. /**
  112838. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  112839. */
  112840. protected _invertNormalMapX: boolean;
  112841. /**
  112842. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  112843. */
  112844. protected _invertNormalMapY: boolean;
  112845. /**
  112846. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112847. */
  112848. protected _twoSidedLighting: boolean;
  112849. /**
  112850. * Defines the alpha limits in alpha test mode.
  112851. */
  112852. protected _alphaCutOff: number;
  112853. /**
  112854. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  112855. */
  112856. protected _forceAlphaTest: boolean;
  112857. /**
  112858. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112859. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  112860. */
  112861. protected _useAlphaFresnel: boolean;
  112862. /**
  112863. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  112864. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  112865. */
  112866. protected _useLinearAlphaFresnel: boolean;
  112867. /**
  112868. * The transparency mode of the material.
  112869. */
  112870. protected _transparencyMode: Nullable<number>;
  112871. /**
  112872. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  112873. * from cos thetav and roughness:
  112874. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  112875. */
  112876. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  112877. /**
  112878. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  112879. */
  112880. protected _forceIrradianceInFragment: boolean;
  112881. /**
  112882. * Force normal to face away from face.
  112883. */
  112884. protected _forceNormalForward: boolean;
  112885. /**
  112886. * Enables specular anti aliasing in the PBR shader.
  112887. * It will both interacts on the Geometry for analytical and IBL lighting.
  112888. * It also prefilter the roughness map based on the bump values.
  112889. */
  112890. protected _enableSpecularAntiAliasing: boolean;
  112891. /**
  112892. * Default configuration related to image processing available in the PBR Material.
  112893. */
  112894. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112895. /**
  112896. * Keep track of the image processing observer to allow dispose and replace.
  112897. */
  112898. private _imageProcessingObserver;
  112899. /**
  112900. * Attaches a new image processing configuration to the PBR Material.
  112901. * @param configuration
  112902. */
  112903. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112904. /**
  112905. * Stores the available render targets.
  112906. */
  112907. private _renderTargets;
  112908. /**
  112909. * Sets the global ambient color for the material used in lighting calculations.
  112910. */
  112911. private _globalAmbientColor;
  112912. /**
  112913. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  112914. */
  112915. private _useLogarithmicDepth;
  112916. /**
  112917. * If set to true, no lighting calculations will be applied.
  112918. */
  112919. private _unlit;
  112920. private _debugMode;
  112921. /**
  112922. * @hidden
  112923. * This is reserved for the inspector.
  112924. * Defines the material debug mode.
  112925. * It helps seeing only some components of the material while troubleshooting.
  112926. */
  112927. debugMode: number;
  112928. /**
  112929. * @hidden
  112930. * This is reserved for the inspector.
  112931. * Specify from where on screen the debug mode should start.
  112932. * The value goes from -1 (full screen) to 1 (not visible)
  112933. * It helps with side by side comparison against the final render
  112934. * This defaults to -1
  112935. */
  112936. private debugLimit;
  112937. /**
  112938. * @hidden
  112939. * This is reserved for the inspector.
  112940. * As the default viewing range might not be enough (if the ambient is really small for instance)
  112941. * You can use the factor to better multiply the final value.
  112942. */
  112943. private debugFactor;
  112944. /**
  112945. * Defines the clear coat layer parameters for the material.
  112946. */
  112947. readonly clearCoat: PBRClearCoatConfiguration;
  112948. /**
  112949. * Defines the anisotropic parameters for the material.
  112950. */
  112951. readonly anisotropy: PBRAnisotropicConfiguration;
  112952. /**
  112953. * Defines the BRDF parameters for the material.
  112954. */
  112955. readonly brdf: PBRBRDFConfiguration;
  112956. /**
  112957. * Defines the Sheen parameters for the material.
  112958. */
  112959. readonly sheen: PBRSheenConfiguration;
  112960. /**
  112961. * Defines the SubSurface parameters for the material.
  112962. */
  112963. readonly subSurface: PBRSubSurfaceConfiguration;
  112964. /**
  112965. * Custom callback helping to override the default shader used in the material.
  112966. */
  112967. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  112968. protected _rebuildInParallel: boolean;
  112969. /**
  112970. * Instantiates a new PBRMaterial instance.
  112971. *
  112972. * @param name The material name
  112973. * @param scene The scene the material will be use in.
  112974. */
  112975. constructor(name: string, scene: Scene);
  112976. /**
  112977. * Gets a boolean indicating that current material needs to register RTT
  112978. */
  112979. readonly hasRenderTargetTextures: boolean;
  112980. /**
  112981. * Gets the name of the material class.
  112982. */
  112983. getClassName(): string;
  112984. /**
  112985. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  112986. */
  112987. /**
  112988. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  112989. */
  112990. useLogarithmicDepth: boolean;
  112991. /**
  112992. * Gets the current transparency mode.
  112993. */
  112994. /**
  112995. * Sets the transparency mode of the material.
  112996. *
  112997. * | Value | Type | Description |
  112998. * | ----- | ----------------------------------- | ----------- |
  112999. * | 0 | OPAQUE | |
  113000. * | 1 | ALPHATEST | |
  113001. * | 2 | ALPHABLEND | |
  113002. * | 3 | ALPHATESTANDBLEND | |
  113003. *
  113004. */
  113005. transparencyMode: Nullable<number>;
  113006. /**
  113007. * Returns true if alpha blending should be disabled.
  113008. */
  113009. private readonly _disableAlphaBlending;
  113010. /**
  113011. * Specifies whether or not this material should be rendered in alpha blend mode.
  113012. */
  113013. needAlphaBlending(): boolean;
  113014. /**
  113015. * Specifies if the mesh will require alpha blending.
  113016. * @param mesh - BJS mesh.
  113017. */
  113018. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113019. /**
  113020. * Specifies whether or not this material should be rendered in alpha test mode.
  113021. */
  113022. needAlphaTesting(): boolean;
  113023. /**
  113024. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113025. */
  113026. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113027. /**
  113028. * Gets the texture used for the alpha test.
  113029. */
  113030. getAlphaTestTexture(): Nullable<BaseTexture>;
  113031. /**
  113032. * Specifies that the submesh is ready to be used.
  113033. * @param mesh - BJS mesh.
  113034. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113035. * @param useInstances - Specifies that instances should be used.
  113036. * @returns - boolean indicating that the submesh is ready or not.
  113037. */
  113038. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113039. /**
  113040. * Specifies if the material uses metallic roughness workflow.
  113041. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113042. */
  113043. isMetallicWorkflow(): boolean;
  113044. private _prepareEffect;
  113045. private _prepareDefines;
  113046. /**
  113047. * Force shader compilation
  113048. */
  113049. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113050. clipPlane: boolean;
  113051. }>): void;
  113052. /**
  113053. * Initializes the uniform buffer layout for the shader.
  113054. */
  113055. buildUniformLayout(): void;
  113056. /**
  113057. * Unbinds the material from the mesh
  113058. */
  113059. unbind(): void;
  113060. /**
  113061. * Binds the submesh data.
  113062. * @param world - The world matrix.
  113063. * @param mesh - The BJS mesh.
  113064. * @param subMesh - A submesh of the BJS mesh.
  113065. */
  113066. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113067. /**
  113068. * Returns the animatable textures.
  113069. * @returns - Array of animatable textures.
  113070. */
  113071. getAnimatables(): IAnimatable[];
  113072. /**
  113073. * Returns the texture used for reflections.
  113074. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113075. */
  113076. private _getReflectionTexture;
  113077. /**
  113078. * Returns an array of the actively used textures.
  113079. * @returns - Array of BaseTextures
  113080. */
  113081. getActiveTextures(): BaseTexture[];
  113082. /**
  113083. * Checks to see if a texture is used in the material.
  113084. * @param texture - Base texture to use.
  113085. * @returns - Boolean specifying if a texture is used in the material.
  113086. */
  113087. hasTexture(texture: BaseTexture): boolean;
  113088. /**
  113089. * Disposes the resources of the material.
  113090. * @param forceDisposeEffect - Forces the disposal of effects.
  113091. * @param forceDisposeTextures - Forces the disposal of all textures.
  113092. */
  113093. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113094. }
  113095. }
  113096. declare module BABYLON {
  113097. /**
  113098. * The Physically based material of BJS.
  113099. *
  113100. * This offers the main features of a standard PBR material.
  113101. * For more information, please refer to the documentation :
  113102. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113103. */
  113104. export class PBRMaterial extends PBRBaseMaterial {
  113105. /**
  113106. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113107. */
  113108. static readonly PBRMATERIAL_OPAQUE: number;
  113109. /**
  113110. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113111. */
  113112. static readonly PBRMATERIAL_ALPHATEST: number;
  113113. /**
  113114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113115. */
  113116. static readonly PBRMATERIAL_ALPHABLEND: number;
  113117. /**
  113118. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113119. * They are also discarded below the alpha cutoff threshold to improve performances.
  113120. */
  113121. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113122. /**
  113123. * Defines the default value of how much AO map is occluding the analytical lights
  113124. * (point spot...).
  113125. */
  113126. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113127. /**
  113128. * Intensity of the direct lights e.g. the four lights available in your scene.
  113129. * This impacts both the direct diffuse and specular highlights.
  113130. */
  113131. directIntensity: number;
  113132. /**
  113133. * Intensity of the emissive part of the material.
  113134. * This helps controlling the emissive effect without modifying the emissive color.
  113135. */
  113136. emissiveIntensity: number;
  113137. /**
  113138. * Intensity of the environment e.g. how much the environment will light the object
  113139. * either through harmonics for rough material or through the refelction for shiny ones.
  113140. */
  113141. environmentIntensity: number;
  113142. /**
  113143. * This is a special control allowing the reduction of the specular highlights coming from the
  113144. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113145. */
  113146. specularIntensity: number;
  113147. /**
  113148. * Debug Control allowing disabling the bump map on this material.
  113149. */
  113150. disableBumpMap: boolean;
  113151. /**
  113152. * AKA Diffuse Texture in standard nomenclature.
  113153. */
  113154. albedoTexture: BaseTexture;
  113155. /**
  113156. * AKA Occlusion Texture in other nomenclature.
  113157. */
  113158. ambientTexture: BaseTexture;
  113159. /**
  113160. * AKA Occlusion Texture Intensity in other nomenclature.
  113161. */
  113162. ambientTextureStrength: number;
  113163. /**
  113164. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113165. * 1 means it completely occludes it
  113166. * 0 mean it has no impact
  113167. */
  113168. ambientTextureImpactOnAnalyticalLights: number;
  113169. /**
  113170. * Stores the alpha values in a texture.
  113171. */
  113172. opacityTexture: BaseTexture;
  113173. /**
  113174. * Stores the reflection values in a texture.
  113175. */
  113176. reflectionTexture: Nullable<BaseTexture>;
  113177. /**
  113178. * Stores the emissive values in a texture.
  113179. */
  113180. emissiveTexture: BaseTexture;
  113181. /**
  113182. * AKA Specular texture in other nomenclature.
  113183. */
  113184. reflectivityTexture: BaseTexture;
  113185. /**
  113186. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113187. */
  113188. metallicTexture: BaseTexture;
  113189. /**
  113190. * Specifies the metallic scalar of the metallic/roughness workflow.
  113191. * Can also be used to scale the metalness values of the metallic texture.
  113192. */
  113193. metallic: Nullable<number>;
  113194. /**
  113195. * Specifies the roughness scalar of the metallic/roughness workflow.
  113196. * Can also be used to scale the roughness values of the metallic texture.
  113197. */
  113198. roughness: Nullable<number>;
  113199. /**
  113200. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113201. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113202. */
  113203. microSurfaceTexture: BaseTexture;
  113204. /**
  113205. * Stores surface normal data used to displace a mesh in a texture.
  113206. */
  113207. bumpTexture: BaseTexture;
  113208. /**
  113209. * Stores the pre-calculated light information of a mesh in a texture.
  113210. */
  113211. lightmapTexture: BaseTexture;
  113212. /**
  113213. * Stores the refracted light information in a texture.
  113214. */
  113215. refractionTexture: Nullable<BaseTexture>;
  113216. /**
  113217. * The color of a material in ambient lighting.
  113218. */
  113219. ambientColor: Color3;
  113220. /**
  113221. * AKA Diffuse Color in other nomenclature.
  113222. */
  113223. albedoColor: Color3;
  113224. /**
  113225. * AKA Specular Color in other nomenclature.
  113226. */
  113227. reflectivityColor: Color3;
  113228. /**
  113229. * The color reflected from the material.
  113230. */
  113231. reflectionColor: Color3;
  113232. /**
  113233. * The color emitted from the material.
  113234. */
  113235. emissiveColor: Color3;
  113236. /**
  113237. * AKA Glossiness in other nomenclature.
  113238. */
  113239. microSurface: number;
  113240. /**
  113241. * source material index of refraction (IOR)' / 'destination material IOR.
  113242. */
  113243. indexOfRefraction: number;
  113244. /**
  113245. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113246. */
  113247. invertRefractionY: boolean;
  113248. /**
  113249. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113250. * Materials half opaque for instance using refraction could benefit from this control.
  113251. */
  113252. linkRefractionWithTransparency: boolean;
  113253. /**
  113254. * If true, the light map contains occlusion information instead of lighting info.
  113255. */
  113256. useLightmapAsShadowmap: boolean;
  113257. /**
  113258. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113259. */
  113260. useAlphaFromAlbedoTexture: boolean;
  113261. /**
  113262. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113263. */
  113264. forceAlphaTest: boolean;
  113265. /**
  113266. * Defines the alpha limits in alpha test mode.
  113267. */
  113268. alphaCutOff: number;
  113269. /**
  113270. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113271. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113272. */
  113273. useSpecularOverAlpha: boolean;
  113274. /**
  113275. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113276. */
  113277. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113278. /**
  113279. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113280. */
  113281. useRoughnessFromMetallicTextureAlpha: boolean;
  113282. /**
  113283. * Specifies if the metallic texture contains the roughness information in its green channel.
  113284. */
  113285. useRoughnessFromMetallicTextureGreen: boolean;
  113286. /**
  113287. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113288. */
  113289. useMetallnessFromMetallicTextureBlue: boolean;
  113290. /**
  113291. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113292. */
  113293. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113294. /**
  113295. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113296. */
  113297. useAmbientInGrayScale: boolean;
  113298. /**
  113299. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113300. * The material will try to infer what glossiness each pixel should be.
  113301. */
  113302. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113303. /**
  113304. * BJS is using an harcoded light falloff based on a manually sets up range.
  113305. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113306. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113307. */
  113308. /**
  113309. * BJS is using an harcoded light falloff based on a manually sets up range.
  113310. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113311. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113312. */
  113313. usePhysicalLightFalloff: boolean;
  113314. /**
  113315. * In order to support the falloff compatibility with gltf, a special mode has been added
  113316. * to reproduce the gltf light falloff.
  113317. */
  113318. /**
  113319. * In order to support the falloff compatibility with gltf, a special mode has been added
  113320. * to reproduce the gltf light falloff.
  113321. */
  113322. useGLTFLightFalloff: boolean;
  113323. /**
  113324. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113325. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113326. */
  113327. useRadianceOverAlpha: boolean;
  113328. /**
  113329. * Allows using an object space normal map (instead of tangent space).
  113330. */
  113331. useObjectSpaceNormalMap: boolean;
  113332. /**
  113333. * Allows using the bump map in parallax mode.
  113334. */
  113335. useParallax: boolean;
  113336. /**
  113337. * Allows using the bump map in parallax occlusion mode.
  113338. */
  113339. useParallaxOcclusion: boolean;
  113340. /**
  113341. * Controls the scale bias of the parallax mode.
  113342. */
  113343. parallaxScaleBias: number;
  113344. /**
  113345. * If sets to true, disables all the lights affecting the material.
  113346. */
  113347. disableLighting: boolean;
  113348. /**
  113349. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113350. */
  113351. forceIrradianceInFragment: boolean;
  113352. /**
  113353. * Number of Simultaneous lights allowed on the material.
  113354. */
  113355. maxSimultaneousLights: number;
  113356. /**
  113357. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113358. */
  113359. invertNormalMapX: boolean;
  113360. /**
  113361. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113362. */
  113363. invertNormalMapY: boolean;
  113364. /**
  113365. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113366. */
  113367. twoSidedLighting: boolean;
  113368. /**
  113369. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113370. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113371. */
  113372. useAlphaFresnel: boolean;
  113373. /**
  113374. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113375. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113376. */
  113377. useLinearAlphaFresnel: boolean;
  113378. /**
  113379. * Let user defines the brdf lookup texture used for IBL.
  113380. * A default 8bit version is embedded but you could point at :
  113381. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113382. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113383. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113384. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113385. */
  113386. environmentBRDFTexture: Nullable<BaseTexture>;
  113387. /**
  113388. * Force normal to face away from face.
  113389. */
  113390. forceNormalForward: boolean;
  113391. /**
  113392. * Enables specular anti aliasing in the PBR shader.
  113393. * It will both interacts on the Geometry for analytical and IBL lighting.
  113394. * It also prefilter the roughness map based on the bump values.
  113395. */
  113396. enableSpecularAntiAliasing: boolean;
  113397. /**
  113398. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113399. * makes the reflect vector face the model (under horizon).
  113400. */
  113401. useHorizonOcclusion: boolean;
  113402. /**
  113403. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113404. * too much the area relying on ambient texture to define their ambient occlusion.
  113405. */
  113406. useRadianceOcclusion: boolean;
  113407. /**
  113408. * If set to true, no lighting calculations will be applied.
  113409. */
  113410. unlit: boolean;
  113411. /**
  113412. * Gets the image processing configuration used either in this material.
  113413. */
  113414. /**
  113415. * Sets the Default image processing configuration used either in the this material.
  113416. *
  113417. * If sets to null, the scene one is in use.
  113418. */
  113419. imageProcessingConfiguration: ImageProcessingConfiguration;
  113420. /**
  113421. * Gets wether the color curves effect is enabled.
  113422. */
  113423. /**
  113424. * Sets wether the color curves effect is enabled.
  113425. */
  113426. cameraColorCurvesEnabled: boolean;
  113427. /**
  113428. * Gets wether the color grading effect is enabled.
  113429. */
  113430. /**
  113431. * Gets wether the color grading effect is enabled.
  113432. */
  113433. cameraColorGradingEnabled: boolean;
  113434. /**
  113435. * Gets wether tonemapping is enabled or not.
  113436. */
  113437. /**
  113438. * Sets wether tonemapping is enabled or not
  113439. */
  113440. cameraToneMappingEnabled: boolean;
  113441. /**
  113442. * The camera exposure used on this material.
  113443. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113444. * This corresponds to a photographic exposure.
  113445. */
  113446. /**
  113447. * The camera exposure used on this material.
  113448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113449. * This corresponds to a photographic exposure.
  113450. */
  113451. cameraExposure: number;
  113452. /**
  113453. * Gets The camera contrast used on this material.
  113454. */
  113455. /**
  113456. * Sets The camera contrast used on this material.
  113457. */
  113458. cameraContrast: number;
  113459. /**
  113460. * Gets the Color Grading 2D Lookup Texture.
  113461. */
  113462. /**
  113463. * Sets the Color Grading 2D Lookup Texture.
  113464. */
  113465. cameraColorGradingTexture: Nullable<BaseTexture>;
  113466. /**
  113467. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113468. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113469. * 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;
  113470. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113471. */
  113472. /**
  113473. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113474. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113475. * 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;
  113476. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113477. */
  113478. cameraColorCurves: Nullable<ColorCurves>;
  113479. /**
  113480. * Instantiates a new PBRMaterial instance.
  113481. *
  113482. * @param name The material name
  113483. * @param scene The scene the material will be use in.
  113484. */
  113485. constructor(name: string, scene: Scene);
  113486. /**
  113487. * Returns the name of this material class.
  113488. */
  113489. getClassName(): string;
  113490. /**
  113491. * Makes a duplicate of the current material.
  113492. * @param name - name to use for the new material.
  113493. */
  113494. clone(name: string): PBRMaterial;
  113495. /**
  113496. * Serializes this PBR Material.
  113497. * @returns - An object with the serialized material.
  113498. */
  113499. serialize(): any;
  113500. /**
  113501. * Parses a PBR Material from a serialized object.
  113502. * @param source - Serialized object.
  113503. * @param scene - BJS scene instance.
  113504. * @param rootUrl - url for the scene object
  113505. * @returns - PBRMaterial
  113506. */
  113507. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113508. }
  113509. }
  113510. declare module BABYLON {
  113511. /**
  113512. * Direct draw surface info
  113513. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113514. */
  113515. export interface DDSInfo {
  113516. /**
  113517. * Width of the texture
  113518. */
  113519. width: number;
  113520. /**
  113521. * Width of the texture
  113522. */
  113523. height: number;
  113524. /**
  113525. * Number of Mipmaps for the texture
  113526. * @see https://en.wikipedia.org/wiki/Mipmap
  113527. */
  113528. mipmapCount: number;
  113529. /**
  113530. * If the textures format is a known fourCC format
  113531. * @see https://www.fourcc.org/
  113532. */
  113533. isFourCC: boolean;
  113534. /**
  113535. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113536. */
  113537. isRGB: boolean;
  113538. /**
  113539. * If the texture is a lumincance format
  113540. */
  113541. isLuminance: boolean;
  113542. /**
  113543. * If this is a cube texture
  113544. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113545. */
  113546. isCube: boolean;
  113547. /**
  113548. * If the texture is a compressed format eg. FOURCC_DXT1
  113549. */
  113550. isCompressed: boolean;
  113551. /**
  113552. * The dxgiFormat of the texture
  113553. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113554. */
  113555. dxgiFormat: number;
  113556. /**
  113557. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113558. */
  113559. textureType: number;
  113560. /**
  113561. * Sphericle polynomial created for the dds texture
  113562. */
  113563. sphericalPolynomial?: SphericalPolynomial;
  113564. }
  113565. /**
  113566. * Class used to provide DDS decompression tools
  113567. */
  113568. export class DDSTools {
  113569. /**
  113570. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113571. */
  113572. static StoreLODInAlphaChannel: boolean;
  113573. /**
  113574. * Gets DDS information from an array buffer
  113575. * @param arrayBuffer defines the array buffer to read data from
  113576. * @returns the DDS information
  113577. */
  113578. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113579. private static _FloatView;
  113580. private static _Int32View;
  113581. private static _ToHalfFloat;
  113582. private static _FromHalfFloat;
  113583. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113584. private static _GetHalfFloatRGBAArrayBuffer;
  113585. private static _GetFloatRGBAArrayBuffer;
  113586. private static _GetFloatAsUIntRGBAArrayBuffer;
  113587. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113588. private static _GetRGBAArrayBuffer;
  113589. private static _ExtractLongWordOrder;
  113590. private static _GetRGBArrayBuffer;
  113591. private static _GetLuminanceArrayBuffer;
  113592. /**
  113593. * Uploads DDS Levels to a Babylon Texture
  113594. * @hidden
  113595. */
  113596. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113597. }
  113598. interface Engine {
  113599. /**
  113600. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113601. * @param rootUrl defines the url where the file to load is located
  113602. * @param scene defines the current scene
  113603. * @param lodScale defines scale to apply to the mip map selection
  113604. * @param lodOffset defines offset to apply to the mip map selection
  113605. * @param onLoad defines an optional callback raised when the texture is loaded
  113606. * @param onError defines an optional callback raised if there is an issue to load the texture
  113607. * @param format defines the format of the data
  113608. * @param forcedExtension defines the extension to use to pick the right loader
  113609. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113610. * @returns the cube texture as an InternalTexture
  113611. */
  113612. 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;
  113613. }
  113614. }
  113615. declare module BABYLON {
  113616. /**
  113617. * Implementation of the DDS Texture Loader.
  113618. * @hidden
  113619. */
  113620. export class _DDSTextureLoader implements IInternalTextureLoader {
  113621. /**
  113622. * Defines wether the loader supports cascade loading the different faces.
  113623. */
  113624. readonly supportCascades: boolean;
  113625. /**
  113626. * This returns if the loader support the current file information.
  113627. * @param extension defines the file extension of the file being loaded
  113628. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113629. * @param fallback defines the fallback internal texture if any
  113630. * @param isBase64 defines whether the texture is encoded as a base64
  113631. * @param isBuffer defines whether the texture data are stored as a buffer
  113632. * @returns true if the loader can load the specified file
  113633. */
  113634. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113635. /**
  113636. * Transform the url before loading if required.
  113637. * @param rootUrl the url of the texture
  113638. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113639. * @returns the transformed texture
  113640. */
  113641. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113642. /**
  113643. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113644. * @param rootUrl the url of the texture
  113645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113646. * @returns the fallback texture
  113647. */
  113648. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113649. /**
  113650. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113651. * @param data contains the texture data
  113652. * @param texture defines the BabylonJS internal texture
  113653. * @param createPolynomials will be true if polynomials have been requested
  113654. * @param onLoad defines the callback to trigger once the texture is ready
  113655. * @param onError defines the callback to trigger in case of error
  113656. */
  113657. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113658. /**
  113659. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113660. * @param data contains the texture data
  113661. * @param texture defines the BabylonJS internal texture
  113662. * @param callback defines the method to call once ready to upload
  113663. */
  113664. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113665. }
  113666. }
  113667. declare module BABYLON {
  113668. /**
  113669. * Implementation of the ENV Texture Loader.
  113670. * @hidden
  113671. */
  113672. export class _ENVTextureLoader implements IInternalTextureLoader {
  113673. /**
  113674. * Defines wether the loader supports cascade loading the different faces.
  113675. */
  113676. readonly supportCascades: boolean;
  113677. /**
  113678. * This returns if the loader support the current file information.
  113679. * @param extension defines the file extension of the file being loaded
  113680. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113681. * @param fallback defines the fallback internal texture if any
  113682. * @param isBase64 defines whether the texture is encoded as a base64
  113683. * @param isBuffer defines whether the texture data are stored as a buffer
  113684. * @returns true if the loader can load the specified file
  113685. */
  113686. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113687. /**
  113688. * Transform the url before loading if required.
  113689. * @param rootUrl the url of the texture
  113690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113691. * @returns the transformed texture
  113692. */
  113693. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113694. /**
  113695. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113696. * @param rootUrl the url of the texture
  113697. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113698. * @returns the fallback texture
  113699. */
  113700. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113701. /**
  113702. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113703. * @param data contains the texture data
  113704. * @param texture defines the BabylonJS internal texture
  113705. * @param createPolynomials will be true if polynomials have been requested
  113706. * @param onLoad defines the callback to trigger once the texture is ready
  113707. * @param onError defines the callback to trigger in case of error
  113708. */
  113709. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113710. /**
  113711. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113712. * @param data contains the texture data
  113713. * @param texture defines the BabylonJS internal texture
  113714. * @param callback defines the method to call once ready to upload
  113715. */
  113716. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113717. }
  113718. }
  113719. declare module BABYLON {
  113720. /**
  113721. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113722. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113723. */
  113724. export class KhronosTextureContainer {
  113725. /** contents of the KTX container file */
  113726. arrayBuffer: any;
  113727. private static HEADER_LEN;
  113728. private static COMPRESSED_2D;
  113729. private static COMPRESSED_3D;
  113730. private static TEX_2D;
  113731. private static TEX_3D;
  113732. /**
  113733. * Gets the openGL type
  113734. */
  113735. glType: number;
  113736. /**
  113737. * Gets the openGL type size
  113738. */
  113739. glTypeSize: number;
  113740. /**
  113741. * Gets the openGL format
  113742. */
  113743. glFormat: number;
  113744. /**
  113745. * Gets the openGL internal format
  113746. */
  113747. glInternalFormat: number;
  113748. /**
  113749. * Gets the base internal format
  113750. */
  113751. glBaseInternalFormat: number;
  113752. /**
  113753. * Gets image width in pixel
  113754. */
  113755. pixelWidth: number;
  113756. /**
  113757. * Gets image height in pixel
  113758. */
  113759. pixelHeight: number;
  113760. /**
  113761. * Gets image depth in pixels
  113762. */
  113763. pixelDepth: number;
  113764. /**
  113765. * Gets the number of array elements
  113766. */
  113767. numberOfArrayElements: number;
  113768. /**
  113769. * Gets the number of faces
  113770. */
  113771. numberOfFaces: number;
  113772. /**
  113773. * Gets the number of mipmap levels
  113774. */
  113775. numberOfMipmapLevels: number;
  113776. /**
  113777. * Gets the bytes of key value data
  113778. */
  113779. bytesOfKeyValueData: number;
  113780. /**
  113781. * Gets the load type
  113782. */
  113783. loadType: number;
  113784. /**
  113785. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  113786. */
  113787. isInvalid: boolean;
  113788. /**
  113789. * Creates a new KhronosTextureContainer
  113790. * @param arrayBuffer contents of the KTX container file
  113791. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  113792. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  113793. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  113794. */
  113795. constructor(
  113796. /** contents of the KTX container file */
  113797. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  113798. /**
  113799. * Uploads KTX content to a Babylon Texture.
  113800. * It is assumed that the texture has already been created & is currently bound
  113801. * @hidden
  113802. */
  113803. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  113804. private _upload2DCompressedLevels;
  113805. }
  113806. }
  113807. declare module BABYLON {
  113808. /**
  113809. * Implementation of the KTX Texture Loader.
  113810. * @hidden
  113811. */
  113812. export class _KTXTextureLoader implements IInternalTextureLoader {
  113813. /**
  113814. * Defines wether the loader supports cascade loading the different faces.
  113815. */
  113816. readonly supportCascades: boolean;
  113817. /**
  113818. * This returns if the loader support the current file information.
  113819. * @param extension defines the file extension of the file being loaded
  113820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113821. * @param fallback defines the fallback internal texture if any
  113822. * @param isBase64 defines whether the texture is encoded as a base64
  113823. * @param isBuffer defines whether the texture data are stored as a buffer
  113824. * @returns true if the loader can load the specified file
  113825. */
  113826. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113827. /**
  113828. * Transform the url before loading if required.
  113829. * @param rootUrl the url of the texture
  113830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113831. * @returns the transformed texture
  113832. */
  113833. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113834. /**
  113835. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113836. * @param rootUrl the url of the texture
  113837. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113838. * @returns the fallback texture
  113839. */
  113840. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113841. /**
  113842. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113843. * @param data contains the texture data
  113844. * @param texture defines the BabylonJS internal texture
  113845. * @param createPolynomials will be true if polynomials have been requested
  113846. * @param onLoad defines the callback to trigger once the texture is ready
  113847. * @param onError defines the callback to trigger in case of error
  113848. */
  113849. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113850. /**
  113851. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113852. * @param data contains the texture data
  113853. * @param texture defines the BabylonJS internal texture
  113854. * @param callback defines the method to call once ready to upload
  113855. */
  113856. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  113857. }
  113858. }
  113859. declare module BABYLON {
  113860. /**
  113861. * Options for the default xr helper
  113862. */
  113863. export class WebXRDefaultExperienceOptions {
  113864. /**
  113865. * Floor meshes that should be used for teleporting
  113866. */
  113867. floorMeshes: Array<AbstractMesh>;
  113868. }
  113869. /**
  113870. * Default experience which provides a similar setup to the previous webVRExperience
  113871. */
  113872. export class WebXRDefaultExperience {
  113873. /**
  113874. * Base experience
  113875. */
  113876. baseExperience: WebXRExperienceHelper;
  113877. /**
  113878. * Input experience extension
  113879. */
  113880. input: WebXRInput;
  113881. /**
  113882. * Loads the controller models
  113883. */
  113884. controllerModelLoader: WebXRControllerModelLoader;
  113885. /**
  113886. * Enables laser pointer and selection
  113887. */
  113888. pointerSelection: WebXRControllerPointerSelection;
  113889. /**
  113890. * Enables teleportation
  113891. */
  113892. teleportation: WebXRControllerTeleportation;
  113893. /**
  113894. * Enables ui for enetering/exiting xr
  113895. */
  113896. enterExitUI: WebXREnterExitUI;
  113897. /**
  113898. * Default output canvas xr should render to
  113899. */
  113900. outputCanvas: WebXRManagedOutputCanvas;
  113901. /**
  113902. * Creates the default xr experience
  113903. * @param scene scene
  113904. * @param options options for basic configuration
  113905. * @returns resulting WebXRDefaultExperience
  113906. */
  113907. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  113908. private constructor();
  113909. /**
  113910. * DIsposes of the experience helper
  113911. */
  113912. dispose(): void;
  113913. }
  113914. }
  113915. declare module BABYLON {
  113916. /** @hidden */
  113917. export var _forceSceneHelpersToBundle: boolean;
  113918. interface Scene {
  113919. /**
  113920. * Creates a default light for the scene.
  113921. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  113922. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  113923. */
  113924. createDefaultLight(replace?: boolean): void;
  113925. /**
  113926. * Creates a default camera for the scene.
  113927. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  113928. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  113929. * @param replace has default false, when true replaces the active camera in the scene
  113930. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  113931. */
  113932. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  113933. /**
  113934. * Creates a default camera and a default light.
  113935. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  113936. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  113937. * @param replace has the default false, when true replaces the active camera/light in the scene
  113938. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  113939. */
  113940. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  113941. /**
  113942. * Creates a new sky box
  113943. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  113944. * @param environmentTexture defines the texture to use as environment texture
  113945. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  113946. * @param scale defines the overall scale of the skybox
  113947. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  113948. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  113949. * @returns a new mesh holding the sky box
  113950. */
  113951. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  113952. /**
  113953. * Creates a new environment
  113954. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  113955. * @param options defines the options you can use to configure the environment
  113956. * @returns the new EnvironmentHelper
  113957. */
  113958. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  113959. /**
  113960. * Creates a new VREXperienceHelper
  113961. * @see http://doc.babylonjs.com/how_to/webvr_helper
  113962. * @param webVROptions defines the options used to create the new VREXperienceHelper
  113963. * @returns a new VREXperienceHelper
  113964. */
  113965. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  113966. /**
  113967. * Creates a new WebXRDefaultExperience
  113968. * @see http://doc.babylonjs.com/how_to/webxr
  113969. * @param options experience options
  113970. * @returns a promise for a new WebXRDefaultExperience
  113971. */
  113972. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  113973. }
  113974. }
  113975. declare module BABYLON {
  113976. /**
  113977. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  113978. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  113979. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  113980. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113981. */
  113982. export class VideoDome extends TransformNode {
  113983. /**
  113984. * Define the video source as a Monoscopic panoramic 360 video.
  113985. */
  113986. static readonly MODE_MONOSCOPIC: number;
  113987. /**
  113988. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  113989. */
  113990. static readonly MODE_TOPBOTTOM: number;
  113991. /**
  113992. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  113993. */
  113994. static readonly MODE_SIDEBYSIDE: number;
  113995. private _halfDome;
  113996. private _useDirectMapping;
  113997. /**
  113998. * The video texture being displayed on the sphere
  113999. */
  114000. protected _videoTexture: VideoTexture;
  114001. /**
  114002. * Gets the video texture being displayed on the sphere
  114003. */
  114004. readonly videoTexture: VideoTexture;
  114005. /**
  114006. * The skybox material
  114007. */
  114008. protected _material: BackgroundMaterial;
  114009. /**
  114010. * The surface used for the skybox
  114011. */
  114012. protected _mesh: Mesh;
  114013. /**
  114014. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114015. */
  114016. private _halfDomeMask;
  114017. /**
  114018. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114019. * Also see the options.resolution property.
  114020. */
  114021. fovMultiplier: number;
  114022. private _videoMode;
  114023. /**
  114024. * Gets or set the current video mode for the video. It can be:
  114025. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114026. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114027. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114028. */
  114029. videoMode: number;
  114030. /**
  114031. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114032. *
  114033. */
  114034. /**
  114035. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114036. */
  114037. halfDome: boolean;
  114038. /**
  114039. * Oberserver used in Stereoscopic VR Mode.
  114040. */
  114041. private _onBeforeCameraRenderObserver;
  114042. /**
  114043. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114044. * @param name Element's name, child elements will append suffixes for their own names.
  114045. * @param urlsOrVideo defines the url(s) or the video element to use
  114046. * @param options An object containing optional or exposed sub element properties
  114047. */
  114048. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114049. resolution?: number;
  114050. clickToPlay?: boolean;
  114051. autoPlay?: boolean;
  114052. loop?: boolean;
  114053. size?: number;
  114054. poster?: string;
  114055. faceForward?: boolean;
  114056. useDirectMapping?: boolean;
  114057. halfDomeMode?: boolean;
  114058. }, scene: Scene);
  114059. private _changeVideoMode;
  114060. /**
  114061. * Releases resources associated with this node.
  114062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114064. */
  114065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114066. }
  114067. }
  114068. declare module BABYLON {
  114069. /**
  114070. * This class can be used to get instrumentation data from a Babylon engine
  114071. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114072. */
  114073. export class EngineInstrumentation implements IDisposable {
  114074. /**
  114075. * Define the instrumented engine.
  114076. */
  114077. engine: Engine;
  114078. private _captureGPUFrameTime;
  114079. private _gpuFrameTimeToken;
  114080. private _gpuFrameTime;
  114081. private _captureShaderCompilationTime;
  114082. private _shaderCompilationTime;
  114083. private _onBeginFrameObserver;
  114084. private _onEndFrameObserver;
  114085. private _onBeforeShaderCompilationObserver;
  114086. private _onAfterShaderCompilationObserver;
  114087. /**
  114088. * Gets the perf counter used for GPU frame time
  114089. */
  114090. readonly gpuFrameTimeCounter: PerfCounter;
  114091. /**
  114092. * Gets the GPU frame time capture status
  114093. */
  114094. /**
  114095. * Enable or disable the GPU frame time capture
  114096. */
  114097. captureGPUFrameTime: boolean;
  114098. /**
  114099. * Gets the perf counter used for shader compilation time
  114100. */
  114101. readonly shaderCompilationTimeCounter: PerfCounter;
  114102. /**
  114103. * Gets the shader compilation time capture status
  114104. */
  114105. /**
  114106. * Enable or disable the shader compilation time capture
  114107. */
  114108. captureShaderCompilationTime: boolean;
  114109. /**
  114110. * Instantiates a new engine instrumentation.
  114111. * This class can be used to get instrumentation data from a Babylon engine
  114112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114113. * @param engine Defines the engine to instrument
  114114. */
  114115. constructor(
  114116. /**
  114117. * Define the instrumented engine.
  114118. */
  114119. engine: Engine);
  114120. /**
  114121. * Dispose and release associated resources.
  114122. */
  114123. dispose(): void;
  114124. }
  114125. }
  114126. declare module BABYLON {
  114127. /**
  114128. * This class can be used to get instrumentation data from a Babylon engine
  114129. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114130. */
  114131. export class SceneInstrumentation implements IDisposable {
  114132. /**
  114133. * Defines the scene to instrument
  114134. */
  114135. scene: Scene;
  114136. private _captureActiveMeshesEvaluationTime;
  114137. private _activeMeshesEvaluationTime;
  114138. private _captureRenderTargetsRenderTime;
  114139. private _renderTargetsRenderTime;
  114140. private _captureFrameTime;
  114141. private _frameTime;
  114142. private _captureRenderTime;
  114143. private _renderTime;
  114144. private _captureInterFrameTime;
  114145. private _interFrameTime;
  114146. private _captureParticlesRenderTime;
  114147. private _particlesRenderTime;
  114148. private _captureSpritesRenderTime;
  114149. private _spritesRenderTime;
  114150. private _capturePhysicsTime;
  114151. private _physicsTime;
  114152. private _captureAnimationsTime;
  114153. private _animationsTime;
  114154. private _captureCameraRenderTime;
  114155. private _cameraRenderTime;
  114156. private _onBeforeActiveMeshesEvaluationObserver;
  114157. private _onAfterActiveMeshesEvaluationObserver;
  114158. private _onBeforeRenderTargetsRenderObserver;
  114159. private _onAfterRenderTargetsRenderObserver;
  114160. private _onAfterRenderObserver;
  114161. private _onBeforeDrawPhaseObserver;
  114162. private _onAfterDrawPhaseObserver;
  114163. private _onBeforeAnimationsObserver;
  114164. private _onBeforeParticlesRenderingObserver;
  114165. private _onAfterParticlesRenderingObserver;
  114166. private _onBeforeSpritesRenderingObserver;
  114167. private _onAfterSpritesRenderingObserver;
  114168. private _onBeforePhysicsObserver;
  114169. private _onAfterPhysicsObserver;
  114170. private _onAfterAnimationsObserver;
  114171. private _onBeforeCameraRenderObserver;
  114172. private _onAfterCameraRenderObserver;
  114173. /**
  114174. * Gets the perf counter used for active meshes evaluation time
  114175. */
  114176. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114177. /**
  114178. * Gets the active meshes evaluation time capture status
  114179. */
  114180. /**
  114181. * Enable or disable the active meshes evaluation time capture
  114182. */
  114183. captureActiveMeshesEvaluationTime: boolean;
  114184. /**
  114185. * Gets the perf counter used for render targets render time
  114186. */
  114187. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114188. /**
  114189. * Gets the render targets render time capture status
  114190. */
  114191. /**
  114192. * Enable or disable the render targets render time capture
  114193. */
  114194. captureRenderTargetsRenderTime: boolean;
  114195. /**
  114196. * Gets the perf counter used for particles render time
  114197. */
  114198. readonly particlesRenderTimeCounter: PerfCounter;
  114199. /**
  114200. * Gets the particles render time capture status
  114201. */
  114202. /**
  114203. * Enable or disable the particles render time capture
  114204. */
  114205. captureParticlesRenderTime: boolean;
  114206. /**
  114207. * Gets the perf counter used for sprites render time
  114208. */
  114209. readonly spritesRenderTimeCounter: PerfCounter;
  114210. /**
  114211. * Gets the sprites render time capture status
  114212. */
  114213. /**
  114214. * Enable or disable the sprites render time capture
  114215. */
  114216. captureSpritesRenderTime: boolean;
  114217. /**
  114218. * Gets the perf counter used for physics time
  114219. */
  114220. readonly physicsTimeCounter: PerfCounter;
  114221. /**
  114222. * Gets the physics time capture status
  114223. */
  114224. /**
  114225. * Enable or disable the physics time capture
  114226. */
  114227. capturePhysicsTime: boolean;
  114228. /**
  114229. * Gets the perf counter used for animations time
  114230. */
  114231. readonly animationsTimeCounter: PerfCounter;
  114232. /**
  114233. * Gets the animations time capture status
  114234. */
  114235. /**
  114236. * Enable or disable the animations time capture
  114237. */
  114238. captureAnimationsTime: boolean;
  114239. /**
  114240. * Gets the perf counter used for frame time capture
  114241. */
  114242. readonly frameTimeCounter: PerfCounter;
  114243. /**
  114244. * Gets the frame time capture status
  114245. */
  114246. /**
  114247. * Enable or disable the frame time capture
  114248. */
  114249. captureFrameTime: boolean;
  114250. /**
  114251. * Gets the perf counter used for inter-frames time capture
  114252. */
  114253. readonly interFrameTimeCounter: PerfCounter;
  114254. /**
  114255. * Gets the inter-frames time capture status
  114256. */
  114257. /**
  114258. * Enable or disable the inter-frames time capture
  114259. */
  114260. captureInterFrameTime: boolean;
  114261. /**
  114262. * Gets the perf counter used for render time capture
  114263. */
  114264. readonly renderTimeCounter: PerfCounter;
  114265. /**
  114266. * Gets the render time capture status
  114267. */
  114268. /**
  114269. * Enable or disable the render time capture
  114270. */
  114271. captureRenderTime: boolean;
  114272. /**
  114273. * Gets the perf counter used for camera render time capture
  114274. */
  114275. readonly cameraRenderTimeCounter: PerfCounter;
  114276. /**
  114277. * Gets the camera render time capture status
  114278. */
  114279. /**
  114280. * Enable or disable the camera render time capture
  114281. */
  114282. captureCameraRenderTime: boolean;
  114283. /**
  114284. * Gets the perf counter used for draw calls
  114285. */
  114286. readonly drawCallsCounter: PerfCounter;
  114287. /**
  114288. * Instantiates a new scene instrumentation.
  114289. * This class can be used to get instrumentation data from a Babylon engine
  114290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114291. * @param scene Defines the scene to instrument
  114292. */
  114293. constructor(
  114294. /**
  114295. * Defines the scene to instrument
  114296. */
  114297. scene: Scene);
  114298. /**
  114299. * Dispose and release associated resources.
  114300. */
  114301. dispose(): void;
  114302. }
  114303. }
  114304. declare module BABYLON {
  114305. /** @hidden */
  114306. export var glowMapGenerationPixelShader: {
  114307. name: string;
  114308. shader: string;
  114309. };
  114310. }
  114311. declare module BABYLON {
  114312. /** @hidden */
  114313. export var glowMapGenerationVertexShader: {
  114314. name: string;
  114315. shader: string;
  114316. };
  114317. }
  114318. declare module BABYLON {
  114319. /**
  114320. * Effect layer options. This helps customizing the behaviour
  114321. * of the effect layer.
  114322. */
  114323. export interface IEffectLayerOptions {
  114324. /**
  114325. * Multiplication factor apply to the canvas size to compute the render target size
  114326. * used to generated the objects (the smaller the faster).
  114327. */
  114328. mainTextureRatio: number;
  114329. /**
  114330. * Enforces a fixed size texture to ensure effect stability across devices.
  114331. */
  114332. mainTextureFixedSize?: number;
  114333. /**
  114334. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114335. */
  114336. alphaBlendingMode: number;
  114337. /**
  114338. * The camera attached to the layer.
  114339. */
  114340. camera: Nullable<Camera>;
  114341. /**
  114342. * The rendering group to draw the layer in.
  114343. */
  114344. renderingGroupId: number;
  114345. }
  114346. /**
  114347. * The effect layer Helps adding post process effect blended with the main pass.
  114348. *
  114349. * This can be for instance use to generate glow or higlight effects on the scene.
  114350. *
  114351. * The effect layer class can not be used directly and is intented to inherited from to be
  114352. * customized per effects.
  114353. */
  114354. export abstract class EffectLayer {
  114355. private _vertexBuffers;
  114356. private _indexBuffer;
  114357. private _cachedDefines;
  114358. private _effectLayerMapGenerationEffect;
  114359. private _effectLayerOptions;
  114360. private _mergeEffect;
  114361. protected _scene: Scene;
  114362. protected _engine: Engine;
  114363. protected _maxSize: number;
  114364. protected _mainTextureDesiredSize: ISize;
  114365. protected _mainTexture: RenderTargetTexture;
  114366. protected _shouldRender: boolean;
  114367. protected _postProcesses: PostProcess[];
  114368. protected _textures: BaseTexture[];
  114369. protected _emissiveTextureAndColor: {
  114370. texture: Nullable<BaseTexture>;
  114371. color: Color4;
  114372. };
  114373. /**
  114374. * The name of the layer
  114375. */
  114376. name: string;
  114377. /**
  114378. * The clear color of the texture used to generate the glow map.
  114379. */
  114380. neutralColor: Color4;
  114381. /**
  114382. * Specifies wether the highlight layer is enabled or not.
  114383. */
  114384. isEnabled: boolean;
  114385. /**
  114386. * Gets the camera attached to the layer.
  114387. */
  114388. readonly camera: Nullable<Camera>;
  114389. /**
  114390. * Gets the rendering group id the layer should render in.
  114391. */
  114392. renderingGroupId: number;
  114393. /**
  114394. * An event triggered when the effect layer has been disposed.
  114395. */
  114396. onDisposeObservable: Observable<EffectLayer>;
  114397. /**
  114398. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114399. */
  114400. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114401. /**
  114402. * An event triggered when the generated texture is being merged in the scene.
  114403. */
  114404. onBeforeComposeObservable: Observable<EffectLayer>;
  114405. /**
  114406. * An event triggered when the generated texture has been merged in the scene.
  114407. */
  114408. onAfterComposeObservable: Observable<EffectLayer>;
  114409. /**
  114410. * An event triggered when the efffect layer changes its size.
  114411. */
  114412. onSizeChangedObservable: Observable<EffectLayer>;
  114413. /** @hidden */
  114414. static _SceneComponentInitialization: (scene: Scene) => void;
  114415. /**
  114416. * Instantiates a new effect Layer and references it in the scene.
  114417. * @param name The name of the layer
  114418. * @param scene The scene to use the layer in
  114419. */
  114420. constructor(
  114421. /** The Friendly of the effect in the scene */
  114422. name: string, scene: Scene);
  114423. /**
  114424. * Get the effect name of the layer.
  114425. * @return The effect name
  114426. */
  114427. abstract getEffectName(): string;
  114428. /**
  114429. * Checks for the readiness of the element composing the layer.
  114430. * @param subMesh the mesh to check for
  114431. * @param useInstances specify wether or not to use instances to render the mesh
  114432. * @return true if ready otherwise, false
  114433. */
  114434. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114435. /**
  114436. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114437. * @returns true if the effect requires stencil during the main canvas render pass.
  114438. */
  114439. abstract needStencil(): boolean;
  114440. /**
  114441. * Create the merge effect. This is the shader use to blit the information back
  114442. * to the main canvas at the end of the scene rendering.
  114443. * @returns The effect containing the shader used to merge the effect on the main canvas
  114444. */
  114445. protected abstract _createMergeEffect(): Effect;
  114446. /**
  114447. * Creates the render target textures and post processes used in the effect layer.
  114448. */
  114449. protected abstract _createTextureAndPostProcesses(): void;
  114450. /**
  114451. * Implementation specific of rendering the generating effect on the main canvas.
  114452. * @param effect The effect used to render through
  114453. */
  114454. protected abstract _internalRender(effect: Effect): void;
  114455. /**
  114456. * Sets the required values for both the emissive texture and and the main color.
  114457. */
  114458. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114459. /**
  114460. * Free any resources and references associated to a mesh.
  114461. * Internal use
  114462. * @param mesh The mesh to free.
  114463. */
  114464. abstract _disposeMesh(mesh: Mesh): void;
  114465. /**
  114466. * Serializes this layer (Glow or Highlight for example)
  114467. * @returns a serialized layer object
  114468. */
  114469. abstract serialize?(): any;
  114470. /**
  114471. * Initializes the effect layer with the required options.
  114472. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114473. */
  114474. protected _init(options: Partial<IEffectLayerOptions>): void;
  114475. /**
  114476. * Generates the index buffer of the full screen quad blending to the main canvas.
  114477. */
  114478. private _generateIndexBuffer;
  114479. /**
  114480. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114481. */
  114482. private _generateVertexBuffer;
  114483. /**
  114484. * Sets the main texture desired size which is the closest power of two
  114485. * of the engine canvas size.
  114486. */
  114487. private _setMainTextureSize;
  114488. /**
  114489. * Creates the main texture for the effect layer.
  114490. */
  114491. protected _createMainTexture(): void;
  114492. /**
  114493. * Adds specific effects defines.
  114494. * @param defines The defines to add specifics to.
  114495. */
  114496. protected _addCustomEffectDefines(defines: string[]): void;
  114497. /**
  114498. * Checks for the readiness of the element composing the layer.
  114499. * @param subMesh the mesh to check for
  114500. * @param useInstances specify wether or not to use instances to render the mesh
  114501. * @param emissiveTexture the associated emissive texture used to generate the glow
  114502. * @return true if ready otherwise, false
  114503. */
  114504. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114505. /**
  114506. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114507. */
  114508. render(): void;
  114509. /**
  114510. * Determine if a given mesh will be used in the current effect.
  114511. * @param mesh mesh to test
  114512. * @returns true if the mesh will be used
  114513. */
  114514. hasMesh(mesh: AbstractMesh): boolean;
  114515. /**
  114516. * Returns true if the layer contains information to display, otherwise false.
  114517. * @returns true if the glow layer should be rendered
  114518. */
  114519. shouldRender(): boolean;
  114520. /**
  114521. * Returns true if the mesh should render, otherwise false.
  114522. * @param mesh The mesh to render
  114523. * @returns true if it should render otherwise false
  114524. */
  114525. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114526. /**
  114527. * Returns true if the mesh can be rendered, otherwise false.
  114528. * @param mesh The mesh to render
  114529. * @param material The material used on the mesh
  114530. * @returns true if it can be rendered otherwise false
  114531. */
  114532. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114533. /**
  114534. * Returns true if the mesh should render, otherwise false.
  114535. * @param mesh The mesh to render
  114536. * @returns true if it should render otherwise false
  114537. */
  114538. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114539. /**
  114540. * Renders the submesh passed in parameter to the generation map.
  114541. */
  114542. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114543. /**
  114544. * Rebuild the required buffers.
  114545. * @hidden Internal use only.
  114546. */
  114547. _rebuild(): void;
  114548. /**
  114549. * Dispose only the render target textures and post process.
  114550. */
  114551. private _disposeTextureAndPostProcesses;
  114552. /**
  114553. * Dispose the highlight layer and free resources.
  114554. */
  114555. dispose(): void;
  114556. /**
  114557. * Gets the class name of the effect layer
  114558. * @returns the string with the class name of the effect layer
  114559. */
  114560. getClassName(): string;
  114561. /**
  114562. * Creates an effect layer from parsed effect layer data
  114563. * @param parsedEffectLayer defines effect layer data
  114564. * @param scene defines the current scene
  114565. * @param rootUrl defines the root URL containing the effect layer information
  114566. * @returns a parsed effect Layer
  114567. */
  114568. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114569. }
  114570. }
  114571. declare module BABYLON {
  114572. interface AbstractScene {
  114573. /**
  114574. * The list of effect layers (highlights/glow) added to the scene
  114575. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114576. * @see http://doc.babylonjs.com/how_to/glow_layer
  114577. */
  114578. effectLayers: Array<EffectLayer>;
  114579. /**
  114580. * Removes the given effect layer from this scene.
  114581. * @param toRemove defines the effect layer to remove
  114582. * @returns the index of the removed effect layer
  114583. */
  114584. removeEffectLayer(toRemove: EffectLayer): number;
  114585. /**
  114586. * Adds the given effect layer to this scene
  114587. * @param newEffectLayer defines the effect layer to add
  114588. */
  114589. addEffectLayer(newEffectLayer: EffectLayer): void;
  114590. }
  114591. /**
  114592. * Defines the layer scene component responsible to manage any effect layers
  114593. * in a given scene.
  114594. */
  114595. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114596. /**
  114597. * The component name helpfull to identify the component in the list of scene components.
  114598. */
  114599. readonly name: string;
  114600. /**
  114601. * The scene the component belongs to.
  114602. */
  114603. scene: Scene;
  114604. private _engine;
  114605. private _renderEffects;
  114606. private _needStencil;
  114607. private _previousStencilState;
  114608. /**
  114609. * Creates a new instance of the component for the given scene
  114610. * @param scene Defines the scene to register the component in
  114611. */
  114612. constructor(scene: Scene);
  114613. /**
  114614. * Registers the component in a given scene
  114615. */
  114616. register(): void;
  114617. /**
  114618. * Rebuilds the elements related to this component in case of
  114619. * context lost for instance.
  114620. */
  114621. rebuild(): void;
  114622. /**
  114623. * Serializes the component data to the specified json object
  114624. * @param serializationObject The object to serialize to
  114625. */
  114626. serialize(serializationObject: any): void;
  114627. /**
  114628. * Adds all the elements from the container to the scene
  114629. * @param container the container holding the elements
  114630. */
  114631. addFromContainer(container: AbstractScene): void;
  114632. /**
  114633. * Removes all the elements in the container from the scene
  114634. * @param container contains the elements to remove
  114635. * @param dispose if the removed element should be disposed (default: false)
  114636. */
  114637. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114638. /**
  114639. * Disposes the component and the associated ressources.
  114640. */
  114641. dispose(): void;
  114642. private _isReadyForMesh;
  114643. private _renderMainTexture;
  114644. private _setStencil;
  114645. private _setStencilBack;
  114646. private _draw;
  114647. private _drawCamera;
  114648. private _drawRenderingGroup;
  114649. }
  114650. }
  114651. declare module BABYLON {
  114652. /** @hidden */
  114653. export var glowMapMergePixelShader: {
  114654. name: string;
  114655. shader: string;
  114656. };
  114657. }
  114658. declare module BABYLON {
  114659. /** @hidden */
  114660. export var glowMapMergeVertexShader: {
  114661. name: string;
  114662. shader: string;
  114663. };
  114664. }
  114665. declare module BABYLON {
  114666. interface AbstractScene {
  114667. /**
  114668. * Return a the first highlight layer of the scene with a given name.
  114669. * @param name The name of the highlight layer to look for.
  114670. * @return The highlight layer if found otherwise null.
  114671. */
  114672. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114673. }
  114674. /**
  114675. * Glow layer options. This helps customizing the behaviour
  114676. * of the glow layer.
  114677. */
  114678. export interface IGlowLayerOptions {
  114679. /**
  114680. * Multiplication factor apply to the canvas size to compute the render target size
  114681. * used to generated the glowing objects (the smaller the faster).
  114682. */
  114683. mainTextureRatio: number;
  114684. /**
  114685. * Enforces a fixed size texture to ensure resize independant blur.
  114686. */
  114687. mainTextureFixedSize?: number;
  114688. /**
  114689. * How big is the kernel of the blur texture.
  114690. */
  114691. blurKernelSize: number;
  114692. /**
  114693. * The camera attached to the layer.
  114694. */
  114695. camera: Nullable<Camera>;
  114696. /**
  114697. * Enable MSAA by chosing the number of samples.
  114698. */
  114699. mainTextureSamples?: number;
  114700. /**
  114701. * The rendering group to draw the layer in.
  114702. */
  114703. renderingGroupId: number;
  114704. }
  114705. /**
  114706. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114707. *
  114708. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114709. * glowy meshes to your scene.
  114710. *
  114711. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114712. */
  114713. export class GlowLayer extends EffectLayer {
  114714. /**
  114715. * Effect Name of the layer.
  114716. */
  114717. static readonly EffectName: string;
  114718. /**
  114719. * The default blur kernel size used for the glow.
  114720. */
  114721. static DefaultBlurKernelSize: number;
  114722. /**
  114723. * The default texture size ratio used for the glow.
  114724. */
  114725. static DefaultTextureRatio: number;
  114726. /**
  114727. * Sets the kernel size of the blur.
  114728. */
  114729. /**
  114730. * Gets the kernel size of the blur.
  114731. */
  114732. blurKernelSize: number;
  114733. /**
  114734. * Sets the glow intensity.
  114735. */
  114736. /**
  114737. * Gets the glow intensity.
  114738. */
  114739. intensity: number;
  114740. private _options;
  114741. private _intensity;
  114742. private _horizontalBlurPostprocess1;
  114743. private _verticalBlurPostprocess1;
  114744. private _horizontalBlurPostprocess2;
  114745. private _verticalBlurPostprocess2;
  114746. private _blurTexture1;
  114747. private _blurTexture2;
  114748. private _postProcesses1;
  114749. private _postProcesses2;
  114750. private _includedOnlyMeshes;
  114751. private _excludedMeshes;
  114752. /**
  114753. * Callback used to let the user override the color selection on a per mesh basis
  114754. */
  114755. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114756. /**
  114757. * Callback used to let the user override the texture selection on a per mesh basis
  114758. */
  114759. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114760. /**
  114761. * Instantiates a new glow Layer and references it to the scene.
  114762. * @param name The name of the layer
  114763. * @param scene The scene to use the layer in
  114764. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114765. */
  114766. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114767. /**
  114768. * Get the effect name of the layer.
  114769. * @return The effect name
  114770. */
  114771. getEffectName(): string;
  114772. /**
  114773. * Create the merge effect. This is the shader use to blit the information back
  114774. * to the main canvas at the end of the scene rendering.
  114775. */
  114776. protected _createMergeEffect(): Effect;
  114777. /**
  114778. * Creates the render target textures and post processes used in the glow layer.
  114779. */
  114780. protected _createTextureAndPostProcesses(): void;
  114781. /**
  114782. * Checks for the readiness of the element composing the layer.
  114783. * @param subMesh the mesh to check for
  114784. * @param useInstances specify wether or not to use instances to render the mesh
  114785. * @param emissiveTexture the associated emissive texture used to generate the glow
  114786. * @return true if ready otherwise, false
  114787. */
  114788. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114789. /**
  114790. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114791. */
  114792. needStencil(): boolean;
  114793. /**
  114794. * Returns true if the mesh can be rendered, otherwise false.
  114795. * @param mesh The mesh to render
  114796. * @param material The material used on the mesh
  114797. * @returns true if it can be rendered otherwise false
  114798. */
  114799. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114800. /**
  114801. * Implementation specific of rendering the generating effect on the main canvas.
  114802. * @param effect The effect used to render through
  114803. */
  114804. protected _internalRender(effect: Effect): void;
  114805. /**
  114806. * Sets the required values for both the emissive texture and and the main color.
  114807. */
  114808. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114809. /**
  114810. * Returns true if the mesh should render, otherwise false.
  114811. * @param mesh The mesh to render
  114812. * @returns true if it should render otherwise false
  114813. */
  114814. protected _shouldRenderMesh(mesh: Mesh): boolean;
  114815. /**
  114816. * Adds specific effects defines.
  114817. * @param defines The defines to add specifics to.
  114818. */
  114819. protected _addCustomEffectDefines(defines: string[]): void;
  114820. /**
  114821. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  114822. * @param mesh The mesh to exclude from the glow layer
  114823. */
  114824. addExcludedMesh(mesh: Mesh): void;
  114825. /**
  114826. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  114827. * @param mesh The mesh to remove
  114828. */
  114829. removeExcludedMesh(mesh: Mesh): void;
  114830. /**
  114831. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  114832. * @param mesh The mesh to include in the glow layer
  114833. */
  114834. addIncludedOnlyMesh(mesh: Mesh): void;
  114835. /**
  114836. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  114837. * @param mesh The mesh to remove
  114838. */
  114839. removeIncludedOnlyMesh(mesh: Mesh): void;
  114840. /**
  114841. * Determine if a given mesh will be used in the glow layer
  114842. * @param mesh The mesh to test
  114843. * @returns true if the mesh will be highlighted by the current glow layer
  114844. */
  114845. hasMesh(mesh: AbstractMesh): boolean;
  114846. /**
  114847. * Free any resources and references associated to a mesh.
  114848. * Internal use
  114849. * @param mesh The mesh to free.
  114850. * @hidden
  114851. */
  114852. _disposeMesh(mesh: Mesh): void;
  114853. /**
  114854. * Gets the class name of the effect layer
  114855. * @returns the string with the class name of the effect layer
  114856. */
  114857. getClassName(): string;
  114858. /**
  114859. * Serializes this glow layer
  114860. * @returns a serialized glow layer object
  114861. */
  114862. serialize(): any;
  114863. /**
  114864. * Creates a Glow Layer from parsed glow layer data
  114865. * @param parsedGlowLayer defines glow layer data
  114866. * @param scene defines the current scene
  114867. * @param rootUrl defines the root URL containing the glow layer information
  114868. * @returns a parsed Glow Layer
  114869. */
  114870. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  114871. }
  114872. }
  114873. declare module BABYLON {
  114874. /** @hidden */
  114875. export var glowBlurPostProcessPixelShader: {
  114876. name: string;
  114877. shader: string;
  114878. };
  114879. }
  114880. declare module BABYLON {
  114881. interface AbstractScene {
  114882. /**
  114883. * Return a the first highlight layer of the scene with a given name.
  114884. * @param name The name of the highlight layer to look for.
  114885. * @return The highlight layer if found otherwise null.
  114886. */
  114887. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  114888. }
  114889. /**
  114890. * Highlight layer options. This helps customizing the behaviour
  114891. * of the highlight layer.
  114892. */
  114893. export interface IHighlightLayerOptions {
  114894. /**
  114895. * Multiplication factor apply to the canvas size to compute the render target size
  114896. * used to generated the glowing objects (the smaller the faster).
  114897. */
  114898. mainTextureRatio: number;
  114899. /**
  114900. * Enforces a fixed size texture to ensure resize independant blur.
  114901. */
  114902. mainTextureFixedSize?: number;
  114903. /**
  114904. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  114905. * of the picture to blur (the smaller the faster).
  114906. */
  114907. blurTextureSizeRatio: number;
  114908. /**
  114909. * How big in texel of the blur texture is the vertical blur.
  114910. */
  114911. blurVerticalSize: number;
  114912. /**
  114913. * How big in texel of the blur texture is the horizontal blur.
  114914. */
  114915. blurHorizontalSize: number;
  114916. /**
  114917. * Alpha blending mode used to apply the blur. Default is combine.
  114918. */
  114919. alphaBlendingMode: number;
  114920. /**
  114921. * The camera attached to the layer.
  114922. */
  114923. camera: Nullable<Camera>;
  114924. /**
  114925. * Should we display highlight as a solid stroke?
  114926. */
  114927. isStroke?: boolean;
  114928. /**
  114929. * The rendering group to draw the layer in.
  114930. */
  114931. renderingGroupId: number;
  114932. }
  114933. /**
  114934. * The highlight layer Helps adding a glow effect around a mesh.
  114935. *
  114936. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114937. * glowy meshes to your scene.
  114938. *
  114939. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  114940. */
  114941. export class HighlightLayer extends EffectLayer {
  114942. name: string;
  114943. /**
  114944. * Effect Name of the highlight layer.
  114945. */
  114946. static readonly EffectName: string;
  114947. /**
  114948. * The neutral color used during the preparation of the glow effect.
  114949. * This is black by default as the blend operation is a blend operation.
  114950. */
  114951. static NeutralColor: Color4;
  114952. /**
  114953. * Stencil value used for glowing meshes.
  114954. */
  114955. static GlowingMeshStencilReference: number;
  114956. /**
  114957. * Stencil value used for the other meshes in the scene.
  114958. */
  114959. static NormalMeshStencilReference: number;
  114960. /**
  114961. * Specifies whether or not the inner glow is ACTIVE in the layer.
  114962. */
  114963. innerGlow: boolean;
  114964. /**
  114965. * Specifies whether or not the outer glow is ACTIVE in the layer.
  114966. */
  114967. outerGlow: boolean;
  114968. /**
  114969. * Specifies the horizontal size of the blur.
  114970. */
  114971. /**
  114972. * Gets the horizontal size of the blur.
  114973. */
  114974. blurHorizontalSize: number;
  114975. /**
  114976. * Specifies the vertical size of the blur.
  114977. */
  114978. /**
  114979. * Gets the vertical size of the blur.
  114980. */
  114981. blurVerticalSize: number;
  114982. /**
  114983. * An event triggered when the highlight layer is being blurred.
  114984. */
  114985. onBeforeBlurObservable: Observable<HighlightLayer>;
  114986. /**
  114987. * An event triggered when the highlight layer has been blurred.
  114988. */
  114989. onAfterBlurObservable: Observable<HighlightLayer>;
  114990. private _instanceGlowingMeshStencilReference;
  114991. private _options;
  114992. private _downSamplePostprocess;
  114993. private _horizontalBlurPostprocess;
  114994. private _verticalBlurPostprocess;
  114995. private _blurTexture;
  114996. private _meshes;
  114997. private _excludedMeshes;
  114998. /**
  114999. * Instantiates a new highlight Layer and references it to the scene..
  115000. * @param name The name of the layer
  115001. * @param scene The scene to use the layer in
  115002. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115003. */
  115004. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115005. /**
  115006. * Get the effect name of the layer.
  115007. * @return The effect name
  115008. */
  115009. getEffectName(): string;
  115010. /**
  115011. * Create the merge effect. This is the shader use to blit the information back
  115012. * to the main canvas at the end of the scene rendering.
  115013. */
  115014. protected _createMergeEffect(): Effect;
  115015. /**
  115016. * Creates the render target textures and post processes used in the highlight layer.
  115017. */
  115018. protected _createTextureAndPostProcesses(): void;
  115019. /**
  115020. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115021. */
  115022. needStencil(): boolean;
  115023. /**
  115024. * Checks for the readiness of the element composing the layer.
  115025. * @param subMesh the mesh to check for
  115026. * @param useInstances specify wether or not to use instances to render the mesh
  115027. * @param emissiveTexture the associated emissive texture used to generate the glow
  115028. * @return true if ready otherwise, false
  115029. */
  115030. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115031. /**
  115032. * Implementation specific of rendering the generating effect on the main canvas.
  115033. * @param effect The effect used to render through
  115034. */
  115035. protected _internalRender(effect: Effect): void;
  115036. /**
  115037. * Returns true if the layer contains information to display, otherwise false.
  115038. */
  115039. shouldRender(): boolean;
  115040. /**
  115041. * Returns true if the mesh should render, otherwise false.
  115042. * @param mesh The mesh to render
  115043. * @returns true if it should render otherwise false
  115044. */
  115045. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115046. /**
  115047. * Sets the required values for both the emissive texture and and the main color.
  115048. */
  115049. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115050. /**
  115051. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115052. * @param mesh The mesh to exclude from the highlight layer
  115053. */
  115054. addExcludedMesh(mesh: Mesh): void;
  115055. /**
  115056. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115057. * @param mesh The mesh to highlight
  115058. */
  115059. removeExcludedMesh(mesh: Mesh): void;
  115060. /**
  115061. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115062. * @param mesh mesh to test
  115063. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115064. */
  115065. hasMesh(mesh: AbstractMesh): boolean;
  115066. /**
  115067. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115068. * @param mesh The mesh to highlight
  115069. * @param color The color of the highlight
  115070. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115071. */
  115072. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115073. /**
  115074. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115075. * @param mesh The mesh to highlight
  115076. */
  115077. removeMesh(mesh: Mesh): void;
  115078. /**
  115079. * Force the stencil to the normal expected value for none glowing parts
  115080. */
  115081. private _defaultStencilReference;
  115082. /**
  115083. * Free any resources and references associated to a mesh.
  115084. * Internal use
  115085. * @param mesh The mesh to free.
  115086. * @hidden
  115087. */
  115088. _disposeMesh(mesh: Mesh): void;
  115089. /**
  115090. * Dispose the highlight layer and free resources.
  115091. */
  115092. dispose(): void;
  115093. /**
  115094. * Gets the class name of the effect layer
  115095. * @returns the string with the class name of the effect layer
  115096. */
  115097. getClassName(): string;
  115098. /**
  115099. * Serializes this Highlight layer
  115100. * @returns a serialized Highlight layer object
  115101. */
  115102. serialize(): any;
  115103. /**
  115104. * Creates a Highlight layer from parsed Highlight layer data
  115105. * @param parsedHightlightLayer defines the Highlight layer data
  115106. * @param scene defines the current scene
  115107. * @param rootUrl defines the root URL containing the Highlight layer information
  115108. * @returns a parsed Highlight layer
  115109. */
  115110. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115111. }
  115112. }
  115113. declare module BABYLON {
  115114. interface AbstractScene {
  115115. /**
  115116. * The list of layers (background and foreground) of the scene
  115117. */
  115118. layers: Array<Layer>;
  115119. }
  115120. /**
  115121. * Defines the layer scene component responsible to manage any layers
  115122. * in a given scene.
  115123. */
  115124. export class LayerSceneComponent implements ISceneComponent {
  115125. /**
  115126. * The component name helpfull to identify the component in the list of scene components.
  115127. */
  115128. readonly name: string;
  115129. /**
  115130. * The scene the component belongs to.
  115131. */
  115132. scene: Scene;
  115133. private _engine;
  115134. /**
  115135. * Creates a new instance of the component for the given scene
  115136. * @param scene Defines the scene to register the component in
  115137. */
  115138. constructor(scene: Scene);
  115139. /**
  115140. * Registers the component in a given scene
  115141. */
  115142. register(): void;
  115143. /**
  115144. * Rebuilds the elements related to this component in case of
  115145. * context lost for instance.
  115146. */
  115147. rebuild(): void;
  115148. /**
  115149. * Disposes the component and the associated ressources.
  115150. */
  115151. dispose(): void;
  115152. private _draw;
  115153. private _drawCameraPredicate;
  115154. private _drawCameraBackground;
  115155. private _drawCameraForeground;
  115156. private _drawRenderTargetPredicate;
  115157. private _drawRenderTargetBackground;
  115158. private _drawRenderTargetForeground;
  115159. /**
  115160. * Adds all the elements from the container to the scene
  115161. * @param container the container holding the elements
  115162. */
  115163. addFromContainer(container: AbstractScene): void;
  115164. /**
  115165. * Removes all the elements in the container from the scene
  115166. * @param container contains the elements to remove
  115167. * @param dispose if the removed element should be disposed (default: false)
  115168. */
  115169. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115170. }
  115171. }
  115172. declare module BABYLON {
  115173. /** @hidden */
  115174. export var layerPixelShader: {
  115175. name: string;
  115176. shader: string;
  115177. };
  115178. }
  115179. declare module BABYLON {
  115180. /** @hidden */
  115181. export var layerVertexShader: {
  115182. name: string;
  115183. shader: string;
  115184. };
  115185. }
  115186. declare module BABYLON {
  115187. /**
  115188. * This represents a full screen 2d layer.
  115189. * This can be useful to display a picture in the background of your scene for instance.
  115190. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115191. */
  115192. export class Layer {
  115193. /**
  115194. * Define the name of the layer.
  115195. */
  115196. name: string;
  115197. /**
  115198. * Define the texture the layer should display.
  115199. */
  115200. texture: Nullable<Texture>;
  115201. /**
  115202. * Is the layer in background or foreground.
  115203. */
  115204. isBackground: boolean;
  115205. /**
  115206. * Define the color of the layer (instead of texture).
  115207. */
  115208. color: Color4;
  115209. /**
  115210. * Define the scale of the layer in order to zoom in out of the texture.
  115211. */
  115212. scale: Vector2;
  115213. /**
  115214. * Define an offset for the layer in order to shift the texture.
  115215. */
  115216. offset: Vector2;
  115217. /**
  115218. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115219. */
  115220. alphaBlendingMode: number;
  115221. /**
  115222. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115223. * Alpha test will not mix with the background color in case of transparency.
  115224. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115225. */
  115226. alphaTest: boolean;
  115227. /**
  115228. * Define a mask to restrict the layer to only some of the scene cameras.
  115229. */
  115230. layerMask: number;
  115231. /**
  115232. * Define the list of render target the layer is visible into.
  115233. */
  115234. renderTargetTextures: RenderTargetTexture[];
  115235. /**
  115236. * Define if the layer is only used in renderTarget or if it also
  115237. * renders in the main frame buffer of the canvas.
  115238. */
  115239. renderOnlyInRenderTargetTextures: boolean;
  115240. private _scene;
  115241. private _vertexBuffers;
  115242. private _indexBuffer;
  115243. private _effect;
  115244. private _alphaTestEffect;
  115245. /**
  115246. * An event triggered when the layer is disposed.
  115247. */
  115248. onDisposeObservable: Observable<Layer>;
  115249. private _onDisposeObserver;
  115250. /**
  115251. * Back compatibility with callback before the onDisposeObservable existed.
  115252. * The set callback will be triggered when the layer has been disposed.
  115253. */
  115254. onDispose: () => void;
  115255. /**
  115256. * An event triggered before rendering the scene
  115257. */
  115258. onBeforeRenderObservable: Observable<Layer>;
  115259. private _onBeforeRenderObserver;
  115260. /**
  115261. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115262. * The set callback will be triggered just before rendering the layer.
  115263. */
  115264. onBeforeRender: () => void;
  115265. /**
  115266. * An event triggered after rendering the scene
  115267. */
  115268. onAfterRenderObservable: Observable<Layer>;
  115269. private _onAfterRenderObserver;
  115270. /**
  115271. * Back compatibility with callback before the onAfterRenderObservable existed.
  115272. * The set callback will be triggered just after rendering the layer.
  115273. */
  115274. onAfterRender: () => void;
  115275. /**
  115276. * Instantiates a new layer.
  115277. * This represents a full screen 2d layer.
  115278. * This can be useful to display a picture in the background of your scene for instance.
  115279. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115280. * @param name Define the name of the layer in the scene
  115281. * @param imgUrl Define the url of the texture to display in the layer
  115282. * @param scene Define the scene the layer belongs to
  115283. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115284. * @param color Defines a color for the layer
  115285. */
  115286. constructor(
  115287. /**
  115288. * Define the name of the layer.
  115289. */
  115290. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115291. private _createIndexBuffer;
  115292. /** @hidden */
  115293. _rebuild(): void;
  115294. /**
  115295. * Renders the layer in the scene.
  115296. */
  115297. render(): void;
  115298. /**
  115299. * Disposes and releases the associated ressources.
  115300. */
  115301. dispose(): void;
  115302. }
  115303. }
  115304. declare module BABYLON {
  115305. /** @hidden */
  115306. export var lensFlarePixelShader: {
  115307. name: string;
  115308. shader: string;
  115309. };
  115310. }
  115311. declare module BABYLON {
  115312. /** @hidden */
  115313. export var lensFlareVertexShader: {
  115314. name: string;
  115315. shader: string;
  115316. };
  115317. }
  115318. declare module BABYLON {
  115319. /**
  115320. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115321. * It is usually composed of several `lensFlare`.
  115322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115323. */
  115324. export class LensFlareSystem {
  115325. /**
  115326. * Define the name of the lens flare system
  115327. */
  115328. name: string;
  115329. /**
  115330. * List of lens flares used in this system.
  115331. */
  115332. lensFlares: LensFlare[];
  115333. /**
  115334. * Define a limit from the border the lens flare can be visible.
  115335. */
  115336. borderLimit: number;
  115337. /**
  115338. * Define a viewport border we do not want to see the lens flare in.
  115339. */
  115340. viewportBorder: number;
  115341. /**
  115342. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115343. */
  115344. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115345. /**
  115346. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115347. */
  115348. layerMask: number;
  115349. /**
  115350. * Define the id of the lens flare system in the scene.
  115351. * (equal to name by default)
  115352. */
  115353. id: string;
  115354. private _scene;
  115355. private _emitter;
  115356. private _vertexBuffers;
  115357. private _indexBuffer;
  115358. private _effect;
  115359. private _positionX;
  115360. private _positionY;
  115361. private _isEnabled;
  115362. /** @hidden */
  115363. static _SceneComponentInitialization: (scene: Scene) => void;
  115364. /**
  115365. * Instantiates a lens flare system.
  115366. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115367. * It is usually composed of several `lensFlare`.
  115368. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115369. * @param name Define the name of the lens flare system in the scene
  115370. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115371. * @param scene Define the scene the lens flare system belongs to
  115372. */
  115373. constructor(
  115374. /**
  115375. * Define the name of the lens flare system
  115376. */
  115377. name: string, emitter: any, scene: Scene);
  115378. /**
  115379. * Define if the lens flare system is enabled.
  115380. */
  115381. isEnabled: boolean;
  115382. /**
  115383. * Get the scene the effects belongs to.
  115384. * @returns the scene holding the lens flare system
  115385. */
  115386. getScene(): Scene;
  115387. /**
  115388. * Get the emitter of the lens flare system.
  115389. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115390. * @returns the emitter of the lens flare system
  115391. */
  115392. getEmitter(): any;
  115393. /**
  115394. * Set the emitter of the lens flare system.
  115395. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115396. * @param newEmitter Define the new emitter of the system
  115397. */
  115398. setEmitter(newEmitter: any): void;
  115399. /**
  115400. * Get the lens flare system emitter position.
  115401. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115402. * @returns the position
  115403. */
  115404. getEmitterPosition(): Vector3;
  115405. /**
  115406. * @hidden
  115407. */
  115408. computeEffectivePosition(globalViewport: Viewport): boolean;
  115409. /** @hidden */
  115410. _isVisible(): boolean;
  115411. /**
  115412. * @hidden
  115413. */
  115414. render(): boolean;
  115415. /**
  115416. * Dispose and release the lens flare with its associated resources.
  115417. */
  115418. dispose(): void;
  115419. /**
  115420. * Parse a lens flare system from a JSON repressentation
  115421. * @param parsedLensFlareSystem Define the JSON to parse
  115422. * @param scene Define the scene the parsed system should be instantiated in
  115423. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115424. * @returns the parsed system
  115425. */
  115426. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115427. /**
  115428. * Serialize the current Lens Flare System into a JSON representation.
  115429. * @returns the serialized JSON
  115430. */
  115431. serialize(): any;
  115432. }
  115433. }
  115434. declare module BABYLON {
  115435. /**
  115436. * This represents one of the lens effect in a `lensFlareSystem`.
  115437. * It controls one of the indiviual texture used in the effect.
  115438. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115439. */
  115440. export class LensFlare {
  115441. /**
  115442. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115443. */
  115444. size: number;
  115445. /**
  115446. * 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.
  115447. */
  115448. position: number;
  115449. /**
  115450. * Define the lens color.
  115451. */
  115452. color: Color3;
  115453. /**
  115454. * Define the lens texture.
  115455. */
  115456. texture: Nullable<Texture>;
  115457. /**
  115458. * Define the alpha mode to render this particular lens.
  115459. */
  115460. alphaMode: number;
  115461. private _system;
  115462. /**
  115463. * Creates a new Lens Flare.
  115464. * This represents one of the lens effect in a `lensFlareSystem`.
  115465. * It controls one of the indiviual texture used in the effect.
  115466. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115467. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115468. * @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.
  115469. * @param color Define the lens color
  115470. * @param imgUrl Define the lens texture url
  115471. * @param system Define the `lensFlareSystem` this flare is part of
  115472. * @returns The newly created Lens Flare
  115473. */
  115474. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115475. /**
  115476. * Instantiates a new Lens Flare.
  115477. * This represents one of the lens effect in a `lensFlareSystem`.
  115478. * It controls one of the indiviual texture used in the effect.
  115479. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115480. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115481. * @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.
  115482. * @param color Define the lens color
  115483. * @param imgUrl Define the lens texture url
  115484. * @param system Define the `lensFlareSystem` this flare is part of
  115485. */
  115486. constructor(
  115487. /**
  115488. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115489. */
  115490. size: number,
  115491. /**
  115492. * 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.
  115493. */
  115494. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115495. /**
  115496. * Dispose and release the lens flare with its associated resources.
  115497. */
  115498. dispose(): void;
  115499. }
  115500. }
  115501. declare module BABYLON {
  115502. interface AbstractScene {
  115503. /**
  115504. * The list of lens flare system added to the scene
  115505. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115506. */
  115507. lensFlareSystems: Array<LensFlareSystem>;
  115508. /**
  115509. * Removes the given lens flare system from this scene.
  115510. * @param toRemove The lens flare system to remove
  115511. * @returns The index of the removed lens flare system
  115512. */
  115513. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115514. /**
  115515. * Adds the given lens flare system to this scene
  115516. * @param newLensFlareSystem The lens flare system to add
  115517. */
  115518. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115519. /**
  115520. * Gets a lens flare system using its name
  115521. * @param name defines the name to look for
  115522. * @returns the lens flare system or null if not found
  115523. */
  115524. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115525. /**
  115526. * Gets a lens flare system using its id
  115527. * @param id defines the id to look for
  115528. * @returns the lens flare system or null if not found
  115529. */
  115530. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115531. }
  115532. /**
  115533. * Defines the lens flare scene component responsible to manage any lens flares
  115534. * in a given scene.
  115535. */
  115536. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115537. /**
  115538. * The component name helpfull to identify the component in the list of scene components.
  115539. */
  115540. readonly name: string;
  115541. /**
  115542. * The scene the component belongs to.
  115543. */
  115544. scene: Scene;
  115545. /**
  115546. * Creates a new instance of the component for the given scene
  115547. * @param scene Defines the scene to register the component in
  115548. */
  115549. constructor(scene: Scene);
  115550. /**
  115551. * Registers the component in a given scene
  115552. */
  115553. register(): void;
  115554. /**
  115555. * Rebuilds the elements related to this component in case of
  115556. * context lost for instance.
  115557. */
  115558. rebuild(): void;
  115559. /**
  115560. * Adds all the elements from the container to the scene
  115561. * @param container the container holding the elements
  115562. */
  115563. addFromContainer(container: AbstractScene): void;
  115564. /**
  115565. * Removes all the elements in the container from the scene
  115566. * @param container contains the elements to remove
  115567. * @param dispose if the removed element should be disposed (default: false)
  115568. */
  115569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115570. /**
  115571. * Serializes the component data to the specified json object
  115572. * @param serializationObject The object to serialize to
  115573. */
  115574. serialize(serializationObject: any): void;
  115575. /**
  115576. * Disposes the component and the associated ressources.
  115577. */
  115578. dispose(): void;
  115579. private _draw;
  115580. }
  115581. }
  115582. declare module BABYLON {
  115583. /**
  115584. * Defines the shadow generator component responsible to manage any shadow generators
  115585. * in a given scene.
  115586. */
  115587. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115588. /**
  115589. * The component name helpfull to identify the component in the list of scene components.
  115590. */
  115591. readonly name: string;
  115592. /**
  115593. * The scene the component belongs to.
  115594. */
  115595. scene: Scene;
  115596. /**
  115597. * Creates a new instance of the component for the given scene
  115598. * @param scene Defines the scene to register the component in
  115599. */
  115600. constructor(scene: Scene);
  115601. /**
  115602. * Registers the component in a given scene
  115603. */
  115604. register(): void;
  115605. /**
  115606. * Rebuilds the elements related to this component in case of
  115607. * context lost for instance.
  115608. */
  115609. rebuild(): void;
  115610. /**
  115611. * Serializes the component data to the specified json object
  115612. * @param serializationObject The object to serialize to
  115613. */
  115614. serialize(serializationObject: any): void;
  115615. /**
  115616. * Adds all the elements from the container to the scene
  115617. * @param container the container holding the elements
  115618. */
  115619. addFromContainer(container: AbstractScene): void;
  115620. /**
  115621. * Removes all the elements in the container from the scene
  115622. * @param container contains the elements to remove
  115623. * @param dispose if the removed element should be disposed (default: false)
  115624. */
  115625. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115626. /**
  115627. * Rebuilds the elements related to this component in case of
  115628. * context lost for instance.
  115629. */
  115630. dispose(): void;
  115631. private _gatherRenderTargets;
  115632. }
  115633. }
  115634. declare module BABYLON {
  115635. /**
  115636. * A point light is a light defined by an unique point in world space.
  115637. * The light is emitted in every direction from this point.
  115638. * A good example of a point light is a standard light bulb.
  115639. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115640. */
  115641. export class PointLight extends ShadowLight {
  115642. private _shadowAngle;
  115643. /**
  115644. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115645. * This specifies what angle the shadow will use to be created.
  115646. *
  115647. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115648. */
  115649. /**
  115650. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115651. * This specifies what angle the shadow will use to be created.
  115652. *
  115653. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115654. */
  115655. shadowAngle: number;
  115656. /**
  115657. * Gets the direction if it has been set.
  115658. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115659. */
  115660. /**
  115661. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115662. */
  115663. direction: Vector3;
  115664. /**
  115665. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115666. * A PointLight emits the light in every direction.
  115667. * It can cast shadows.
  115668. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115669. * ```javascript
  115670. * var pointLight = new PointLight("pl", camera.position, scene);
  115671. * ```
  115672. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115673. * @param name The light friendly name
  115674. * @param position The position of the point light in the scene
  115675. * @param scene The scene the lights belongs to
  115676. */
  115677. constructor(name: string, position: Vector3, scene: Scene);
  115678. /**
  115679. * Returns the string "PointLight"
  115680. * @returns the class name
  115681. */
  115682. getClassName(): string;
  115683. /**
  115684. * Returns the integer 0.
  115685. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115686. */
  115687. getTypeID(): number;
  115688. /**
  115689. * Specifies wether or not the shadowmap should be a cube texture.
  115690. * @returns true if the shadowmap needs to be a cube texture.
  115691. */
  115692. needCube(): boolean;
  115693. /**
  115694. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115695. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115696. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115697. */
  115698. getShadowDirection(faceIndex?: number): Vector3;
  115699. /**
  115700. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115701. * - fov = PI / 2
  115702. * - aspect ratio : 1.0
  115703. * - z-near and far equal to the active camera minZ and maxZ.
  115704. * Returns the PointLight.
  115705. */
  115706. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115707. protected _buildUniformLayout(): void;
  115708. /**
  115709. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115710. * @param effect The effect to update
  115711. * @param lightIndex The index of the light in the effect to update
  115712. * @returns The point light
  115713. */
  115714. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115715. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115716. /**
  115717. * Prepares the list of defines specific to the light type.
  115718. * @param defines the list of defines
  115719. * @param lightIndex defines the index of the light for the effect
  115720. */
  115721. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115722. }
  115723. }
  115724. declare module BABYLON {
  115725. /**
  115726. * Header information of HDR texture files.
  115727. */
  115728. export interface HDRInfo {
  115729. /**
  115730. * The height of the texture in pixels.
  115731. */
  115732. height: number;
  115733. /**
  115734. * The width of the texture in pixels.
  115735. */
  115736. width: number;
  115737. /**
  115738. * The index of the beginning of the data in the binary file.
  115739. */
  115740. dataPosition: number;
  115741. }
  115742. /**
  115743. * This groups tools to convert HDR texture to native colors array.
  115744. */
  115745. export class HDRTools {
  115746. private static Ldexp;
  115747. private static Rgbe2float;
  115748. private static readStringLine;
  115749. /**
  115750. * Reads header information from an RGBE texture stored in a native array.
  115751. * More information on this format are available here:
  115752. * https://en.wikipedia.org/wiki/RGBE_image_format
  115753. *
  115754. * @param uint8array The binary file stored in native array.
  115755. * @return The header information.
  115756. */
  115757. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115758. /**
  115759. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115760. * This RGBE texture needs to store the information as a panorama.
  115761. *
  115762. * More information on this format are available here:
  115763. * https://en.wikipedia.org/wiki/RGBE_image_format
  115764. *
  115765. * @param buffer The binary file stored in an array buffer.
  115766. * @param size The expected size of the extracted cubemap.
  115767. * @return The Cube Map information.
  115768. */
  115769. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115770. /**
  115771. * Returns the pixels data extracted from an RGBE texture.
  115772. * This pixels will be stored left to right up to down in the R G B order in one array.
  115773. *
  115774. * More information on this format are available here:
  115775. * https://en.wikipedia.org/wiki/RGBE_image_format
  115776. *
  115777. * @param uint8array The binary file stored in an array buffer.
  115778. * @param hdrInfo The header information of the file.
  115779. * @return The pixels data in RGB right to left up to down order.
  115780. */
  115781. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  115782. private static RGBE_ReadPixels_RLE;
  115783. }
  115784. }
  115785. declare module BABYLON {
  115786. /**
  115787. * This represents a texture coming from an HDR input.
  115788. *
  115789. * The only supported format is currently panorama picture stored in RGBE format.
  115790. * Example of such files can be found on HDRLib: http://hdrlib.com/
  115791. */
  115792. export class HDRCubeTexture extends BaseTexture {
  115793. private static _facesMapping;
  115794. private _generateHarmonics;
  115795. private _noMipmap;
  115796. private _textureMatrix;
  115797. private _size;
  115798. private _onLoad;
  115799. private _onError;
  115800. /**
  115801. * The texture URL.
  115802. */
  115803. url: string;
  115804. /**
  115805. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  115806. */
  115807. coordinatesMode: number;
  115808. protected _isBlocking: boolean;
  115809. /**
  115810. * Sets wether or not the texture is blocking during loading.
  115811. */
  115812. /**
  115813. * Gets wether or not the texture is blocking during loading.
  115814. */
  115815. isBlocking: boolean;
  115816. protected _rotationY: number;
  115817. /**
  115818. * Sets texture matrix rotation angle around Y axis in radians.
  115819. */
  115820. /**
  115821. * Gets texture matrix rotation angle around Y axis radians.
  115822. */
  115823. rotationY: number;
  115824. /**
  115825. * Gets or sets the center of the bounding box associated with the cube texture
  115826. * It must define where the camera used to render the texture was set
  115827. */
  115828. boundingBoxPosition: Vector3;
  115829. private _boundingBoxSize;
  115830. /**
  115831. * Gets or sets the size of the bounding box associated with the cube texture
  115832. * When defined, the cubemap will switch to local mode
  115833. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  115834. * @example https://www.babylonjs-playground.com/#RNASML
  115835. */
  115836. boundingBoxSize: Vector3;
  115837. /**
  115838. * Instantiates an HDRTexture from the following parameters.
  115839. *
  115840. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  115841. * @param scene The scene the texture will be used in
  115842. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115843. * @param noMipmap Forces to not generate the mipmap if true
  115844. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  115845. * @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)
  115846. * @param reserved Reserved flag for internal use.
  115847. */
  115848. 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>);
  115849. /**
  115850. * Get the current class name of the texture useful for serialization or dynamic coding.
  115851. * @returns "HDRCubeTexture"
  115852. */
  115853. getClassName(): string;
  115854. /**
  115855. * Occurs when the file is raw .hdr file.
  115856. */
  115857. private loadTexture;
  115858. clone(): HDRCubeTexture;
  115859. delayLoad(): void;
  115860. /**
  115861. * Get the texture reflection matrix used to rotate/transform the reflection.
  115862. * @returns the reflection matrix
  115863. */
  115864. getReflectionTextureMatrix(): Matrix;
  115865. /**
  115866. * Set the texture reflection matrix used to rotate/transform the reflection.
  115867. * @param value Define the reflection matrix to set
  115868. */
  115869. setReflectionTextureMatrix(value: Matrix): void;
  115870. /**
  115871. * Parses a JSON representation of an HDR Texture in order to create the texture
  115872. * @param parsedTexture Define the JSON representation
  115873. * @param scene Define the scene the texture should be created in
  115874. * @param rootUrl Define the root url in case we need to load relative dependencies
  115875. * @returns the newly created texture after parsing
  115876. */
  115877. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  115878. serialize(): any;
  115879. }
  115880. }
  115881. declare module BABYLON {
  115882. /**
  115883. * Class used to control physics engine
  115884. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115885. */
  115886. export class PhysicsEngine implements IPhysicsEngine {
  115887. private _physicsPlugin;
  115888. /**
  115889. * Global value used to control the smallest number supported by the simulation
  115890. */
  115891. static Epsilon: number;
  115892. private _impostors;
  115893. private _joints;
  115894. /**
  115895. * Gets the gravity vector used by the simulation
  115896. */
  115897. gravity: Vector3;
  115898. /**
  115899. * Factory used to create the default physics plugin.
  115900. * @returns The default physics plugin
  115901. */
  115902. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  115903. /**
  115904. * Creates a new Physics Engine
  115905. * @param gravity defines the gravity vector used by the simulation
  115906. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  115907. */
  115908. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  115909. /**
  115910. * Sets the gravity vector used by the simulation
  115911. * @param gravity defines the gravity vector to use
  115912. */
  115913. setGravity(gravity: Vector3): void;
  115914. /**
  115915. * Set the time step of the physics engine.
  115916. * Default is 1/60.
  115917. * To slow it down, enter 1/600 for example.
  115918. * To speed it up, 1/30
  115919. * @param newTimeStep defines the new timestep to apply to this world.
  115920. */
  115921. setTimeStep(newTimeStep?: number): void;
  115922. /**
  115923. * Get the time step of the physics engine.
  115924. * @returns the current time step
  115925. */
  115926. getTimeStep(): number;
  115927. /**
  115928. * Release all resources
  115929. */
  115930. dispose(): void;
  115931. /**
  115932. * Gets the name of the current physics plugin
  115933. * @returns the name of the plugin
  115934. */
  115935. getPhysicsPluginName(): string;
  115936. /**
  115937. * Adding a new impostor for the impostor tracking.
  115938. * This will be done by the impostor itself.
  115939. * @param impostor the impostor to add
  115940. */
  115941. addImpostor(impostor: PhysicsImpostor): void;
  115942. /**
  115943. * Remove an impostor from the engine.
  115944. * This impostor and its mesh will not longer be updated by the physics engine.
  115945. * @param impostor the impostor to remove
  115946. */
  115947. removeImpostor(impostor: PhysicsImpostor): void;
  115948. /**
  115949. * Add a joint to the physics engine
  115950. * @param mainImpostor defines the main impostor to which the joint is added.
  115951. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  115952. * @param joint defines the joint that will connect both impostors.
  115953. */
  115954. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115955. /**
  115956. * Removes a joint from the simulation
  115957. * @param mainImpostor defines the impostor used with the joint
  115958. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  115959. * @param joint defines the joint to remove
  115960. */
  115961. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  115962. /**
  115963. * Called by the scene. No need to call it.
  115964. * @param delta defines the timespam between frames
  115965. */
  115966. _step(delta: number): void;
  115967. /**
  115968. * Gets the current plugin used to run the simulation
  115969. * @returns current plugin
  115970. */
  115971. getPhysicsPlugin(): IPhysicsEnginePlugin;
  115972. /**
  115973. * Gets the list of physic impostors
  115974. * @returns an array of PhysicsImpostor
  115975. */
  115976. getImpostors(): Array<PhysicsImpostor>;
  115977. /**
  115978. * Gets the impostor for a physics enabled object
  115979. * @param object defines the object impersonated by the impostor
  115980. * @returns the PhysicsImpostor or null if not found
  115981. */
  115982. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  115983. /**
  115984. * Gets the impostor for a physics body object
  115985. * @param body defines physics body used by the impostor
  115986. * @returns the PhysicsImpostor or null if not found
  115987. */
  115988. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  115989. /**
  115990. * Does a raycast in the physics world
  115991. * @param from when should the ray start?
  115992. * @param to when should the ray end?
  115993. * @returns PhysicsRaycastResult
  115994. */
  115995. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  115996. }
  115997. }
  115998. declare module BABYLON {
  115999. /** @hidden */
  116000. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116001. private _useDeltaForWorldStep;
  116002. world: any;
  116003. name: string;
  116004. private _physicsMaterials;
  116005. private _fixedTimeStep;
  116006. private _cannonRaycastResult;
  116007. private _raycastResult;
  116008. private _physicsBodysToRemoveAfterStep;
  116009. BJSCANNON: any;
  116010. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116011. setGravity(gravity: Vector3): void;
  116012. setTimeStep(timeStep: number): void;
  116013. getTimeStep(): number;
  116014. executeStep(delta: number): void;
  116015. private _removeMarkedPhysicsBodiesFromWorld;
  116016. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116017. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116018. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116019. private _processChildMeshes;
  116020. removePhysicsBody(impostor: PhysicsImpostor): void;
  116021. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116022. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116023. private _addMaterial;
  116024. private _checkWithEpsilon;
  116025. private _createShape;
  116026. private _createHeightmap;
  116027. private _minus90X;
  116028. private _plus90X;
  116029. private _tmpPosition;
  116030. private _tmpDeltaPosition;
  116031. private _tmpUnityRotation;
  116032. private _updatePhysicsBodyTransformation;
  116033. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116034. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116035. isSupported(): boolean;
  116036. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116037. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116038. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116039. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116040. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116041. getBodyMass(impostor: PhysicsImpostor): number;
  116042. getBodyFriction(impostor: PhysicsImpostor): number;
  116043. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116044. getBodyRestitution(impostor: PhysicsImpostor): number;
  116045. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116046. sleepBody(impostor: PhysicsImpostor): void;
  116047. wakeUpBody(impostor: PhysicsImpostor): void;
  116048. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116049. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116050. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116051. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116052. getRadius(impostor: PhysicsImpostor): number;
  116053. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116054. dispose(): void;
  116055. private _extendNamespace;
  116056. /**
  116057. * Does a raycast in the physics world
  116058. * @param from when should the ray start?
  116059. * @param to when should the ray end?
  116060. * @returns PhysicsRaycastResult
  116061. */
  116062. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116063. }
  116064. }
  116065. declare module BABYLON {
  116066. /** @hidden */
  116067. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116068. world: any;
  116069. name: string;
  116070. BJSOIMO: any;
  116071. private _raycastResult;
  116072. constructor(iterations?: number, oimoInjection?: any);
  116073. setGravity(gravity: Vector3): void;
  116074. setTimeStep(timeStep: number): void;
  116075. getTimeStep(): number;
  116076. private _tmpImpostorsArray;
  116077. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116078. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116079. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116080. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116081. private _tmpPositionVector;
  116082. removePhysicsBody(impostor: PhysicsImpostor): void;
  116083. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116084. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116085. isSupported(): boolean;
  116086. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116087. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116088. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116089. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116090. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116091. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116092. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116093. getBodyMass(impostor: PhysicsImpostor): number;
  116094. getBodyFriction(impostor: PhysicsImpostor): number;
  116095. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116096. getBodyRestitution(impostor: PhysicsImpostor): number;
  116097. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116098. sleepBody(impostor: PhysicsImpostor): void;
  116099. wakeUpBody(impostor: PhysicsImpostor): void;
  116100. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116101. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116102. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116103. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116104. getRadius(impostor: PhysicsImpostor): number;
  116105. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116106. dispose(): void;
  116107. /**
  116108. * Does a raycast in the physics world
  116109. * @param from when should the ray start?
  116110. * @param to when should the ray end?
  116111. * @returns PhysicsRaycastResult
  116112. */
  116113. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116114. }
  116115. }
  116116. declare module BABYLON {
  116117. /**
  116118. * Class containing static functions to help procedurally build meshes
  116119. */
  116120. export class RibbonBuilder {
  116121. /**
  116122. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116123. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116124. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116125. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116126. * * 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
  116127. * * 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
  116128. * * 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
  116129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116130. * * 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
  116131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116132. * * 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
  116133. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116134. * * 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
  116135. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116137. * @param name defines the name of the mesh
  116138. * @param options defines the options used to create the mesh
  116139. * @param scene defines the hosting scene
  116140. * @returns the ribbon mesh
  116141. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116142. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116143. */
  116144. static CreateRibbon(name: string, options: {
  116145. pathArray: Vector3[][];
  116146. closeArray?: boolean;
  116147. closePath?: boolean;
  116148. offset?: number;
  116149. updatable?: boolean;
  116150. sideOrientation?: number;
  116151. frontUVs?: Vector4;
  116152. backUVs?: Vector4;
  116153. instance?: Mesh;
  116154. invertUV?: boolean;
  116155. uvs?: Vector2[];
  116156. colors?: Color4[];
  116157. }, scene?: Nullable<Scene>): Mesh;
  116158. }
  116159. }
  116160. declare module BABYLON {
  116161. /**
  116162. * Class containing static functions to help procedurally build meshes
  116163. */
  116164. export class ShapeBuilder {
  116165. /**
  116166. * 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.
  116167. * * 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.
  116168. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116169. * * 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.
  116170. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116171. * * 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
  116172. * * 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
  116173. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116175. * * 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
  116176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116178. * @param name defines the name of the mesh
  116179. * @param options defines the options used to create the mesh
  116180. * @param scene defines the hosting scene
  116181. * @returns the extruded shape mesh
  116182. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116184. */
  116185. static ExtrudeShape(name: string, options: {
  116186. shape: Vector3[];
  116187. path: Vector3[];
  116188. scale?: number;
  116189. rotation?: number;
  116190. cap?: number;
  116191. updatable?: boolean;
  116192. sideOrientation?: number;
  116193. frontUVs?: Vector4;
  116194. backUVs?: Vector4;
  116195. instance?: Mesh;
  116196. invertUV?: boolean;
  116197. }, scene?: Nullable<Scene>): Mesh;
  116198. /**
  116199. * Creates an custom extruded shape mesh.
  116200. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116201. * * 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.
  116202. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116203. * * 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
  116204. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116205. * * 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
  116206. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116207. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116208. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116209. * * 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
  116210. * * 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
  116211. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116213. * * 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
  116214. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116216. * @param name defines the name of the mesh
  116217. * @param options defines the options used to create the mesh
  116218. * @param scene defines the hosting scene
  116219. * @returns the custom extruded shape mesh
  116220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116221. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116223. */
  116224. static ExtrudeShapeCustom(name: string, options: {
  116225. shape: Vector3[];
  116226. path: Vector3[];
  116227. scaleFunction?: any;
  116228. rotationFunction?: any;
  116229. ribbonCloseArray?: boolean;
  116230. ribbonClosePath?: boolean;
  116231. cap?: number;
  116232. updatable?: boolean;
  116233. sideOrientation?: number;
  116234. frontUVs?: Vector4;
  116235. backUVs?: Vector4;
  116236. instance?: Mesh;
  116237. invertUV?: boolean;
  116238. }, scene?: Nullable<Scene>): Mesh;
  116239. private static _ExtrudeShapeGeneric;
  116240. }
  116241. }
  116242. declare module BABYLON {
  116243. /**
  116244. * AmmoJS Physics plugin
  116245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116246. * @see https://github.com/kripken/ammo.js/
  116247. */
  116248. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116249. private _useDeltaForWorldStep;
  116250. /**
  116251. * Reference to the Ammo library
  116252. */
  116253. bjsAMMO: any;
  116254. /**
  116255. * Created ammoJS world which physics bodies are added to
  116256. */
  116257. world: any;
  116258. /**
  116259. * Name of the plugin
  116260. */
  116261. name: string;
  116262. private _timeStep;
  116263. private _fixedTimeStep;
  116264. private _maxSteps;
  116265. private _tmpQuaternion;
  116266. private _tmpAmmoTransform;
  116267. private _tmpAmmoQuaternion;
  116268. private _tmpAmmoConcreteContactResultCallback;
  116269. private _collisionConfiguration;
  116270. private _dispatcher;
  116271. private _overlappingPairCache;
  116272. private _solver;
  116273. private _softBodySolver;
  116274. private _tmpAmmoVectorA;
  116275. private _tmpAmmoVectorB;
  116276. private _tmpAmmoVectorC;
  116277. private _tmpAmmoVectorD;
  116278. private _tmpContactCallbackResult;
  116279. private _tmpAmmoVectorRCA;
  116280. private _tmpAmmoVectorRCB;
  116281. private _raycastResult;
  116282. private static readonly DISABLE_COLLISION_FLAG;
  116283. private static readonly KINEMATIC_FLAG;
  116284. private static readonly DISABLE_DEACTIVATION_FLAG;
  116285. /**
  116286. * Initializes the ammoJS plugin
  116287. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116288. * @param ammoInjection can be used to inject your own ammo reference
  116289. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116290. */
  116291. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116292. /**
  116293. * Sets the gravity of the physics world (m/(s^2))
  116294. * @param gravity Gravity to set
  116295. */
  116296. setGravity(gravity: Vector3): void;
  116297. /**
  116298. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116299. * @param timeStep timestep to use in seconds
  116300. */
  116301. setTimeStep(timeStep: number): void;
  116302. /**
  116303. * 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)
  116304. * @param fixedTimeStep fixedTimeStep to use in seconds
  116305. */
  116306. setFixedTimeStep(fixedTimeStep: number): void;
  116307. /**
  116308. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116309. * @param maxSteps the maximum number of steps by the physics engine per frame
  116310. */
  116311. setMaxSteps(maxSteps: number): void;
  116312. /**
  116313. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116314. * @returns the current timestep in seconds
  116315. */
  116316. getTimeStep(): number;
  116317. private _isImpostorInContact;
  116318. private _isImpostorPairInContact;
  116319. private _stepSimulation;
  116320. /**
  116321. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116322. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116323. * After the step the babylon meshes are set to the position of the physics imposters
  116324. * @param delta amount of time to step forward
  116325. * @param impostors array of imposters to update before/after the step
  116326. */
  116327. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116328. /**
  116329. * Update babylon mesh to match physics world object
  116330. * @param impostor imposter to match
  116331. */
  116332. private _afterSoftStep;
  116333. /**
  116334. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116335. * @param impostor imposter to match
  116336. */
  116337. private _ropeStep;
  116338. /**
  116339. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116340. * @param impostor imposter to match
  116341. */
  116342. private _softbodyOrClothStep;
  116343. private _tmpVector;
  116344. private _tmpMatrix;
  116345. /**
  116346. * Applies an impulse on the imposter
  116347. * @param impostor imposter to apply impulse to
  116348. * @param force amount of force to be applied to the imposter
  116349. * @param contactPoint the location to apply the impulse on the imposter
  116350. */
  116351. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116352. /**
  116353. * Applies a force on the imposter
  116354. * @param impostor imposter to apply force
  116355. * @param force amount of force to be applied to the imposter
  116356. * @param contactPoint the location to apply the force on the imposter
  116357. */
  116358. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116359. /**
  116360. * Creates a physics body using the plugin
  116361. * @param impostor the imposter to create the physics body on
  116362. */
  116363. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116364. /**
  116365. * Removes the physics body from the imposter and disposes of the body's memory
  116366. * @param impostor imposter to remove the physics body from
  116367. */
  116368. removePhysicsBody(impostor: PhysicsImpostor): void;
  116369. /**
  116370. * Generates a joint
  116371. * @param impostorJoint the imposter joint to create the joint with
  116372. */
  116373. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116374. /**
  116375. * Removes a joint
  116376. * @param impostorJoint the imposter joint to remove the joint from
  116377. */
  116378. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116379. private _addMeshVerts;
  116380. /**
  116381. * Initialise the soft body vertices to match its object's (mesh) vertices
  116382. * Softbody vertices (nodes) are in world space and to match this
  116383. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116384. * @param impostor to create the softbody for
  116385. */
  116386. private _softVertexData;
  116387. /**
  116388. * Create an impostor's soft body
  116389. * @param impostor to create the softbody for
  116390. */
  116391. private _createSoftbody;
  116392. /**
  116393. * Create cloth for an impostor
  116394. * @param impostor to create the softbody for
  116395. */
  116396. private _createCloth;
  116397. /**
  116398. * Create rope for an impostor
  116399. * @param impostor to create the softbody for
  116400. */
  116401. private _createRope;
  116402. private _addHullVerts;
  116403. private _createShape;
  116404. /**
  116405. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116406. * @param impostor imposter containing the physics body and babylon object
  116407. */
  116408. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116409. /**
  116410. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116411. * @param impostor imposter containing the physics body and babylon object
  116412. * @param newPosition new position
  116413. * @param newRotation new rotation
  116414. */
  116415. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116416. /**
  116417. * If this plugin is supported
  116418. * @returns true if its supported
  116419. */
  116420. isSupported(): boolean;
  116421. /**
  116422. * Sets the linear velocity of the physics body
  116423. * @param impostor imposter to set the velocity on
  116424. * @param velocity velocity to set
  116425. */
  116426. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116427. /**
  116428. * Sets the angular velocity of the physics body
  116429. * @param impostor imposter to set the velocity on
  116430. * @param velocity velocity to set
  116431. */
  116432. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116433. /**
  116434. * gets the linear velocity
  116435. * @param impostor imposter to get linear velocity from
  116436. * @returns linear velocity
  116437. */
  116438. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116439. /**
  116440. * gets the angular velocity
  116441. * @param impostor imposter to get angular velocity from
  116442. * @returns angular velocity
  116443. */
  116444. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116445. /**
  116446. * Sets the mass of physics body
  116447. * @param impostor imposter to set the mass on
  116448. * @param mass mass to set
  116449. */
  116450. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116451. /**
  116452. * Gets the mass of the physics body
  116453. * @param impostor imposter to get the mass from
  116454. * @returns mass
  116455. */
  116456. getBodyMass(impostor: PhysicsImpostor): number;
  116457. /**
  116458. * Gets friction of the impostor
  116459. * @param impostor impostor to get friction from
  116460. * @returns friction value
  116461. */
  116462. getBodyFriction(impostor: PhysicsImpostor): number;
  116463. /**
  116464. * Sets friction of the impostor
  116465. * @param impostor impostor to set friction on
  116466. * @param friction friction value
  116467. */
  116468. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116469. /**
  116470. * Gets restitution of the impostor
  116471. * @param impostor impostor to get restitution from
  116472. * @returns restitution value
  116473. */
  116474. getBodyRestitution(impostor: PhysicsImpostor): number;
  116475. /**
  116476. * Sets resitution of the impostor
  116477. * @param impostor impostor to set resitution on
  116478. * @param restitution resitution value
  116479. */
  116480. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116481. /**
  116482. * Gets pressure inside the impostor
  116483. * @param impostor impostor to get pressure from
  116484. * @returns pressure value
  116485. */
  116486. getBodyPressure(impostor: PhysicsImpostor): number;
  116487. /**
  116488. * Sets pressure inside a soft body impostor
  116489. * Cloth and rope must remain 0 pressure
  116490. * @param impostor impostor to set pressure on
  116491. * @param pressure pressure value
  116492. */
  116493. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116494. /**
  116495. * Gets stiffness of the impostor
  116496. * @param impostor impostor to get stiffness from
  116497. * @returns pressure value
  116498. */
  116499. getBodyStiffness(impostor: PhysicsImpostor): number;
  116500. /**
  116501. * Sets stiffness of the impostor
  116502. * @param impostor impostor to set stiffness on
  116503. * @param stiffness stiffness value from 0 to 1
  116504. */
  116505. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116506. /**
  116507. * Gets velocityIterations of the impostor
  116508. * @param impostor impostor to get velocity iterations from
  116509. * @returns velocityIterations value
  116510. */
  116511. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116512. /**
  116513. * Sets velocityIterations of the impostor
  116514. * @param impostor impostor to set velocity iterations on
  116515. * @param velocityIterations velocityIterations value
  116516. */
  116517. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116518. /**
  116519. * Gets positionIterations of the impostor
  116520. * @param impostor impostor to get position iterations from
  116521. * @returns positionIterations value
  116522. */
  116523. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116524. /**
  116525. * Sets positionIterations of the impostor
  116526. * @param impostor impostor to set position on
  116527. * @param positionIterations positionIterations value
  116528. */
  116529. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116530. /**
  116531. * Append an anchor to a cloth object
  116532. * @param impostor is the cloth impostor to add anchor to
  116533. * @param otherImpostor is the rigid impostor to anchor to
  116534. * @param width ratio across width from 0 to 1
  116535. * @param height ratio up height from 0 to 1
  116536. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116537. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116538. */
  116539. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116540. /**
  116541. * Append an hook to a rope object
  116542. * @param impostor is the rope impostor to add hook to
  116543. * @param otherImpostor is the rigid impostor to hook to
  116544. * @param length ratio along the rope from 0 to 1
  116545. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116546. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116547. */
  116548. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116549. /**
  116550. * Sleeps the physics body and stops it from being active
  116551. * @param impostor impostor to sleep
  116552. */
  116553. sleepBody(impostor: PhysicsImpostor): void;
  116554. /**
  116555. * Activates the physics body
  116556. * @param impostor impostor to activate
  116557. */
  116558. wakeUpBody(impostor: PhysicsImpostor): void;
  116559. /**
  116560. * Updates the distance parameters of the joint
  116561. * @param joint joint to update
  116562. * @param maxDistance maximum distance of the joint
  116563. * @param minDistance minimum distance of the joint
  116564. */
  116565. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116566. /**
  116567. * Sets a motor on the joint
  116568. * @param joint joint to set motor on
  116569. * @param speed speed of the motor
  116570. * @param maxForce maximum force of the motor
  116571. * @param motorIndex index of the motor
  116572. */
  116573. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116574. /**
  116575. * Sets the motors limit
  116576. * @param joint joint to set limit on
  116577. * @param upperLimit upper limit
  116578. * @param lowerLimit lower limit
  116579. */
  116580. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116581. /**
  116582. * Syncs the position and rotation of a mesh with the impostor
  116583. * @param mesh mesh to sync
  116584. * @param impostor impostor to update the mesh with
  116585. */
  116586. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116587. /**
  116588. * Gets the radius of the impostor
  116589. * @param impostor impostor to get radius from
  116590. * @returns the radius
  116591. */
  116592. getRadius(impostor: PhysicsImpostor): number;
  116593. /**
  116594. * Gets the box size of the impostor
  116595. * @param impostor impostor to get box size from
  116596. * @param result the resulting box size
  116597. */
  116598. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116599. /**
  116600. * Disposes of the impostor
  116601. */
  116602. dispose(): void;
  116603. /**
  116604. * Does a raycast in the physics world
  116605. * @param from when should the ray start?
  116606. * @param to when should the ray end?
  116607. * @returns PhysicsRaycastResult
  116608. */
  116609. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116610. }
  116611. }
  116612. declare module BABYLON {
  116613. interface AbstractScene {
  116614. /**
  116615. * The list of reflection probes added to the scene
  116616. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116617. */
  116618. reflectionProbes: Array<ReflectionProbe>;
  116619. /**
  116620. * Removes the given reflection probe from this scene.
  116621. * @param toRemove The reflection probe to remove
  116622. * @returns The index of the removed reflection probe
  116623. */
  116624. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116625. /**
  116626. * Adds the given reflection probe to this scene.
  116627. * @param newReflectionProbe The reflection probe to add
  116628. */
  116629. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116630. }
  116631. /**
  116632. * Class used to generate realtime reflection / refraction cube textures
  116633. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116634. */
  116635. export class ReflectionProbe {
  116636. /** defines the name of the probe */
  116637. name: string;
  116638. private _scene;
  116639. private _renderTargetTexture;
  116640. private _projectionMatrix;
  116641. private _viewMatrix;
  116642. private _target;
  116643. private _add;
  116644. private _attachedMesh;
  116645. private _invertYAxis;
  116646. /** Gets or sets probe position (center of the cube map) */
  116647. position: Vector3;
  116648. /**
  116649. * Creates a new reflection probe
  116650. * @param name defines the name of the probe
  116651. * @param size defines the texture resolution (for each face)
  116652. * @param scene defines the hosting scene
  116653. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116654. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116655. */
  116656. constructor(
  116657. /** defines the name of the probe */
  116658. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116659. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116660. samples: number;
  116661. /** Gets or sets the refresh rate to use (on every frame by default) */
  116662. refreshRate: number;
  116663. /**
  116664. * Gets the hosting scene
  116665. * @returns a Scene
  116666. */
  116667. getScene(): Scene;
  116668. /** Gets the internal CubeTexture used to render to */
  116669. readonly cubeTexture: RenderTargetTexture;
  116670. /** Gets the list of meshes to render */
  116671. readonly renderList: Nullable<AbstractMesh[]>;
  116672. /**
  116673. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116674. * @param mesh defines the mesh to attach to
  116675. */
  116676. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116677. /**
  116678. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116679. * @param renderingGroupId The rendering group id corresponding to its index
  116680. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116681. */
  116682. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116683. /**
  116684. * Clean all associated resources
  116685. */
  116686. dispose(): void;
  116687. /**
  116688. * Converts the reflection probe information to a readable string for debug purpose.
  116689. * @param fullDetails Supports for multiple levels of logging within scene loading
  116690. * @returns the human readable reflection probe info
  116691. */
  116692. toString(fullDetails?: boolean): string;
  116693. /**
  116694. * Get the class name of the relfection probe.
  116695. * @returns "ReflectionProbe"
  116696. */
  116697. getClassName(): string;
  116698. /**
  116699. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116700. * @returns The JSON representation of the texture
  116701. */
  116702. serialize(): any;
  116703. /**
  116704. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116705. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116706. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116707. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116708. * @returns The parsed reflection probe if successful
  116709. */
  116710. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116711. }
  116712. }
  116713. declare module BABYLON {
  116714. /** @hidden */
  116715. export var _BabylonLoaderRegistered: boolean;
  116716. }
  116717. declare module BABYLON {
  116718. /**
  116719. * The Physically based simple base material of BJS.
  116720. *
  116721. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116722. * It is used as the base class for both the specGloss and metalRough conventions.
  116723. */
  116724. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116725. /**
  116726. * Number of Simultaneous lights allowed on the material.
  116727. */
  116728. maxSimultaneousLights: number;
  116729. /**
  116730. * If sets to true, disables all the lights affecting the material.
  116731. */
  116732. disableLighting: boolean;
  116733. /**
  116734. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116735. */
  116736. environmentTexture: BaseTexture;
  116737. /**
  116738. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116739. */
  116740. invertNormalMapX: boolean;
  116741. /**
  116742. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116743. */
  116744. invertNormalMapY: boolean;
  116745. /**
  116746. * Normal map used in the model.
  116747. */
  116748. normalTexture: BaseTexture;
  116749. /**
  116750. * Emissivie color used to self-illuminate the model.
  116751. */
  116752. emissiveColor: Color3;
  116753. /**
  116754. * Emissivie texture used to self-illuminate the model.
  116755. */
  116756. emissiveTexture: BaseTexture;
  116757. /**
  116758. * Occlusion Channel Strenght.
  116759. */
  116760. occlusionStrength: number;
  116761. /**
  116762. * Occlusion Texture of the material (adding extra occlusion effects).
  116763. */
  116764. occlusionTexture: BaseTexture;
  116765. /**
  116766. * Defines the alpha limits in alpha test mode.
  116767. */
  116768. alphaCutOff: number;
  116769. /**
  116770. * Gets the current double sided mode.
  116771. */
  116772. /**
  116773. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116774. */
  116775. doubleSided: boolean;
  116776. /**
  116777. * Stores the pre-calculated light information of a mesh in a texture.
  116778. */
  116779. lightmapTexture: BaseTexture;
  116780. /**
  116781. * If true, the light map contains occlusion information instead of lighting info.
  116782. */
  116783. useLightmapAsShadowmap: boolean;
  116784. /**
  116785. * Instantiates a new PBRMaterial instance.
  116786. *
  116787. * @param name The material name
  116788. * @param scene The scene the material will be use in.
  116789. */
  116790. constructor(name: string, scene: Scene);
  116791. getClassName(): string;
  116792. }
  116793. }
  116794. declare module BABYLON {
  116795. /**
  116796. * The PBR material of BJS following the metal roughness convention.
  116797. *
  116798. * This fits to the PBR convention in the GLTF definition:
  116799. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  116800. */
  116801. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  116802. /**
  116803. * The base color has two different interpretations depending on the value of metalness.
  116804. * When the material is a metal, the base color is the specific measured reflectance value
  116805. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  116806. * of the material.
  116807. */
  116808. baseColor: Color3;
  116809. /**
  116810. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  116811. * well as opacity information in the alpha channel.
  116812. */
  116813. baseTexture: BaseTexture;
  116814. /**
  116815. * Specifies the metallic scalar value of the material.
  116816. * Can also be used to scale the metalness values of the metallic texture.
  116817. */
  116818. metallic: number;
  116819. /**
  116820. * Specifies the roughness scalar value of the material.
  116821. * Can also be used to scale the roughness values of the metallic texture.
  116822. */
  116823. roughness: number;
  116824. /**
  116825. * Texture containing both the metallic value in the B channel and the
  116826. * roughness value in the G channel to keep better precision.
  116827. */
  116828. metallicRoughnessTexture: BaseTexture;
  116829. /**
  116830. * Instantiates a new PBRMetalRoughnessMaterial instance.
  116831. *
  116832. * @param name The material name
  116833. * @param scene The scene the material will be use in.
  116834. */
  116835. constructor(name: string, scene: Scene);
  116836. /**
  116837. * Return the currrent class name of the material.
  116838. */
  116839. getClassName(): string;
  116840. /**
  116841. * Makes a duplicate of the current material.
  116842. * @param name - name to use for the new material.
  116843. */
  116844. clone(name: string): PBRMetallicRoughnessMaterial;
  116845. /**
  116846. * Serialize the material to a parsable JSON object.
  116847. */
  116848. serialize(): any;
  116849. /**
  116850. * Parses a JSON object correponding to the serialize function.
  116851. */
  116852. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  116853. }
  116854. }
  116855. declare module BABYLON {
  116856. /**
  116857. * The PBR material of BJS following the specular glossiness convention.
  116858. *
  116859. * This fits to the PBR convention in the GLTF definition:
  116860. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  116861. */
  116862. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  116863. /**
  116864. * Specifies the diffuse color of the material.
  116865. */
  116866. diffuseColor: Color3;
  116867. /**
  116868. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  116869. * channel.
  116870. */
  116871. diffuseTexture: BaseTexture;
  116872. /**
  116873. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  116874. */
  116875. specularColor: Color3;
  116876. /**
  116877. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  116878. */
  116879. glossiness: number;
  116880. /**
  116881. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  116882. */
  116883. specularGlossinessTexture: BaseTexture;
  116884. /**
  116885. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  116886. *
  116887. * @param name The material name
  116888. * @param scene The scene the material will be use in.
  116889. */
  116890. constructor(name: string, scene: Scene);
  116891. /**
  116892. * Return the currrent class name of the material.
  116893. */
  116894. getClassName(): string;
  116895. /**
  116896. * Makes a duplicate of the current material.
  116897. * @param name - name to use for the new material.
  116898. */
  116899. clone(name: string): PBRSpecularGlossinessMaterial;
  116900. /**
  116901. * Serialize the material to a parsable JSON object.
  116902. */
  116903. serialize(): any;
  116904. /**
  116905. * Parses a JSON object correponding to the serialize function.
  116906. */
  116907. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  116908. }
  116909. }
  116910. declare module BABYLON {
  116911. /**
  116912. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  116913. * It can help converting any input color in a desired output one. This can then be used to create effects
  116914. * from sepia, black and white to sixties or futuristic rendering...
  116915. *
  116916. * The only supported format is currently 3dl.
  116917. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  116918. */
  116919. export class ColorGradingTexture extends BaseTexture {
  116920. /**
  116921. * The current texture matrix. (will always be identity in color grading texture)
  116922. */
  116923. private _textureMatrix;
  116924. /**
  116925. * The texture URL.
  116926. */
  116927. url: string;
  116928. /**
  116929. * Empty line regex stored for GC.
  116930. */
  116931. private static _noneEmptyLineRegex;
  116932. private _engine;
  116933. /**
  116934. * Instantiates a ColorGradingTexture from the following parameters.
  116935. *
  116936. * @param url The location of the color gradind data (currently only supporting 3dl)
  116937. * @param scene The scene the texture will be used in
  116938. */
  116939. constructor(url: string, scene: Scene);
  116940. /**
  116941. * Returns the texture matrix used in most of the material.
  116942. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  116943. */
  116944. getTextureMatrix(): Matrix;
  116945. /**
  116946. * Occurs when the file being loaded is a .3dl LUT file.
  116947. */
  116948. private load3dlTexture;
  116949. /**
  116950. * Starts the loading process of the texture.
  116951. */
  116952. private loadTexture;
  116953. /**
  116954. * Clones the color gradind texture.
  116955. */
  116956. clone(): ColorGradingTexture;
  116957. /**
  116958. * Called during delayed load for textures.
  116959. */
  116960. delayLoad(): void;
  116961. /**
  116962. * Parses a color grading texture serialized by Babylon.
  116963. * @param parsedTexture The texture information being parsedTexture
  116964. * @param scene The scene to load the texture in
  116965. * @param rootUrl The root url of the data assets to load
  116966. * @return A color gradind texture
  116967. */
  116968. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  116969. /**
  116970. * Serializes the LUT texture to json format.
  116971. */
  116972. serialize(): any;
  116973. }
  116974. }
  116975. declare module BABYLON {
  116976. /**
  116977. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  116978. */
  116979. export class EquiRectangularCubeTexture extends BaseTexture {
  116980. /** The six faces of the cube. */
  116981. private static _FacesMapping;
  116982. private _noMipmap;
  116983. private _onLoad;
  116984. private _onError;
  116985. /** The size of the cubemap. */
  116986. private _size;
  116987. /** The buffer of the image. */
  116988. private _buffer;
  116989. /** The width of the input image. */
  116990. private _width;
  116991. /** The height of the input image. */
  116992. private _height;
  116993. /** The URL to the image. */
  116994. url: string;
  116995. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  116996. coordinatesMode: number;
  116997. /**
  116998. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  116999. * @param url The location of the image
  117000. * @param scene The scene the texture will be used in
  117001. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117002. * @param noMipmap Forces to not generate the mipmap if true
  117003. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117004. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117005. * @param onLoad — defines a callback called when texture is loaded
  117006. * @param onError — defines a callback called if there is an error
  117007. */
  117008. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117009. /**
  117010. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117011. */
  117012. private loadImage;
  117013. /**
  117014. * Convert the image buffer into a cubemap and create a CubeTexture.
  117015. */
  117016. private loadTexture;
  117017. /**
  117018. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117019. * @param buffer The ArrayBuffer that should be converted.
  117020. * @returns The buffer as Float32Array.
  117021. */
  117022. private getFloat32ArrayFromArrayBuffer;
  117023. /**
  117024. * Get the current class name of the texture useful for serialization or dynamic coding.
  117025. * @returns "EquiRectangularCubeTexture"
  117026. */
  117027. getClassName(): string;
  117028. /**
  117029. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117030. * @returns A clone of the current EquiRectangularCubeTexture.
  117031. */
  117032. clone(): EquiRectangularCubeTexture;
  117033. }
  117034. }
  117035. declare module BABYLON {
  117036. /**
  117037. * Based on jsTGALoader - Javascript loader for TGA file
  117038. * By Vincent Thibault
  117039. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117040. */
  117041. export class TGATools {
  117042. private static _TYPE_INDEXED;
  117043. private static _TYPE_RGB;
  117044. private static _TYPE_GREY;
  117045. private static _TYPE_RLE_INDEXED;
  117046. private static _TYPE_RLE_RGB;
  117047. private static _TYPE_RLE_GREY;
  117048. private static _ORIGIN_MASK;
  117049. private static _ORIGIN_SHIFT;
  117050. private static _ORIGIN_BL;
  117051. private static _ORIGIN_BR;
  117052. private static _ORIGIN_UL;
  117053. private static _ORIGIN_UR;
  117054. /**
  117055. * Gets the header of a TGA file
  117056. * @param data defines the TGA data
  117057. * @returns the header
  117058. */
  117059. static GetTGAHeader(data: Uint8Array): any;
  117060. /**
  117061. * Uploads TGA content to a Babylon Texture
  117062. * @hidden
  117063. */
  117064. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117065. /** @hidden */
  117066. 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;
  117067. /** @hidden */
  117068. 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;
  117069. /** @hidden */
  117070. 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;
  117071. /** @hidden */
  117072. 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;
  117073. /** @hidden */
  117074. 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;
  117075. /** @hidden */
  117076. 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;
  117077. }
  117078. }
  117079. declare module BABYLON {
  117080. /**
  117081. * Implementation of the TGA Texture Loader.
  117082. * @hidden
  117083. */
  117084. export class _TGATextureLoader implements IInternalTextureLoader {
  117085. /**
  117086. * Defines wether the loader supports cascade loading the different faces.
  117087. */
  117088. readonly supportCascades: boolean;
  117089. /**
  117090. * This returns if the loader support the current file information.
  117091. * @param extension defines the file extension of the file being loaded
  117092. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117093. * @param fallback defines the fallback internal texture if any
  117094. * @param isBase64 defines whether the texture is encoded as a base64
  117095. * @param isBuffer defines whether the texture data are stored as a buffer
  117096. * @returns true if the loader can load the specified file
  117097. */
  117098. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117099. /**
  117100. * Transform the url before loading if required.
  117101. * @param rootUrl the url of the texture
  117102. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117103. * @returns the transformed texture
  117104. */
  117105. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117106. /**
  117107. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117108. * @param rootUrl the url of the texture
  117109. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117110. * @returns the fallback texture
  117111. */
  117112. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117113. /**
  117114. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117115. * @param data contains the texture data
  117116. * @param texture defines the BabylonJS internal texture
  117117. * @param createPolynomials will be true if polynomials have been requested
  117118. * @param onLoad defines the callback to trigger once the texture is ready
  117119. * @param onError defines the callback to trigger in case of error
  117120. */
  117121. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117122. /**
  117123. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117124. * @param data contains the texture data
  117125. * @param texture defines the BabylonJS internal texture
  117126. * @param callback defines the method to call once ready to upload
  117127. */
  117128. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117129. }
  117130. }
  117131. declare module BABYLON {
  117132. /**
  117133. * Info about the .basis files
  117134. */
  117135. class BasisFileInfo {
  117136. /**
  117137. * If the file has alpha
  117138. */
  117139. hasAlpha: boolean;
  117140. /**
  117141. * Info about each image of the basis file
  117142. */
  117143. images: Array<{
  117144. levels: Array<{
  117145. width: number;
  117146. height: number;
  117147. transcodedPixels: ArrayBufferView;
  117148. }>;
  117149. }>;
  117150. }
  117151. /**
  117152. * Result of transcoding a basis file
  117153. */
  117154. class TranscodeResult {
  117155. /**
  117156. * Info about the .basis file
  117157. */
  117158. fileInfo: BasisFileInfo;
  117159. /**
  117160. * Format to use when loading the file
  117161. */
  117162. format: number;
  117163. }
  117164. /**
  117165. * Configuration options for the Basis transcoder
  117166. */
  117167. export class BasisTranscodeConfiguration {
  117168. /**
  117169. * Supported compression formats used to determine the supported output format of the transcoder
  117170. */
  117171. supportedCompressionFormats?: {
  117172. /**
  117173. * etc1 compression format
  117174. */
  117175. etc1?: boolean;
  117176. /**
  117177. * s3tc compression format
  117178. */
  117179. s3tc?: boolean;
  117180. /**
  117181. * pvrtc compression format
  117182. */
  117183. pvrtc?: boolean;
  117184. /**
  117185. * etc2 compression format
  117186. */
  117187. etc2?: boolean;
  117188. };
  117189. /**
  117190. * If mipmap levels should be loaded for transcoded images (Default: true)
  117191. */
  117192. loadMipmapLevels?: boolean;
  117193. /**
  117194. * Index of a single image to load (Default: all images)
  117195. */
  117196. loadSingleImage?: number;
  117197. }
  117198. /**
  117199. * Used to load .Basis files
  117200. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117201. */
  117202. export class BasisTools {
  117203. private static _IgnoreSupportedFormats;
  117204. /**
  117205. * URL to use when loading the basis transcoder
  117206. */
  117207. static JSModuleURL: string;
  117208. /**
  117209. * URL to use when loading the wasm module for the transcoder
  117210. */
  117211. static WasmModuleURL: string;
  117212. /**
  117213. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117214. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117215. * @returns internal format corresponding to the Basis format
  117216. */
  117217. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117218. private static _WorkerPromise;
  117219. private static _Worker;
  117220. private static _actionId;
  117221. private static _CreateWorkerAsync;
  117222. /**
  117223. * Transcodes a loaded image file to compressed pixel data
  117224. * @param imageData image data to transcode
  117225. * @param config configuration options for the transcoding
  117226. * @returns a promise resulting in the transcoded image
  117227. */
  117228. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117229. /**
  117230. * Loads a texture from the transcode result
  117231. * @param texture texture load to
  117232. * @param transcodeResult the result of transcoding the basis file to load from
  117233. */
  117234. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117235. }
  117236. }
  117237. declare module BABYLON {
  117238. /**
  117239. * Loader for .basis file format
  117240. */
  117241. export class _BasisTextureLoader implements IInternalTextureLoader {
  117242. /**
  117243. * Defines whether the loader supports cascade loading the different faces.
  117244. */
  117245. readonly supportCascades: boolean;
  117246. /**
  117247. * This returns if the loader support the current file information.
  117248. * @param extension defines the file extension of the file being loaded
  117249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117250. * @param fallback defines the fallback internal texture if any
  117251. * @param isBase64 defines whether the texture is encoded as a base64
  117252. * @param isBuffer defines whether the texture data are stored as a buffer
  117253. * @returns true if the loader can load the specified file
  117254. */
  117255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117256. /**
  117257. * Transform the url before loading if required.
  117258. * @param rootUrl the url of the texture
  117259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117260. * @returns the transformed texture
  117261. */
  117262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117263. /**
  117264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117265. * @param rootUrl the url of the texture
  117266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117267. * @returns the fallback texture
  117268. */
  117269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117270. /**
  117271. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117272. * @param data contains the texture data
  117273. * @param texture defines the BabylonJS internal texture
  117274. * @param createPolynomials will be true if polynomials have been requested
  117275. * @param onLoad defines the callback to trigger once the texture is ready
  117276. * @param onError defines the callback to trigger in case of error
  117277. */
  117278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117279. /**
  117280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117281. * @param data contains the texture data
  117282. * @param texture defines the BabylonJS internal texture
  117283. * @param callback defines the method to call once ready to upload
  117284. */
  117285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117286. }
  117287. }
  117288. declare module BABYLON {
  117289. /**
  117290. * 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.
  117291. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117292. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117293. */
  117294. export class CustomProceduralTexture extends ProceduralTexture {
  117295. private _animate;
  117296. private _time;
  117297. private _config;
  117298. private _texturePath;
  117299. /**
  117300. * Instantiates a new Custom Procedural Texture.
  117301. * 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.
  117302. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117303. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117304. * @param name Define the name of the texture
  117305. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117306. * @param size Define the size of the texture to create
  117307. * @param scene Define the scene the texture belongs to
  117308. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117309. * @param generateMipMaps Define if the texture should creates mip maps or not
  117310. */
  117311. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117312. private _loadJson;
  117313. /**
  117314. * Is the texture ready to be used ? (rendered at least once)
  117315. * @returns true if ready, otherwise, false.
  117316. */
  117317. isReady(): boolean;
  117318. /**
  117319. * Render the texture to its associated render target.
  117320. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117321. */
  117322. render(useCameraPostProcess?: boolean): void;
  117323. /**
  117324. * Update the list of dependant textures samplers in the shader.
  117325. */
  117326. updateTextures(): void;
  117327. /**
  117328. * Update the uniform values of the procedural texture in the shader.
  117329. */
  117330. updateShaderUniforms(): void;
  117331. /**
  117332. * Define if the texture animates or not.
  117333. */
  117334. animate: boolean;
  117335. }
  117336. }
  117337. declare module BABYLON {
  117338. /** @hidden */
  117339. export var noisePixelShader: {
  117340. name: string;
  117341. shader: string;
  117342. };
  117343. }
  117344. declare module BABYLON {
  117345. /**
  117346. * Class used to generate noise procedural textures
  117347. */
  117348. export class NoiseProceduralTexture extends ProceduralTexture {
  117349. private _time;
  117350. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117351. brightness: number;
  117352. /** Defines the number of octaves to process */
  117353. octaves: number;
  117354. /** Defines the level of persistence (0.8 by default) */
  117355. persistence: number;
  117356. /** Gets or sets animation speed factor (default is 1) */
  117357. animationSpeedFactor: number;
  117358. /**
  117359. * Creates a new NoiseProceduralTexture
  117360. * @param name defines the name fo the texture
  117361. * @param size defines the size of the texture (default is 256)
  117362. * @param scene defines the hosting scene
  117363. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117364. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117365. */
  117366. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117367. private _updateShaderUniforms;
  117368. protected _getDefines(): string;
  117369. /** Generate the current state of the procedural texture */
  117370. render(useCameraPostProcess?: boolean): void;
  117371. /**
  117372. * Serializes this noise procedural texture
  117373. * @returns a serialized noise procedural texture object
  117374. */
  117375. serialize(): any;
  117376. /**
  117377. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117378. * @param parsedTexture defines parsed texture data
  117379. * @param scene defines the current scene
  117380. * @param rootUrl defines the root URL containing noise procedural texture information
  117381. * @returns a parsed NoiseProceduralTexture
  117382. */
  117383. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117384. }
  117385. }
  117386. declare module BABYLON {
  117387. /**
  117388. * Raw cube texture where the raw buffers are passed in
  117389. */
  117390. export class RawCubeTexture extends CubeTexture {
  117391. /**
  117392. * Creates a cube texture where the raw buffers are passed in.
  117393. * @param scene defines the scene the texture is attached to
  117394. * @param data defines the array of data to use to create each face
  117395. * @param size defines the size of the textures
  117396. * @param format defines the format of the data
  117397. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117398. * @param generateMipMaps defines if the engine should generate the mip levels
  117399. * @param invertY defines if data must be stored with Y axis inverted
  117400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117401. * @param compression defines the compression used (null by default)
  117402. */
  117403. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117404. /**
  117405. * Updates the raw cube texture.
  117406. * @param data defines the data to store
  117407. * @param format defines the data format
  117408. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117409. * @param invertY defines if data must be stored with Y axis inverted
  117410. * @param compression defines the compression used (null by default)
  117411. * @param level defines which level of the texture to update
  117412. */
  117413. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117414. /**
  117415. * Updates a raw cube texture with RGBD encoded data.
  117416. * @param data defines the array of data [mipmap][face] to use to create each face
  117417. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117418. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117419. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117420. * @returns a promsie that resolves when the operation is complete
  117421. */
  117422. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117423. /**
  117424. * Clones the raw cube texture.
  117425. * @return a new cube texture
  117426. */
  117427. clone(): CubeTexture;
  117428. /** @hidden */
  117429. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117430. }
  117431. }
  117432. declare module BABYLON {
  117433. /**
  117434. * Class used to store 3D textures containing user data
  117435. */
  117436. export class RawTexture3D extends Texture {
  117437. /** Gets or sets the texture format to use */
  117438. format: number;
  117439. private _engine;
  117440. /**
  117441. * Create a new RawTexture3D
  117442. * @param data defines the data of the texture
  117443. * @param width defines the width of the texture
  117444. * @param height defines the height of the texture
  117445. * @param depth defines the depth of the texture
  117446. * @param format defines the texture format to use
  117447. * @param scene defines the hosting scene
  117448. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117449. * @param invertY defines if texture must be stored with Y axis inverted
  117450. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117451. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117452. */
  117453. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117454. /** Gets or sets the texture format to use */
  117455. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117456. /**
  117457. * Update the texture with new data
  117458. * @param data defines the data to store in the texture
  117459. */
  117460. update(data: ArrayBufferView): void;
  117461. }
  117462. }
  117463. declare module BABYLON {
  117464. /**
  117465. * Creates a refraction texture used by refraction channel of the standard material.
  117466. * It is like a mirror but to see through a material.
  117467. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117468. */
  117469. export class RefractionTexture extends RenderTargetTexture {
  117470. /**
  117471. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117472. * 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.
  117473. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117474. */
  117475. refractionPlane: Plane;
  117476. /**
  117477. * Define how deep under the surface we should see.
  117478. */
  117479. depth: number;
  117480. /**
  117481. * Creates a refraction texture used by refraction channel of the standard material.
  117482. * It is like a mirror but to see through a material.
  117483. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117484. * @param name Define the texture name
  117485. * @param size Define the size of the underlying texture
  117486. * @param scene Define the scene the refraction belongs to
  117487. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117488. */
  117489. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117490. /**
  117491. * Clone the refraction texture.
  117492. * @returns the cloned texture
  117493. */
  117494. clone(): RefractionTexture;
  117495. /**
  117496. * Serialize the texture to a JSON representation you could use in Parse later on
  117497. * @returns the serialized JSON representation
  117498. */
  117499. serialize(): any;
  117500. }
  117501. }
  117502. declare module BABYLON {
  117503. /**
  117504. * Defines the options related to the creation of an HtmlElementTexture
  117505. */
  117506. export interface IHtmlElementTextureOptions {
  117507. /**
  117508. * Defines wether mip maps should be created or not.
  117509. */
  117510. generateMipMaps?: boolean;
  117511. /**
  117512. * Defines the sampling mode of the texture.
  117513. */
  117514. samplingMode?: number;
  117515. /**
  117516. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117517. */
  117518. engine: Nullable<Engine>;
  117519. /**
  117520. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117521. */
  117522. scene: Nullable<Scene>;
  117523. }
  117524. /**
  117525. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117526. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117527. * is automatically managed.
  117528. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117529. * in your application.
  117530. *
  117531. * As the update is not automatic, you need to call them manually.
  117532. */
  117533. export class HtmlElementTexture extends BaseTexture {
  117534. /**
  117535. * The texture URL.
  117536. */
  117537. element: HTMLVideoElement | HTMLCanvasElement;
  117538. private static readonly DefaultOptions;
  117539. private _textureMatrix;
  117540. private _engine;
  117541. private _isVideo;
  117542. private _generateMipMaps;
  117543. private _samplingMode;
  117544. /**
  117545. * Instantiates a HtmlElementTexture from the following parameters.
  117546. *
  117547. * @param name Defines the name of the texture
  117548. * @param element Defines the video or canvas the texture is filled with
  117549. * @param options Defines the other none mandatory texture creation options
  117550. */
  117551. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117552. private _createInternalTexture;
  117553. /**
  117554. * Returns the texture matrix used in most of the material.
  117555. */
  117556. getTextureMatrix(): Matrix;
  117557. /**
  117558. * Updates the content of the texture.
  117559. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117560. */
  117561. update(invertY?: Nullable<boolean>): void;
  117562. }
  117563. }
  117564. declare module BABYLON {
  117565. /**
  117566. * Enum used to define the target of a block
  117567. */
  117568. export enum NodeMaterialBlockTargets {
  117569. /** Vertex shader */
  117570. Vertex = 1,
  117571. /** Fragment shader */
  117572. Fragment = 2,
  117573. /** Neutral */
  117574. Neutral = 4,
  117575. /** Vertex and Fragment */
  117576. VertexAndFragment = 3
  117577. }
  117578. }
  117579. declare module BABYLON {
  117580. /**
  117581. * Defines the kind of connection point for node based material
  117582. */
  117583. export enum NodeMaterialBlockConnectionPointTypes {
  117584. /** Float */
  117585. Float = 1,
  117586. /** Int */
  117587. Int = 2,
  117588. /** Vector2 */
  117589. Vector2 = 4,
  117590. /** Vector3 */
  117591. Vector3 = 8,
  117592. /** Vector4 */
  117593. Vector4 = 16,
  117594. /** Color3 */
  117595. Color3 = 32,
  117596. /** Color4 */
  117597. Color4 = 64,
  117598. /** Matrix */
  117599. Matrix = 128,
  117600. /** Detect type based on connection */
  117601. AutoDetect = 1024,
  117602. /** Output type that will be defined by input type */
  117603. BasedOnInput = 2048
  117604. }
  117605. }
  117606. declare module BABYLON {
  117607. /**
  117608. * Root class for all node material optimizers
  117609. */
  117610. export class NodeMaterialOptimizer {
  117611. /**
  117612. * Function used to optimize a NodeMaterial graph
  117613. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117614. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117615. */
  117616. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117617. }
  117618. }
  117619. declare module BABYLON {
  117620. /**
  117621. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117622. */
  117623. export class TransformBlock extends NodeMaterialBlock {
  117624. /**
  117625. * Defines the value to use to complement W value to transform it to a Vector4
  117626. */
  117627. complementW: number;
  117628. /**
  117629. * Defines the value to use to complement z value to transform it to a Vector4
  117630. */
  117631. complementZ: number;
  117632. /**
  117633. * Creates a new TransformBlock
  117634. * @param name defines the block name
  117635. */
  117636. constructor(name: string);
  117637. /**
  117638. * Gets the current class name
  117639. * @returns the class name
  117640. */
  117641. getClassName(): string;
  117642. /**
  117643. * Gets the vector input
  117644. */
  117645. readonly vector: NodeMaterialConnectionPoint;
  117646. /**
  117647. * Gets the output component
  117648. */
  117649. readonly output: NodeMaterialConnectionPoint;
  117650. /**
  117651. * Gets the matrix transform input
  117652. */
  117653. readonly transform: NodeMaterialConnectionPoint;
  117654. protected _buildBlock(state: NodeMaterialBuildState): this;
  117655. serialize(): any;
  117656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117657. protected _dumpPropertiesCode(): string;
  117658. }
  117659. }
  117660. declare module BABYLON {
  117661. /**
  117662. * Block used to output the vertex position
  117663. */
  117664. export class VertexOutputBlock extends NodeMaterialBlock {
  117665. /**
  117666. * Creates a new VertexOutputBlock
  117667. * @param name defines the block name
  117668. */
  117669. constructor(name: string);
  117670. /**
  117671. * Gets the current class name
  117672. * @returns the class name
  117673. */
  117674. getClassName(): string;
  117675. /**
  117676. * Gets the vector input component
  117677. */
  117678. readonly vector: NodeMaterialConnectionPoint;
  117679. protected _buildBlock(state: NodeMaterialBuildState): this;
  117680. }
  117681. }
  117682. declare module BABYLON {
  117683. /**
  117684. * Block used to output the final color
  117685. */
  117686. export class FragmentOutputBlock extends NodeMaterialBlock {
  117687. /**
  117688. * Create a new FragmentOutputBlock
  117689. * @param name defines the block name
  117690. */
  117691. constructor(name: string);
  117692. /**
  117693. * Gets the current class name
  117694. * @returns the class name
  117695. */
  117696. getClassName(): string;
  117697. /**
  117698. * Gets the rgba input component
  117699. */
  117700. readonly rgba: NodeMaterialConnectionPoint;
  117701. /**
  117702. * Gets the rgb input component
  117703. */
  117704. readonly rgb: NodeMaterialConnectionPoint;
  117705. /**
  117706. * Gets the a input component
  117707. */
  117708. readonly a: NodeMaterialConnectionPoint;
  117709. protected _buildBlock(state: NodeMaterialBuildState): this;
  117710. }
  117711. }
  117712. declare module BABYLON {
  117713. /**
  117714. * Enum used to define system values e.g. values automatically provided by the system
  117715. */
  117716. export enum NodeMaterialSystemValues {
  117717. /** World */
  117718. World = 1,
  117719. /** View */
  117720. View = 2,
  117721. /** Projection */
  117722. Projection = 3,
  117723. /** ViewProjection */
  117724. ViewProjection = 4,
  117725. /** WorldView */
  117726. WorldView = 5,
  117727. /** WorldViewProjection */
  117728. WorldViewProjection = 6,
  117729. /** CameraPosition */
  117730. CameraPosition = 7,
  117731. /** Fog Color */
  117732. FogColor = 8
  117733. }
  117734. }
  117735. declare module BABYLON {
  117736. /**
  117737. * Block used to read a reflection texture from a sampler
  117738. */
  117739. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117740. private _define3DName;
  117741. private _defineCubicName;
  117742. private _defineExplicitName;
  117743. private _defineProjectionName;
  117744. private _defineLocalCubicName;
  117745. private _defineSphericalName;
  117746. private _definePlanarName;
  117747. private _defineEquirectangularName;
  117748. private _defineMirroredEquirectangularFixedName;
  117749. private _defineEquirectangularFixedName;
  117750. private _defineSkyboxName;
  117751. private _cubeSamplerName;
  117752. private _2DSamplerName;
  117753. private _positionUVWName;
  117754. private _directionWName;
  117755. private _reflectionCoordsName;
  117756. private _reflection2DCoordsName;
  117757. private _reflectionColorName;
  117758. private _reflectionMatrixName;
  117759. /**
  117760. * Gets or sets the texture associated with the node
  117761. */
  117762. texture: Nullable<BaseTexture>;
  117763. /**
  117764. * Create a new TextureBlock
  117765. * @param name defines the block name
  117766. */
  117767. constructor(name: string);
  117768. /**
  117769. * Gets the current class name
  117770. * @returns the class name
  117771. */
  117772. getClassName(): string;
  117773. /**
  117774. * Gets the world position input component
  117775. */
  117776. readonly position: NodeMaterialConnectionPoint;
  117777. /**
  117778. * Gets the world position input component
  117779. */
  117780. readonly worldPosition: NodeMaterialConnectionPoint;
  117781. /**
  117782. * Gets the world normal input component
  117783. */
  117784. readonly worldNormal: NodeMaterialConnectionPoint;
  117785. /**
  117786. * Gets the world input component
  117787. */
  117788. readonly world: NodeMaterialConnectionPoint;
  117789. /**
  117790. * Gets the camera (or eye) position component
  117791. */
  117792. readonly cameraPosition: NodeMaterialConnectionPoint;
  117793. /**
  117794. * Gets the view input component
  117795. */
  117796. readonly view: NodeMaterialConnectionPoint;
  117797. /**
  117798. * Gets the rgb output component
  117799. */
  117800. readonly rgb: NodeMaterialConnectionPoint;
  117801. /**
  117802. * Gets the r output component
  117803. */
  117804. readonly r: NodeMaterialConnectionPoint;
  117805. /**
  117806. * Gets the g output component
  117807. */
  117808. readonly g: NodeMaterialConnectionPoint;
  117809. /**
  117810. * Gets the b output component
  117811. */
  117812. readonly b: NodeMaterialConnectionPoint;
  117813. autoConfigure(material: NodeMaterial): void;
  117814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117815. isReady(): boolean;
  117816. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117817. private _injectVertexCode;
  117818. private _writeOutput;
  117819. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117820. serialize(): any;
  117821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117822. }
  117823. }
  117824. declare module BABYLON {
  117825. /**
  117826. * Interface used to configure the node material editor
  117827. */
  117828. export interface INodeMaterialEditorOptions {
  117829. /** Define the URl to load node editor script */
  117830. editorURL?: string;
  117831. }
  117832. /** @hidden */
  117833. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  117834. /** BONES */
  117835. NUM_BONE_INFLUENCERS: number;
  117836. BonesPerMesh: number;
  117837. BONETEXTURE: boolean;
  117838. /** MORPH TARGETS */
  117839. MORPHTARGETS: boolean;
  117840. MORPHTARGETS_NORMAL: boolean;
  117841. MORPHTARGETS_TANGENT: boolean;
  117842. MORPHTARGETS_UV: boolean;
  117843. NUM_MORPH_INFLUENCERS: number;
  117844. /** IMAGE PROCESSING */
  117845. IMAGEPROCESSING: boolean;
  117846. VIGNETTE: boolean;
  117847. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117848. VIGNETTEBLENDMODEOPAQUE: boolean;
  117849. TONEMAPPING: boolean;
  117850. TONEMAPPING_ACES: boolean;
  117851. CONTRAST: boolean;
  117852. EXPOSURE: boolean;
  117853. COLORCURVES: boolean;
  117854. COLORGRADING: boolean;
  117855. COLORGRADING3D: boolean;
  117856. SAMPLER3DGREENDEPTH: boolean;
  117857. SAMPLER3DBGRMAP: boolean;
  117858. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117859. /** MISC. */
  117860. BUMPDIRECTUV: number;
  117861. constructor();
  117862. setValue(name: string, value: boolean): void;
  117863. }
  117864. /**
  117865. * Class used to configure NodeMaterial
  117866. */
  117867. export interface INodeMaterialOptions {
  117868. /**
  117869. * Defines if blocks should emit comments
  117870. */
  117871. emitComments: boolean;
  117872. }
  117873. /**
  117874. * Class used to create a node based material built by assembling shader blocks
  117875. */
  117876. export class NodeMaterial extends PushMaterial {
  117877. private static _BuildIdGenerator;
  117878. private _options;
  117879. private _vertexCompilationState;
  117880. private _fragmentCompilationState;
  117881. private _sharedData;
  117882. private _buildId;
  117883. private _buildWasSuccessful;
  117884. private _cachedWorldViewMatrix;
  117885. private _cachedWorldViewProjectionMatrix;
  117886. private _optimizers;
  117887. private _animationFrame;
  117888. /** Define the URl to load node editor script */
  117889. static EditorURL: string;
  117890. private BJSNODEMATERIALEDITOR;
  117891. /** Get the inspector from bundle or global */
  117892. private _getGlobalNodeMaterialEditor;
  117893. /**
  117894. * 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)
  117895. */
  117896. ignoreAlpha: boolean;
  117897. /**
  117898. * Defines the maximum number of lights that can be used in the material
  117899. */
  117900. maxSimultaneousLights: number;
  117901. /**
  117902. * Observable raised when the material is built
  117903. */
  117904. onBuildObservable: Observable<NodeMaterial>;
  117905. /**
  117906. * Gets or sets the root nodes of the material vertex shader
  117907. */
  117908. _vertexOutputNodes: NodeMaterialBlock[];
  117909. /**
  117910. * Gets or sets the root nodes of the material fragment (pixel) shader
  117911. */
  117912. _fragmentOutputNodes: NodeMaterialBlock[];
  117913. /** Gets or sets options to control the node material overall behavior */
  117914. options: INodeMaterialOptions;
  117915. /**
  117916. * Default configuration related to image processing available in the standard Material.
  117917. */
  117918. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117919. /**
  117920. * Gets the image processing configuration used either in this material.
  117921. */
  117922. /**
  117923. * Sets the Default image processing configuration used either in the this material.
  117924. *
  117925. * If sets to null, the scene one is in use.
  117926. */
  117927. imageProcessingConfiguration: ImageProcessingConfiguration;
  117928. /**
  117929. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  117930. */
  117931. attachedBlocks: NodeMaterialBlock[];
  117932. /**
  117933. * Create a new node based material
  117934. * @param name defines the material name
  117935. * @param scene defines the hosting scene
  117936. * @param options defines creation option
  117937. */
  117938. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  117939. /**
  117940. * Gets the current class name of the material e.g. "NodeMaterial"
  117941. * @returns the class name
  117942. */
  117943. getClassName(): string;
  117944. /**
  117945. * Keep track of the image processing observer to allow dispose and replace.
  117946. */
  117947. private _imageProcessingObserver;
  117948. /**
  117949. * Attaches a new image processing configuration to the Standard Material.
  117950. * @param configuration
  117951. */
  117952. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117953. /**
  117954. * Get a block by its name
  117955. * @param name defines the name of the block to retrieve
  117956. * @returns the required block or null if not found
  117957. */
  117958. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  117959. /**
  117960. * Get a block by its name
  117961. * @param predicate defines the predicate used to find the good candidate
  117962. * @returns the required block or null if not found
  117963. */
  117964. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  117965. /**
  117966. * Get an input block by its name
  117967. * @param predicate defines the predicate used to find the good candidate
  117968. * @returns the required input block or null if not found
  117969. */
  117970. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  117971. /**
  117972. * Gets the list of input blocks attached to this material
  117973. * @returns an array of InputBlocks
  117974. */
  117975. getInputBlocks(): InputBlock[];
  117976. /**
  117977. * Adds a new optimizer to the list of optimizers
  117978. * @param optimizer defines the optimizers to add
  117979. * @returns the current material
  117980. */
  117981. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117982. /**
  117983. * Remove an optimizer from the list of optimizers
  117984. * @param optimizer defines the optimizers to remove
  117985. * @returns the current material
  117986. */
  117987. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  117988. /**
  117989. * Add a new block to the list of output nodes
  117990. * @param node defines the node to add
  117991. * @returns the current material
  117992. */
  117993. addOutputNode(node: NodeMaterialBlock): this;
  117994. /**
  117995. * Remove a block from the list of root nodes
  117996. * @param node defines the node to remove
  117997. * @returns the current material
  117998. */
  117999. removeOutputNode(node: NodeMaterialBlock): this;
  118000. private _addVertexOutputNode;
  118001. private _removeVertexOutputNode;
  118002. private _addFragmentOutputNode;
  118003. private _removeFragmentOutputNode;
  118004. /**
  118005. * Specifies if the material will require alpha blending
  118006. * @returns a boolean specifying if alpha blending is needed
  118007. */
  118008. needAlphaBlending(): boolean;
  118009. /**
  118010. * Specifies if this material should be rendered in alpha test mode
  118011. * @returns a boolean specifying if an alpha test is needed.
  118012. */
  118013. needAlphaTesting(): boolean;
  118014. private _initializeBlock;
  118015. private _resetDualBlocks;
  118016. /**
  118017. * Build the material and generates the inner effect
  118018. * @param verbose defines if the build should log activity
  118019. */
  118020. build(verbose?: boolean): void;
  118021. /**
  118022. * Runs an otpimization phase to try to improve the shader code
  118023. */
  118024. optimize(): void;
  118025. private _prepareDefinesForAttributes;
  118026. /**
  118027. * Get if the submesh is ready to be used and all its information available.
  118028. * Child classes can use it to update shaders
  118029. * @param mesh defines the mesh to check
  118030. * @param subMesh defines which submesh to check
  118031. * @param useInstances specifies that instances should be used
  118032. * @returns a boolean indicating that the submesh is ready or not
  118033. */
  118034. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118035. /**
  118036. * Get a string representing the shaders built by the current node graph
  118037. */
  118038. readonly compiledShaders: string;
  118039. /**
  118040. * Binds the world matrix to the material
  118041. * @param world defines the world transformation matrix
  118042. */
  118043. bindOnlyWorldMatrix(world: Matrix): void;
  118044. /**
  118045. * Binds the submesh to this material by preparing the effect and shader to draw
  118046. * @param world defines the world transformation matrix
  118047. * @param mesh defines the mesh containing the submesh
  118048. * @param subMesh defines the submesh to bind the material to
  118049. */
  118050. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118051. /**
  118052. * Gets the active textures from the material
  118053. * @returns an array of textures
  118054. */
  118055. getActiveTextures(): BaseTexture[];
  118056. /**
  118057. * Gets the list of texture blocks
  118058. * @returns an array of texture blocks
  118059. */
  118060. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118061. /**
  118062. * Specifies if the material uses a texture
  118063. * @param texture defines the texture to check against the material
  118064. * @returns a boolean specifying if the material uses the texture
  118065. */
  118066. hasTexture(texture: BaseTexture): boolean;
  118067. /**
  118068. * Disposes the material
  118069. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118070. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118071. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118072. */
  118073. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118074. /** Creates the node editor window. */
  118075. private _createNodeEditor;
  118076. /**
  118077. * Launch the node material editor
  118078. * @param config Define the configuration of the editor
  118079. * @return a promise fulfilled when the node editor is visible
  118080. */
  118081. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118082. /**
  118083. * Clear the current material
  118084. */
  118085. clear(): void;
  118086. /**
  118087. * Clear the current material and set it to a default state
  118088. */
  118089. setToDefault(): void;
  118090. /**
  118091. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118092. * @param url defines the url to load from
  118093. * @returns a promise that will fullfil when the material is fully loaded
  118094. */
  118095. loadAsync(url: string): Promise<unknown>;
  118096. private _gatherBlocks;
  118097. /**
  118098. * Generate a string containing the code declaration required to create an equivalent of this material
  118099. * @returns a string
  118100. */
  118101. generateCode(): string;
  118102. /**
  118103. * Serializes this material in a JSON representation
  118104. * @returns the serialized material object
  118105. */
  118106. serialize(): any;
  118107. private _restoreConnections;
  118108. /**
  118109. * Clear the current graph and load a new one from a serialization object
  118110. * @param source defines the JSON representation of the material
  118111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118112. */
  118113. loadFromSerialization(source: any, rootUrl?: string): void;
  118114. /**
  118115. * Creates a node material from parsed material data
  118116. * @param source defines the JSON representation of the material
  118117. * @param scene defines the hosting scene
  118118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118119. * @returns a new node material
  118120. */
  118121. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118122. /**
  118123. * Creates a new node material set to default basic configuration
  118124. * @param name defines the name of the material
  118125. * @param scene defines the hosting scene
  118126. * @returns a new NodeMaterial
  118127. */
  118128. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118129. }
  118130. }
  118131. declare module BABYLON {
  118132. /**
  118133. * Block used to read a texture from a sampler
  118134. */
  118135. export class TextureBlock extends NodeMaterialBlock {
  118136. private _defineName;
  118137. private _samplerName;
  118138. private _transformedUVName;
  118139. private _textureTransformName;
  118140. private _textureInfoName;
  118141. private _mainUVName;
  118142. private _mainUVDefineName;
  118143. /**
  118144. * Gets or sets the texture associated with the node
  118145. */
  118146. texture: Nullable<BaseTexture>;
  118147. /**
  118148. * Create a new TextureBlock
  118149. * @param name defines the block name
  118150. */
  118151. constructor(name: string);
  118152. /**
  118153. * Gets the current class name
  118154. * @returns the class name
  118155. */
  118156. getClassName(): string;
  118157. /**
  118158. * Gets the uv input component
  118159. */
  118160. readonly uv: NodeMaterialConnectionPoint;
  118161. /**
  118162. * Gets the rgba output component
  118163. */
  118164. readonly rgba: NodeMaterialConnectionPoint;
  118165. /**
  118166. * Gets the rgb output component
  118167. */
  118168. readonly rgb: NodeMaterialConnectionPoint;
  118169. /**
  118170. * Gets the r output component
  118171. */
  118172. readonly r: NodeMaterialConnectionPoint;
  118173. /**
  118174. * Gets the g output component
  118175. */
  118176. readonly g: NodeMaterialConnectionPoint;
  118177. /**
  118178. * Gets the b output component
  118179. */
  118180. readonly b: NodeMaterialConnectionPoint;
  118181. /**
  118182. * Gets the a output component
  118183. */
  118184. readonly a: NodeMaterialConnectionPoint;
  118185. readonly target: NodeMaterialBlockTargets;
  118186. autoConfigure(material: NodeMaterial): void;
  118187. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118188. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118189. isReady(): boolean;
  118190. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118191. private readonly _isMixed;
  118192. private _injectVertexCode;
  118193. private _writeOutput;
  118194. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118195. protected _dumpPropertiesCode(): string;
  118196. serialize(): any;
  118197. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118198. }
  118199. }
  118200. declare module BABYLON {
  118201. /**
  118202. * Class used to store shared data between 2 NodeMaterialBuildState
  118203. */
  118204. export class NodeMaterialBuildStateSharedData {
  118205. /**
  118206. * Gets the list of emitted varyings
  118207. */
  118208. temps: string[];
  118209. /**
  118210. * Gets the list of emitted varyings
  118211. */
  118212. varyings: string[];
  118213. /**
  118214. * Gets the varying declaration string
  118215. */
  118216. varyingDeclaration: string;
  118217. /**
  118218. * Input blocks
  118219. */
  118220. inputBlocks: InputBlock[];
  118221. /**
  118222. * Input blocks
  118223. */
  118224. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118225. /**
  118226. * Bindable blocks (Blocks that need to set data to the effect)
  118227. */
  118228. bindableBlocks: NodeMaterialBlock[];
  118229. /**
  118230. * List of blocks that can provide a compilation fallback
  118231. */
  118232. blocksWithFallbacks: NodeMaterialBlock[];
  118233. /**
  118234. * List of blocks that can provide a define update
  118235. */
  118236. blocksWithDefines: NodeMaterialBlock[];
  118237. /**
  118238. * List of blocks that can provide a repeatable content
  118239. */
  118240. repeatableContentBlocks: NodeMaterialBlock[];
  118241. /**
  118242. * List of blocks that can provide a dynamic list of uniforms
  118243. */
  118244. dynamicUniformBlocks: NodeMaterialBlock[];
  118245. /**
  118246. * List of blocks that can block the isReady function for the material
  118247. */
  118248. blockingBlocks: NodeMaterialBlock[];
  118249. /**
  118250. * Gets the list of animated inputs
  118251. */
  118252. animatedInputs: InputBlock[];
  118253. /**
  118254. * Build Id used to avoid multiple recompilations
  118255. */
  118256. buildId: number;
  118257. /** List of emitted variables */
  118258. variableNames: {
  118259. [key: string]: number;
  118260. };
  118261. /** List of emitted defines */
  118262. defineNames: {
  118263. [key: string]: number;
  118264. };
  118265. /** Should emit comments? */
  118266. emitComments: boolean;
  118267. /** Emit build activity */
  118268. verbose: boolean;
  118269. /**
  118270. * Gets the compilation hints emitted at compilation time
  118271. */
  118272. hints: {
  118273. needWorldViewMatrix: boolean;
  118274. needWorldViewProjectionMatrix: boolean;
  118275. needAlphaBlending: boolean;
  118276. needAlphaTesting: boolean;
  118277. };
  118278. /**
  118279. * List of compilation checks
  118280. */
  118281. checks: {
  118282. emitVertex: boolean;
  118283. emitFragment: boolean;
  118284. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118285. };
  118286. /** Creates a new shared data */
  118287. constructor();
  118288. /**
  118289. * Emits console errors and exceptions if there is a failing check
  118290. */
  118291. emitErrors(): void;
  118292. }
  118293. }
  118294. declare module BABYLON {
  118295. /**
  118296. * Class used to store node based material build state
  118297. */
  118298. export class NodeMaterialBuildState {
  118299. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118300. supportUniformBuffers: boolean;
  118301. /**
  118302. * Gets the list of emitted attributes
  118303. */
  118304. attributes: string[];
  118305. /**
  118306. * Gets the list of emitted uniforms
  118307. */
  118308. uniforms: string[];
  118309. /**
  118310. * Gets the list of emitted uniform buffers
  118311. */
  118312. uniformBuffers: string[];
  118313. /**
  118314. * Gets the list of emitted samplers
  118315. */
  118316. samplers: string[];
  118317. /**
  118318. * Gets the list of emitted functions
  118319. */
  118320. functions: {
  118321. [key: string]: string;
  118322. };
  118323. /**
  118324. * Gets the list of emitted extensions
  118325. */
  118326. extensions: {
  118327. [key: string]: string;
  118328. };
  118329. /**
  118330. * Gets the target of the compilation state
  118331. */
  118332. target: NodeMaterialBlockTargets;
  118333. /**
  118334. * Gets the list of emitted counters
  118335. */
  118336. counters: {
  118337. [key: string]: number;
  118338. };
  118339. /**
  118340. * Shared data between multiple NodeMaterialBuildState instances
  118341. */
  118342. sharedData: NodeMaterialBuildStateSharedData;
  118343. /** @hidden */
  118344. _vertexState: NodeMaterialBuildState;
  118345. /** @hidden */
  118346. _attributeDeclaration: string;
  118347. /** @hidden */
  118348. _uniformDeclaration: string;
  118349. /** @hidden */
  118350. _samplerDeclaration: string;
  118351. /** @hidden */
  118352. _varyingTransfer: string;
  118353. private _repeatableContentAnchorIndex;
  118354. /** @hidden */
  118355. _builtCompilationString: string;
  118356. /**
  118357. * Gets the emitted compilation strings
  118358. */
  118359. compilationString: string;
  118360. /**
  118361. * Finalize the compilation strings
  118362. * @param state defines the current compilation state
  118363. */
  118364. finalize(state: NodeMaterialBuildState): void;
  118365. /** @hidden */
  118366. readonly _repeatableContentAnchor: string;
  118367. /** @hidden */
  118368. _getFreeVariableName(prefix: string): string;
  118369. /** @hidden */
  118370. _getFreeDefineName(prefix: string): string;
  118371. /** @hidden */
  118372. _excludeVariableName(name: string): void;
  118373. /** @hidden */
  118374. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118375. /** @hidden */
  118376. _emitExtension(name: string, extension: string): void;
  118377. /** @hidden */
  118378. _emitFunction(name: string, code: string, comments: string): void;
  118379. /** @hidden */
  118380. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118381. replaceStrings?: {
  118382. search: RegExp;
  118383. replace: string;
  118384. }[];
  118385. repeatKey?: string;
  118386. }): string;
  118387. /** @hidden */
  118388. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118389. repeatKey?: string;
  118390. removeAttributes?: boolean;
  118391. removeUniforms?: boolean;
  118392. removeVaryings?: boolean;
  118393. removeIfDef?: boolean;
  118394. replaceStrings?: {
  118395. search: RegExp;
  118396. replace: string;
  118397. }[];
  118398. }, storeKey?: string): void;
  118399. /** @hidden */
  118400. _registerTempVariable(name: string): boolean;
  118401. /** @hidden */
  118402. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118403. /** @hidden */
  118404. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118405. }
  118406. }
  118407. declare module BABYLON {
  118408. /**
  118409. * Defines a block that can be used inside a node based material
  118410. */
  118411. export class NodeMaterialBlock {
  118412. private _buildId;
  118413. private _buildTarget;
  118414. private _target;
  118415. private _isFinalMerger;
  118416. private _isInput;
  118417. /** @hidden */
  118418. _codeVariableName: string;
  118419. /** @hidden */
  118420. _inputs: NodeMaterialConnectionPoint[];
  118421. /** @hidden */
  118422. _outputs: NodeMaterialConnectionPoint[];
  118423. /** @hidden */
  118424. _preparationId: number;
  118425. /**
  118426. * Gets or sets the name of the block
  118427. */
  118428. name: string;
  118429. /**
  118430. * Gets or sets the unique id of the node
  118431. */
  118432. uniqueId: number;
  118433. /**
  118434. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118435. */
  118436. readonly isFinalMerger: boolean;
  118437. /**
  118438. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118439. */
  118440. readonly isInput: boolean;
  118441. /**
  118442. * Gets or sets the build Id
  118443. */
  118444. buildId: number;
  118445. /**
  118446. * Gets or sets the target of the block
  118447. */
  118448. target: NodeMaterialBlockTargets;
  118449. /**
  118450. * Gets the list of input points
  118451. */
  118452. readonly inputs: NodeMaterialConnectionPoint[];
  118453. /** Gets the list of output points */
  118454. readonly outputs: NodeMaterialConnectionPoint[];
  118455. /**
  118456. * Find an input by its name
  118457. * @param name defines the name of the input to look for
  118458. * @returns the input or null if not found
  118459. */
  118460. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118461. /**
  118462. * Find an output by its name
  118463. * @param name defines the name of the outputto look for
  118464. * @returns the output or null if not found
  118465. */
  118466. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118467. /**
  118468. * Creates a new NodeMaterialBlock
  118469. * @param name defines the block name
  118470. * @param target defines the target of that block (Vertex by default)
  118471. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118472. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118473. */
  118474. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118475. /**
  118476. * Initialize the block and prepare the context for build
  118477. * @param state defines the state that will be used for the build
  118478. */
  118479. initialize(state: NodeMaterialBuildState): void;
  118480. /**
  118481. * Bind data to effect. Will only be called for blocks with isBindable === true
  118482. * @param effect defines the effect to bind data to
  118483. * @param nodeMaterial defines the hosting NodeMaterial
  118484. * @param mesh defines the mesh that will be rendered
  118485. */
  118486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118487. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118488. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118489. protected _writeFloat(value: number): string;
  118490. /**
  118491. * Gets the current class name e.g. "NodeMaterialBlock"
  118492. * @returns the class name
  118493. */
  118494. getClassName(): string;
  118495. /**
  118496. * Register a new input. Must be called inside a block constructor
  118497. * @param name defines the connection point name
  118498. * @param type defines the connection point type
  118499. * @param isOptional defines a boolean indicating that this input can be omitted
  118500. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118501. * @returns the current block
  118502. */
  118503. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118504. /**
  118505. * Register a new output. Must be called inside a block constructor
  118506. * @param name defines the connection point name
  118507. * @param type defines the connection point type
  118508. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118509. * @returns the current block
  118510. */
  118511. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118512. /**
  118513. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118514. * @param forOutput defines an optional connection point to check compatibility with
  118515. * @returns the first available input or null
  118516. */
  118517. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118518. /**
  118519. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118520. * @param forBlock defines an optional block to check compatibility with
  118521. * @returns the first available input or null
  118522. */
  118523. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118524. /**
  118525. * Gets the sibling of the given output
  118526. * @param current defines the current output
  118527. * @returns the next output in the list or null
  118528. */
  118529. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118530. /**
  118531. * Connect current block with another block
  118532. * @param other defines the block to connect with
  118533. * @param options define the various options to help pick the right connections
  118534. * @returns the current block
  118535. */
  118536. connectTo(other: NodeMaterialBlock, options?: {
  118537. input?: string;
  118538. output?: string;
  118539. outputSwizzle?: string;
  118540. }): this | undefined;
  118541. protected _buildBlock(state: NodeMaterialBuildState): void;
  118542. /**
  118543. * Add uniforms, samplers and uniform buffers at compilation time
  118544. * @param state defines the state to update
  118545. * @param nodeMaterial defines the node material requesting the update
  118546. * @param defines defines the material defines to update
  118547. */
  118548. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118549. /**
  118550. * Add potential fallbacks if shader compilation fails
  118551. * @param mesh defines the mesh to be rendered
  118552. * @param fallbacks defines the current prioritized list of fallbacks
  118553. */
  118554. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118555. /**
  118556. * Update defines for shader compilation
  118557. * @param mesh defines the mesh to be rendered
  118558. * @param nodeMaterial defines the node material requesting the update
  118559. * @param defines defines the material defines to update
  118560. * @param useInstances specifies that instances should be used
  118561. */
  118562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118563. /**
  118564. * Initialize defines for shader compilation
  118565. * @param mesh defines the mesh to be rendered
  118566. * @param nodeMaterial defines the node material requesting the update
  118567. * @param defines defines the material defines to be prepared
  118568. * @param useInstances specifies that instances should be used
  118569. */
  118570. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118571. /**
  118572. * Lets the block try to connect some inputs automatically
  118573. * @param material defines the hosting NodeMaterial
  118574. */
  118575. autoConfigure(material: NodeMaterial): void;
  118576. /**
  118577. * Function called when a block is declared as repeatable content generator
  118578. * @param vertexShaderState defines the current compilation state for the vertex shader
  118579. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118580. * @param mesh defines the mesh to be rendered
  118581. * @param defines defines the material defines to update
  118582. */
  118583. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118584. /**
  118585. * Checks if the block is ready
  118586. * @param mesh defines the mesh to be rendered
  118587. * @param nodeMaterial defines the node material requesting the update
  118588. * @param defines defines the material defines to update
  118589. * @param useInstances specifies that instances should be used
  118590. * @returns true if the block is ready
  118591. */
  118592. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118593. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118594. private _processBuild;
  118595. /**
  118596. * Compile the current node and generate the shader code
  118597. * @param state defines the current compilation state (uniforms, samplers, current string)
  118598. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118599. * @returns true if already built
  118600. */
  118601. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118602. protected _inputRename(name: string): string;
  118603. protected _outputRename(name: string): string;
  118604. protected _dumpPropertiesCode(): string;
  118605. /** @hidden */
  118606. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118607. /**
  118608. * Clone the current block to a new identical block
  118609. * @param scene defines the hosting scene
  118610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118611. * @returns a copy of the current block
  118612. */
  118613. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118614. /**
  118615. * Serializes this block in a JSON representation
  118616. * @returns the serialized block object
  118617. */
  118618. serialize(): any;
  118619. /** @hidden */
  118620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118621. }
  118622. }
  118623. declare module BABYLON {
  118624. /**
  118625. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118626. */
  118627. export enum NodeMaterialBlockConnectionPointMode {
  118628. /** Value is an uniform */
  118629. Uniform = 0,
  118630. /** Value is a mesh attribute */
  118631. Attribute = 1,
  118632. /** Value is a varying between vertex and fragment shaders */
  118633. Varying = 2,
  118634. /** Mode is undefined */
  118635. Undefined = 3
  118636. }
  118637. }
  118638. declare module BABYLON {
  118639. /**
  118640. * Enum defining the type of animations supported by InputBlock
  118641. */
  118642. export enum AnimatedInputBlockTypes {
  118643. /** No animation */
  118644. None = 0,
  118645. /** Time based animation. Will only work for floats */
  118646. Time = 1
  118647. }
  118648. }
  118649. declare module BABYLON {
  118650. /**
  118651. * Block used to expose an input value
  118652. */
  118653. export class InputBlock extends NodeMaterialBlock {
  118654. private _mode;
  118655. private _associatedVariableName;
  118656. private _storedValue;
  118657. private _valueCallback;
  118658. private _type;
  118659. private _animationType;
  118660. /** @hidden */
  118661. _systemValue: Nullable<NodeMaterialSystemValues>;
  118662. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118663. visibleInInspector: boolean;
  118664. /**
  118665. * Gets or sets the connection point type (default is float)
  118666. */
  118667. readonly type: NodeMaterialBlockConnectionPointTypes;
  118668. /**
  118669. * Creates a new InputBlock
  118670. * @param name defines the block name
  118671. * @param target defines the target of that block (Vertex by default)
  118672. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118673. */
  118674. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118675. /**
  118676. * Gets the output component
  118677. */
  118678. readonly output: NodeMaterialConnectionPoint;
  118679. /**
  118680. * Set the source of this connection point to a vertex attribute
  118681. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118682. * @returns the current connection point
  118683. */
  118684. setAsAttribute(attributeName?: string): InputBlock;
  118685. /**
  118686. * Set the source of this connection point to a system value
  118687. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  118688. * @returns the current connection point
  118689. */
  118690. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  118691. /**
  118692. * Gets or sets the value of that point.
  118693. * Please note that this value will be ignored if valueCallback is defined
  118694. */
  118695. value: any;
  118696. /**
  118697. * Gets or sets a callback used to get the value of that point.
  118698. * Please note that setting this value will force the connection point to ignore the value property
  118699. */
  118700. valueCallback: () => any;
  118701. /**
  118702. * Gets or sets the associated variable name in the shader
  118703. */
  118704. associatedVariableName: string;
  118705. /** Gets or sets the type of animation applied to the input */
  118706. animationType: AnimatedInputBlockTypes;
  118707. /**
  118708. * Gets a boolean indicating that this connection point not defined yet
  118709. */
  118710. readonly isUndefined: boolean;
  118711. /**
  118712. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118713. * In this case the connection point name must be the name of the uniform to use.
  118714. * Can only be set on inputs
  118715. */
  118716. isUniform: boolean;
  118717. /**
  118718. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118719. * In this case the connection point name must be the name of the attribute to use
  118720. * Can only be set on inputs
  118721. */
  118722. isAttribute: boolean;
  118723. /**
  118724. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118725. * Can only be set on exit points
  118726. */
  118727. isVarying: boolean;
  118728. /**
  118729. * Gets a boolean indicating that the current connection point is a system value
  118730. */
  118731. readonly isSystemValue: boolean;
  118732. /**
  118733. * Gets or sets the current well known value or null if not defined as a system value
  118734. */
  118735. systemValue: Nullable<NodeMaterialSystemValues>;
  118736. /**
  118737. * Gets the current class name
  118738. * @returns the class name
  118739. */
  118740. getClassName(): string;
  118741. /**
  118742. * Animate the input if animationType !== None
  118743. * @param scene defines the rendering scene
  118744. */
  118745. animate(scene: Scene): void;
  118746. private _emitDefine;
  118747. initialize(state: NodeMaterialBuildState): void;
  118748. /**
  118749. * Set the input block to its default value (based on its type)
  118750. */
  118751. setDefaultValue(): void;
  118752. protected _dumpPropertiesCode(): string;
  118753. private _emit;
  118754. /** @hidden */
  118755. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  118756. /** @hidden */
  118757. _transmit(effect: Effect, scene: Scene): void;
  118758. protected _buildBlock(state: NodeMaterialBuildState): void;
  118759. serialize(): any;
  118760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118761. }
  118762. }
  118763. declare module BABYLON {
  118764. /**
  118765. * Defines a connection point for a block
  118766. */
  118767. export class NodeMaterialConnectionPoint {
  118768. /** @hidden */
  118769. _ownerBlock: NodeMaterialBlock;
  118770. /** @hidden */
  118771. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118772. private _endpoints;
  118773. private _associatedVariableName;
  118774. /** @hidden */
  118775. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118776. /** @hidden */
  118777. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118778. private _type;
  118779. /** @hidden */
  118780. _enforceAssociatedVariableName: boolean;
  118781. /**
  118782. * Gets or sets the additional types supported byt this connection point
  118783. */
  118784. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  118785. /**
  118786. * Gets or sets the associated variable name in the shader
  118787. */
  118788. associatedVariableName: string;
  118789. /**
  118790. * Gets or sets the connection point type (default is float)
  118791. */
  118792. type: NodeMaterialBlockConnectionPointTypes;
  118793. /**
  118794. * Gets or sets the connection point name
  118795. */
  118796. name: string;
  118797. /**
  118798. * Gets or sets a boolean indicating that this connection point can be omitted
  118799. */
  118800. isOptional: boolean;
  118801. /**
  118802. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  118803. */
  118804. define: string;
  118805. /** Gets or sets the target of that connection point */
  118806. target: NodeMaterialBlockTargets;
  118807. /**
  118808. * Gets a boolean indicating that the current point is connected
  118809. */
  118810. readonly isConnected: boolean;
  118811. /**
  118812. * Gets a boolean indicating that the current point is connected to an input block
  118813. */
  118814. readonly isConnectedToInputBlock: boolean;
  118815. /**
  118816. * Gets a the connected input block (if any)
  118817. */
  118818. readonly connectInputBlock: Nullable<InputBlock>;
  118819. /** Get the other side of the connection (if any) */
  118820. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118821. /** Get the block that owns this connection point */
  118822. readonly ownerBlock: NodeMaterialBlock;
  118823. /** Get the block connected on the other side of this connection (if any) */
  118824. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  118825. /** Get the block connected on the endpoints of this connection (if any) */
  118826. readonly connectedBlocks: Array<NodeMaterialBlock>;
  118827. /** Gets the list of connected endpoints */
  118828. readonly endpoints: NodeMaterialConnectionPoint[];
  118829. /** Gets a boolean indicating if that output point is connected to at least one input */
  118830. readonly hasEndpoints: boolean;
  118831. /**
  118832. * Creates a new connection point
  118833. * @param name defines the connection point name
  118834. * @param ownerBlock defines the block hosting this connection point
  118835. */
  118836. constructor(name: string, ownerBlock: NodeMaterialBlock);
  118837. /**
  118838. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  118839. * @returns the class name
  118840. */
  118841. getClassName(): string;
  118842. /**
  118843. * Gets an boolean indicating if the current point can be connected to another point
  118844. * @param connectionPoint defines the other connection point
  118845. * @returns true if the connection is possible
  118846. */
  118847. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  118848. /**
  118849. * Connect this point to another connection point
  118850. * @param connectionPoint defines the other connection point
  118851. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  118852. * @returns the current connection point
  118853. */
  118854. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  118855. /**
  118856. * Disconnect this point from one of his endpoint
  118857. * @param endpoint defines the other connection point
  118858. * @returns the current connection point
  118859. */
  118860. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  118861. /**
  118862. * Serializes this point in a JSON representation
  118863. * @returns the serialized point object
  118864. */
  118865. serialize(): any;
  118866. }
  118867. }
  118868. declare module BABYLON {
  118869. /**
  118870. * Block used to add support for vertex skinning (bones)
  118871. */
  118872. export class BonesBlock extends NodeMaterialBlock {
  118873. /**
  118874. * Creates a new BonesBlock
  118875. * @param name defines the block name
  118876. */
  118877. constructor(name: string);
  118878. /**
  118879. * Initialize the block and prepare the context for build
  118880. * @param state defines the state that will be used for the build
  118881. */
  118882. initialize(state: NodeMaterialBuildState): void;
  118883. /**
  118884. * Gets the current class name
  118885. * @returns the class name
  118886. */
  118887. getClassName(): string;
  118888. /**
  118889. * Gets the matrix indices input component
  118890. */
  118891. readonly matricesIndices: NodeMaterialConnectionPoint;
  118892. /**
  118893. * Gets the matrix weights input component
  118894. */
  118895. readonly matricesWeights: NodeMaterialConnectionPoint;
  118896. /**
  118897. * Gets the extra matrix indices input component
  118898. */
  118899. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  118900. /**
  118901. * Gets the extra matrix weights input component
  118902. */
  118903. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  118904. /**
  118905. * Gets the world input component
  118906. */
  118907. readonly world: NodeMaterialConnectionPoint;
  118908. /**
  118909. * Gets the output component
  118910. */
  118911. readonly output: NodeMaterialConnectionPoint;
  118912. autoConfigure(material: NodeMaterial): void;
  118913. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118914. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118916. protected _buildBlock(state: NodeMaterialBuildState): this;
  118917. }
  118918. }
  118919. declare module BABYLON {
  118920. /**
  118921. * Block used to add support for instances
  118922. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  118923. */
  118924. export class InstancesBlock extends NodeMaterialBlock {
  118925. /**
  118926. * Creates a new InstancesBlock
  118927. * @param name defines the block name
  118928. */
  118929. constructor(name: string);
  118930. /**
  118931. * Gets the current class name
  118932. * @returns the class name
  118933. */
  118934. getClassName(): string;
  118935. /**
  118936. * Gets the first world row input component
  118937. */
  118938. readonly world0: NodeMaterialConnectionPoint;
  118939. /**
  118940. * Gets the second world row input component
  118941. */
  118942. readonly world1: NodeMaterialConnectionPoint;
  118943. /**
  118944. * Gets the third world row input component
  118945. */
  118946. readonly world2: NodeMaterialConnectionPoint;
  118947. /**
  118948. * Gets the forth world row input component
  118949. */
  118950. readonly world3: NodeMaterialConnectionPoint;
  118951. /**
  118952. * Gets the world input component
  118953. */
  118954. readonly world: NodeMaterialConnectionPoint;
  118955. /**
  118956. * Gets the output component
  118957. */
  118958. readonly output: NodeMaterialConnectionPoint;
  118959. autoConfigure(material: NodeMaterial): void;
  118960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118961. protected _buildBlock(state: NodeMaterialBuildState): this;
  118962. }
  118963. }
  118964. declare module BABYLON {
  118965. /**
  118966. * Block used to add morph targets support to vertex shader
  118967. */
  118968. export class MorphTargetsBlock extends NodeMaterialBlock {
  118969. private _repeatableContentAnchor;
  118970. private _repeatebleContentGenerated;
  118971. /**
  118972. * Create a new MorphTargetsBlock
  118973. * @param name defines the block name
  118974. */
  118975. constructor(name: string);
  118976. /**
  118977. * Gets the current class name
  118978. * @returns the class name
  118979. */
  118980. getClassName(): string;
  118981. /**
  118982. * Gets the position input component
  118983. */
  118984. readonly position: NodeMaterialConnectionPoint;
  118985. /**
  118986. * Gets the normal input component
  118987. */
  118988. readonly normal: NodeMaterialConnectionPoint;
  118989. /**
  118990. * Gets the tangent input component
  118991. */
  118992. readonly tangent: NodeMaterialConnectionPoint;
  118993. /**
  118994. * Gets the tangent input component
  118995. */
  118996. readonly uv: NodeMaterialConnectionPoint;
  118997. /**
  118998. * Gets the position output component
  118999. */
  119000. readonly positionOutput: NodeMaterialConnectionPoint;
  119001. /**
  119002. * Gets the normal output component
  119003. */
  119004. readonly normalOutput: NodeMaterialConnectionPoint;
  119005. /**
  119006. * Gets the tangent output component
  119007. */
  119008. readonly tangentOutput: NodeMaterialConnectionPoint;
  119009. /**
  119010. * Gets the tangent output component
  119011. */
  119012. readonly uvOutput: NodeMaterialConnectionPoint;
  119013. initialize(state: NodeMaterialBuildState): void;
  119014. autoConfigure(material: NodeMaterial): void;
  119015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119016. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119017. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119018. protected _buildBlock(state: NodeMaterialBuildState): this;
  119019. }
  119020. }
  119021. declare module BABYLON {
  119022. /**
  119023. * Block used to get data information from a light
  119024. */
  119025. export class LightInformationBlock extends NodeMaterialBlock {
  119026. private _lightDataDefineName;
  119027. private _lightColorDefineName;
  119028. /**
  119029. * Gets or sets the light associated with this block
  119030. */
  119031. light: Nullable<Light>;
  119032. /**
  119033. * Creates a new LightInformationBlock
  119034. * @param name defines the block name
  119035. */
  119036. constructor(name: string);
  119037. /**
  119038. * Gets the current class name
  119039. * @returns the class name
  119040. */
  119041. getClassName(): string;
  119042. /**
  119043. * Gets the world position input component
  119044. */
  119045. readonly worldPosition: NodeMaterialConnectionPoint;
  119046. /**
  119047. * Gets the direction output component
  119048. */
  119049. readonly direction: NodeMaterialConnectionPoint;
  119050. /**
  119051. * Gets the direction output component
  119052. */
  119053. readonly color: NodeMaterialConnectionPoint;
  119054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119055. protected _buildBlock(state: NodeMaterialBuildState): this;
  119056. serialize(): any;
  119057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119058. }
  119059. }
  119060. declare module BABYLON {
  119061. /**
  119062. * Block used to add an alpha test in the fragment shader
  119063. */
  119064. export class AlphaTestBlock extends NodeMaterialBlock {
  119065. /**
  119066. * Gets or sets the alpha value where alpha testing happens
  119067. */
  119068. alphaCutOff: number;
  119069. /**
  119070. * Create a new AlphaTestBlock
  119071. * @param name defines the block name
  119072. */
  119073. constructor(name: string);
  119074. /**
  119075. * Gets the current class name
  119076. * @returns the class name
  119077. */
  119078. getClassName(): string;
  119079. /**
  119080. * Gets the color input component
  119081. */
  119082. readonly color: NodeMaterialConnectionPoint;
  119083. /**
  119084. * Gets the alpha input component
  119085. */
  119086. readonly alpha: NodeMaterialConnectionPoint;
  119087. protected _buildBlock(state: NodeMaterialBuildState): this;
  119088. protected _dumpPropertiesCode(): string;
  119089. serialize(): any;
  119090. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119091. }
  119092. }
  119093. declare module BABYLON {
  119094. /**
  119095. * Block used to add image processing support to fragment shader
  119096. */
  119097. export class ImageProcessingBlock extends NodeMaterialBlock {
  119098. /**
  119099. * Create a new ImageProcessingBlock
  119100. * @param name defines the block name
  119101. */
  119102. constructor(name: string);
  119103. /**
  119104. * Gets the current class name
  119105. * @returns the class name
  119106. */
  119107. getClassName(): string;
  119108. /**
  119109. * Gets the color input component
  119110. */
  119111. readonly color: NodeMaterialConnectionPoint;
  119112. /**
  119113. * Gets the output component
  119114. */
  119115. readonly output: NodeMaterialConnectionPoint;
  119116. /**
  119117. * Initialize the block and prepare the context for build
  119118. * @param state defines the state that will be used for the build
  119119. */
  119120. initialize(state: NodeMaterialBuildState): void;
  119121. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119122. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119123. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119124. protected _buildBlock(state: NodeMaterialBuildState): this;
  119125. }
  119126. }
  119127. declare module BABYLON {
  119128. /**
  119129. * Block used to pertub normals based on a normal map
  119130. */
  119131. export class PerturbNormalBlock extends NodeMaterialBlock {
  119132. private _tangentSpaceParameterName;
  119133. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119134. invertX: boolean;
  119135. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119136. invertY: boolean;
  119137. /**
  119138. * Create a new PerturbNormalBlock
  119139. * @param name defines the block name
  119140. */
  119141. constructor(name: string);
  119142. /**
  119143. * Gets the current class name
  119144. * @returns the class name
  119145. */
  119146. getClassName(): string;
  119147. /**
  119148. * Gets the world position input component
  119149. */
  119150. readonly worldPosition: NodeMaterialConnectionPoint;
  119151. /**
  119152. * Gets the world normal input component
  119153. */
  119154. readonly worldNormal: NodeMaterialConnectionPoint;
  119155. /**
  119156. * Gets the uv input component
  119157. */
  119158. readonly uv: NodeMaterialConnectionPoint;
  119159. /**
  119160. * Gets the normal map color input component
  119161. */
  119162. readonly normalMapColor: NodeMaterialConnectionPoint;
  119163. /**
  119164. * Gets the strength input component
  119165. */
  119166. readonly strength: NodeMaterialConnectionPoint;
  119167. /**
  119168. * Gets the output component
  119169. */
  119170. readonly output: NodeMaterialConnectionPoint;
  119171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119173. autoConfigure(material: NodeMaterial): void;
  119174. protected _buildBlock(state: NodeMaterialBuildState): this;
  119175. protected _dumpPropertiesCode(): string;
  119176. serialize(): any;
  119177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119178. }
  119179. }
  119180. declare module BABYLON {
  119181. /**
  119182. * Block used to add support for scene fog
  119183. */
  119184. export class FogBlock extends NodeMaterialBlock {
  119185. private _fogDistanceName;
  119186. private _fogParameters;
  119187. /**
  119188. * Create a new FogBlock
  119189. * @param name defines the block name
  119190. */
  119191. constructor(name: string);
  119192. /**
  119193. * Gets the current class name
  119194. * @returns the class name
  119195. */
  119196. getClassName(): string;
  119197. /**
  119198. * Gets the world position input component
  119199. */
  119200. readonly worldPosition: NodeMaterialConnectionPoint;
  119201. /**
  119202. * Gets the view input component
  119203. */
  119204. readonly view: NodeMaterialConnectionPoint;
  119205. /**
  119206. * Gets the color input component
  119207. */
  119208. readonly input: NodeMaterialConnectionPoint;
  119209. /**
  119210. * Gets the fog color input component
  119211. */
  119212. readonly fogColor: NodeMaterialConnectionPoint;
  119213. /**
  119214. * Gets the output component
  119215. */
  119216. readonly output: NodeMaterialConnectionPoint;
  119217. autoConfigure(material: NodeMaterial): void;
  119218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119219. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119220. protected _buildBlock(state: NodeMaterialBuildState): this;
  119221. }
  119222. }
  119223. declare module BABYLON {
  119224. /**
  119225. * Block used to add light in the fragment shader
  119226. */
  119227. export class LightBlock extends NodeMaterialBlock {
  119228. private _lightId;
  119229. /**
  119230. * Gets or sets the light associated with this block
  119231. */
  119232. light: Nullable<Light>;
  119233. /**
  119234. * Create a new LightBlock
  119235. * @param name defines the block name
  119236. */
  119237. constructor(name: string);
  119238. /**
  119239. * Gets the current class name
  119240. * @returns the class name
  119241. */
  119242. getClassName(): string;
  119243. /**
  119244. * Gets the world position input component
  119245. */
  119246. readonly worldPosition: NodeMaterialConnectionPoint;
  119247. /**
  119248. * Gets the world normal input component
  119249. */
  119250. readonly worldNormal: NodeMaterialConnectionPoint;
  119251. /**
  119252. * Gets the camera (or eye) position component
  119253. */
  119254. readonly cameraPosition: NodeMaterialConnectionPoint;
  119255. /**
  119256. * Gets the diffuse output component
  119257. */
  119258. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119259. /**
  119260. * Gets the specular output component
  119261. */
  119262. readonly specularOutput: NodeMaterialConnectionPoint;
  119263. autoConfigure(material: NodeMaterial): void;
  119264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119265. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119267. private _injectVertexCode;
  119268. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119269. serialize(): any;
  119270. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119271. }
  119272. }
  119273. declare module BABYLON {
  119274. /**
  119275. * Block used to multiply 2 values
  119276. */
  119277. export class MultiplyBlock extends NodeMaterialBlock {
  119278. /**
  119279. * Creates a new MultiplyBlock
  119280. * @param name defines the block name
  119281. */
  119282. constructor(name: string);
  119283. /**
  119284. * Gets the current class name
  119285. * @returns the class name
  119286. */
  119287. getClassName(): string;
  119288. /**
  119289. * Gets the left operand input component
  119290. */
  119291. readonly left: NodeMaterialConnectionPoint;
  119292. /**
  119293. * Gets the right operand input component
  119294. */
  119295. readonly right: NodeMaterialConnectionPoint;
  119296. /**
  119297. * Gets the output component
  119298. */
  119299. readonly output: NodeMaterialConnectionPoint;
  119300. protected _buildBlock(state: NodeMaterialBuildState): this;
  119301. }
  119302. }
  119303. declare module BABYLON {
  119304. /**
  119305. * Block used to add 2 vectors
  119306. */
  119307. export class AddBlock extends NodeMaterialBlock {
  119308. /**
  119309. * Creates a new AddBlock
  119310. * @param name defines the block name
  119311. */
  119312. constructor(name: string);
  119313. /**
  119314. * Gets the current class name
  119315. * @returns the class name
  119316. */
  119317. getClassName(): string;
  119318. /**
  119319. * Gets the left operand input component
  119320. */
  119321. readonly left: NodeMaterialConnectionPoint;
  119322. /**
  119323. * Gets the right operand input component
  119324. */
  119325. readonly right: NodeMaterialConnectionPoint;
  119326. /**
  119327. * Gets the output component
  119328. */
  119329. readonly output: NodeMaterialConnectionPoint;
  119330. protected _buildBlock(state: NodeMaterialBuildState): this;
  119331. }
  119332. }
  119333. declare module BABYLON {
  119334. /**
  119335. * Block used to scale a vector by a float
  119336. */
  119337. export class ScaleBlock extends NodeMaterialBlock {
  119338. /**
  119339. * Creates a new ScaleBlock
  119340. * @param name defines the block name
  119341. */
  119342. constructor(name: string);
  119343. /**
  119344. * Gets the current class name
  119345. * @returns the class name
  119346. */
  119347. getClassName(): string;
  119348. /**
  119349. * Gets the input component
  119350. */
  119351. readonly input: NodeMaterialConnectionPoint;
  119352. /**
  119353. * Gets the factor input component
  119354. */
  119355. readonly factor: NodeMaterialConnectionPoint;
  119356. /**
  119357. * Gets the output component
  119358. */
  119359. readonly output: NodeMaterialConnectionPoint;
  119360. protected _buildBlock(state: NodeMaterialBuildState): this;
  119361. }
  119362. }
  119363. declare module BABYLON {
  119364. /**
  119365. * Block used to clamp a float
  119366. */
  119367. export class ClampBlock extends NodeMaterialBlock {
  119368. /** Gets or sets the minimum range */
  119369. minimum: number;
  119370. /** Gets or sets the maximum range */
  119371. maximum: number;
  119372. /**
  119373. * Creates a new ClampBlock
  119374. * @param name defines the block name
  119375. */
  119376. constructor(name: string);
  119377. /**
  119378. * Gets the current class name
  119379. * @returns the class name
  119380. */
  119381. getClassName(): string;
  119382. /**
  119383. * Gets the value input component
  119384. */
  119385. readonly value: NodeMaterialConnectionPoint;
  119386. /**
  119387. * Gets the output component
  119388. */
  119389. readonly output: NodeMaterialConnectionPoint;
  119390. protected _buildBlock(state: NodeMaterialBuildState): this;
  119391. protected _dumpPropertiesCode(): string;
  119392. serialize(): any;
  119393. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119394. }
  119395. }
  119396. declare module BABYLON {
  119397. /**
  119398. * Block used to apply a cross product between 2 vectors
  119399. */
  119400. export class CrossBlock extends NodeMaterialBlock {
  119401. /**
  119402. * Creates a new CrossBlock
  119403. * @param name defines the block name
  119404. */
  119405. constructor(name: string);
  119406. /**
  119407. * Gets the current class name
  119408. * @returns the class name
  119409. */
  119410. getClassName(): string;
  119411. /**
  119412. * Gets the left operand input component
  119413. */
  119414. readonly left: NodeMaterialConnectionPoint;
  119415. /**
  119416. * Gets the right operand input component
  119417. */
  119418. readonly right: NodeMaterialConnectionPoint;
  119419. /**
  119420. * Gets the output component
  119421. */
  119422. readonly output: NodeMaterialConnectionPoint;
  119423. protected _buildBlock(state: NodeMaterialBuildState): this;
  119424. }
  119425. }
  119426. declare module BABYLON {
  119427. /**
  119428. * Block used to apply a dot product between 2 vectors
  119429. */
  119430. export class DotBlock extends NodeMaterialBlock {
  119431. /**
  119432. * Creates a new DotBlock
  119433. * @param name defines the block name
  119434. */
  119435. constructor(name: string);
  119436. /**
  119437. * Gets the current class name
  119438. * @returns the class name
  119439. */
  119440. getClassName(): string;
  119441. /**
  119442. * Gets the left operand input component
  119443. */
  119444. readonly left: NodeMaterialConnectionPoint;
  119445. /**
  119446. * Gets the right operand input component
  119447. */
  119448. readonly right: NodeMaterialConnectionPoint;
  119449. /**
  119450. * Gets the output component
  119451. */
  119452. readonly output: NodeMaterialConnectionPoint;
  119453. protected _buildBlock(state: NodeMaterialBuildState): this;
  119454. }
  119455. }
  119456. declare module BABYLON {
  119457. /**
  119458. * Block used to remap a float from a range to a new one
  119459. */
  119460. export class RemapBlock extends NodeMaterialBlock {
  119461. /**
  119462. * Gets or sets the source range
  119463. */
  119464. sourceRange: Vector2;
  119465. /**
  119466. * Gets or sets the target range
  119467. */
  119468. targetRange: Vector2;
  119469. /**
  119470. * Creates a new RemapBlock
  119471. * @param name defines the block name
  119472. */
  119473. constructor(name: string);
  119474. /**
  119475. * Gets the current class name
  119476. * @returns the class name
  119477. */
  119478. getClassName(): string;
  119479. /**
  119480. * Gets the input component
  119481. */
  119482. readonly input: NodeMaterialConnectionPoint;
  119483. /**
  119484. * Gets the source min input component
  119485. */
  119486. readonly sourceMin: NodeMaterialConnectionPoint;
  119487. /**
  119488. * Gets the source max input component
  119489. */
  119490. readonly sourceMax: NodeMaterialConnectionPoint;
  119491. /**
  119492. * Gets the target min input component
  119493. */
  119494. readonly targetMin: NodeMaterialConnectionPoint;
  119495. /**
  119496. * Gets the target max input component
  119497. */
  119498. readonly targetMax: NodeMaterialConnectionPoint;
  119499. /**
  119500. * Gets the output component
  119501. */
  119502. readonly output: NodeMaterialConnectionPoint;
  119503. protected _buildBlock(state: NodeMaterialBuildState): this;
  119504. protected _dumpPropertiesCode(): string;
  119505. serialize(): any;
  119506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119507. }
  119508. }
  119509. declare module BABYLON {
  119510. /**
  119511. * Block used to normalize a vector
  119512. */
  119513. export class NormalizeBlock extends NodeMaterialBlock {
  119514. /**
  119515. * Creates a new NormalizeBlock
  119516. * @param name defines the block name
  119517. */
  119518. constructor(name: string);
  119519. /**
  119520. * Gets the current class name
  119521. * @returns the class name
  119522. */
  119523. getClassName(): string;
  119524. /**
  119525. * Gets the input component
  119526. */
  119527. readonly input: NodeMaterialConnectionPoint;
  119528. /**
  119529. * Gets the output component
  119530. */
  119531. readonly output: NodeMaterialConnectionPoint;
  119532. protected _buildBlock(state: NodeMaterialBuildState): this;
  119533. }
  119534. }
  119535. declare module BABYLON {
  119536. /**
  119537. * Operations supported by the Trigonometry block
  119538. */
  119539. export enum TrigonometryBlockOperations {
  119540. /** Cos */
  119541. Cos = 0,
  119542. /** Sin */
  119543. Sin = 1,
  119544. /** Abs */
  119545. Abs = 2,
  119546. /** Exp */
  119547. Exp = 3,
  119548. /** Exp2 */
  119549. Exp2 = 4,
  119550. /** Round */
  119551. Round = 5,
  119552. /** Floor */
  119553. Floor = 6,
  119554. /** Ceiling */
  119555. Ceiling = 7
  119556. }
  119557. /**
  119558. * Block used to apply trigonometry operation to floats
  119559. */
  119560. export class TrigonometryBlock extends NodeMaterialBlock {
  119561. /**
  119562. * Gets or sets the operation applied by the block
  119563. */
  119564. operation: TrigonometryBlockOperations;
  119565. /**
  119566. * Creates a new TrigonometryBlock
  119567. * @param name defines the block name
  119568. */
  119569. constructor(name: string);
  119570. /**
  119571. * Gets the current class name
  119572. * @returns the class name
  119573. */
  119574. getClassName(): string;
  119575. /**
  119576. * Gets the input component
  119577. */
  119578. readonly input: NodeMaterialConnectionPoint;
  119579. /**
  119580. * Gets the output component
  119581. */
  119582. readonly output: NodeMaterialConnectionPoint;
  119583. protected _buildBlock(state: NodeMaterialBuildState): this;
  119584. serialize(): any;
  119585. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119586. }
  119587. }
  119588. declare module BABYLON {
  119589. /**
  119590. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119591. */
  119592. export class ColorMergerBlock extends NodeMaterialBlock {
  119593. /**
  119594. * Create a new ColorMergerBlock
  119595. * @param name defines the block name
  119596. */
  119597. constructor(name: string);
  119598. /**
  119599. * Gets the current class name
  119600. * @returns the class name
  119601. */
  119602. getClassName(): string;
  119603. /**
  119604. * Gets the r component (input)
  119605. */
  119606. readonly r: NodeMaterialConnectionPoint;
  119607. /**
  119608. * Gets the g component (input)
  119609. */
  119610. readonly g: NodeMaterialConnectionPoint;
  119611. /**
  119612. * Gets the b component (input)
  119613. */
  119614. readonly b: NodeMaterialConnectionPoint;
  119615. /**
  119616. * Gets the a component (input)
  119617. */
  119618. readonly a: NodeMaterialConnectionPoint;
  119619. /**
  119620. * Gets the rgba component (output)
  119621. */
  119622. readonly rgba: NodeMaterialConnectionPoint;
  119623. /**
  119624. * Gets the rgb component (output)
  119625. */
  119626. readonly rgb: NodeMaterialConnectionPoint;
  119627. protected _buildBlock(state: NodeMaterialBuildState): this;
  119628. }
  119629. }
  119630. declare module BABYLON {
  119631. /**
  119632. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119633. */
  119634. export class VectorMergerBlock extends NodeMaterialBlock {
  119635. /**
  119636. * Create a new VectorMergerBlock
  119637. * @param name defines the block name
  119638. */
  119639. constructor(name: string);
  119640. /**
  119641. * Gets the current class name
  119642. * @returns the class name
  119643. */
  119644. getClassName(): string;
  119645. /**
  119646. * Gets the x component (input)
  119647. */
  119648. readonly x: NodeMaterialConnectionPoint;
  119649. /**
  119650. * Gets the y component (input)
  119651. */
  119652. readonly y: NodeMaterialConnectionPoint;
  119653. /**
  119654. * Gets the z component (input)
  119655. */
  119656. readonly z: NodeMaterialConnectionPoint;
  119657. /**
  119658. * Gets the w component (input)
  119659. */
  119660. readonly w: NodeMaterialConnectionPoint;
  119661. /**
  119662. * Gets the xyzw component (output)
  119663. */
  119664. readonly xyzw: NodeMaterialConnectionPoint;
  119665. /**
  119666. * Gets the xyz component (output)
  119667. */
  119668. readonly xyz: NodeMaterialConnectionPoint;
  119669. /**
  119670. * Gets the xy component (output)
  119671. */
  119672. readonly xy: NodeMaterialConnectionPoint;
  119673. protected _buildBlock(state: NodeMaterialBuildState): this;
  119674. }
  119675. }
  119676. declare module BABYLON {
  119677. /**
  119678. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119679. */
  119680. export class ColorSplitterBlock extends NodeMaterialBlock {
  119681. /**
  119682. * Create a new ColorSplitterBlock
  119683. * @param name defines the block name
  119684. */
  119685. constructor(name: string);
  119686. /**
  119687. * Gets the current class name
  119688. * @returns the class name
  119689. */
  119690. getClassName(): string;
  119691. /**
  119692. * Gets the rgba component (input)
  119693. */
  119694. readonly rgba: NodeMaterialConnectionPoint;
  119695. /**
  119696. * Gets the rgb component (input)
  119697. */
  119698. readonly rgbIn: NodeMaterialConnectionPoint;
  119699. /**
  119700. * Gets the rgb component (output)
  119701. */
  119702. readonly rgbOut: NodeMaterialConnectionPoint;
  119703. /**
  119704. * Gets the r component (output)
  119705. */
  119706. readonly r: NodeMaterialConnectionPoint;
  119707. /**
  119708. * Gets the g component (output)
  119709. */
  119710. readonly g: NodeMaterialConnectionPoint;
  119711. /**
  119712. * Gets the b component (output)
  119713. */
  119714. readonly b: NodeMaterialConnectionPoint;
  119715. /**
  119716. * Gets the a component (output)
  119717. */
  119718. readonly a: NodeMaterialConnectionPoint;
  119719. protected _inputRename(name: string): string;
  119720. protected _outputRename(name: string): string;
  119721. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119722. }
  119723. }
  119724. declare module BABYLON {
  119725. /**
  119726. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119727. */
  119728. export class VectorSplitterBlock extends NodeMaterialBlock {
  119729. /**
  119730. * Create a new VectorSplitterBlock
  119731. * @param name defines the block name
  119732. */
  119733. constructor(name: string);
  119734. /**
  119735. * Gets the current class name
  119736. * @returns the class name
  119737. */
  119738. getClassName(): string;
  119739. /**
  119740. * Gets the xyzw component (input)
  119741. */
  119742. readonly xyzw: NodeMaterialConnectionPoint;
  119743. /**
  119744. * Gets the xyz component (input)
  119745. */
  119746. readonly xyzIn: NodeMaterialConnectionPoint;
  119747. /**
  119748. * Gets the xy component (input)
  119749. */
  119750. readonly xyIn: NodeMaterialConnectionPoint;
  119751. /**
  119752. * Gets the xyz component (output)
  119753. */
  119754. readonly xyzOut: NodeMaterialConnectionPoint;
  119755. /**
  119756. * Gets the xy component (output)
  119757. */
  119758. readonly xyOut: NodeMaterialConnectionPoint;
  119759. /**
  119760. * Gets the x component (output)
  119761. */
  119762. readonly x: NodeMaterialConnectionPoint;
  119763. /**
  119764. * Gets the y component (output)
  119765. */
  119766. readonly y: NodeMaterialConnectionPoint;
  119767. /**
  119768. * Gets the z component (output)
  119769. */
  119770. readonly z: NodeMaterialConnectionPoint;
  119771. /**
  119772. * Gets the w component (output)
  119773. */
  119774. readonly w: NodeMaterialConnectionPoint;
  119775. protected _inputRename(name: string): string;
  119776. protected _outputRename(name: string): string;
  119777. protected _buildBlock(state: NodeMaterialBuildState): this;
  119778. }
  119779. }
  119780. declare module BABYLON {
  119781. /**
  119782. * Block used to lerp 2 values
  119783. */
  119784. export class LerpBlock extends NodeMaterialBlock {
  119785. /**
  119786. * Creates a new LerpBlock
  119787. * @param name defines the block name
  119788. */
  119789. constructor(name: string);
  119790. /**
  119791. * Gets the current class name
  119792. * @returns the class name
  119793. */
  119794. getClassName(): string;
  119795. /**
  119796. * Gets the left operand input component
  119797. */
  119798. readonly left: NodeMaterialConnectionPoint;
  119799. /**
  119800. * Gets the right operand input component
  119801. */
  119802. readonly right: NodeMaterialConnectionPoint;
  119803. /**
  119804. * Gets the gradient operand input component
  119805. */
  119806. readonly gradient: NodeMaterialConnectionPoint;
  119807. /**
  119808. * Gets the output component
  119809. */
  119810. readonly output: NodeMaterialConnectionPoint;
  119811. protected _buildBlock(state: NodeMaterialBuildState): this;
  119812. }
  119813. }
  119814. declare module BABYLON {
  119815. /**
  119816. * Block used to divide 2 vectors
  119817. */
  119818. export class DivideBlock extends NodeMaterialBlock {
  119819. /**
  119820. * Creates a new DivideBlock
  119821. * @param name defines the block name
  119822. */
  119823. constructor(name: string);
  119824. /**
  119825. * Gets the current class name
  119826. * @returns the class name
  119827. */
  119828. getClassName(): string;
  119829. /**
  119830. * Gets the left operand input component
  119831. */
  119832. readonly left: NodeMaterialConnectionPoint;
  119833. /**
  119834. * Gets the right operand input component
  119835. */
  119836. readonly right: NodeMaterialConnectionPoint;
  119837. /**
  119838. * Gets the output component
  119839. */
  119840. readonly output: NodeMaterialConnectionPoint;
  119841. protected _buildBlock(state: NodeMaterialBuildState): this;
  119842. }
  119843. }
  119844. declare module BABYLON {
  119845. /**
  119846. * Block used to subtract 2 vectors
  119847. */
  119848. export class SubtractBlock extends NodeMaterialBlock {
  119849. /**
  119850. * Creates a new SubtractBlock
  119851. * @param name defines the block name
  119852. */
  119853. constructor(name: string);
  119854. /**
  119855. * Gets the current class name
  119856. * @returns the class name
  119857. */
  119858. getClassName(): string;
  119859. /**
  119860. * Gets the left operand input component
  119861. */
  119862. readonly left: NodeMaterialConnectionPoint;
  119863. /**
  119864. * Gets the right operand input component
  119865. */
  119866. readonly right: NodeMaterialConnectionPoint;
  119867. /**
  119868. * Gets the output component
  119869. */
  119870. readonly output: NodeMaterialConnectionPoint;
  119871. protected _buildBlock(state: NodeMaterialBuildState): this;
  119872. }
  119873. }
  119874. declare module BABYLON {
  119875. /**
  119876. * Block used to step a value
  119877. */
  119878. export class StepBlock extends NodeMaterialBlock {
  119879. /**
  119880. * Creates a new AddBlock
  119881. * @param name defines the block name
  119882. */
  119883. constructor(name: string);
  119884. /**
  119885. * Gets the current class name
  119886. * @returns the class name
  119887. */
  119888. getClassName(): string;
  119889. /**
  119890. * Gets the value operand input component
  119891. */
  119892. readonly value: NodeMaterialConnectionPoint;
  119893. /**
  119894. * Gets the edge operand input component
  119895. */
  119896. readonly edge: NodeMaterialConnectionPoint;
  119897. /**
  119898. * Gets the output component
  119899. */
  119900. readonly output: NodeMaterialConnectionPoint;
  119901. protected _buildBlock(state: NodeMaterialBuildState): this;
  119902. }
  119903. }
  119904. declare module BABYLON {
  119905. /**
  119906. * Block used to get the opposite (1 - x) of a value
  119907. */
  119908. export class OneMinusBlock extends NodeMaterialBlock {
  119909. /**
  119910. * Creates a new OneMinusBlock
  119911. * @param name defines the block name
  119912. */
  119913. constructor(name: string);
  119914. /**
  119915. * Gets the current class name
  119916. * @returns the class name
  119917. */
  119918. getClassName(): string;
  119919. /**
  119920. * Gets the input component
  119921. */
  119922. readonly input: NodeMaterialConnectionPoint;
  119923. /**
  119924. * Gets the output component
  119925. */
  119926. readonly output: NodeMaterialConnectionPoint;
  119927. protected _buildBlock(state: NodeMaterialBuildState): this;
  119928. }
  119929. }
  119930. declare module BABYLON {
  119931. /**
  119932. * Block used to get the view direction
  119933. */
  119934. export class ViewDirectionBlock extends NodeMaterialBlock {
  119935. /**
  119936. * Creates a new ViewDirectionBlock
  119937. * @param name defines the block name
  119938. */
  119939. constructor(name: string);
  119940. /**
  119941. * Gets the current class name
  119942. * @returns the class name
  119943. */
  119944. getClassName(): string;
  119945. /**
  119946. * Gets the world position component
  119947. */
  119948. readonly worldPosition: NodeMaterialConnectionPoint;
  119949. /**
  119950. * Gets the camera position component
  119951. */
  119952. readonly cameraPosition: NodeMaterialConnectionPoint;
  119953. /**
  119954. * Gets the output component
  119955. */
  119956. readonly output: NodeMaterialConnectionPoint;
  119957. autoConfigure(material: NodeMaterial): void;
  119958. protected _buildBlock(state: NodeMaterialBuildState): this;
  119959. }
  119960. }
  119961. declare module BABYLON {
  119962. /**
  119963. * Block used to compute fresnel value
  119964. */
  119965. export class FresnelBlock extends NodeMaterialBlock {
  119966. /**
  119967. * Create a new FresnelBlock
  119968. * @param name defines the block name
  119969. */
  119970. constructor(name: string);
  119971. /**
  119972. * Gets the current class name
  119973. * @returns the class name
  119974. */
  119975. getClassName(): string;
  119976. /**
  119977. * Gets the world normal input component
  119978. */
  119979. readonly worldNormal: NodeMaterialConnectionPoint;
  119980. /**
  119981. * Gets the view direction input component
  119982. */
  119983. readonly viewDirection: NodeMaterialConnectionPoint;
  119984. /**
  119985. * Gets the bias input component
  119986. */
  119987. readonly bias: NodeMaterialConnectionPoint;
  119988. /**
  119989. * Gets the camera (or eye) position component
  119990. */
  119991. readonly power: NodeMaterialConnectionPoint;
  119992. /**
  119993. * Gets the fresnel output component
  119994. */
  119995. readonly fresnel: NodeMaterialConnectionPoint;
  119996. autoConfigure(material: NodeMaterial): void;
  119997. protected _buildBlock(state: NodeMaterialBuildState): this;
  119998. }
  119999. }
  120000. declare module BABYLON {
  120001. /**
  120002. * Block used to get the max of 2 values
  120003. */
  120004. export class MaxBlock extends NodeMaterialBlock {
  120005. /**
  120006. * Creates a new MaxBlock
  120007. * @param name defines the block name
  120008. */
  120009. constructor(name: string);
  120010. /**
  120011. * Gets the current class name
  120012. * @returns the class name
  120013. */
  120014. getClassName(): string;
  120015. /**
  120016. * Gets the left operand input component
  120017. */
  120018. readonly left: NodeMaterialConnectionPoint;
  120019. /**
  120020. * Gets the right operand input component
  120021. */
  120022. readonly right: NodeMaterialConnectionPoint;
  120023. /**
  120024. * Gets the output component
  120025. */
  120026. readonly output: NodeMaterialConnectionPoint;
  120027. protected _buildBlock(state: NodeMaterialBuildState): this;
  120028. }
  120029. }
  120030. declare module BABYLON {
  120031. /**
  120032. * Block used to get the min of 2 values
  120033. */
  120034. export class MinBlock extends NodeMaterialBlock {
  120035. /**
  120036. * Creates a new MinBlock
  120037. * @param name defines the block name
  120038. */
  120039. constructor(name: string);
  120040. /**
  120041. * Gets the current class name
  120042. * @returns the class name
  120043. */
  120044. getClassName(): string;
  120045. /**
  120046. * Gets the left operand input component
  120047. */
  120048. readonly left: NodeMaterialConnectionPoint;
  120049. /**
  120050. * Gets the right operand input component
  120051. */
  120052. readonly right: NodeMaterialConnectionPoint;
  120053. /**
  120054. * Gets the output component
  120055. */
  120056. readonly output: NodeMaterialConnectionPoint;
  120057. protected _buildBlock(state: NodeMaterialBuildState): this;
  120058. }
  120059. }
  120060. declare module BABYLON {
  120061. /**
  120062. * Effect Render Options
  120063. */
  120064. export interface IEffectRendererOptions {
  120065. /**
  120066. * Defines the vertices positions.
  120067. */
  120068. positions?: number[];
  120069. /**
  120070. * Defines the indices.
  120071. */
  120072. indices?: number[];
  120073. }
  120074. /**
  120075. * Helper class to render one or more effects
  120076. */
  120077. export class EffectRenderer {
  120078. private engine;
  120079. private static _DefaultOptions;
  120080. private _vertexBuffers;
  120081. private _indexBuffer;
  120082. private _ringBufferIndex;
  120083. private _ringScreenBuffer;
  120084. private _fullscreenViewport;
  120085. private _getNextFrameBuffer;
  120086. /**
  120087. * Creates an effect renderer
  120088. * @param engine the engine to use for rendering
  120089. * @param options defines the options of the effect renderer
  120090. */
  120091. constructor(engine: Engine, options?: IEffectRendererOptions);
  120092. /**
  120093. * Sets the current viewport in normalized coordinates 0-1
  120094. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120095. */
  120096. setViewport(viewport?: Viewport): void;
  120097. /**
  120098. * Binds the embedded attributes buffer to the effect.
  120099. * @param effect Defines the effect to bind the attributes for
  120100. */
  120101. bindBuffers(effect: Effect): void;
  120102. /**
  120103. * Sets the current effect wrapper to use during draw.
  120104. * The effect needs to be ready before calling this api.
  120105. * This also sets the default full screen position attribute.
  120106. * @param effectWrapper Defines the effect to draw with
  120107. */
  120108. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120109. /**
  120110. * Draws a full screen quad.
  120111. */
  120112. draw(): void;
  120113. /**
  120114. * renders one or more effects to a specified texture
  120115. * @param effectWrappers list of effects to renderer
  120116. * @param outputTexture texture to draw to, if null it will render to the screen
  120117. */
  120118. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120119. /**
  120120. * Disposes of the effect renderer
  120121. */
  120122. dispose(): void;
  120123. }
  120124. /**
  120125. * Options to create an EffectWrapper
  120126. */
  120127. interface EffectWrapperCreationOptions {
  120128. /**
  120129. * Engine to use to create the effect
  120130. */
  120131. engine: Engine;
  120132. /**
  120133. * Fragment shader for the effect
  120134. */
  120135. fragmentShader: string;
  120136. /**
  120137. * Vertex shader for the effect
  120138. */
  120139. vertexShader?: string;
  120140. /**
  120141. * Attributes to use in the shader
  120142. */
  120143. attributeNames?: Array<string>;
  120144. /**
  120145. * Uniforms to use in the shader
  120146. */
  120147. uniformNames?: Array<string>;
  120148. /**
  120149. * Texture sampler names to use in the shader
  120150. */
  120151. samplerNames?: Array<string>;
  120152. /**
  120153. * The friendly name of the effect displayed in Spector.
  120154. */
  120155. name?: string;
  120156. }
  120157. /**
  120158. * Wraps an effect to be used for rendering
  120159. */
  120160. export class EffectWrapper {
  120161. /**
  120162. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120163. */
  120164. onApplyObservable: Observable<{}>;
  120165. /**
  120166. * The underlying effect
  120167. */
  120168. effect: Effect;
  120169. /**
  120170. * Creates an effect to be renderer
  120171. * @param creationOptions options to create the effect
  120172. */
  120173. constructor(creationOptions: EffectWrapperCreationOptions);
  120174. /**
  120175. * Disposes of the effect wrapper
  120176. */
  120177. dispose(): void;
  120178. }
  120179. }
  120180. declare module BABYLON {
  120181. /**
  120182. * Helper class to push actions to a pool of workers.
  120183. */
  120184. export class WorkerPool implements IDisposable {
  120185. private _workerInfos;
  120186. private _pendingActions;
  120187. /**
  120188. * Constructor
  120189. * @param workers Array of workers to use for actions
  120190. */
  120191. constructor(workers: Array<Worker>);
  120192. /**
  120193. * Terminates all workers and clears any pending actions.
  120194. */
  120195. dispose(): void;
  120196. /**
  120197. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120198. * pended until a worker has completed its action.
  120199. * @param action The action to perform. Call onComplete when the action is complete.
  120200. */
  120201. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120202. private _execute;
  120203. }
  120204. }
  120205. declare module BABYLON {
  120206. /**
  120207. * Configuration for Draco compression
  120208. */
  120209. export interface IDracoCompressionConfiguration {
  120210. /**
  120211. * Configuration for the decoder.
  120212. */
  120213. decoder: {
  120214. /**
  120215. * The url to the WebAssembly module.
  120216. */
  120217. wasmUrl?: string;
  120218. /**
  120219. * The url to the WebAssembly binary.
  120220. */
  120221. wasmBinaryUrl?: string;
  120222. /**
  120223. * The url to the fallback JavaScript module.
  120224. */
  120225. fallbackUrl?: string;
  120226. };
  120227. }
  120228. /**
  120229. * Draco compression (https://google.github.io/draco/)
  120230. *
  120231. * This class wraps the Draco module.
  120232. *
  120233. * **Encoder**
  120234. *
  120235. * The encoder is not currently implemented.
  120236. *
  120237. * **Decoder**
  120238. *
  120239. * 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.
  120240. *
  120241. * To update the configuration, use the following code:
  120242. * ```javascript
  120243. * DracoCompression.Configuration = {
  120244. * decoder: {
  120245. * wasmUrl: "<url to the WebAssembly library>",
  120246. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120247. * fallbackUrl: "<url to the fallback JavaScript library>",
  120248. * }
  120249. * };
  120250. * ```
  120251. *
  120252. * 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.
  120253. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120254. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120255. *
  120256. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120257. * ```javascript
  120258. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120259. * ```
  120260. *
  120261. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120262. */
  120263. export class DracoCompression implements IDisposable {
  120264. private _workerPoolPromise?;
  120265. private _decoderModulePromise?;
  120266. /**
  120267. * The configuration. Defaults to the following urls:
  120268. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120269. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120270. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120271. */
  120272. static Configuration: IDracoCompressionConfiguration;
  120273. /**
  120274. * Returns true if the decoder configuration is available.
  120275. */
  120276. static readonly DecoderAvailable: boolean;
  120277. /**
  120278. * Default number of workers to create when creating the draco compression object.
  120279. */
  120280. static DefaultNumWorkers: number;
  120281. private static GetDefaultNumWorkers;
  120282. private static _Default;
  120283. /**
  120284. * Default instance for the draco compression object.
  120285. */
  120286. static readonly Default: DracoCompression;
  120287. /**
  120288. * Constructor
  120289. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120290. */
  120291. constructor(numWorkers?: number);
  120292. /**
  120293. * Stop all async operations and release resources.
  120294. */
  120295. dispose(): void;
  120296. /**
  120297. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120298. * @returns a promise that resolves when ready
  120299. */
  120300. whenReadyAsync(): Promise<void>;
  120301. /**
  120302. * Decode Draco compressed mesh data to vertex data.
  120303. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120304. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120305. * @returns A promise that resolves with the decoded vertex data
  120306. */
  120307. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120308. [kind: string]: number;
  120309. }): Promise<VertexData>;
  120310. }
  120311. }
  120312. declare module BABYLON {
  120313. /**
  120314. * Class for building Constructive Solid Geometry
  120315. */
  120316. export class CSG {
  120317. private polygons;
  120318. /**
  120319. * The world matrix
  120320. */
  120321. matrix: Matrix;
  120322. /**
  120323. * Stores the position
  120324. */
  120325. position: Vector3;
  120326. /**
  120327. * Stores the rotation
  120328. */
  120329. rotation: Vector3;
  120330. /**
  120331. * Stores the rotation quaternion
  120332. */
  120333. rotationQuaternion: Nullable<Quaternion>;
  120334. /**
  120335. * Stores the scaling vector
  120336. */
  120337. scaling: Vector3;
  120338. /**
  120339. * Convert the Mesh to CSG
  120340. * @param mesh The Mesh to convert to CSG
  120341. * @returns A new CSG from the Mesh
  120342. */
  120343. static FromMesh(mesh: Mesh): CSG;
  120344. /**
  120345. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120346. * @param polygons Polygons used to construct a CSG solid
  120347. */
  120348. private static FromPolygons;
  120349. /**
  120350. * Clones, or makes a deep copy, of the CSG
  120351. * @returns A new CSG
  120352. */
  120353. clone(): CSG;
  120354. /**
  120355. * Unions this CSG with another CSG
  120356. * @param csg The CSG to union against this CSG
  120357. * @returns The unioned CSG
  120358. */
  120359. union(csg: CSG): CSG;
  120360. /**
  120361. * Unions this CSG with another CSG in place
  120362. * @param csg The CSG to union against this CSG
  120363. */
  120364. unionInPlace(csg: CSG): void;
  120365. /**
  120366. * Subtracts this CSG with another CSG
  120367. * @param csg The CSG to subtract against this CSG
  120368. * @returns A new CSG
  120369. */
  120370. subtract(csg: CSG): CSG;
  120371. /**
  120372. * Subtracts this CSG with another CSG in place
  120373. * @param csg The CSG to subtact against this CSG
  120374. */
  120375. subtractInPlace(csg: CSG): void;
  120376. /**
  120377. * Intersect this CSG with another CSG
  120378. * @param csg The CSG to intersect against this CSG
  120379. * @returns A new CSG
  120380. */
  120381. intersect(csg: CSG): CSG;
  120382. /**
  120383. * Intersects this CSG with another CSG in place
  120384. * @param csg The CSG to intersect against this CSG
  120385. */
  120386. intersectInPlace(csg: CSG): void;
  120387. /**
  120388. * Return a new CSG solid with solid and empty space switched. This solid is
  120389. * not modified.
  120390. * @returns A new CSG solid with solid and empty space switched
  120391. */
  120392. inverse(): CSG;
  120393. /**
  120394. * Inverses the CSG in place
  120395. */
  120396. inverseInPlace(): void;
  120397. /**
  120398. * This is used to keep meshes transformations so they can be restored
  120399. * when we build back a Babylon Mesh
  120400. * NB : All CSG operations are performed in world coordinates
  120401. * @param csg The CSG to copy the transform attributes from
  120402. * @returns This CSG
  120403. */
  120404. copyTransformAttributes(csg: CSG): CSG;
  120405. /**
  120406. * Build Raw mesh from CSG
  120407. * Coordinates here are in world space
  120408. * @param name The name of the mesh geometry
  120409. * @param scene The Scene
  120410. * @param keepSubMeshes Specifies if the submeshes should be kept
  120411. * @returns A new Mesh
  120412. */
  120413. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120414. /**
  120415. * Build Mesh from CSG taking material and transforms into account
  120416. * @param name The name of the Mesh
  120417. * @param material The material of the Mesh
  120418. * @param scene The Scene
  120419. * @param keepSubMeshes Specifies if submeshes should be kept
  120420. * @returns The new Mesh
  120421. */
  120422. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120423. }
  120424. }
  120425. declare module BABYLON {
  120426. /**
  120427. * Class used to create a trail following a mesh
  120428. */
  120429. export class TrailMesh extends Mesh {
  120430. private _generator;
  120431. private _autoStart;
  120432. private _running;
  120433. private _diameter;
  120434. private _length;
  120435. private _sectionPolygonPointsCount;
  120436. private _sectionVectors;
  120437. private _sectionNormalVectors;
  120438. private _beforeRenderObserver;
  120439. /**
  120440. * @constructor
  120441. * @param name The value used by scene.getMeshByName() to do a lookup.
  120442. * @param generator The mesh to generate a trail.
  120443. * @param scene The scene to add this mesh to.
  120444. * @param diameter Diameter of trailing mesh. Default is 1.
  120445. * @param length Length of trailing mesh. Default is 60.
  120446. * @param autoStart Automatically start trailing mesh. Default true.
  120447. */
  120448. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120449. /**
  120450. * "TrailMesh"
  120451. * @returns "TrailMesh"
  120452. */
  120453. getClassName(): string;
  120454. private _createMesh;
  120455. /**
  120456. * Start trailing mesh.
  120457. */
  120458. start(): void;
  120459. /**
  120460. * Stop trailing mesh.
  120461. */
  120462. stop(): void;
  120463. /**
  120464. * Update trailing mesh geometry.
  120465. */
  120466. update(): void;
  120467. /**
  120468. * Returns a new TrailMesh object.
  120469. * @param name is a string, the name given to the new mesh
  120470. * @param newGenerator use new generator object for cloned trail mesh
  120471. * @returns a new mesh
  120472. */
  120473. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120474. /**
  120475. * Serializes this trail mesh
  120476. * @param serializationObject object to write serialization to
  120477. */
  120478. serialize(serializationObject: any): void;
  120479. /**
  120480. * Parses a serialized trail mesh
  120481. * @param parsedMesh the serialized mesh
  120482. * @param scene the scene to create the trail mesh in
  120483. * @returns the created trail mesh
  120484. */
  120485. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120486. }
  120487. }
  120488. declare module BABYLON {
  120489. /**
  120490. * Class containing static functions to help procedurally build meshes
  120491. */
  120492. export class TiledBoxBuilder {
  120493. /**
  120494. * Creates a box mesh
  120495. * 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)
  120496. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120498. * * 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
  120499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120500. * @param name defines the name of the mesh
  120501. * @param options defines the options used to create the mesh
  120502. * @param scene defines the hosting scene
  120503. * @returns the box mesh
  120504. */
  120505. static CreateTiledBox(name: string, options: {
  120506. pattern?: number;
  120507. width?: number;
  120508. height?: number;
  120509. depth?: number;
  120510. tileSize?: number;
  120511. tileWidth?: number;
  120512. tileHeight?: number;
  120513. alignHorizontal?: number;
  120514. alignVertical?: number;
  120515. faceUV?: Vector4[];
  120516. faceColors?: Color4[];
  120517. sideOrientation?: number;
  120518. updatable?: boolean;
  120519. }, scene?: Nullable<Scene>): Mesh;
  120520. }
  120521. }
  120522. declare module BABYLON {
  120523. /**
  120524. * Class containing static functions to help procedurally build meshes
  120525. */
  120526. export class TorusKnotBuilder {
  120527. /**
  120528. * Creates a torus knot mesh
  120529. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120530. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120531. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120532. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120534. * * 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
  120535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120536. * @param name defines the name of the mesh
  120537. * @param options defines the options used to create the mesh
  120538. * @param scene defines the hosting scene
  120539. * @returns the torus knot mesh
  120540. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120541. */
  120542. static CreateTorusKnot(name: string, options: {
  120543. radius?: number;
  120544. tube?: number;
  120545. radialSegments?: number;
  120546. tubularSegments?: number;
  120547. p?: number;
  120548. q?: number;
  120549. updatable?: boolean;
  120550. sideOrientation?: number;
  120551. frontUVs?: Vector4;
  120552. backUVs?: Vector4;
  120553. }, scene: any): Mesh;
  120554. }
  120555. }
  120556. declare module BABYLON {
  120557. /**
  120558. * Polygon
  120559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120560. */
  120561. export class Polygon {
  120562. /**
  120563. * Creates a rectangle
  120564. * @param xmin bottom X coord
  120565. * @param ymin bottom Y coord
  120566. * @param xmax top X coord
  120567. * @param ymax top Y coord
  120568. * @returns points that make the resulting rectation
  120569. */
  120570. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120571. /**
  120572. * Creates a circle
  120573. * @param radius radius of circle
  120574. * @param cx scale in x
  120575. * @param cy scale in y
  120576. * @param numberOfSides number of sides that make up the circle
  120577. * @returns points that make the resulting circle
  120578. */
  120579. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120580. /**
  120581. * Creates a polygon from input string
  120582. * @param input Input polygon data
  120583. * @returns the parsed points
  120584. */
  120585. static Parse(input: string): Vector2[];
  120586. /**
  120587. * Starts building a polygon from x and y coordinates
  120588. * @param x x coordinate
  120589. * @param y y coordinate
  120590. * @returns the started path2
  120591. */
  120592. static StartingAt(x: number, y: number): Path2;
  120593. }
  120594. /**
  120595. * Builds a polygon
  120596. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120597. */
  120598. export class PolygonMeshBuilder {
  120599. private _points;
  120600. private _outlinepoints;
  120601. private _holes;
  120602. private _name;
  120603. private _scene;
  120604. private _epoints;
  120605. private _eholes;
  120606. private _addToepoint;
  120607. /**
  120608. * Babylon reference to the earcut plugin.
  120609. */
  120610. bjsEarcut: any;
  120611. /**
  120612. * Creates a PolygonMeshBuilder
  120613. * @param name name of the builder
  120614. * @param contours Path of the polygon
  120615. * @param scene scene to add to when creating the mesh
  120616. * @param earcutInjection can be used to inject your own earcut reference
  120617. */
  120618. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120619. /**
  120620. * Adds a whole within the polygon
  120621. * @param hole Array of points defining the hole
  120622. * @returns this
  120623. */
  120624. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120625. /**
  120626. * Creates the polygon
  120627. * @param updatable If the mesh should be updatable
  120628. * @param depth The depth of the mesh created
  120629. * @returns the created mesh
  120630. */
  120631. build(updatable?: boolean, depth?: number): Mesh;
  120632. /**
  120633. * Creates the polygon
  120634. * @param depth The depth of the mesh created
  120635. * @returns the created VertexData
  120636. */
  120637. buildVertexData(depth?: number): VertexData;
  120638. /**
  120639. * Adds a side to the polygon
  120640. * @param positions points that make the polygon
  120641. * @param normals normals of the polygon
  120642. * @param uvs uvs of the polygon
  120643. * @param indices indices of the polygon
  120644. * @param bounds bounds of the polygon
  120645. * @param points points of the polygon
  120646. * @param depth depth of the polygon
  120647. * @param flip flip of the polygon
  120648. */
  120649. private addSide;
  120650. }
  120651. }
  120652. declare module BABYLON {
  120653. /**
  120654. * Class containing static functions to help procedurally build meshes
  120655. */
  120656. export class PolygonBuilder {
  120657. /**
  120658. * Creates a polygon mesh
  120659. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120660. * * 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
  120661. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120663. * * 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)
  120664. * * Remember you can only change the shape positions, not their number when updating a polygon
  120665. * @param name defines the name of the mesh
  120666. * @param options defines the options used to create the mesh
  120667. * @param scene defines the hosting scene
  120668. * @param earcutInjection can be used to inject your own earcut reference
  120669. * @returns the polygon mesh
  120670. */
  120671. static CreatePolygon(name: string, options: {
  120672. shape: Vector3[];
  120673. holes?: Vector3[][];
  120674. depth?: number;
  120675. faceUV?: Vector4[];
  120676. faceColors?: Color4[];
  120677. updatable?: boolean;
  120678. sideOrientation?: number;
  120679. frontUVs?: Vector4;
  120680. backUVs?: Vector4;
  120681. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120682. /**
  120683. * Creates an extruded polygon mesh, with depth in the Y direction.
  120684. * * 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)
  120685. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120686. * @param name defines the name of the mesh
  120687. * @param options defines the options used to create the mesh
  120688. * @param scene defines the hosting scene
  120689. * @param earcutInjection can be used to inject your own earcut reference
  120690. * @returns the polygon mesh
  120691. */
  120692. static ExtrudePolygon(name: string, options: {
  120693. shape: Vector3[];
  120694. holes?: Vector3[][];
  120695. depth?: number;
  120696. faceUV?: Vector4[];
  120697. faceColors?: Color4[];
  120698. updatable?: boolean;
  120699. sideOrientation?: number;
  120700. frontUVs?: Vector4;
  120701. backUVs?: Vector4;
  120702. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  120703. }
  120704. }
  120705. declare module BABYLON {
  120706. /**
  120707. * Class containing static functions to help procedurally build meshes
  120708. */
  120709. export class LatheBuilder {
  120710. /**
  120711. * Creates lathe mesh.
  120712. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  120713. * * 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
  120714. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  120715. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  120716. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  120717. * * 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
  120718. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  120719. * * 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
  120720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120721. * * 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
  120722. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120724. * @param name defines the name of the mesh
  120725. * @param options defines the options used to create the mesh
  120726. * @param scene defines the hosting scene
  120727. * @returns the lathe mesh
  120728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  120729. */
  120730. static CreateLathe(name: string, options: {
  120731. shape: Vector3[];
  120732. radius?: number;
  120733. tessellation?: number;
  120734. clip?: number;
  120735. arc?: number;
  120736. closed?: boolean;
  120737. updatable?: boolean;
  120738. sideOrientation?: number;
  120739. frontUVs?: Vector4;
  120740. backUVs?: Vector4;
  120741. cap?: number;
  120742. invertUV?: boolean;
  120743. }, scene?: Nullable<Scene>): Mesh;
  120744. }
  120745. }
  120746. declare module BABYLON {
  120747. /**
  120748. * Class containing static functions to help procedurally build meshes
  120749. */
  120750. export class TiledPlaneBuilder {
  120751. /**
  120752. * Creates a tiled plane mesh
  120753. * * The parameter `pattern` will, depending on value, do nothing or
  120754. * * * flip (reflect about central vertical) alternate tiles across and up
  120755. * * * flip every tile on alternate rows
  120756. * * * rotate (180 degs) alternate tiles across and up
  120757. * * * rotate every tile on alternate rows
  120758. * * * flip and rotate alternate tiles across and up
  120759. * * * flip and rotate every tile on alternate rows
  120760. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  120761. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  120762. * * 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
  120763. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120764. * * 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)
  120765. * * 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)
  120766. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120767. * @param name defines the name of the mesh
  120768. * @param options defines the options used to create the mesh
  120769. * @param scene defines the hosting scene
  120770. * @returns the box mesh
  120771. */
  120772. static CreateTiledPlane(name: string, options: {
  120773. pattern?: number;
  120774. tileSize?: number;
  120775. tileWidth?: number;
  120776. tileHeight?: number;
  120777. size?: number;
  120778. width?: number;
  120779. height?: number;
  120780. alignHorizontal?: number;
  120781. alignVertical?: number;
  120782. sideOrientation?: number;
  120783. frontUVs?: Vector4;
  120784. backUVs?: Vector4;
  120785. updatable?: boolean;
  120786. }, scene?: Nullable<Scene>): Mesh;
  120787. }
  120788. }
  120789. declare module BABYLON {
  120790. /**
  120791. * Class containing static functions to help procedurally build meshes
  120792. */
  120793. export class TubeBuilder {
  120794. /**
  120795. * Creates a tube mesh.
  120796. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120797. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  120798. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  120799. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  120800. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  120801. * * 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)
  120802. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  120803. * * 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
  120804. * * 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
  120805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120806. * * 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
  120807. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120809. * @param name defines the name of the mesh
  120810. * @param options defines the options used to create the mesh
  120811. * @param scene defines the hosting scene
  120812. * @returns the tube mesh
  120813. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120814. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  120815. */
  120816. static CreateTube(name: string, options: {
  120817. path: Vector3[];
  120818. radius?: number;
  120819. tessellation?: number;
  120820. radiusFunction?: {
  120821. (i: number, distance: number): number;
  120822. };
  120823. cap?: number;
  120824. arc?: number;
  120825. updatable?: boolean;
  120826. sideOrientation?: number;
  120827. frontUVs?: Vector4;
  120828. backUVs?: Vector4;
  120829. instance?: Mesh;
  120830. invertUV?: boolean;
  120831. }, scene?: Nullable<Scene>): Mesh;
  120832. }
  120833. }
  120834. declare module BABYLON {
  120835. /**
  120836. * Class containing static functions to help procedurally build meshes
  120837. */
  120838. export class IcoSphereBuilder {
  120839. /**
  120840. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  120841. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  120842. * * 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`)
  120843. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  120844. * * 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
  120845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120846. * * 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
  120847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120848. * @param name defines the name of the mesh
  120849. * @param options defines the options used to create the mesh
  120850. * @param scene defines the hosting scene
  120851. * @returns the icosahedron mesh
  120852. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  120853. */
  120854. static CreateIcoSphere(name: string, options: {
  120855. radius?: number;
  120856. radiusX?: number;
  120857. radiusY?: number;
  120858. radiusZ?: number;
  120859. flat?: boolean;
  120860. subdivisions?: number;
  120861. sideOrientation?: number;
  120862. frontUVs?: Vector4;
  120863. backUVs?: Vector4;
  120864. updatable?: boolean;
  120865. }, scene?: Nullable<Scene>): Mesh;
  120866. }
  120867. }
  120868. declare module BABYLON {
  120869. /**
  120870. * Class containing static functions to help procedurally build meshes
  120871. */
  120872. export class DecalBuilder {
  120873. /**
  120874. * Creates a decal mesh.
  120875. * 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
  120876. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  120877. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  120878. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  120879. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  120880. * @param name defines the name of the mesh
  120881. * @param sourceMesh defines the mesh where the decal must be applied
  120882. * @param options defines the options used to create the mesh
  120883. * @param scene defines the hosting scene
  120884. * @returns the decal mesh
  120885. * @see https://doc.babylonjs.com/how_to/decals
  120886. */
  120887. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  120888. position?: Vector3;
  120889. normal?: Vector3;
  120890. size?: Vector3;
  120891. angle?: number;
  120892. }): Mesh;
  120893. }
  120894. }
  120895. declare module BABYLON {
  120896. /**
  120897. * Class containing static functions to help procedurally build meshes
  120898. */
  120899. export class MeshBuilder {
  120900. /**
  120901. * Creates a box mesh
  120902. * * The parameter `size` sets the size (float) of each box side (default 1)
  120903. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120904. * * 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)
  120905. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120907. * * 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
  120908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120909. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120910. * @param name defines the name of the mesh
  120911. * @param options defines the options used to create the mesh
  120912. * @param scene defines the hosting scene
  120913. * @returns the box mesh
  120914. */
  120915. static CreateBox(name: string, options: {
  120916. size?: number;
  120917. width?: number;
  120918. height?: number;
  120919. depth?: number;
  120920. faceUV?: Vector4[];
  120921. faceColors?: Color4[];
  120922. sideOrientation?: number;
  120923. frontUVs?: Vector4;
  120924. backUVs?: Vector4;
  120925. updatable?: boolean;
  120926. }, scene?: Nullable<Scene>): Mesh;
  120927. /**
  120928. * Creates a tiled box mesh
  120929. * * faceTiles sets the pattern, tile size and number of tiles for a face
  120930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120931. * @param name defines the name of the mesh
  120932. * @param options defines the options used to create the mesh
  120933. * @param scene defines the hosting scene
  120934. * @returns the tiled box mesh
  120935. */
  120936. static CreateTiledBox(name: string, options: {
  120937. pattern?: number;
  120938. size?: number;
  120939. width?: number;
  120940. height?: number;
  120941. depth: number;
  120942. tileSize?: number;
  120943. tileWidth?: number;
  120944. tileHeight?: number;
  120945. faceUV?: Vector4[];
  120946. faceColors?: Color4[];
  120947. alignHorizontal?: number;
  120948. alignVertical?: number;
  120949. sideOrientation?: number;
  120950. updatable?: boolean;
  120951. }, scene?: Nullable<Scene>): Mesh;
  120952. /**
  120953. * Creates a sphere mesh
  120954. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  120955. * * 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`)
  120956. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  120957. * * 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
  120958. * * 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)
  120959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120960. * * 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
  120961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120962. * @param name defines the name of the mesh
  120963. * @param options defines the options used to create the mesh
  120964. * @param scene defines the hosting scene
  120965. * @returns the sphere mesh
  120966. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  120967. */
  120968. static CreateSphere(name: string, options: {
  120969. segments?: number;
  120970. diameter?: number;
  120971. diameterX?: number;
  120972. diameterY?: number;
  120973. diameterZ?: number;
  120974. arc?: number;
  120975. slice?: number;
  120976. sideOrientation?: number;
  120977. frontUVs?: Vector4;
  120978. backUVs?: Vector4;
  120979. updatable?: boolean;
  120980. }, scene?: Nullable<Scene>): Mesh;
  120981. /**
  120982. * Creates a plane polygonal mesh. By default, this is a disc
  120983. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  120984. * * 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
  120985. * * 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
  120986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120987. * * 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
  120988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120989. * @param name defines the name of the mesh
  120990. * @param options defines the options used to create the mesh
  120991. * @param scene defines the hosting scene
  120992. * @returns the plane polygonal mesh
  120993. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  120994. */
  120995. static CreateDisc(name: string, options: {
  120996. radius?: number;
  120997. tessellation?: number;
  120998. arc?: number;
  120999. updatable?: boolean;
  121000. sideOrientation?: number;
  121001. frontUVs?: Vector4;
  121002. backUVs?: Vector4;
  121003. }, scene?: Nullable<Scene>): Mesh;
  121004. /**
  121005. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121006. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121007. * * 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`)
  121008. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121009. * * 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
  121010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121011. * * 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
  121012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121013. * @param name defines the name of the mesh
  121014. * @param options defines the options used to create the mesh
  121015. * @param scene defines the hosting scene
  121016. * @returns the icosahedron mesh
  121017. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121018. */
  121019. static CreateIcoSphere(name: string, options: {
  121020. radius?: number;
  121021. radiusX?: number;
  121022. radiusY?: number;
  121023. radiusZ?: number;
  121024. flat?: boolean;
  121025. subdivisions?: number;
  121026. sideOrientation?: number;
  121027. frontUVs?: Vector4;
  121028. backUVs?: Vector4;
  121029. updatable?: boolean;
  121030. }, scene?: Nullable<Scene>): Mesh;
  121031. /**
  121032. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121033. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121034. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121035. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121036. * * 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
  121037. * * 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
  121038. * * 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
  121039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121040. * * 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
  121041. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121042. * * 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
  121043. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121044. * * 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
  121045. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121047. * @param name defines the name of the mesh
  121048. * @param options defines the options used to create the mesh
  121049. * @param scene defines the hosting scene
  121050. * @returns the ribbon mesh
  121051. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121052. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121053. */
  121054. static CreateRibbon(name: string, options: {
  121055. pathArray: Vector3[][];
  121056. closeArray?: boolean;
  121057. closePath?: boolean;
  121058. offset?: number;
  121059. updatable?: boolean;
  121060. sideOrientation?: number;
  121061. frontUVs?: Vector4;
  121062. backUVs?: Vector4;
  121063. instance?: Mesh;
  121064. invertUV?: boolean;
  121065. uvs?: Vector2[];
  121066. colors?: Color4[];
  121067. }, scene?: Nullable<Scene>): Mesh;
  121068. /**
  121069. * Creates a cylinder or a cone mesh
  121070. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121071. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121072. * * 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.
  121073. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121074. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121075. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121076. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121077. * * 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).
  121078. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121079. * * 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).
  121080. * * 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
  121081. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121082. * * 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
  121083. * * 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.
  121084. * * If `enclose` is false, a ring surface is one element.
  121085. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121086. * * 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
  121087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121088. * * 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
  121089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121090. * @param name defines the name of the mesh
  121091. * @param options defines the options used to create the mesh
  121092. * @param scene defines the hosting scene
  121093. * @returns the cylinder mesh
  121094. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121095. */
  121096. static CreateCylinder(name: string, options: {
  121097. height?: number;
  121098. diameterTop?: number;
  121099. diameterBottom?: number;
  121100. diameter?: number;
  121101. tessellation?: number;
  121102. subdivisions?: number;
  121103. arc?: number;
  121104. faceColors?: Color4[];
  121105. faceUV?: Vector4[];
  121106. updatable?: boolean;
  121107. hasRings?: boolean;
  121108. enclose?: boolean;
  121109. cap?: number;
  121110. sideOrientation?: number;
  121111. frontUVs?: Vector4;
  121112. backUVs?: Vector4;
  121113. }, scene?: Nullable<Scene>): Mesh;
  121114. /**
  121115. * Creates a torus mesh
  121116. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121117. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121118. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121120. * * 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
  121121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121122. * @param name defines the name of the mesh
  121123. * @param options defines the options used to create the mesh
  121124. * @param scene defines the hosting scene
  121125. * @returns the torus mesh
  121126. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121127. */
  121128. static CreateTorus(name: string, options: {
  121129. diameter?: number;
  121130. thickness?: number;
  121131. tessellation?: number;
  121132. updatable?: boolean;
  121133. sideOrientation?: number;
  121134. frontUVs?: Vector4;
  121135. backUVs?: Vector4;
  121136. }, scene?: Nullable<Scene>): Mesh;
  121137. /**
  121138. * Creates a torus knot mesh
  121139. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121140. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121141. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121142. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121144. * * 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
  121145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121146. * @param name defines the name of the mesh
  121147. * @param options defines the options used to create the mesh
  121148. * @param scene defines the hosting scene
  121149. * @returns the torus knot mesh
  121150. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121151. */
  121152. static CreateTorusKnot(name: string, options: {
  121153. radius?: number;
  121154. tube?: number;
  121155. radialSegments?: number;
  121156. tubularSegments?: number;
  121157. p?: number;
  121158. q?: number;
  121159. updatable?: boolean;
  121160. sideOrientation?: number;
  121161. frontUVs?: Vector4;
  121162. backUVs?: Vector4;
  121163. }, scene?: Nullable<Scene>): Mesh;
  121164. /**
  121165. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121166. * * 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
  121167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121168. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121169. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121170. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121171. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121172. * * 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
  121173. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121176. * @param name defines the name of the new line system
  121177. * @param options defines the options used to create the line system
  121178. * @param scene defines the hosting scene
  121179. * @returns a new line system mesh
  121180. */
  121181. static CreateLineSystem(name: string, options: {
  121182. lines: Vector3[][];
  121183. updatable?: boolean;
  121184. instance?: Nullable<LinesMesh>;
  121185. colors?: Nullable<Color4[][]>;
  121186. useVertexAlpha?: boolean;
  121187. }, scene: Nullable<Scene>): LinesMesh;
  121188. /**
  121189. * Creates a line mesh
  121190. * 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
  121191. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121192. * * The parameter `points` is an array successive Vector3
  121193. * * 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
  121194. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121195. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121196. * * When updating an instance, remember that only point positions can change, not the number of points
  121197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121199. * @param name defines the name of the new line system
  121200. * @param options defines the options used to create the line system
  121201. * @param scene defines the hosting scene
  121202. * @returns a new line mesh
  121203. */
  121204. static CreateLines(name: string, options: {
  121205. points: Vector3[];
  121206. updatable?: boolean;
  121207. instance?: Nullable<LinesMesh>;
  121208. colors?: Color4[];
  121209. useVertexAlpha?: boolean;
  121210. }, scene?: Nullable<Scene>): LinesMesh;
  121211. /**
  121212. * Creates a dashed line mesh
  121213. * * 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
  121214. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121215. * * The parameter `points` is an array successive Vector3
  121216. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121217. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121218. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121219. * * 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
  121220. * * When updating an instance, remember that only point positions can change, not the number of points
  121221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121222. * @param name defines the name of the mesh
  121223. * @param options defines the options used to create the mesh
  121224. * @param scene defines the hosting scene
  121225. * @returns the dashed line mesh
  121226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121227. */
  121228. static CreateDashedLines(name: string, options: {
  121229. points: Vector3[];
  121230. dashSize?: number;
  121231. gapSize?: number;
  121232. dashNb?: number;
  121233. updatable?: boolean;
  121234. instance?: LinesMesh;
  121235. }, scene?: Nullable<Scene>): LinesMesh;
  121236. /**
  121237. * 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.
  121238. * * 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.
  121239. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121240. * * 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.
  121241. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121242. * * 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
  121243. * * 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
  121244. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121246. * * 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
  121247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121249. * @param name defines the name of the mesh
  121250. * @param options defines the options used to create the mesh
  121251. * @param scene defines the hosting scene
  121252. * @returns the extruded shape mesh
  121253. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121254. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121255. */
  121256. static ExtrudeShape(name: string, options: {
  121257. shape: Vector3[];
  121258. path: Vector3[];
  121259. scale?: number;
  121260. rotation?: number;
  121261. cap?: number;
  121262. updatable?: boolean;
  121263. sideOrientation?: number;
  121264. frontUVs?: Vector4;
  121265. backUVs?: Vector4;
  121266. instance?: Mesh;
  121267. invertUV?: boolean;
  121268. }, scene?: Nullable<Scene>): Mesh;
  121269. /**
  121270. * Creates an custom extruded shape mesh.
  121271. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121272. * * 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.
  121273. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121274. * * 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
  121275. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121276. * * 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
  121277. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121278. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121279. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121280. * * 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
  121281. * * 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
  121282. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121284. * * 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
  121285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121287. * @param name defines the name of the mesh
  121288. * @param options defines the options used to create the mesh
  121289. * @param scene defines the hosting scene
  121290. * @returns the custom extruded shape mesh
  121291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121292. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121294. */
  121295. static ExtrudeShapeCustom(name: string, options: {
  121296. shape: Vector3[];
  121297. path: Vector3[];
  121298. scaleFunction?: any;
  121299. rotationFunction?: any;
  121300. ribbonCloseArray?: boolean;
  121301. ribbonClosePath?: boolean;
  121302. cap?: number;
  121303. updatable?: boolean;
  121304. sideOrientation?: number;
  121305. frontUVs?: Vector4;
  121306. backUVs?: Vector4;
  121307. instance?: Mesh;
  121308. invertUV?: boolean;
  121309. }, scene?: Nullable<Scene>): Mesh;
  121310. /**
  121311. * Creates lathe mesh.
  121312. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121313. * * 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
  121314. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121315. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121316. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121317. * * 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
  121318. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121319. * * 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
  121320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121321. * * 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
  121322. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121324. * @param name defines the name of the mesh
  121325. * @param options defines the options used to create the mesh
  121326. * @param scene defines the hosting scene
  121327. * @returns the lathe mesh
  121328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121329. */
  121330. static CreateLathe(name: string, options: {
  121331. shape: Vector3[];
  121332. radius?: number;
  121333. tessellation?: number;
  121334. clip?: number;
  121335. arc?: number;
  121336. closed?: boolean;
  121337. updatable?: boolean;
  121338. sideOrientation?: number;
  121339. frontUVs?: Vector4;
  121340. backUVs?: Vector4;
  121341. cap?: number;
  121342. invertUV?: boolean;
  121343. }, scene?: Nullable<Scene>): Mesh;
  121344. /**
  121345. * Creates a tiled plane mesh
  121346. * * You can set a limited pattern arrangement with the tiles
  121347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121348. * * 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
  121349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121350. * @param name defines the name of the mesh
  121351. * @param options defines the options used to create the mesh
  121352. * @param scene defines the hosting scene
  121353. * @returns the plane mesh
  121354. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121355. */
  121356. static CreateTiledPlane(name: string, options: {
  121357. pattern?: number;
  121358. tileSize?: number;
  121359. tileWidth?: number;
  121360. tileHeight?: number;
  121361. size?: number;
  121362. width?: number;
  121363. height?: number;
  121364. alignHorizontal?: number;
  121365. alignVertical?: number;
  121366. sideOrientation?: number;
  121367. frontUVs?: Vector4;
  121368. backUVs?: Vector4;
  121369. updatable?: boolean;
  121370. }, scene?: Nullable<Scene>): Mesh;
  121371. /**
  121372. * Creates a plane mesh
  121373. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121374. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121375. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121377. * * 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
  121378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121379. * @param name defines the name of the mesh
  121380. * @param options defines the options used to create the mesh
  121381. * @param scene defines the hosting scene
  121382. * @returns the plane mesh
  121383. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121384. */
  121385. static CreatePlane(name: string, options: {
  121386. size?: number;
  121387. width?: number;
  121388. height?: number;
  121389. sideOrientation?: number;
  121390. frontUVs?: Vector4;
  121391. backUVs?: Vector4;
  121392. updatable?: boolean;
  121393. sourcePlane?: Plane;
  121394. }, scene?: Nullable<Scene>): Mesh;
  121395. /**
  121396. * Creates a ground mesh
  121397. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121398. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121400. * @param name defines the name of the mesh
  121401. * @param options defines the options used to create the mesh
  121402. * @param scene defines the hosting scene
  121403. * @returns the ground mesh
  121404. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121405. */
  121406. static CreateGround(name: string, options: {
  121407. width?: number;
  121408. height?: number;
  121409. subdivisions?: number;
  121410. subdivisionsX?: number;
  121411. subdivisionsY?: number;
  121412. updatable?: boolean;
  121413. }, scene?: Nullable<Scene>): Mesh;
  121414. /**
  121415. * Creates a tiled ground mesh
  121416. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121417. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121418. * * 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
  121419. * * 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
  121420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121421. * @param name defines the name of the mesh
  121422. * @param options defines the options used to create the mesh
  121423. * @param scene defines the hosting scene
  121424. * @returns the tiled ground mesh
  121425. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121426. */
  121427. static CreateTiledGround(name: string, options: {
  121428. xmin: number;
  121429. zmin: number;
  121430. xmax: number;
  121431. zmax: number;
  121432. subdivisions?: {
  121433. w: number;
  121434. h: number;
  121435. };
  121436. precision?: {
  121437. w: number;
  121438. h: number;
  121439. };
  121440. updatable?: boolean;
  121441. }, scene?: Nullable<Scene>): Mesh;
  121442. /**
  121443. * Creates a ground mesh from a height map
  121444. * * The parameter `url` sets the URL of the height map image resource.
  121445. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121446. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121447. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121448. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121449. * * 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.
  121450. * * 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).
  121451. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121453. * @param name defines the name of the mesh
  121454. * @param url defines the url to the height map
  121455. * @param options defines the options used to create the mesh
  121456. * @param scene defines the hosting scene
  121457. * @returns the ground mesh
  121458. * @see https://doc.babylonjs.com/babylon101/height_map
  121459. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121460. */
  121461. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121462. width?: number;
  121463. height?: number;
  121464. subdivisions?: number;
  121465. minHeight?: number;
  121466. maxHeight?: number;
  121467. colorFilter?: Color3;
  121468. alphaFilter?: number;
  121469. updatable?: boolean;
  121470. onReady?: (mesh: GroundMesh) => void;
  121471. }, scene?: Nullable<Scene>): GroundMesh;
  121472. /**
  121473. * Creates a polygon mesh
  121474. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121475. * * 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
  121476. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121478. * * 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)
  121479. * * Remember you can only change the shape positions, not their number when updating a polygon
  121480. * @param name defines the name of the mesh
  121481. * @param options defines the options used to create the mesh
  121482. * @param scene defines the hosting scene
  121483. * @param earcutInjection can be used to inject your own earcut reference
  121484. * @returns the polygon mesh
  121485. */
  121486. static CreatePolygon(name: string, options: {
  121487. shape: Vector3[];
  121488. holes?: Vector3[][];
  121489. depth?: number;
  121490. faceUV?: Vector4[];
  121491. faceColors?: Color4[];
  121492. updatable?: boolean;
  121493. sideOrientation?: number;
  121494. frontUVs?: Vector4;
  121495. backUVs?: Vector4;
  121496. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121497. /**
  121498. * Creates an extruded polygon mesh, with depth in the Y direction.
  121499. * * 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)
  121500. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121501. * @param name defines the name of the mesh
  121502. * @param options defines the options used to create the mesh
  121503. * @param scene defines the hosting scene
  121504. * @param earcutInjection can be used to inject your own earcut reference
  121505. * @returns the polygon mesh
  121506. */
  121507. static ExtrudePolygon(name: string, options: {
  121508. shape: Vector3[];
  121509. holes?: Vector3[][];
  121510. depth?: number;
  121511. faceUV?: Vector4[];
  121512. faceColors?: Color4[];
  121513. updatable?: boolean;
  121514. sideOrientation?: number;
  121515. frontUVs?: Vector4;
  121516. backUVs?: Vector4;
  121517. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121518. /**
  121519. * Creates a tube mesh.
  121520. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121521. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121522. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121523. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121524. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121525. * * 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)
  121526. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121527. * * 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
  121528. * * 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
  121529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121530. * * 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
  121531. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121533. * @param name defines the name of the mesh
  121534. * @param options defines the options used to create the mesh
  121535. * @param scene defines the hosting scene
  121536. * @returns the tube mesh
  121537. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121538. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121539. */
  121540. static CreateTube(name: string, options: {
  121541. path: Vector3[];
  121542. radius?: number;
  121543. tessellation?: number;
  121544. radiusFunction?: {
  121545. (i: number, distance: number): number;
  121546. };
  121547. cap?: number;
  121548. arc?: number;
  121549. updatable?: boolean;
  121550. sideOrientation?: number;
  121551. frontUVs?: Vector4;
  121552. backUVs?: Vector4;
  121553. instance?: Mesh;
  121554. invertUV?: boolean;
  121555. }, scene?: Nullable<Scene>): Mesh;
  121556. /**
  121557. * Creates a polyhedron mesh
  121558. * * 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
  121559. * * The parameter `size` (positive float, default 1) sets the polygon size
  121560. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121561. * * 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`
  121562. * * 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
  121563. * * 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)`)
  121564. * * 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
  121565. * * 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
  121566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121567. * * 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
  121568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121569. * @param name defines the name of the mesh
  121570. * @param options defines the options used to create the mesh
  121571. * @param scene defines the hosting scene
  121572. * @returns the polyhedron mesh
  121573. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121574. */
  121575. static CreatePolyhedron(name: string, options: {
  121576. type?: number;
  121577. size?: number;
  121578. sizeX?: number;
  121579. sizeY?: number;
  121580. sizeZ?: number;
  121581. custom?: any;
  121582. faceUV?: Vector4[];
  121583. faceColors?: Color4[];
  121584. flat?: boolean;
  121585. updatable?: boolean;
  121586. sideOrientation?: number;
  121587. frontUVs?: Vector4;
  121588. backUVs?: Vector4;
  121589. }, scene?: Nullable<Scene>): Mesh;
  121590. /**
  121591. * Creates a decal mesh.
  121592. * 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
  121593. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121594. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121595. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121596. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121597. * @param name defines the name of the mesh
  121598. * @param sourceMesh defines the mesh where the decal must be applied
  121599. * @param options defines the options used to create the mesh
  121600. * @param scene defines the hosting scene
  121601. * @returns the decal mesh
  121602. * @see https://doc.babylonjs.com/how_to/decals
  121603. */
  121604. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121605. position?: Vector3;
  121606. normal?: Vector3;
  121607. size?: Vector3;
  121608. angle?: number;
  121609. }): Mesh;
  121610. }
  121611. }
  121612. declare module BABYLON {
  121613. /**
  121614. * A simplifier interface for future simplification implementations
  121615. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121616. */
  121617. export interface ISimplifier {
  121618. /**
  121619. * Simplification of a given mesh according to the given settings.
  121620. * Since this requires computation, it is assumed that the function runs async.
  121621. * @param settings The settings of the simplification, including quality and distance
  121622. * @param successCallback A callback that will be called after the mesh was simplified.
  121623. * @param errorCallback in case of an error, this callback will be called. optional.
  121624. */
  121625. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121626. }
  121627. /**
  121628. * Expected simplification settings.
  121629. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121630. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121631. */
  121632. export interface ISimplificationSettings {
  121633. /**
  121634. * Gets or sets the expected quality
  121635. */
  121636. quality: number;
  121637. /**
  121638. * Gets or sets the distance when this optimized version should be used
  121639. */
  121640. distance: number;
  121641. /**
  121642. * Gets an already optimized mesh
  121643. */
  121644. optimizeMesh?: boolean;
  121645. }
  121646. /**
  121647. * Class used to specify simplification options
  121648. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121649. */
  121650. export class SimplificationSettings implements ISimplificationSettings {
  121651. /** expected quality */
  121652. quality: number;
  121653. /** distance when this optimized version should be used */
  121654. distance: number;
  121655. /** already optimized mesh */
  121656. optimizeMesh?: boolean | undefined;
  121657. /**
  121658. * Creates a SimplificationSettings
  121659. * @param quality expected quality
  121660. * @param distance distance when this optimized version should be used
  121661. * @param optimizeMesh already optimized mesh
  121662. */
  121663. constructor(
  121664. /** expected quality */
  121665. quality: number,
  121666. /** distance when this optimized version should be used */
  121667. distance: number,
  121668. /** already optimized mesh */
  121669. optimizeMesh?: boolean | undefined);
  121670. }
  121671. /**
  121672. * Interface used to define a simplification task
  121673. */
  121674. export interface ISimplificationTask {
  121675. /**
  121676. * Array of settings
  121677. */
  121678. settings: Array<ISimplificationSettings>;
  121679. /**
  121680. * Simplification type
  121681. */
  121682. simplificationType: SimplificationType;
  121683. /**
  121684. * Mesh to simplify
  121685. */
  121686. mesh: Mesh;
  121687. /**
  121688. * Callback called on success
  121689. */
  121690. successCallback?: () => void;
  121691. /**
  121692. * Defines if parallel processing can be used
  121693. */
  121694. parallelProcessing: boolean;
  121695. }
  121696. /**
  121697. * Queue used to order the simplification tasks
  121698. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121699. */
  121700. export class SimplificationQueue {
  121701. private _simplificationArray;
  121702. /**
  121703. * Gets a boolean indicating that the process is still running
  121704. */
  121705. running: boolean;
  121706. /**
  121707. * Creates a new queue
  121708. */
  121709. constructor();
  121710. /**
  121711. * Adds a new simplification task
  121712. * @param task defines a task to add
  121713. */
  121714. addTask(task: ISimplificationTask): void;
  121715. /**
  121716. * Execute next task
  121717. */
  121718. executeNext(): void;
  121719. /**
  121720. * Execute a simplification task
  121721. * @param task defines the task to run
  121722. */
  121723. runSimplification(task: ISimplificationTask): void;
  121724. private getSimplifier;
  121725. }
  121726. /**
  121727. * The implemented types of simplification
  121728. * At the moment only Quadratic Error Decimation is implemented
  121729. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121730. */
  121731. export enum SimplificationType {
  121732. /** Quadratic error decimation */
  121733. QUADRATIC = 0
  121734. }
  121735. }
  121736. declare module BABYLON {
  121737. interface Scene {
  121738. /** @hidden (Backing field) */
  121739. _simplificationQueue: SimplificationQueue;
  121740. /**
  121741. * Gets or sets the simplification queue attached to the scene
  121742. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121743. */
  121744. simplificationQueue: SimplificationQueue;
  121745. }
  121746. interface Mesh {
  121747. /**
  121748. * Simplify the mesh according to the given array of settings.
  121749. * Function will return immediately and will simplify async
  121750. * @param settings a collection of simplification settings
  121751. * @param parallelProcessing should all levels calculate parallel or one after the other
  121752. * @param simplificationType the type of simplification to run
  121753. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  121754. * @returns the current mesh
  121755. */
  121756. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  121757. }
  121758. /**
  121759. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  121760. * created in a scene
  121761. */
  121762. export class SimplicationQueueSceneComponent implements ISceneComponent {
  121763. /**
  121764. * The component name helpfull to identify the component in the list of scene components.
  121765. */
  121766. readonly name: string;
  121767. /**
  121768. * The scene the component belongs to.
  121769. */
  121770. scene: Scene;
  121771. /**
  121772. * Creates a new instance of the component for the given scene
  121773. * @param scene Defines the scene to register the component in
  121774. */
  121775. constructor(scene: Scene);
  121776. /**
  121777. * Registers the component in a given scene
  121778. */
  121779. register(): void;
  121780. /**
  121781. * Rebuilds the elements related to this component in case of
  121782. * context lost for instance.
  121783. */
  121784. rebuild(): void;
  121785. /**
  121786. * Disposes the component and the associated ressources
  121787. */
  121788. dispose(): void;
  121789. private _beforeCameraUpdate;
  121790. }
  121791. }
  121792. declare module BABYLON {
  121793. /**
  121794. * Navigation plugin interface to add navigation constrained by a navigation mesh
  121795. */
  121796. export interface INavigationEnginePlugin {
  121797. /**
  121798. * plugin name
  121799. */
  121800. name: string;
  121801. /**
  121802. * Creates a navigation mesh
  121803. * @param meshes array of all the geometry used to compute the navigatio mesh
  121804. * @param parameters bunch of parameters used to filter geometry
  121805. */
  121806. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  121807. /**
  121808. * Create a navigation mesh debug mesh
  121809. * @param scene is where the mesh will be added
  121810. * @returns debug display mesh
  121811. */
  121812. createDebugNavMesh(scene: Scene): Mesh;
  121813. /**
  121814. * Get a navigation mesh constrained position, closest to the parameter position
  121815. * @param position world position
  121816. * @returns the closest point to position constrained by the navigation mesh
  121817. */
  121818. getClosestPoint(position: Vector3): Vector3;
  121819. /**
  121820. * Get a navigation mesh constrained position, within a particular radius
  121821. * @param position world position
  121822. * @param maxRadius the maximum distance to the constrained world position
  121823. * @returns the closest point to position constrained by the navigation mesh
  121824. */
  121825. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  121826. /**
  121827. * Compute the final position from a segment made of destination-position
  121828. * @param position world position
  121829. * @param destination world position
  121830. * @returns the resulting point along the navmesh
  121831. */
  121832. moveAlong(position: Vector3, destination: Vector3): Vector3;
  121833. /**
  121834. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  121835. * @param start world position
  121836. * @param end world position
  121837. * @returns array containing world position composing the path
  121838. */
  121839. computePath(start: Vector3, end: Vector3): Vector3[];
  121840. /**
  121841. * If this plugin is supported
  121842. * @returns true if plugin is supported
  121843. */
  121844. isSupported(): boolean;
  121845. /**
  121846. * Create a new Crowd so you can add agents
  121847. * @param maxAgents the maximum agent count in the crowd
  121848. * @param maxAgentRadius the maximum radius an agent can have
  121849. * @param scene to attach the crowd to
  121850. * @returns the crowd you can add agents to
  121851. */
  121852. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  121853. /**
  121854. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121855. * The queries will try to find a solution within those bounds
  121856. * default is (1,1,1)
  121857. * @param extent x,y,z value that define the extent around the queries point of reference
  121858. */
  121859. setDefaultQueryExtent(extent: Vector3): void;
  121860. /**
  121861. * Get the Bounding box extent specified by setDefaultQueryExtent
  121862. * @returns the box extent values
  121863. */
  121864. getDefaultQueryExtent(): Vector3;
  121865. /**
  121866. * Release all resources
  121867. */
  121868. dispose(): void;
  121869. }
  121870. /**
  121871. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  121872. */
  121873. export interface ICrowd {
  121874. /**
  121875. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  121876. * You can attach anything to that node. The node position is updated in the scene update tick.
  121877. * @param pos world position that will be constrained by the navigation mesh
  121878. * @param parameters agent parameters
  121879. * @param transform hooked to the agent that will be update by the scene
  121880. * @returns agent index
  121881. */
  121882. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  121883. /**
  121884. * Returns the agent position in world space
  121885. * @param index agent index returned by addAgent
  121886. * @returns world space position
  121887. */
  121888. getAgentPosition(index: number): Vector3;
  121889. /**
  121890. * Gets the agent velocity in world space
  121891. * @param index agent index returned by addAgent
  121892. * @returns world space velocity
  121893. */
  121894. getAgentVelocity(index: number): Vector3;
  121895. /**
  121896. * remove a particular agent previously created
  121897. * @param index agent index returned by addAgent
  121898. */
  121899. removeAgent(index: number): void;
  121900. /**
  121901. * get the list of all agents attached to this crowd
  121902. * @returns list of agent indices
  121903. */
  121904. getAgents(): number[];
  121905. /**
  121906. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  121907. * @param deltaTime in seconds
  121908. */
  121909. update(deltaTime: number): void;
  121910. /**
  121911. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  121912. * @param index agent index returned by addAgent
  121913. * @param destination targeted world position
  121914. */
  121915. agentGoto(index: number, destination: Vector3): void;
  121916. /**
  121917. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  121918. * The queries will try to find a solution within those bounds
  121919. * default is (1,1,1)
  121920. * @param extent x,y,z value that define the extent around the queries point of reference
  121921. */
  121922. setDefaultQueryExtent(extent: Vector3): void;
  121923. /**
  121924. * Get the Bounding box extent specified by setDefaultQueryExtent
  121925. * @returns the box extent values
  121926. */
  121927. getDefaultQueryExtent(): Vector3;
  121928. /**
  121929. * Release all resources
  121930. */
  121931. dispose(): void;
  121932. }
  121933. /**
  121934. * Configures an agent
  121935. */
  121936. export interface IAgentParameters {
  121937. /**
  121938. * Agent radius. [Limit: >= 0]
  121939. */
  121940. radius: number;
  121941. /**
  121942. * Agent height. [Limit: > 0]
  121943. */
  121944. height: number;
  121945. /**
  121946. * Maximum allowed acceleration. [Limit: >= 0]
  121947. */
  121948. maxAcceleration: number;
  121949. /**
  121950. * Maximum allowed speed. [Limit: >= 0]
  121951. */
  121952. maxSpeed: number;
  121953. /**
  121954. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  121955. */
  121956. collisionQueryRange: number;
  121957. /**
  121958. * The path visibility optimization range. [Limit: > 0]
  121959. */
  121960. pathOptimizationRange: number;
  121961. /**
  121962. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  121963. */
  121964. separationWeight: number;
  121965. }
  121966. /**
  121967. * Configures the navigation mesh creation
  121968. */
  121969. export interface INavMeshParameters {
  121970. /**
  121971. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  121972. */
  121973. cs: number;
  121974. /**
  121975. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  121976. */
  121977. ch: number;
  121978. /**
  121979. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  121980. */
  121981. walkableSlopeAngle: number;
  121982. /**
  121983. * Minimum floor to 'ceiling' height that will still allow the floor area to
  121984. * be considered walkable. [Limit: >= 3] [Units: vx]
  121985. */
  121986. walkableHeight: number;
  121987. /**
  121988. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  121989. */
  121990. walkableClimb: number;
  121991. /**
  121992. * The distance to erode/shrink the walkable area of the heightfield away from
  121993. * obstructions. [Limit: >=0] [Units: vx]
  121994. */
  121995. walkableRadius: number;
  121996. /**
  121997. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  121998. */
  121999. maxEdgeLen: number;
  122000. /**
  122001. * The maximum distance a simplfied contour's border edges should deviate
  122002. * the original raw contour. [Limit: >=0] [Units: vx]
  122003. */
  122004. maxSimplificationError: number;
  122005. /**
  122006. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122007. */
  122008. minRegionArea: number;
  122009. /**
  122010. * Any regions with a span count smaller than this value will, if possible,
  122011. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122012. */
  122013. mergeRegionArea: number;
  122014. /**
  122015. * The maximum number of vertices allowed for polygons generated during the
  122016. * contour to polygon conversion process. [Limit: >= 3]
  122017. */
  122018. maxVertsPerPoly: number;
  122019. /**
  122020. * Sets the sampling distance to use when generating the detail mesh.
  122021. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122022. */
  122023. detailSampleDist: number;
  122024. /**
  122025. * The maximum distance the detail mesh surface should deviate from heightfield
  122026. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122027. */
  122028. detailSampleMaxError: number;
  122029. }
  122030. }
  122031. declare module BABYLON {
  122032. /**
  122033. * RecastJS navigation plugin
  122034. */
  122035. export class RecastJSPlugin implements INavigationEnginePlugin {
  122036. /**
  122037. * Reference to the Recast library
  122038. */
  122039. bjsRECAST: any;
  122040. /**
  122041. * plugin name
  122042. */
  122043. name: string;
  122044. /**
  122045. * the first navmesh created. We might extend this to support multiple navmeshes
  122046. */
  122047. navMesh: any;
  122048. /**
  122049. * Initializes the recastJS plugin
  122050. * @param recastInjection can be used to inject your own recast reference
  122051. */
  122052. constructor(recastInjection?: any);
  122053. /**
  122054. * Creates a navigation mesh
  122055. * @param meshes array of all the geometry used to compute the navigatio mesh
  122056. * @param parameters bunch of parameters used to filter geometry
  122057. */
  122058. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122059. /**
  122060. * Create a navigation mesh debug mesh
  122061. * @param scene is where the mesh will be added
  122062. * @returns debug display mesh
  122063. */
  122064. createDebugNavMesh(scene: Scene): Mesh;
  122065. /**
  122066. * Get a navigation mesh constrained position, closest to the parameter position
  122067. * @param position world position
  122068. * @returns the closest point to position constrained by the navigation mesh
  122069. */
  122070. getClosestPoint(position: Vector3): Vector3;
  122071. /**
  122072. * Get a navigation mesh constrained position, within a particular radius
  122073. * @param position world position
  122074. * @param maxRadius the maximum distance to the constrained world position
  122075. * @returns the closest point to position constrained by the navigation mesh
  122076. */
  122077. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122078. /**
  122079. * Compute the final position from a segment made of destination-position
  122080. * @param position world position
  122081. * @param destination world position
  122082. * @returns the resulting point along the navmesh
  122083. */
  122084. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122085. /**
  122086. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122087. * @param start world position
  122088. * @param end world position
  122089. * @returns array containing world position composing the path
  122090. */
  122091. computePath(start: Vector3, end: Vector3): Vector3[];
  122092. /**
  122093. * Create a new Crowd so you can add agents
  122094. * @param maxAgents the maximum agent count in the crowd
  122095. * @param maxAgentRadius the maximum radius an agent can have
  122096. * @param scene to attach the crowd to
  122097. * @returns the crowd you can add agents to
  122098. */
  122099. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122100. /**
  122101. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122102. * The queries will try to find a solution within those bounds
  122103. * default is (1,1,1)
  122104. * @param extent x,y,z value that define the extent around the queries point of reference
  122105. */
  122106. setDefaultQueryExtent(extent: Vector3): void;
  122107. /**
  122108. * Get the Bounding box extent specified by setDefaultQueryExtent
  122109. * @returns the box extent values
  122110. */
  122111. getDefaultQueryExtent(): Vector3;
  122112. /**
  122113. * Disposes
  122114. */
  122115. dispose(): void;
  122116. /**
  122117. * If this plugin is supported
  122118. * @returns true if plugin is supported
  122119. */
  122120. isSupported(): boolean;
  122121. }
  122122. /**
  122123. * Recast detour crowd implementation
  122124. */
  122125. export class RecastJSCrowd implements ICrowd {
  122126. /**
  122127. * Recast/detour plugin
  122128. */
  122129. bjsRECASTPlugin: RecastJSPlugin;
  122130. /**
  122131. * Link to the detour crowd
  122132. */
  122133. recastCrowd: any;
  122134. /**
  122135. * One transform per agent
  122136. */
  122137. transforms: TransformNode[];
  122138. /**
  122139. * All agents created
  122140. */
  122141. agents: number[];
  122142. /**
  122143. * Link to the scene is kept to unregister the crowd from the scene
  122144. */
  122145. private _scene;
  122146. /**
  122147. * Observer for crowd updates
  122148. */
  122149. private _onBeforeAnimationsObserver;
  122150. /**
  122151. * Constructor
  122152. * @param plugin recastJS plugin
  122153. * @param maxAgents the maximum agent count in the crowd
  122154. * @param maxAgentRadius the maximum radius an agent can have
  122155. * @param scene to attach the crowd to
  122156. * @returns the crowd you can add agents to
  122157. */
  122158. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122159. /**
  122160. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122161. * You can attach anything to that node. The node position is updated in the scene update tick.
  122162. * @param pos world position that will be constrained by the navigation mesh
  122163. * @param parameters agent parameters
  122164. * @param transform hooked to the agent that will be update by the scene
  122165. * @returns agent index
  122166. */
  122167. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122168. /**
  122169. * Returns the agent position in world space
  122170. * @param index agent index returned by addAgent
  122171. * @returns world space position
  122172. */
  122173. getAgentPosition(index: number): Vector3;
  122174. /**
  122175. * Returns the agent velocity in world space
  122176. * @param index agent index returned by addAgent
  122177. * @returns world space velocity
  122178. */
  122179. getAgentVelocity(index: number): Vector3;
  122180. /**
  122181. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122182. * @param index agent index returned by addAgent
  122183. * @param destination targeted world position
  122184. */
  122185. agentGoto(index: number, destination: Vector3): void;
  122186. /**
  122187. * remove a particular agent previously created
  122188. * @param index agent index returned by addAgent
  122189. */
  122190. removeAgent(index: number): void;
  122191. /**
  122192. * get the list of all agents attached to this crowd
  122193. * @returns list of agent indices
  122194. */
  122195. getAgents(): number[];
  122196. /**
  122197. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122198. * @param deltaTime in seconds
  122199. */
  122200. update(deltaTime: number): void;
  122201. /**
  122202. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122203. * The queries will try to find a solution within those bounds
  122204. * default is (1,1,1)
  122205. * @param extent x,y,z value that define the extent around the queries point of reference
  122206. */
  122207. setDefaultQueryExtent(extent: Vector3): void;
  122208. /**
  122209. * Get the Bounding box extent specified by setDefaultQueryExtent
  122210. * @returns the box extent values
  122211. */
  122212. getDefaultQueryExtent(): Vector3;
  122213. /**
  122214. * Release all resources
  122215. */
  122216. dispose(): void;
  122217. }
  122218. }
  122219. declare module BABYLON {
  122220. /**
  122221. * Class used to enable access to IndexedDB
  122222. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122223. */
  122224. export class Database implements IOfflineProvider {
  122225. private _callbackManifestChecked;
  122226. private _currentSceneUrl;
  122227. private _db;
  122228. private _enableSceneOffline;
  122229. private _enableTexturesOffline;
  122230. private _manifestVersionFound;
  122231. private _mustUpdateRessources;
  122232. private _hasReachedQuota;
  122233. private _isSupported;
  122234. private _idbFactory;
  122235. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122236. private static IsUASupportingBlobStorage;
  122237. /**
  122238. * Gets a boolean indicating if Database storate is enabled (off by default)
  122239. */
  122240. static IDBStorageEnabled: boolean;
  122241. /**
  122242. * Gets a boolean indicating if scene must be saved in the database
  122243. */
  122244. readonly enableSceneOffline: boolean;
  122245. /**
  122246. * Gets a boolean indicating if textures must be saved in the database
  122247. */
  122248. readonly enableTexturesOffline: boolean;
  122249. /**
  122250. * Creates a new Database
  122251. * @param urlToScene defines the url to load the scene
  122252. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122253. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122254. */
  122255. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122256. private static _ParseURL;
  122257. private static _ReturnFullUrlLocation;
  122258. private _checkManifestFile;
  122259. /**
  122260. * Open the database and make it available
  122261. * @param successCallback defines the callback to call on success
  122262. * @param errorCallback defines the callback to call on error
  122263. */
  122264. open(successCallback: () => void, errorCallback: () => void): void;
  122265. /**
  122266. * Loads an image from the database
  122267. * @param url defines the url to load from
  122268. * @param image defines the target DOM image
  122269. */
  122270. loadImage(url: string, image: HTMLImageElement): void;
  122271. private _loadImageFromDBAsync;
  122272. private _saveImageIntoDBAsync;
  122273. private _checkVersionFromDB;
  122274. private _loadVersionFromDBAsync;
  122275. private _saveVersionIntoDBAsync;
  122276. /**
  122277. * Loads a file from database
  122278. * @param url defines the URL to load from
  122279. * @param sceneLoaded defines a callback to call on success
  122280. * @param progressCallBack defines a callback to call when progress changed
  122281. * @param errorCallback defines a callback to call on error
  122282. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122283. */
  122284. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122285. private _loadFileAsync;
  122286. private _saveFileAsync;
  122287. /**
  122288. * Validates if xhr data is correct
  122289. * @param xhr defines the request to validate
  122290. * @param dataType defines the expected data type
  122291. * @returns true if data is correct
  122292. */
  122293. private static _ValidateXHRData;
  122294. }
  122295. }
  122296. declare module BABYLON {
  122297. /** @hidden */
  122298. export var gpuUpdateParticlesPixelShader: {
  122299. name: string;
  122300. shader: string;
  122301. };
  122302. }
  122303. declare module BABYLON {
  122304. /** @hidden */
  122305. export var gpuUpdateParticlesVertexShader: {
  122306. name: string;
  122307. shader: string;
  122308. };
  122309. }
  122310. declare module BABYLON {
  122311. /** @hidden */
  122312. export var clipPlaneFragmentDeclaration2: {
  122313. name: string;
  122314. shader: string;
  122315. };
  122316. }
  122317. declare module BABYLON {
  122318. /** @hidden */
  122319. export var gpuRenderParticlesPixelShader: {
  122320. name: string;
  122321. shader: string;
  122322. };
  122323. }
  122324. declare module BABYLON {
  122325. /** @hidden */
  122326. export var clipPlaneVertexDeclaration2: {
  122327. name: string;
  122328. shader: string;
  122329. };
  122330. }
  122331. declare module BABYLON {
  122332. /** @hidden */
  122333. export var gpuRenderParticlesVertexShader: {
  122334. name: string;
  122335. shader: string;
  122336. };
  122337. }
  122338. declare module BABYLON {
  122339. /**
  122340. * This represents a GPU particle system in Babylon
  122341. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122342. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122343. */
  122344. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122345. /**
  122346. * The layer mask we are rendering the particles through.
  122347. */
  122348. layerMask: number;
  122349. private _capacity;
  122350. private _activeCount;
  122351. private _currentActiveCount;
  122352. private _accumulatedCount;
  122353. private _renderEffect;
  122354. private _updateEffect;
  122355. private _buffer0;
  122356. private _buffer1;
  122357. private _spriteBuffer;
  122358. private _updateVAO;
  122359. private _renderVAO;
  122360. private _targetIndex;
  122361. private _sourceBuffer;
  122362. private _targetBuffer;
  122363. private _engine;
  122364. private _currentRenderId;
  122365. private _started;
  122366. private _stopped;
  122367. private _timeDelta;
  122368. private _randomTexture;
  122369. private _randomTexture2;
  122370. private _attributesStrideSize;
  122371. private _updateEffectOptions;
  122372. private _randomTextureSize;
  122373. private _actualFrame;
  122374. private readonly _rawTextureWidth;
  122375. /**
  122376. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122377. */
  122378. static readonly IsSupported: boolean;
  122379. /**
  122380. * An event triggered when the system is disposed.
  122381. */
  122382. onDisposeObservable: Observable<GPUParticleSystem>;
  122383. /**
  122384. * Gets the maximum number of particles active at the same time.
  122385. * @returns The max number of active particles.
  122386. */
  122387. getCapacity(): number;
  122388. /**
  122389. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122390. * to override the particles.
  122391. */
  122392. forceDepthWrite: boolean;
  122393. /**
  122394. * Gets or set the number of active particles
  122395. */
  122396. activeParticleCount: number;
  122397. private _preWarmDone;
  122398. /**
  122399. * Is this system ready to be used/rendered
  122400. * @return true if the system is ready
  122401. */
  122402. isReady(): boolean;
  122403. /**
  122404. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122405. * @returns True if it has been started, otherwise false.
  122406. */
  122407. isStarted(): boolean;
  122408. /**
  122409. * Starts the particle system and begins to emit
  122410. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122411. */
  122412. start(delay?: number): void;
  122413. /**
  122414. * Stops the particle system.
  122415. */
  122416. stop(): void;
  122417. /**
  122418. * Remove all active particles
  122419. */
  122420. reset(): void;
  122421. /**
  122422. * Returns the string "GPUParticleSystem"
  122423. * @returns a string containing the class name
  122424. */
  122425. getClassName(): string;
  122426. private _colorGradientsTexture;
  122427. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122428. /**
  122429. * Adds a new color gradient
  122430. * @param gradient defines the gradient to use (between 0 and 1)
  122431. * @param color1 defines the color to affect to the specified gradient
  122432. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122433. * @returns the current particle system
  122434. */
  122435. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122436. /**
  122437. * Remove a specific color gradient
  122438. * @param gradient defines the gradient to remove
  122439. * @returns the current particle system
  122440. */
  122441. removeColorGradient(gradient: number): GPUParticleSystem;
  122442. private _angularSpeedGradientsTexture;
  122443. private _sizeGradientsTexture;
  122444. private _velocityGradientsTexture;
  122445. private _limitVelocityGradientsTexture;
  122446. private _dragGradientsTexture;
  122447. private _addFactorGradient;
  122448. /**
  122449. * Adds a new size gradient
  122450. * @param gradient defines the gradient to use (between 0 and 1)
  122451. * @param factor defines the size factor to affect to the specified gradient
  122452. * @returns the current particle system
  122453. */
  122454. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122455. /**
  122456. * Remove a specific size gradient
  122457. * @param gradient defines the gradient to remove
  122458. * @returns the current particle system
  122459. */
  122460. removeSizeGradient(gradient: number): GPUParticleSystem;
  122461. /**
  122462. * Adds a new angular speed gradient
  122463. * @param gradient defines the gradient to use (between 0 and 1)
  122464. * @param factor defines the angular speed to affect to the specified gradient
  122465. * @returns the current particle system
  122466. */
  122467. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122468. /**
  122469. * Remove a specific angular speed gradient
  122470. * @param gradient defines the gradient to remove
  122471. * @returns the current particle system
  122472. */
  122473. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122474. /**
  122475. * Adds a new velocity gradient
  122476. * @param gradient defines the gradient to use (between 0 and 1)
  122477. * @param factor defines the velocity to affect to the specified gradient
  122478. * @returns the current particle system
  122479. */
  122480. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122481. /**
  122482. * Remove a specific velocity gradient
  122483. * @param gradient defines the gradient to remove
  122484. * @returns the current particle system
  122485. */
  122486. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122487. /**
  122488. * Adds a new limit velocity gradient
  122489. * @param gradient defines the gradient to use (between 0 and 1)
  122490. * @param factor defines the limit velocity value to affect to the specified gradient
  122491. * @returns the current particle system
  122492. */
  122493. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122494. /**
  122495. * Remove a specific limit velocity gradient
  122496. * @param gradient defines the gradient to remove
  122497. * @returns the current particle system
  122498. */
  122499. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122500. /**
  122501. * Adds a new drag gradient
  122502. * @param gradient defines the gradient to use (between 0 and 1)
  122503. * @param factor defines the drag value to affect to the specified gradient
  122504. * @returns the current particle system
  122505. */
  122506. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122507. /**
  122508. * Remove a specific drag gradient
  122509. * @param gradient defines the gradient to remove
  122510. * @returns the current particle system
  122511. */
  122512. removeDragGradient(gradient: number): GPUParticleSystem;
  122513. /**
  122514. * Not supported by GPUParticleSystem
  122515. * @param gradient defines the gradient to use (between 0 and 1)
  122516. * @param factor defines the emit rate value to affect to the specified gradient
  122517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122518. * @returns the current particle system
  122519. */
  122520. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122521. /**
  122522. * Not supported by GPUParticleSystem
  122523. * @param gradient defines the gradient to remove
  122524. * @returns the current particle system
  122525. */
  122526. removeEmitRateGradient(gradient: number): IParticleSystem;
  122527. /**
  122528. * Not supported by GPUParticleSystem
  122529. * @param gradient defines the gradient to use (between 0 and 1)
  122530. * @param factor defines the start size value to affect to the specified gradient
  122531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122532. * @returns the current particle system
  122533. */
  122534. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122535. /**
  122536. * Not supported by GPUParticleSystem
  122537. * @param gradient defines the gradient to remove
  122538. * @returns the current particle system
  122539. */
  122540. removeStartSizeGradient(gradient: number): IParticleSystem;
  122541. /**
  122542. * Not supported by GPUParticleSystem
  122543. * @param gradient defines the gradient to use (between 0 and 1)
  122544. * @param min defines the color remap minimal range
  122545. * @param max defines the color remap maximal range
  122546. * @returns the current particle system
  122547. */
  122548. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122549. /**
  122550. * Not supported by GPUParticleSystem
  122551. * @param gradient defines the gradient to remove
  122552. * @returns the current particle system
  122553. */
  122554. removeColorRemapGradient(): IParticleSystem;
  122555. /**
  122556. * Not supported by GPUParticleSystem
  122557. * @param gradient defines the gradient to use (between 0 and 1)
  122558. * @param min defines the alpha remap minimal range
  122559. * @param max defines the alpha remap maximal range
  122560. * @returns the current particle system
  122561. */
  122562. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122563. /**
  122564. * Not supported by GPUParticleSystem
  122565. * @param gradient defines the gradient to remove
  122566. * @returns the current particle system
  122567. */
  122568. removeAlphaRemapGradient(): IParticleSystem;
  122569. /**
  122570. * Not supported by GPUParticleSystem
  122571. * @param gradient defines the gradient to use (between 0 and 1)
  122572. * @param color defines the color to affect to the specified gradient
  122573. * @returns the current particle system
  122574. */
  122575. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122576. /**
  122577. * Not supported by GPUParticleSystem
  122578. * @param gradient defines the gradient to remove
  122579. * @returns the current particle system
  122580. */
  122581. removeRampGradient(): IParticleSystem;
  122582. /**
  122583. * Not supported by GPUParticleSystem
  122584. * @returns the list of ramp gradients
  122585. */
  122586. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122587. /**
  122588. * Not supported by GPUParticleSystem
  122589. * Gets or sets a boolean indicating that ramp gradients must be used
  122590. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122591. */
  122592. useRampGradients: boolean;
  122593. /**
  122594. * Not supported by GPUParticleSystem
  122595. * @param gradient defines the gradient to use (between 0 and 1)
  122596. * @param factor defines the life time factor to affect to the specified gradient
  122597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122598. * @returns the current particle system
  122599. */
  122600. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122601. /**
  122602. * Not supported by GPUParticleSystem
  122603. * @param gradient defines the gradient to remove
  122604. * @returns the current particle system
  122605. */
  122606. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122607. /**
  122608. * Instantiates a GPU particle system.
  122609. * 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.
  122610. * @param name The name of the particle system
  122611. * @param options The options used to create the system
  122612. * @param scene The scene the particle system belongs to
  122613. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122614. */
  122615. constructor(name: string, options: Partial<{
  122616. capacity: number;
  122617. randomTextureSize: number;
  122618. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122619. protected _reset(): void;
  122620. private _createUpdateVAO;
  122621. private _createRenderVAO;
  122622. private _initialize;
  122623. /** @hidden */
  122624. _recreateUpdateEffect(): void;
  122625. /** @hidden */
  122626. _recreateRenderEffect(): void;
  122627. /**
  122628. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122629. * @param preWarm defines if we are in the pre-warmimg phase
  122630. */
  122631. animate(preWarm?: boolean): void;
  122632. private _createFactorGradientTexture;
  122633. private _createSizeGradientTexture;
  122634. private _createAngularSpeedGradientTexture;
  122635. private _createVelocityGradientTexture;
  122636. private _createLimitVelocityGradientTexture;
  122637. private _createDragGradientTexture;
  122638. private _createColorGradientTexture;
  122639. /**
  122640. * Renders the particle system in its current state
  122641. * @param preWarm defines if the system should only update the particles but not render them
  122642. * @returns the current number of particles
  122643. */
  122644. render(preWarm?: boolean): number;
  122645. /**
  122646. * Rebuilds the particle system
  122647. */
  122648. rebuild(): void;
  122649. private _releaseBuffers;
  122650. private _releaseVAOs;
  122651. /**
  122652. * Disposes the particle system and free the associated resources
  122653. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  122654. */
  122655. dispose(disposeTexture?: boolean): void;
  122656. /**
  122657. * Clones the particle system.
  122658. * @param name The name of the cloned object
  122659. * @param newEmitter The new emitter to use
  122660. * @returns the cloned particle system
  122661. */
  122662. clone(name: string, newEmitter: any): GPUParticleSystem;
  122663. /**
  122664. * Serializes the particle system to a JSON object.
  122665. * @returns the JSON object
  122666. */
  122667. serialize(): any;
  122668. /**
  122669. * Parses a JSON object to create a GPU particle system.
  122670. * @param parsedParticleSystem The JSON object to parse
  122671. * @param scene The scene to create the particle system in
  122672. * @param rootUrl The root url to use to load external dependencies like texture
  122673. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  122674. * @returns the parsed GPU particle system
  122675. */
  122676. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  122677. }
  122678. }
  122679. declare module BABYLON {
  122680. /**
  122681. * Represents a set of particle systems working together to create a specific effect
  122682. */
  122683. export class ParticleSystemSet implements IDisposable {
  122684. private _emitterCreationOptions;
  122685. private _emitterNode;
  122686. /**
  122687. * Gets the particle system list
  122688. */
  122689. systems: IParticleSystem[];
  122690. /**
  122691. * Gets the emitter node used with this set
  122692. */
  122693. readonly emitterNode: Nullable<TransformNode>;
  122694. /**
  122695. * Creates a new emitter mesh as a sphere
  122696. * @param options defines the options used to create the sphere
  122697. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  122698. * @param scene defines the hosting scene
  122699. */
  122700. setEmitterAsSphere(options: {
  122701. diameter: number;
  122702. segments: number;
  122703. color: Color3;
  122704. }, renderingGroupId: number, scene: Scene): void;
  122705. /**
  122706. * Starts all particle systems of the set
  122707. * @param emitter defines an optional mesh to use as emitter for the particle systems
  122708. */
  122709. start(emitter?: AbstractMesh): void;
  122710. /**
  122711. * Release all associated resources
  122712. */
  122713. dispose(): void;
  122714. /**
  122715. * Serialize the set into a JSON compatible object
  122716. * @returns a JSON compatible representation of the set
  122717. */
  122718. serialize(): any;
  122719. /**
  122720. * Parse a new ParticleSystemSet from a serialized source
  122721. * @param data defines a JSON compatible representation of the set
  122722. * @param scene defines the hosting scene
  122723. * @param gpu defines if we want GPU particles or CPU particles
  122724. * @returns a new ParticleSystemSet
  122725. */
  122726. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  122727. }
  122728. }
  122729. declare module BABYLON {
  122730. /**
  122731. * This class is made for on one-liner static method to help creating particle system set.
  122732. */
  122733. export class ParticleHelper {
  122734. /**
  122735. * Gets or sets base Assets URL
  122736. */
  122737. static BaseAssetsUrl: string;
  122738. /**
  122739. * Create a default particle system that you can tweak
  122740. * @param emitter defines the emitter to use
  122741. * @param capacity defines the system capacity (default is 500 particles)
  122742. * @param scene defines the hosting scene
  122743. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  122744. * @returns the new Particle system
  122745. */
  122746. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  122747. /**
  122748. * This is the main static method (one-liner) of this helper to create different particle systems
  122749. * @param type This string represents the type to the particle system to create
  122750. * @param scene The scene where the particle system should live
  122751. * @param gpu If the system will use gpu
  122752. * @returns the ParticleSystemSet created
  122753. */
  122754. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  122755. /**
  122756. * Static function used to export a particle system to a ParticleSystemSet variable.
  122757. * Please note that the emitter shape is not exported
  122758. * @param systems defines the particle systems to export
  122759. * @returns the created particle system set
  122760. */
  122761. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  122762. }
  122763. }
  122764. declare module BABYLON {
  122765. interface Engine {
  122766. /**
  122767. * Create an effect to use with particle systems.
  122768. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  122769. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  122770. * @param uniformsNames defines a list of attribute names
  122771. * @param samplers defines an array of string used to represent textures
  122772. * @param defines defines the string containing the defines to use to compile the shaders
  122773. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  122774. * @param onCompiled defines a function to call when the effect creation is successful
  122775. * @param onError defines a function to call when the effect creation has failed
  122776. * @returns the new Effect
  122777. */
  122778. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  122779. }
  122780. interface Mesh {
  122781. /**
  122782. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  122783. * @returns an array of IParticleSystem
  122784. */
  122785. getEmittedParticleSystems(): IParticleSystem[];
  122786. /**
  122787. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  122788. * @returns an array of IParticleSystem
  122789. */
  122790. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  122791. }
  122792. /**
  122793. * @hidden
  122794. */
  122795. export var _IDoNeedToBeInTheBuild: number;
  122796. }
  122797. declare module BABYLON {
  122798. interface Scene {
  122799. /** @hidden (Backing field) */
  122800. _physicsEngine: Nullable<IPhysicsEngine>;
  122801. /**
  122802. * Gets the current physics engine
  122803. * @returns a IPhysicsEngine or null if none attached
  122804. */
  122805. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  122806. /**
  122807. * Enables physics to the current scene
  122808. * @param gravity defines the scene's gravity for the physics engine
  122809. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  122810. * @return a boolean indicating if the physics engine was initialized
  122811. */
  122812. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  122813. /**
  122814. * Disables and disposes the physics engine associated with the scene
  122815. */
  122816. disablePhysicsEngine(): void;
  122817. /**
  122818. * Gets a boolean indicating if there is an active physics engine
  122819. * @returns a boolean indicating if there is an active physics engine
  122820. */
  122821. isPhysicsEnabled(): boolean;
  122822. /**
  122823. * Deletes a physics compound impostor
  122824. * @param compound defines the compound to delete
  122825. */
  122826. deleteCompoundImpostor(compound: any): void;
  122827. /**
  122828. * An event triggered when physic simulation is about to be run
  122829. */
  122830. onBeforePhysicsObservable: Observable<Scene>;
  122831. /**
  122832. * An event triggered when physic simulation has been done
  122833. */
  122834. onAfterPhysicsObservable: Observable<Scene>;
  122835. }
  122836. interface AbstractMesh {
  122837. /** @hidden */
  122838. _physicsImpostor: Nullable<PhysicsImpostor>;
  122839. /**
  122840. * Gets or sets impostor used for physic simulation
  122841. * @see http://doc.babylonjs.com/features/physics_engine
  122842. */
  122843. physicsImpostor: Nullable<PhysicsImpostor>;
  122844. /**
  122845. * Gets the current physics impostor
  122846. * @see http://doc.babylonjs.com/features/physics_engine
  122847. * @returns a physics impostor or null
  122848. */
  122849. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  122850. /** Apply a physic impulse to the mesh
  122851. * @param force defines the force to apply
  122852. * @param contactPoint defines where to apply the force
  122853. * @returns the current mesh
  122854. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  122855. */
  122856. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  122857. /**
  122858. * Creates a physic joint between two meshes
  122859. * @param otherMesh defines the other mesh to use
  122860. * @param pivot1 defines the pivot to use on this mesh
  122861. * @param pivot2 defines the pivot to use on the other mesh
  122862. * @param options defines additional options (can be plugin dependent)
  122863. * @returns the current mesh
  122864. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  122865. */
  122866. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  122867. /** @hidden */
  122868. _disposePhysicsObserver: Nullable<Observer<Node>>;
  122869. }
  122870. /**
  122871. * Defines the physics engine scene component responsible to manage a physics engine
  122872. */
  122873. export class PhysicsEngineSceneComponent implements ISceneComponent {
  122874. /**
  122875. * The component name helpful to identify the component in the list of scene components.
  122876. */
  122877. readonly name: string;
  122878. /**
  122879. * The scene the component belongs to.
  122880. */
  122881. scene: Scene;
  122882. /**
  122883. * Creates a new instance of the component for the given scene
  122884. * @param scene Defines the scene to register the component in
  122885. */
  122886. constructor(scene: Scene);
  122887. /**
  122888. * Registers the component in a given scene
  122889. */
  122890. register(): void;
  122891. /**
  122892. * Rebuilds the elements related to this component in case of
  122893. * context lost for instance.
  122894. */
  122895. rebuild(): void;
  122896. /**
  122897. * Disposes the component and the associated ressources
  122898. */
  122899. dispose(): void;
  122900. }
  122901. }
  122902. declare module BABYLON {
  122903. /**
  122904. * A helper for physics simulations
  122905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  122906. */
  122907. export class PhysicsHelper {
  122908. private _scene;
  122909. private _physicsEngine;
  122910. /**
  122911. * Initializes the Physics helper
  122912. * @param scene Babylon.js scene
  122913. */
  122914. constructor(scene: Scene);
  122915. /**
  122916. * Applies a radial explosion impulse
  122917. * @param origin the origin of the explosion
  122918. * @param radiusOrEventOptions the radius or the options of radial explosion
  122919. * @param strength the explosion strength
  122920. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122921. * @returns A physics radial explosion event, or null
  122922. */
  122923. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  122924. /**
  122925. * Applies a radial explosion force
  122926. * @param origin the origin of the explosion
  122927. * @param radiusOrEventOptions the radius or the options of radial explosion
  122928. * @param strength the explosion strength
  122929. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122930. * @returns A physics radial explosion event, or null
  122931. */
  122932. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  122933. /**
  122934. * Creates a gravitational field
  122935. * @param origin the origin of the explosion
  122936. * @param radiusOrEventOptions the radius or the options of radial explosion
  122937. * @param strength the explosion strength
  122938. * @param falloff possible options: Constant & Linear. Defaults to Constant
  122939. * @returns A physics gravitational field event, or null
  122940. */
  122941. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  122942. /**
  122943. * Creates a physics updraft event
  122944. * @param origin the origin of the updraft
  122945. * @param radiusOrEventOptions the radius or the options of the updraft
  122946. * @param strength the strength of the updraft
  122947. * @param height the height of the updraft
  122948. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  122949. * @returns A physics updraft event, or null
  122950. */
  122951. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  122952. /**
  122953. * Creates a physics vortex event
  122954. * @param origin the of the vortex
  122955. * @param radiusOrEventOptions the radius or the options of the vortex
  122956. * @param strength the strength of the vortex
  122957. * @param height the height of the vortex
  122958. * @returns a Physics vortex event, or null
  122959. * A physics vortex event or null
  122960. */
  122961. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  122962. }
  122963. /**
  122964. * Represents a physics radial explosion event
  122965. */
  122966. class PhysicsRadialExplosionEvent {
  122967. private _scene;
  122968. private _options;
  122969. private _sphere;
  122970. private _dataFetched;
  122971. /**
  122972. * Initializes a radial explosioin event
  122973. * @param _scene BabylonJS scene
  122974. * @param _options The options for the vortex event
  122975. */
  122976. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  122977. /**
  122978. * Returns the data related to the radial explosion event (sphere).
  122979. * @returns The radial explosion event data
  122980. */
  122981. getData(): PhysicsRadialExplosionEventData;
  122982. /**
  122983. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  122984. * @param impostor A physics imposter
  122985. * @param origin the origin of the explosion
  122986. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  122987. */
  122988. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  122989. /**
  122990. * Triggers affecterd impostors callbacks
  122991. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  122992. */
  122993. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  122994. /**
  122995. * Disposes the sphere.
  122996. * @param force Specifies if the sphere should be disposed by force
  122997. */
  122998. dispose(force?: boolean): void;
  122999. /*** Helpers ***/
  123000. private _prepareSphere;
  123001. private _intersectsWithSphere;
  123002. }
  123003. /**
  123004. * Represents a gravitational field event
  123005. */
  123006. class PhysicsGravitationalFieldEvent {
  123007. private _physicsHelper;
  123008. private _scene;
  123009. private _origin;
  123010. private _options;
  123011. private _tickCallback;
  123012. private _sphere;
  123013. private _dataFetched;
  123014. /**
  123015. * Initializes the physics gravitational field event
  123016. * @param _physicsHelper A physics helper
  123017. * @param _scene BabylonJS scene
  123018. * @param _origin The origin position of the gravitational field event
  123019. * @param _options The options for the vortex event
  123020. */
  123021. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123022. /**
  123023. * Returns the data related to the gravitational field event (sphere).
  123024. * @returns A gravitational field event
  123025. */
  123026. getData(): PhysicsGravitationalFieldEventData;
  123027. /**
  123028. * Enables the gravitational field.
  123029. */
  123030. enable(): void;
  123031. /**
  123032. * Disables the gravitational field.
  123033. */
  123034. disable(): void;
  123035. /**
  123036. * Disposes the sphere.
  123037. * @param force The force to dispose from the gravitational field event
  123038. */
  123039. dispose(force?: boolean): void;
  123040. private _tick;
  123041. }
  123042. /**
  123043. * Represents a physics updraft event
  123044. */
  123045. class PhysicsUpdraftEvent {
  123046. private _scene;
  123047. private _origin;
  123048. private _options;
  123049. private _physicsEngine;
  123050. private _originTop;
  123051. private _originDirection;
  123052. private _tickCallback;
  123053. private _cylinder;
  123054. private _cylinderPosition;
  123055. private _dataFetched;
  123056. /**
  123057. * Initializes the physics updraft event
  123058. * @param _scene BabylonJS scene
  123059. * @param _origin The origin position of the updraft
  123060. * @param _options The options for the updraft event
  123061. */
  123062. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123063. /**
  123064. * Returns the data related to the updraft event (cylinder).
  123065. * @returns A physics updraft event
  123066. */
  123067. getData(): PhysicsUpdraftEventData;
  123068. /**
  123069. * Enables the updraft.
  123070. */
  123071. enable(): void;
  123072. /**
  123073. * Disables the updraft.
  123074. */
  123075. disable(): void;
  123076. /**
  123077. * Disposes the cylinder.
  123078. * @param force Specifies if the updraft should be disposed by force
  123079. */
  123080. dispose(force?: boolean): void;
  123081. private getImpostorHitData;
  123082. private _tick;
  123083. /*** Helpers ***/
  123084. private _prepareCylinder;
  123085. private _intersectsWithCylinder;
  123086. }
  123087. /**
  123088. * Represents a physics vortex event
  123089. */
  123090. class PhysicsVortexEvent {
  123091. private _scene;
  123092. private _origin;
  123093. private _options;
  123094. private _physicsEngine;
  123095. private _originTop;
  123096. private _tickCallback;
  123097. private _cylinder;
  123098. private _cylinderPosition;
  123099. private _dataFetched;
  123100. /**
  123101. * Initializes the physics vortex event
  123102. * @param _scene The BabylonJS scene
  123103. * @param _origin The origin position of the vortex
  123104. * @param _options The options for the vortex event
  123105. */
  123106. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123107. /**
  123108. * Returns the data related to the vortex event (cylinder).
  123109. * @returns The physics vortex event data
  123110. */
  123111. getData(): PhysicsVortexEventData;
  123112. /**
  123113. * Enables the vortex.
  123114. */
  123115. enable(): void;
  123116. /**
  123117. * Disables the cortex.
  123118. */
  123119. disable(): void;
  123120. /**
  123121. * Disposes the sphere.
  123122. * @param force
  123123. */
  123124. dispose(force?: boolean): void;
  123125. private getImpostorHitData;
  123126. private _tick;
  123127. /*** Helpers ***/
  123128. private _prepareCylinder;
  123129. private _intersectsWithCylinder;
  123130. }
  123131. /**
  123132. * Options fot the radial explosion event
  123133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123134. */
  123135. export class PhysicsRadialExplosionEventOptions {
  123136. /**
  123137. * The radius of the sphere for the radial explosion.
  123138. */
  123139. radius: number;
  123140. /**
  123141. * The strenth of the explosion.
  123142. */
  123143. strength: number;
  123144. /**
  123145. * The strenght of the force in correspondence to the distance of the affected object
  123146. */
  123147. falloff: PhysicsRadialImpulseFalloff;
  123148. /**
  123149. * Sphere options for the radial explosion.
  123150. */
  123151. sphere: {
  123152. segments: number;
  123153. diameter: number;
  123154. };
  123155. /**
  123156. * Sphere options for the radial explosion.
  123157. */
  123158. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123159. }
  123160. /**
  123161. * Options fot the updraft event
  123162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123163. */
  123164. export class PhysicsUpdraftEventOptions {
  123165. /**
  123166. * The radius of the cylinder for the vortex
  123167. */
  123168. radius: number;
  123169. /**
  123170. * The strenth of the updraft.
  123171. */
  123172. strength: number;
  123173. /**
  123174. * The height of the cylinder for the updraft.
  123175. */
  123176. height: number;
  123177. /**
  123178. * The mode for the the updraft.
  123179. */
  123180. updraftMode: PhysicsUpdraftMode;
  123181. }
  123182. /**
  123183. * Options fot the vortex event
  123184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123185. */
  123186. export class PhysicsVortexEventOptions {
  123187. /**
  123188. * The radius of the cylinder for the vortex
  123189. */
  123190. radius: number;
  123191. /**
  123192. * The strenth of the vortex.
  123193. */
  123194. strength: number;
  123195. /**
  123196. * The height of the cylinder for the vortex.
  123197. */
  123198. height: number;
  123199. /**
  123200. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123201. */
  123202. centripetalForceThreshold: number;
  123203. /**
  123204. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123205. */
  123206. centripetalForceMultiplier: number;
  123207. /**
  123208. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123209. */
  123210. centrifugalForceMultiplier: number;
  123211. /**
  123212. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123213. */
  123214. updraftForceMultiplier: number;
  123215. }
  123216. /**
  123217. * The strenght of the force in correspondence to the distance of the affected object
  123218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123219. */
  123220. export enum PhysicsRadialImpulseFalloff {
  123221. /** Defines that impulse is constant in strength across it's whole radius */
  123222. Constant = 0,
  123223. /** Defines that impulse gets weaker if it's further from the origin */
  123224. Linear = 1
  123225. }
  123226. /**
  123227. * The strength of the force in correspondence to the distance of the affected object
  123228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123229. */
  123230. export enum PhysicsUpdraftMode {
  123231. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123232. Center = 0,
  123233. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123234. Perpendicular = 1
  123235. }
  123236. /**
  123237. * Interface for a physics hit data
  123238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123239. */
  123240. export interface PhysicsHitData {
  123241. /**
  123242. * The force applied at the contact point
  123243. */
  123244. force: Vector3;
  123245. /**
  123246. * The contact point
  123247. */
  123248. contactPoint: Vector3;
  123249. /**
  123250. * The distance from the origin to the contact point
  123251. */
  123252. distanceFromOrigin: number;
  123253. }
  123254. /**
  123255. * Interface for radial explosion event data
  123256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123257. */
  123258. export interface PhysicsRadialExplosionEventData {
  123259. /**
  123260. * A sphere used for the radial explosion event
  123261. */
  123262. sphere: Mesh;
  123263. }
  123264. /**
  123265. * Interface for gravitational field event data
  123266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123267. */
  123268. export interface PhysicsGravitationalFieldEventData {
  123269. /**
  123270. * A sphere mesh used for the gravitational field event
  123271. */
  123272. sphere: Mesh;
  123273. }
  123274. /**
  123275. * Interface for updraft event data
  123276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123277. */
  123278. export interface PhysicsUpdraftEventData {
  123279. /**
  123280. * A cylinder used for the updraft event
  123281. */
  123282. cylinder: Mesh;
  123283. }
  123284. /**
  123285. * Interface for vortex event data
  123286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123287. */
  123288. export interface PhysicsVortexEventData {
  123289. /**
  123290. * A cylinder used for the vortex event
  123291. */
  123292. cylinder: Mesh;
  123293. }
  123294. /**
  123295. * Interface for an affected physics impostor
  123296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123297. */
  123298. export interface PhysicsAffectedImpostorWithData {
  123299. /**
  123300. * The impostor affected by the effect
  123301. */
  123302. impostor: PhysicsImpostor;
  123303. /**
  123304. * The data about the hit/horce from the explosion
  123305. */
  123306. hitData: PhysicsHitData;
  123307. }
  123308. }
  123309. declare module BABYLON {
  123310. /** @hidden */
  123311. export var blackAndWhitePixelShader: {
  123312. name: string;
  123313. shader: string;
  123314. };
  123315. }
  123316. declare module BABYLON {
  123317. /**
  123318. * Post process used to render in black and white
  123319. */
  123320. export class BlackAndWhitePostProcess extends PostProcess {
  123321. /**
  123322. * Linear about to convert he result to black and white (default: 1)
  123323. */
  123324. degree: number;
  123325. /**
  123326. * Creates a black and white post process
  123327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123328. * @param name The name of the effect.
  123329. * @param options The required width/height ratio to downsize to before computing the render pass.
  123330. * @param camera The camera to apply the render pass to.
  123331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123332. * @param engine The engine which the post process will be applied. (default: current engine)
  123333. * @param reusable If the post process can be reused on the same frame. (default: false)
  123334. */
  123335. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123336. }
  123337. }
  123338. declare module BABYLON {
  123339. /**
  123340. * This represents a set of one or more post processes in Babylon.
  123341. * A post process can be used to apply a shader to a texture after it is rendered.
  123342. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123343. */
  123344. export class PostProcessRenderEffect {
  123345. private _postProcesses;
  123346. private _getPostProcesses;
  123347. private _singleInstance;
  123348. private _cameras;
  123349. private _indicesForCamera;
  123350. /**
  123351. * Name of the effect
  123352. * @hidden
  123353. */
  123354. _name: string;
  123355. /**
  123356. * Instantiates a post process render effect.
  123357. * A post process can be used to apply a shader to a texture after it is rendered.
  123358. * @param engine The engine the effect is tied to
  123359. * @param name The name of the effect
  123360. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123361. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123362. */
  123363. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123364. /**
  123365. * Checks if all the post processes in the effect are supported.
  123366. */
  123367. readonly isSupported: boolean;
  123368. /**
  123369. * Updates the current state of the effect
  123370. * @hidden
  123371. */
  123372. _update(): void;
  123373. /**
  123374. * Attaches the effect on cameras
  123375. * @param cameras The camera to attach to.
  123376. * @hidden
  123377. */
  123378. _attachCameras(cameras: Camera): void;
  123379. /**
  123380. * Attaches the effect on cameras
  123381. * @param cameras The camera to attach to.
  123382. * @hidden
  123383. */
  123384. _attachCameras(cameras: Camera[]): void;
  123385. /**
  123386. * Detaches the effect on cameras
  123387. * @param cameras The camera to detatch from.
  123388. * @hidden
  123389. */
  123390. _detachCameras(cameras: Camera): void;
  123391. /**
  123392. * Detatches the effect on cameras
  123393. * @param cameras The camera to detatch from.
  123394. * @hidden
  123395. */
  123396. _detachCameras(cameras: Camera[]): void;
  123397. /**
  123398. * Enables the effect on given cameras
  123399. * @param cameras The camera to enable.
  123400. * @hidden
  123401. */
  123402. _enable(cameras: Camera): void;
  123403. /**
  123404. * Enables the effect on given cameras
  123405. * @param cameras The camera to enable.
  123406. * @hidden
  123407. */
  123408. _enable(cameras: Nullable<Camera[]>): void;
  123409. /**
  123410. * Disables the effect on the given cameras
  123411. * @param cameras The camera to disable.
  123412. * @hidden
  123413. */
  123414. _disable(cameras: Camera): void;
  123415. /**
  123416. * Disables the effect on the given cameras
  123417. * @param cameras The camera to disable.
  123418. * @hidden
  123419. */
  123420. _disable(cameras: Nullable<Camera[]>): void;
  123421. /**
  123422. * Gets a list of the post processes contained in the effect.
  123423. * @param camera The camera to get the post processes on.
  123424. * @returns The list of the post processes in the effect.
  123425. */
  123426. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123427. }
  123428. }
  123429. declare module BABYLON {
  123430. /** @hidden */
  123431. export var extractHighlightsPixelShader: {
  123432. name: string;
  123433. shader: string;
  123434. };
  123435. }
  123436. declare module BABYLON {
  123437. /**
  123438. * 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.
  123439. */
  123440. export class ExtractHighlightsPostProcess extends PostProcess {
  123441. /**
  123442. * The luminance threshold, pixels below this value will be set to black.
  123443. */
  123444. threshold: number;
  123445. /** @hidden */
  123446. _exposure: number;
  123447. /**
  123448. * Post process which has the input texture to be used when performing highlight extraction
  123449. * @hidden
  123450. */
  123451. _inputPostProcess: Nullable<PostProcess>;
  123452. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123453. }
  123454. }
  123455. declare module BABYLON {
  123456. /** @hidden */
  123457. export var bloomMergePixelShader: {
  123458. name: string;
  123459. shader: string;
  123460. };
  123461. }
  123462. declare module BABYLON {
  123463. /**
  123464. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123465. */
  123466. export class BloomMergePostProcess extends PostProcess {
  123467. /** Weight of the bloom to be added to the original input. */
  123468. weight: number;
  123469. /**
  123470. * Creates a new instance of @see BloomMergePostProcess
  123471. * @param name The name of the effect.
  123472. * @param originalFromInput Post process which's input will be used for the merge.
  123473. * @param blurred Blurred highlights post process which's output will be used.
  123474. * @param weight Weight of the bloom to be added to the original input.
  123475. * @param options The required width/height ratio to downsize to before computing the render pass.
  123476. * @param camera The camera to apply the render pass to.
  123477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123478. * @param engine The engine which the post process will be applied. (default: current engine)
  123479. * @param reusable If the post process can be reused on the same frame. (default: false)
  123480. * @param textureType Type of textures used when performing the post process. (default: 0)
  123481. * @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)
  123482. */
  123483. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123484. /** Weight of the bloom to be added to the original input. */
  123485. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123486. }
  123487. }
  123488. declare module BABYLON {
  123489. /**
  123490. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123491. */
  123492. export class BloomEffect extends PostProcessRenderEffect {
  123493. private bloomScale;
  123494. /**
  123495. * @hidden Internal
  123496. */
  123497. _effects: Array<PostProcess>;
  123498. /**
  123499. * @hidden Internal
  123500. */
  123501. _downscale: ExtractHighlightsPostProcess;
  123502. private _blurX;
  123503. private _blurY;
  123504. private _merge;
  123505. /**
  123506. * The luminance threshold to find bright areas of the image to bloom.
  123507. */
  123508. threshold: number;
  123509. /**
  123510. * The strength of the bloom.
  123511. */
  123512. weight: number;
  123513. /**
  123514. * Specifies the size of the bloom blur kernel, relative to the final output size
  123515. */
  123516. kernel: number;
  123517. /**
  123518. * Creates a new instance of @see BloomEffect
  123519. * @param scene The scene the effect belongs to.
  123520. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123521. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123522. * @param bloomWeight The the strength of bloom.
  123523. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123524. * @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)
  123525. */
  123526. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123527. /**
  123528. * Disposes each of the internal effects for a given camera.
  123529. * @param camera The camera to dispose the effect on.
  123530. */
  123531. disposeEffects(camera: Camera): void;
  123532. /**
  123533. * @hidden Internal
  123534. */
  123535. _updateEffects(): void;
  123536. /**
  123537. * Internal
  123538. * @returns if all the contained post processes are ready.
  123539. * @hidden
  123540. */
  123541. _isReady(): boolean;
  123542. }
  123543. }
  123544. declare module BABYLON {
  123545. /** @hidden */
  123546. export var chromaticAberrationPixelShader: {
  123547. name: string;
  123548. shader: string;
  123549. };
  123550. }
  123551. declare module BABYLON {
  123552. /**
  123553. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123554. */
  123555. export class ChromaticAberrationPostProcess extends PostProcess {
  123556. /**
  123557. * The amount of seperation of rgb channels (default: 30)
  123558. */
  123559. aberrationAmount: number;
  123560. /**
  123561. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123562. */
  123563. radialIntensity: number;
  123564. /**
  123565. * 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))
  123566. */
  123567. direction: Vector2;
  123568. /**
  123569. * 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))
  123570. */
  123571. centerPosition: Vector2;
  123572. /**
  123573. * Creates a new instance ChromaticAberrationPostProcess
  123574. * @param name The name of the effect.
  123575. * @param screenWidth The width of the screen to apply the effect on.
  123576. * @param screenHeight The height of the screen to apply the effect on.
  123577. * @param options The required width/height ratio to downsize to before computing the render pass.
  123578. * @param camera The camera to apply the render pass to.
  123579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123580. * @param engine The engine which the post process will be applied. (default: current engine)
  123581. * @param reusable If the post process can be reused on the same frame. (default: false)
  123582. * @param textureType Type of textures used when performing the post process. (default: 0)
  123583. * @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)
  123584. */
  123585. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123586. }
  123587. }
  123588. declare module BABYLON {
  123589. /** @hidden */
  123590. export var circleOfConfusionPixelShader: {
  123591. name: string;
  123592. shader: string;
  123593. };
  123594. }
  123595. declare module BABYLON {
  123596. /**
  123597. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123598. */
  123599. export class CircleOfConfusionPostProcess extends PostProcess {
  123600. /**
  123601. * 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.
  123602. */
  123603. lensSize: number;
  123604. /**
  123605. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123606. */
  123607. fStop: number;
  123608. /**
  123609. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123610. */
  123611. focusDistance: number;
  123612. /**
  123613. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123614. */
  123615. focalLength: number;
  123616. private _depthTexture;
  123617. /**
  123618. * Creates a new instance CircleOfConfusionPostProcess
  123619. * @param name The name of the effect.
  123620. * @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.
  123621. * @param options The required width/height ratio to downsize to before computing the render pass.
  123622. * @param camera The camera to apply the render pass to.
  123623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123624. * @param engine The engine which the post process will be applied. (default: current engine)
  123625. * @param reusable If the post process can be reused on the same frame. (default: false)
  123626. * @param textureType Type of textures used when performing the post process. (default: 0)
  123627. * @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)
  123628. */
  123629. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123630. /**
  123631. * 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.
  123632. */
  123633. depthTexture: RenderTargetTexture;
  123634. }
  123635. }
  123636. declare module BABYLON {
  123637. /** @hidden */
  123638. export var colorCorrectionPixelShader: {
  123639. name: string;
  123640. shader: string;
  123641. };
  123642. }
  123643. declare module BABYLON {
  123644. /**
  123645. *
  123646. * This post-process allows the modification of rendered colors by using
  123647. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123648. *
  123649. * The object needs to be provided an url to a texture containing the color
  123650. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123651. * Use an image editing software to tweak the LUT to match your needs.
  123652. *
  123653. * For an example of a color LUT, see here:
  123654. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123655. * For explanations on color grading, see here:
  123656. * @see http://udn.epicgames.com/Three/ColorGrading.html
  123657. *
  123658. */
  123659. export class ColorCorrectionPostProcess extends PostProcess {
  123660. private _colorTableTexture;
  123661. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123662. }
  123663. }
  123664. declare module BABYLON {
  123665. /** @hidden */
  123666. export var convolutionPixelShader: {
  123667. name: string;
  123668. shader: string;
  123669. };
  123670. }
  123671. declare module BABYLON {
  123672. /**
  123673. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  123674. * input texture to perform effects such as edge detection or sharpening
  123675. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123676. */
  123677. export class ConvolutionPostProcess extends PostProcess {
  123678. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  123679. kernel: number[];
  123680. /**
  123681. * Creates a new instance ConvolutionPostProcess
  123682. * @param name The name of the effect.
  123683. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  123684. * @param options The required width/height ratio to downsize to before computing the render pass.
  123685. * @param camera The camera to apply the render pass to.
  123686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123687. * @param engine The engine which the post process will be applied. (default: current engine)
  123688. * @param reusable If the post process can be reused on the same frame. (default: false)
  123689. * @param textureType Type of textures used when performing the post process. (default: 0)
  123690. */
  123691. constructor(name: string,
  123692. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  123693. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123694. /**
  123695. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123696. */
  123697. static EdgeDetect0Kernel: number[];
  123698. /**
  123699. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123700. */
  123701. static EdgeDetect1Kernel: number[];
  123702. /**
  123703. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123704. */
  123705. static EdgeDetect2Kernel: number[];
  123706. /**
  123707. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123708. */
  123709. static SharpenKernel: number[];
  123710. /**
  123711. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123712. */
  123713. static EmbossKernel: number[];
  123714. /**
  123715. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123716. */
  123717. static GaussianKernel: number[];
  123718. }
  123719. }
  123720. declare module BABYLON {
  123721. /**
  123722. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  123723. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  123724. * based on samples that have a large difference in distance than the center pixel.
  123725. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123726. */
  123727. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  123728. direction: Vector2;
  123729. /**
  123730. * Creates a new instance CircleOfConfusionPostProcess
  123731. * @param name The name of the effect.
  123732. * @param scene The scene the effect belongs to.
  123733. * @param direction The direction the blur should be applied.
  123734. * @param kernel The size of the kernel used to blur.
  123735. * @param options The required width/height ratio to downsize to before computing the render pass.
  123736. * @param camera The camera to apply the render pass to.
  123737. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  123738. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  123739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123740. * @param engine The engine which the post process will be applied. (default: current engine)
  123741. * @param reusable If the post process can be reused on the same frame. (default: false)
  123742. * @param textureType Type of textures used when performing the post process. (default: 0)
  123743. * @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)
  123744. */
  123745. 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);
  123746. }
  123747. }
  123748. declare module BABYLON {
  123749. /** @hidden */
  123750. export var depthOfFieldMergePixelShader: {
  123751. name: string;
  123752. shader: string;
  123753. };
  123754. }
  123755. declare module BABYLON {
  123756. /**
  123757. * Options to be set when merging outputs from the default pipeline.
  123758. */
  123759. export class DepthOfFieldMergePostProcessOptions {
  123760. /**
  123761. * The original image to merge on top of
  123762. */
  123763. originalFromInput: PostProcess;
  123764. /**
  123765. * Parameters to perform the merge of the depth of field effect
  123766. */
  123767. depthOfField?: {
  123768. circleOfConfusion: PostProcess;
  123769. blurSteps: Array<PostProcess>;
  123770. };
  123771. /**
  123772. * Parameters to perform the merge of bloom effect
  123773. */
  123774. bloom?: {
  123775. blurred: PostProcess;
  123776. weight: number;
  123777. };
  123778. }
  123779. /**
  123780. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123781. */
  123782. export class DepthOfFieldMergePostProcess extends PostProcess {
  123783. private blurSteps;
  123784. /**
  123785. * Creates a new instance of DepthOfFieldMergePostProcess
  123786. * @param name The name of the effect.
  123787. * @param originalFromInput Post process which's input will be used for the merge.
  123788. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  123789. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  123790. * @param options The required width/height ratio to downsize to before computing the render pass.
  123791. * @param camera The camera to apply the render pass to.
  123792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123793. * @param engine The engine which the post process will be applied. (default: current engine)
  123794. * @param reusable If the post process can be reused on the same frame. (default: false)
  123795. * @param textureType Type of textures used when performing the post process. (default: 0)
  123796. * @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)
  123797. */
  123798. 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);
  123799. /**
  123800. * Updates the effect with the current post process compile time values and recompiles the shader.
  123801. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123802. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123803. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123804. * @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
  123805. * @param onCompiled Called when the shader has been compiled.
  123806. * @param onError Called if there is an error when compiling a shader.
  123807. */
  123808. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  123809. }
  123810. }
  123811. declare module BABYLON {
  123812. /**
  123813. * Specifies the level of max blur that should be applied when using the depth of field effect
  123814. */
  123815. export enum DepthOfFieldEffectBlurLevel {
  123816. /**
  123817. * Subtle blur
  123818. */
  123819. Low = 0,
  123820. /**
  123821. * Medium blur
  123822. */
  123823. Medium = 1,
  123824. /**
  123825. * Large blur
  123826. */
  123827. High = 2
  123828. }
  123829. /**
  123830. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  123831. */
  123832. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  123833. private _circleOfConfusion;
  123834. /**
  123835. * @hidden Internal, blurs from high to low
  123836. */
  123837. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  123838. private _depthOfFieldBlurY;
  123839. private _dofMerge;
  123840. /**
  123841. * @hidden Internal post processes in depth of field effect
  123842. */
  123843. _effects: Array<PostProcess>;
  123844. /**
  123845. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  123846. */
  123847. focalLength: number;
  123848. /**
  123849. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123850. */
  123851. fStop: number;
  123852. /**
  123853. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123854. */
  123855. focusDistance: number;
  123856. /**
  123857. * 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.
  123858. */
  123859. lensSize: number;
  123860. /**
  123861. * Creates a new instance DepthOfFieldEffect
  123862. * @param scene The scene the effect belongs to.
  123863. * @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.
  123864. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123865. * @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)
  123866. */
  123867. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  123868. /**
  123869. * Get the current class name of the current effet
  123870. * @returns "DepthOfFieldEffect"
  123871. */
  123872. getClassName(): string;
  123873. /**
  123874. * 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.
  123875. */
  123876. depthTexture: RenderTargetTexture;
  123877. /**
  123878. * Disposes each of the internal effects for a given camera.
  123879. * @param camera The camera to dispose the effect on.
  123880. */
  123881. disposeEffects(camera: Camera): void;
  123882. /**
  123883. * @hidden Internal
  123884. */
  123885. _updateEffects(): void;
  123886. /**
  123887. * Internal
  123888. * @returns if all the contained post processes are ready.
  123889. * @hidden
  123890. */
  123891. _isReady(): boolean;
  123892. }
  123893. }
  123894. declare module BABYLON {
  123895. /** @hidden */
  123896. export var displayPassPixelShader: {
  123897. name: string;
  123898. shader: string;
  123899. };
  123900. }
  123901. declare module BABYLON {
  123902. /**
  123903. * DisplayPassPostProcess which produces an output the same as it's input
  123904. */
  123905. export class DisplayPassPostProcess extends PostProcess {
  123906. /**
  123907. * Creates the DisplayPassPostProcess
  123908. * @param name The name of the effect.
  123909. * @param options The required width/height ratio to downsize to before computing the render pass.
  123910. * @param camera The camera to apply the render pass to.
  123911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123912. * @param engine The engine which the post process will be applied. (default: current engine)
  123913. * @param reusable If the post process can be reused on the same frame. (default: false)
  123914. */
  123915. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123916. }
  123917. }
  123918. declare module BABYLON {
  123919. /** @hidden */
  123920. export var filterPixelShader: {
  123921. name: string;
  123922. shader: string;
  123923. };
  123924. }
  123925. declare module BABYLON {
  123926. /**
  123927. * Applies a kernel filter to the image
  123928. */
  123929. export class FilterPostProcess extends PostProcess {
  123930. /** The matrix to be applied to the image */
  123931. kernelMatrix: Matrix;
  123932. /**
  123933. *
  123934. * @param name The name of the effect.
  123935. * @param kernelMatrix The matrix to be applied to the image
  123936. * @param options The required width/height ratio to downsize to before computing the render pass.
  123937. * @param camera The camera to apply the render pass to.
  123938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123939. * @param engine The engine which the post process will be applied. (default: current engine)
  123940. * @param reusable If the post process can be reused on the same frame. (default: false)
  123941. */
  123942. constructor(name: string,
  123943. /** The matrix to be applied to the image */
  123944. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123945. }
  123946. }
  123947. declare module BABYLON {
  123948. /** @hidden */
  123949. export var fxaaPixelShader: {
  123950. name: string;
  123951. shader: string;
  123952. };
  123953. }
  123954. declare module BABYLON {
  123955. /** @hidden */
  123956. export var fxaaVertexShader: {
  123957. name: string;
  123958. shader: string;
  123959. };
  123960. }
  123961. declare module BABYLON {
  123962. /**
  123963. * Fxaa post process
  123964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  123965. */
  123966. export class FxaaPostProcess extends PostProcess {
  123967. /** @hidden */
  123968. texelWidth: number;
  123969. /** @hidden */
  123970. texelHeight: number;
  123971. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  123972. private _getDefines;
  123973. }
  123974. }
  123975. declare module BABYLON {
  123976. /** @hidden */
  123977. export var grainPixelShader: {
  123978. name: string;
  123979. shader: string;
  123980. };
  123981. }
  123982. declare module BABYLON {
  123983. /**
  123984. * The GrainPostProcess adds noise to the image at mid luminance levels
  123985. */
  123986. export class GrainPostProcess extends PostProcess {
  123987. /**
  123988. * The intensity of the grain added (default: 30)
  123989. */
  123990. intensity: number;
  123991. /**
  123992. * If the grain should be randomized on every frame
  123993. */
  123994. animated: boolean;
  123995. /**
  123996. * Creates a new instance of @see GrainPostProcess
  123997. * @param name The name of the effect.
  123998. * @param options The required width/height ratio to downsize to before computing the render pass.
  123999. * @param camera The camera to apply the render pass to.
  124000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124001. * @param engine The engine which the post process will be applied. (default: current engine)
  124002. * @param reusable If the post process can be reused on the same frame. (default: false)
  124003. * @param textureType Type of textures used when performing the post process. (default: 0)
  124004. * @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)
  124005. */
  124006. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124007. }
  124008. }
  124009. declare module BABYLON {
  124010. /** @hidden */
  124011. export var highlightsPixelShader: {
  124012. name: string;
  124013. shader: string;
  124014. };
  124015. }
  124016. declare module BABYLON {
  124017. /**
  124018. * Extracts highlights from the image
  124019. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124020. */
  124021. export class HighlightsPostProcess extends PostProcess {
  124022. /**
  124023. * Extracts highlights from the image
  124024. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124025. * @param name The name of the effect.
  124026. * @param options The required width/height ratio to downsize to before computing the render pass.
  124027. * @param camera The camera to apply the render pass to.
  124028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124029. * @param engine The engine which the post process will be applied. (default: current engine)
  124030. * @param reusable If the post process can be reused on the same frame. (default: false)
  124031. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124032. */
  124033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124034. }
  124035. }
  124036. declare module BABYLON {
  124037. /** @hidden */
  124038. export var mrtFragmentDeclaration: {
  124039. name: string;
  124040. shader: string;
  124041. };
  124042. }
  124043. declare module BABYLON {
  124044. /** @hidden */
  124045. export var geometryPixelShader: {
  124046. name: string;
  124047. shader: string;
  124048. };
  124049. }
  124050. declare module BABYLON {
  124051. /** @hidden */
  124052. export var geometryVertexShader: {
  124053. name: string;
  124054. shader: string;
  124055. };
  124056. }
  124057. declare module BABYLON {
  124058. /** @hidden */
  124059. interface ISavedTransformationMatrix {
  124060. world: Matrix;
  124061. viewProjection: Matrix;
  124062. }
  124063. /**
  124064. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124065. */
  124066. export class GeometryBufferRenderer {
  124067. /**
  124068. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124069. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124070. */
  124071. static readonly POSITION_TEXTURE_TYPE: number;
  124072. /**
  124073. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124074. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124075. */
  124076. static readonly VELOCITY_TEXTURE_TYPE: number;
  124077. /**
  124078. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124079. * in order to compute objects velocities when enableVelocity is set to "true"
  124080. * @hidden
  124081. */
  124082. _previousTransformationMatrices: {
  124083. [index: number]: ISavedTransformationMatrix;
  124084. };
  124085. /**
  124086. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124087. * in order to compute objects velocities when enableVelocity is set to "true"
  124088. * @hidden
  124089. */
  124090. _previousBonesTransformationMatrices: {
  124091. [index: number]: Float32Array;
  124092. };
  124093. /**
  124094. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124095. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124096. */
  124097. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124098. private _scene;
  124099. private _multiRenderTarget;
  124100. private _ratio;
  124101. private _enablePosition;
  124102. private _enableVelocity;
  124103. private _positionIndex;
  124104. private _velocityIndex;
  124105. protected _effect: Effect;
  124106. protected _cachedDefines: string;
  124107. /**
  124108. * Set the render list (meshes to be rendered) used in the G buffer.
  124109. */
  124110. renderList: Mesh[];
  124111. /**
  124112. * Gets wether or not G buffer are supported by the running hardware.
  124113. * This requires draw buffer supports
  124114. */
  124115. readonly isSupported: boolean;
  124116. /**
  124117. * Returns the index of the given texture type in the G-Buffer textures array
  124118. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124119. * @returns the index of the given texture type in the G-Buffer textures array
  124120. */
  124121. getTextureIndex(textureType: number): number;
  124122. /**
  124123. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124124. */
  124125. /**
  124126. * Sets whether or not objects positions are enabled for the G buffer.
  124127. */
  124128. enablePosition: boolean;
  124129. /**
  124130. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124131. */
  124132. /**
  124133. * Sets wether or not objects velocities are enabled for the G buffer.
  124134. */
  124135. enableVelocity: boolean;
  124136. /**
  124137. * Gets the scene associated with the buffer.
  124138. */
  124139. readonly scene: Scene;
  124140. /**
  124141. * Gets the ratio used by the buffer during its creation.
  124142. * How big is the buffer related to the main canvas.
  124143. */
  124144. readonly ratio: number;
  124145. /** @hidden */
  124146. static _SceneComponentInitialization: (scene: Scene) => void;
  124147. /**
  124148. * Creates a new G Buffer for the scene
  124149. * @param scene The scene the buffer belongs to
  124150. * @param ratio How big is the buffer related to the main canvas.
  124151. */
  124152. constructor(scene: Scene, ratio?: number);
  124153. /**
  124154. * Checks wether everything is ready to render a submesh to the G buffer.
  124155. * @param subMesh the submesh to check readiness for
  124156. * @param useInstances is the mesh drawn using instance or not
  124157. * @returns true if ready otherwise false
  124158. */
  124159. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124160. /**
  124161. * Gets the current underlying G Buffer.
  124162. * @returns the buffer
  124163. */
  124164. getGBuffer(): MultiRenderTarget;
  124165. /**
  124166. * Gets the number of samples used to render the buffer (anti aliasing).
  124167. */
  124168. /**
  124169. * Sets the number of samples used to render the buffer (anti aliasing).
  124170. */
  124171. samples: number;
  124172. /**
  124173. * Disposes the renderer and frees up associated resources.
  124174. */
  124175. dispose(): void;
  124176. protected _createRenderTargets(): void;
  124177. private _copyBonesTransformationMatrices;
  124178. }
  124179. }
  124180. declare module BABYLON {
  124181. interface Scene {
  124182. /** @hidden (Backing field) */
  124183. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124184. /**
  124185. * Gets or Sets the current geometry buffer associated to the scene.
  124186. */
  124187. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124188. /**
  124189. * Enables a GeometryBufferRender and associates it with the scene
  124190. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124191. * @returns the GeometryBufferRenderer
  124192. */
  124193. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124194. /**
  124195. * Disables the GeometryBufferRender associated with the scene
  124196. */
  124197. disableGeometryBufferRenderer(): void;
  124198. }
  124199. /**
  124200. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124201. * in several rendering techniques.
  124202. */
  124203. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124204. /**
  124205. * The component name helpful to identify the component in the list of scene components.
  124206. */
  124207. readonly name: string;
  124208. /**
  124209. * The scene the component belongs to.
  124210. */
  124211. scene: Scene;
  124212. /**
  124213. * Creates a new instance of the component for the given scene
  124214. * @param scene Defines the scene to register the component in
  124215. */
  124216. constructor(scene: Scene);
  124217. /**
  124218. * Registers the component in a given scene
  124219. */
  124220. register(): void;
  124221. /**
  124222. * Rebuilds the elements related to this component in case of
  124223. * context lost for instance.
  124224. */
  124225. rebuild(): void;
  124226. /**
  124227. * Disposes the component and the associated ressources
  124228. */
  124229. dispose(): void;
  124230. private _gatherRenderTargets;
  124231. }
  124232. }
  124233. declare module BABYLON {
  124234. /** @hidden */
  124235. export var motionBlurPixelShader: {
  124236. name: string;
  124237. shader: string;
  124238. };
  124239. }
  124240. declare module BABYLON {
  124241. /**
  124242. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124243. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124244. * As an example, all you have to do is to create the post-process:
  124245. * var mb = new BABYLON.MotionBlurPostProcess(
  124246. * 'mb', // The name of the effect.
  124247. * scene, // The scene containing the objects to blur according to their velocity.
  124248. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124249. * camera // The camera to apply the render pass to.
  124250. * );
  124251. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124252. */
  124253. export class MotionBlurPostProcess extends PostProcess {
  124254. /**
  124255. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124256. */
  124257. motionStrength: number;
  124258. /**
  124259. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124260. */
  124261. /**
  124262. * Sets the number of iterations to be used for motion blur quality
  124263. */
  124264. motionBlurSamples: number;
  124265. private _motionBlurSamples;
  124266. private _geometryBufferRenderer;
  124267. /**
  124268. * Creates a new instance MotionBlurPostProcess
  124269. * @param name The name of the effect.
  124270. * @param scene The scene containing the objects to blur according to their velocity.
  124271. * @param options The required width/height ratio to downsize to before computing the render pass.
  124272. * @param camera The camera to apply the render pass to.
  124273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124274. * @param engine The engine which the post process will be applied. (default: current engine)
  124275. * @param reusable If the post process can be reused on the same frame. (default: false)
  124276. * @param textureType Type of textures used when performing the post process. (default: 0)
  124277. * @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)
  124278. */
  124279. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124280. /**
  124281. * Excludes the given skinned mesh from computing bones velocities.
  124282. * 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.
  124283. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124284. */
  124285. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124286. /**
  124287. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124288. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124289. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124290. */
  124291. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124292. /**
  124293. * Disposes the post process.
  124294. * @param camera The camera to dispose the post process on.
  124295. */
  124296. dispose(camera?: Camera): void;
  124297. }
  124298. }
  124299. declare module BABYLON {
  124300. /** @hidden */
  124301. export var refractionPixelShader: {
  124302. name: string;
  124303. shader: string;
  124304. };
  124305. }
  124306. declare module BABYLON {
  124307. /**
  124308. * Post process which applies a refractin texture
  124309. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124310. */
  124311. export class RefractionPostProcess extends PostProcess {
  124312. /** the base color of the refraction (used to taint the rendering) */
  124313. color: Color3;
  124314. /** simulated refraction depth */
  124315. depth: number;
  124316. /** the coefficient of the base color (0 to remove base color tainting) */
  124317. colorLevel: number;
  124318. private _refTexture;
  124319. private _ownRefractionTexture;
  124320. /**
  124321. * Gets or sets the refraction texture
  124322. * Please note that you are responsible for disposing the texture if you set it manually
  124323. */
  124324. refractionTexture: Texture;
  124325. /**
  124326. * Initializes the RefractionPostProcess
  124327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124328. * @param name The name of the effect.
  124329. * @param refractionTextureUrl Url of the refraction texture to use
  124330. * @param color the base color of the refraction (used to taint the rendering)
  124331. * @param depth simulated refraction depth
  124332. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124333. * @param camera The camera to apply the render pass to.
  124334. * @param options The required width/height ratio to downsize to before computing the render pass.
  124335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124336. * @param engine The engine which the post process will be applied. (default: current engine)
  124337. * @param reusable If the post process can be reused on the same frame. (default: false)
  124338. */
  124339. constructor(name: string, refractionTextureUrl: string,
  124340. /** the base color of the refraction (used to taint the rendering) */
  124341. color: Color3,
  124342. /** simulated refraction depth */
  124343. depth: number,
  124344. /** the coefficient of the base color (0 to remove base color tainting) */
  124345. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124346. /**
  124347. * Disposes of the post process
  124348. * @param camera Camera to dispose post process on
  124349. */
  124350. dispose(camera: Camera): void;
  124351. }
  124352. }
  124353. declare module BABYLON {
  124354. /** @hidden */
  124355. export var sharpenPixelShader: {
  124356. name: string;
  124357. shader: string;
  124358. };
  124359. }
  124360. declare module BABYLON {
  124361. /**
  124362. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124363. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124364. */
  124365. export class SharpenPostProcess extends PostProcess {
  124366. /**
  124367. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124368. */
  124369. colorAmount: number;
  124370. /**
  124371. * How much sharpness should be applied (default: 0.3)
  124372. */
  124373. edgeAmount: number;
  124374. /**
  124375. * Creates a new instance ConvolutionPostProcess
  124376. * @param name The name of the effect.
  124377. * @param options The required width/height ratio to downsize to before computing the render pass.
  124378. * @param camera The camera to apply the render pass to.
  124379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124380. * @param engine The engine which the post process will be applied. (default: current engine)
  124381. * @param reusable If the post process can be reused on the same frame. (default: false)
  124382. * @param textureType Type of textures used when performing the post process. (default: 0)
  124383. * @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)
  124384. */
  124385. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124386. }
  124387. }
  124388. declare module BABYLON {
  124389. /**
  124390. * PostProcessRenderPipeline
  124391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124392. */
  124393. export class PostProcessRenderPipeline {
  124394. private engine;
  124395. private _renderEffects;
  124396. private _renderEffectsForIsolatedPass;
  124397. /**
  124398. * List of inspectable custom properties (used by the Inspector)
  124399. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124400. */
  124401. inspectableCustomProperties: IInspectable[];
  124402. /**
  124403. * @hidden
  124404. */
  124405. protected _cameras: Camera[];
  124406. /** @hidden */
  124407. _name: string;
  124408. /**
  124409. * Gets pipeline name
  124410. */
  124411. readonly name: string;
  124412. /**
  124413. * Initializes a PostProcessRenderPipeline
  124414. * @param engine engine to add the pipeline to
  124415. * @param name name of the pipeline
  124416. */
  124417. constructor(engine: Engine, name: string);
  124418. /**
  124419. * Gets the class name
  124420. * @returns "PostProcessRenderPipeline"
  124421. */
  124422. getClassName(): string;
  124423. /**
  124424. * If all the render effects in the pipeline are supported
  124425. */
  124426. readonly isSupported: boolean;
  124427. /**
  124428. * Adds an effect to the pipeline
  124429. * @param renderEffect the effect to add
  124430. */
  124431. addEffect(renderEffect: PostProcessRenderEffect): void;
  124432. /** @hidden */
  124433. _rebuild(): void;
  124434. /** @hidden */
  124435. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124436. /** @hidden */
  124437. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124438. /** @hidden */
  124439. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124440. /** @hidden */
  124441. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124442. /** @hidden */
  124443. _attachCameras(cameras: Camera, unique: boolean): void;
  124444. /** @hidden */
  124445. _attachCameras(cameras: Camera[], unique: boolean): void;
  124446. /** @hidden */
  124447. _detachCameras(cameras: Camera): void;
  124448. /** @hidden */
  124449. _detachCameras(cameras: Nullable<Camera[]>): void;
  124450. /** @hidden */
  124451. _update(): void;
  124452. /** @hidden */
  124453. _reset(): void;
  124454. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124455. /**
  124456. * Disposes of the pipeline
  124457. */
  124458. dispose(): void;
  124459. }
  124460. }
  124461. declare module BABYLON {
  124462. /**
  124463. * PostProcessRenderPipelineManager class
  124464. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124465. */
  124466. export class PostProcessRenderPipelineManager {
  124467. private _renderPipelines;
  124468. /**
  124469. * Initializes a PostProcessRenderPipelineManager
  124470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124471. */
  124472. constructor();
  124473. /**
  124474. * Gets the list of supported render pipelines
  124475. */
  124476. readonly supportedPipelines: PostProcessRenderPipeline[];
  124477. /**
  124478. * Adds a pipeline to the manager
  124479. * @param renderPipeline The pipeline to add
  124480. */
  124481. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124482. /**
  124483. * Attaches a camera to the pipeline
  124484. * @param renderPipelineName The name of the pipeline to attach to
  124485. * @param cameras the camera to attach
  124486. * @param unique if the camera can be attached multiple times to the pipeline
  124487. */
  124488. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124489. /**
  124490. * Detaches a camera from the pipeline
  124491. * @param renderPipelineName The name of the pipeline to detach from
  124492. * @param cameras the camera to detach
  124493. */
  124494. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124495. /**
  124496. * Enables an effect by name on a pipeline
  124497. * @param renderPipelineName the name of the pipeline to enable the effect in
  124498. * @param renderEffectName the name of the effect to enable
  124499. * @param cameras the cameras that the effect should be enabled on
  124500. */
  124501. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124502. /**
  124503. * Disables an effect by name on a pipeline
  124504. * @param renderPipelineName the name of the pipeline to disable the effect in
  124505. * @param renderEffectName the name of the effect to disable
  124506. * @param cameras the cameras that the effect should be disabled on
  124507. */
  124508. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124509. /**
  124510. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124511. */
  124512. update(): void;
  124513. /** @hidden */
  124514. _rebuild(): void;
  124515. /**
  124516. * Disposes of the manager and pipelines
  124517. */
  124518. dispose(): void;
  124519. }
  124520. }
  124521. declare module BABYLON {
  124522. interface Scene {
  124523. /** @hidden (Backing field) */
  124524. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124525. /**
  124526. * Gets the postprocess render pipeline manager
  124527. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124528. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124529. */
  124530. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124531. }
  124532. /**
  124533. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124534. */
  124535. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124536. /**
  124537. * The component name helpfull to identify the component in the list of scene components.
  124538. */
  124539. readonly name: string;
  124540. /**
  124541. * The scene the component belongs to.
  124542. */
  124543. scene: Scene;
  124544. /**
  124545. * Creates a new instance of the component for the given scene
  124546. * @param scene Defines the scene to register the component in
  124547. */
  124548. constructor(scene: Scene);
  124549. /**
  124550. * Registers the component in a given scene
  124551. */
  124552. register(): void;
  124553. /**
  124554. * Rebuilds the elements related to this component in case of
  124555. * context lost for instance.
  124556. */
  124557. rebuild(): void;
  124558. /**
  124559. * Disposes the component and the associated ressources
  124560. */
  124561. dispose(): void;
  124562. private _gatherRenderTargets;
  124563. }
  124564. }
  124565. declare module BABYLON {
  124566. /**
  124567. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124568. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124569. */
  124570. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124571. private _scene;
  124572. private _camerasToBeAttached;
  124573. /**
  124574. * ID of the sharpen post process,
  124575. */
  124576. private readonly SharpenPostProcessId;
  124577. /**
  124578. * @ignore
  124579. * ID of the image processing post process;
  124580. */
  124581. readonly ImageProcessingPostProcessId: string;
  124582. /**
  124583. * @ignore
  124584. * ID of the Fast Approximate Anti-Aliasing post process;
  124585. */
  124586. readonly FxaaPostProcessId: string;
  124587. /**
  124588. * ID of the chromatic aberration post process,
  124589. */
  124590. private readonly ChromaticAberrationPostProcessId;
  124591. /**
  124592. * ID of the grain post process
  124593. */
  124594. private readonly GrainPostProcessId;
  124595. /**
  124596. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124597. */
  124598. sharpen: SharpenPostProcess;
  124599. private _sharpenEffect;
  124600. private bloom;
  124601. /**
  124602. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124603. */
  124604. depthOfField: DepthOfFieldEffect;
  124605. /**
  124606. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124607. */
  124608. fxaa: FxaaPostProcess;
  124609. /**
  124610. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124611. */
  124612. imageProcessing: ImageProcessingPostProcess;
  124613. /**
  124614. * Chromatic aberration post process which will shift rgb colors in the image
  124615. */
  124616. chromaticAberration: ChromaticAberrationPostProcess;
  124617. private _chromaticAberrationEffect;
  124618. /**
  124619. * Grain post process which add noise to the image
  124620. */
  124621. grain: GrainPostProcess;
  124622. private _grainEffect;
  124623. /**
  124624. * Glow post process which adds a glow to emissive areas of the image
  124625. */
  124626. private _glowLayer;
  124627. /**
  124628. * Animations which can be used to tweak settings over a period of time
  124629. */
  124630. animations: Animation[];
  124631. private _imageProcessingConfigurationObserver;
  124632. private _sharpenEnabled;
  124633. private _bloomEnabled;
  124634. private _depthOfFieldEnabled;
  124635. private _depthOfFieldBlurLevel;
  124636. private _fxaaEnabled;
  124637. private _imageProcessingEnabled;
  124638. private _defaultPipelineTextureType;
  124639. private _bloomScale;
  124640. private _chromaticAberrationEnabled;
  124641. private _grainEnabled;
  124642. private _buildAllowed;
  124643. /**
  124644. * Gets active scene
  124645. */
  124646. readonly scene: Scene;
  124647. /**
  124648. * Enable or disable the sharpen process from the pipeline
  124649. */
  124650. sharpenEnabled: boolean;
  124651. private _resizeObserver;
  124652. private _hardwareScaleLevel;
  124653. private _bloomKernel;
  124654. /**
  124655. * Specifies the size of the bloom blur kernel, relative to the final output size
  124656. */
  124657. bloomKernel: number;
  124658. /**
  124659. * Specifies the weight of the bloom in the final rendering
  124660. */
  124661. private _bloomWeight;
  124662. /**
  124663. * Specifies the luma threshold for the area that will be blurred by the bloom
  124664. */
  124665. private _bloomThreshold;
  124666. private _hdr;
  124667. /**
  124668. * The strength of the bloom.
  124669. */
  124670. bloomWeight: number;
  124671. /**
  124672. * The strength of the bloom.
  124673. */
  124674. bloomThreshold: number;
  124675. /**
  124676. * The scale of the bloom, lower value will provide better performance.
  124677. */
  124678. bloomScale: number;
  124679. /**
  124680. * Enable or disable the bloom from the pipeline
  124681. */
  124682. bloomEnabled: boolean;
  124683. private _rebuildBloom;
  124684. /**
  124685. * If the depth of field is enabled.
  124686. */
  124687. depthOfFieldEnabled: boolean;
  124688. /**
  124689. * Blur level of the depth of field effect. (Higher blur will effect performance)
  124690. */
  124691. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  124692. /**
  124693. * If the anti aliasing is enabled.
  124694. */
  124695. fxaaEnabled: boolean;
  124696. private _samples;
  124697. /**
  124698. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  124699. */
  124700. samples: number;
  124701. /**
  124702. * If image processing is enabled.
  124703. */
  124704. imageProcessingEnabled: boolean;
  124705. /**
  124706. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  124707. */
  124708. glowLayerEnabled: boolean;
  124709. /**
  124710. * Gets the glow layer (or null if not defined)
  124711. */
  124712. readonly glowLayer: Nullable<GlowLayer>;
  124713. /**
  124714. * Enable or disable the chromaticAberration process from the pipeline
  124715. */
  124716. chromaticAberrationEnabled: boolean;
  124717. /**
  124718. * Enable or disable the grain process from the pipeline
  124719. */
  124720. grainEnabled: boolean;
  124721. /**
  124722. * @constructor
  124723. * @param name - The rendering pipeline name (default: "")
  124724. * @param hdr - If high dynamic range textures should be used (default: true)
  124725. * @param scene - The scene linked to this pipeline (default: the last created scene)
  124726. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  124727. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  124728. */
  124729. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  124730. /**
  124731. * Get the class name
  124732. * @returns "DefaultRenderingPipeline"
  124733. */
  124734. getClassName(): string;
  124735. /**
  124736. * Force the compilation of the entire pipeline.
  124737. */
  124738. prepare(): void;
  124739. private _hasCleared;
  124740. private _prevPostProcess;
  124741. private _prevPrevPostProcess;
  124742. private _setAutoClearAndTextureSharing;
  124743. private _depthOfFieldSceneObserver;
  124744. private _buildPipeline;
  124745. private _disposePostProcesses;
  124746. /**
  124747. * Adds a camera to the pipeline
  124748. * @param camera the camera to be added
  124749. */
  124750. addCamera(camera: Camera): void;
  124751. /**
  124752. * Removes a camera from the pipeline
  124753. * @param camera the camera to remove
  124754. */
  124755. removeCamera(camera: Camera): void;
  124756. /**
  124757. * Dispose of the pipeline and stop all post processes
  124758. */
  124759. dispose(): void;
  124760. /**
  124761. * Serialize the rendering pipeline (Used when exporting)
  124762. * @returns the serialized object
  124763. */
  124764. serialize(): any;
  124765. /**
  124766. * Parse the serialized pipeline
  124767. * @param source Source pipeline.
  124768. * @param scene The scene to load the pipeline to.
  124769. * @param rootUrl The URL of the serialized pipeline.
  124770. * @returns An instantiated pipeline from the serialized object.
  124771. */
  124772. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  124773. }
  124774. }
  124775. declare module BABYLON {
  124776. /** @hidden */
  124777. export var lensHighlightsPixelShader: {
  124778. name: string;
  124779. shader: string;
  124780. };
  124781. }
  124782. declare module BABYLON {
  124783. /** @hidden */
  124784. export var depthOfFieldPixelShader: {
  124785. name: string;
  124786. shader: string;
  124787. };
  124788. }
  124789. declare module BABYLON {
  124790. /**
  124791. * BABYLON.JS Chromatic Aberration GLSL Shader
  124792. * Author: Olivier Guyot
  124793. * Separates very slightly R, G and B colors on the edges of the screen
  124794. * Inspired by Francois Tarlier & Martins Upitis
  124795. */
  124796. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  124797. /**
  124798. * @ignore
  124799. * The chromatic aberration PostProcess id in the pipeline
  124800. */
  124801. LensChromaticAberrationEffect: string;
  124802. /**
  124803. * @ignore
  124804. * The highlights enhancing PostProcess id in the pipeline
  124805. */
  124806. HighlightsEnhancingEffect: string;
  124807. /**
  124808. * @ignore
  124809. * The depth-of-field PostProcess id in the pipeline
  124810. */
  124811. LensDepthOfFieldEffect: string;
  124812. private _scene;
  124813. private _depthTexture;
  124814. private _grainTexture;
  124815. private _chromaticAberrationPostProcess;
  124816. private _highlightsPostProcess;
  124817. private _depthOfFieldPostProcess;
  124818. private _edgeBlur;
  124819. private _grainAmount;
  124820. private _chromaticAberration;
  124821. private _distortion;
  124822. private _highlightsGain;
  124823. private _highlightsThreshold;
  124824. private _dofDistance;
  124825. private _dofAperture;
  124826. private _dofDarken;
  124827. private _dofPentagon;
  124828. private _blurNoise;
  124829. /**
  124830. * @constructor
  124831. *
  124832. * Effect parameters are as follow:
  124833. * {
  124834. * chromatic_aberration: number; // from 0 to x (1 for realism)
  124835. * edge_blur: number; // from 0 to x (1 for realism)
  124836. * distortion: number; // from 0 to x (1 for realism)
  124837. * grain_amount: number; // from 0 to 1
  124838. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  124839. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  124840. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  124841. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  124842. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  124843. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  124844. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  124845. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  124846. * }
  124847. * Note: if an effect parameter is unset, effect is disabled
  124848. *
  124849. * @param name The rendering pipeline name
  124850. * @param parameters - An object containing all parameters (see above)
  124851. * @param scene The scene linked to this pipeline
  124852. * @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)
  124853. * @param cameras The array of cameras that the rendering pipeline will be attached to
  124854. */
  124855. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  124856. /**
  124857. * Get the class name
  124858. * @returns "LensRenderingPipeline"
  124859. */
  124860. getClassName(): string;
  124861. /**
  124862. * Gets associated scene
  124863. */
  124864. readonly scene: Scene;
  124865. /**
  124866. * Gets or sets the edge blur
  124867. */
  124868. edgeBlur: number;
  124869. /**
  124870. * Gets or sets the grain amount
  124871. */
  124872. grainAmount: number;
  124873. /**
  124874. * Gets or sets the chromatic aberration amount
  124875. */
  124876. chromaticAberration: number;
  124877. /**
  124878. * Gets or sets the depth of field aperture
  124879. */
  124880. dofAperture: number;
  124881. /**
  124882. * Gets or sets the edge distortion
  124883. */
  124884. edgeDistortion: number;
  124885. /**
  124886. * Gets or sets the depth of field distortion
  124887. */
  124888. dofDistortion: number;
  124889. /**
  124890. * Gets or sets the darken out of focus amount
  124891. */
  124892. darkenOutOfFocus: number;
  124893. /**
  124894. * Gets or sets a boolean indicating if blur noise is enabled
  124895. */
  124896. blurNoise: boolean;
  124897. /**
  124898. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  124899. */
  124900. pentagonBokeh: boolean;
  124901. /**
  124902. * Gets or sets the highlight grain amount
  124903. */
  124904. highlightsGain: number;
  124905. /**
  124906. * Gets or sets the highlight threshold
  124907. */
  124908. highlightsThreshold: number;
  124909. /**
  124910. * Sets the amount of blur at the edges
  124911. * @param amount blur amount
  124912. */
  124913. setEdgeBlur(amount: number): void;
  124914. /**
  124915. * Sets edge blur to 0
  124916. */
  124917. disableEdgeBlur(): void;
  124918. /**
  124919. * Sets the amout of grain
  124920. * @param amount Amount of grain
  124921. */
  124922. setGrainAmount(amount: number): void;
  124923. /**
  124924. * Set grain amount to 0
  124925. */
  124926. disableGrain(): void;
  124927. /**
  124928. * Sets the chromatic aberration amount
  124929. * @param amount amount of chromatic aberration
  124930. */
  124931. setChromaticAberration(amount: number): void;
  124932. /**
  124933. * Sets chromatic aberration amount to 0
  124934. */
  124935. disableChromaticAberration(): void;
  124936. /**
  124937. * Sets the EdgeDistortion amount
  124938. * @param amount amount of EdgeDistortion
  124939. */
  124940. setEdgeDistortion(amount: number): void;
  124941. /**
  124942. * Sets edge distortion to 0
  124943. */
  124944. disableEdgeDistortion(): void;
  124945. /**
  124946. * Sets the FocusDistance amount
  124947. * @param amount amount of FocusDistance
  124948. */
  124949. setFocusDistance(amount: number): void;
  124950. /**
  124951. * Disables depth of field
  124952. */
  124953. disableDepthOfField(): void;
  124954. /**
  124955. * Sets the Aperture amount
  124956. * @param amount amount of Aperture
  124957. */
  124958. setAperture(amount: number): void;
  124959. /**
  124960. * Sets the DarkenOutOfFocus amount
  124961. * @param amount amount of DarkenOutOfFocus
  124962. */
  124963. setDarkenOutOfFocus(amount: number): void;
  124964. private _pentagonBokehIsEnabled;
  124965. /**
  124966. * Creates a pentagon bokeh effect
  124967. */
  124968. enablePentagonBokeh(): void;
  124969. /**
  124970. * Disables the pentagon bokeh effect
  124971. */
  124972. disablePentagonBokeh(): void;
  124973. /**
  124974. * Enables noise blur
  124975. */
  124976. enableNoiseBlur(): void;
  124977. /**
  124978. * Disables noise blur
  124979. */
  124980. disableNoiseBlur(): void;
  124981. /**
  124982. * Sets the HighlightsGain amount
  124983. * @param amount amount of HighlightsGain
  124984. */
  124985. setHighlightsGain(amount: number): void;
  124986. /**
  124987. * Sets the HighlightsThreshold amount
  124988. * @param amount amount of HighlightsThreshold
  124989. */
  124990. setHighlightsThreshold(amount: number): void;
  124991. /**
  124992. * Disables highlights
  124993. */
  124994. disableHighlights(): void;
  124995. /**
  124996. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  124997. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  124998. */
  124999. dispose(disableDepthRender?: boolean): void;
  125000. private _createChromaticAberrationPostProcess;
  125001. private _createHighlightsPostProcess;
  125002. private _createDepthOfFieldPostProcess;
  125003. private _createGrainTexture;
  125004. }
  125005. }
  125006. declare module BABYLON {
  125007. /** @hidden */
  125008. export var ssao2PixelShader: {
  125009. name: string;
  125010. shader: string;
  125011. };
  125012. }
  125013. declare module BABYLON {
  125014. /** @hidden */
  125015. export var ssaoCombinePixelShader: {
  125016. name: string;
  125017. shader: string;
  125018. };
  125019. }
  125020. declare module BABYLON {
  125021. /**
  125022. * Render pipeline to produce ssao effect
  125023. */
  125024. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125025. /**
  125026. * @ignore
  125027. * The PassPostProcess id in the pipeline that contains the original scene color
  125028. */
  125029. SSAOOriginalSceneColorEffect: string;
  125030. /**
  125031. * @ignore
  125032. * The SSAO PostProcess id in the pipeline
  125033. */
  125034. SSAORenderEffect: string;
  125035. /**
  125036. * @ignore
  125037. * The horizontal blur PostProcess id in the pipeline
  125038. */
  125039. SSAOBlurHRenderEffect: string;
  125040. /**
  125041. * @ignore
  125042. * The vertical blur PostProcess id in the pipeline
  125043. */
  125044. SSAOBlurVRenderEffect: string;
  125045. /**
  125046. * @ignore
  125047. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125048. */
  125049. SSAOCombineRenderEffect: string;
  125050. /**
  125051. * The output strength of the SSAO post-process. Default value is 1.0.
  125052. */
  125053. totalStrength: number;
  125054. /**
  125055. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125056. */
  125057. maxZ: number;
  125058. /**
  125059. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125060. */
  125061. minZAspect: number;
  125062. private _samples;
  125063. /**
  125064. * Number of samples used for the SSAO calculations. Default value is 8
  125065. */
  125066. samples: number;
  125067. private _textureSamples;
  125068. /**
  125069. * Number of samples to use for antialiasing
  125070. */
  125071. textureSamples: number;
  125072. /**
  125073. * Ratio object used for SSAO ratio and blur ratio
  125074. */
  125075. private _ratio;
  125076. /**
  125077. * Dynamically generated sphere sampler.
  125078. */
  125079. private _sampleSphere;
  125080. /**
  125081. * Blur filter offsets
  125082. */
  125083. private _samplerOffsets;
  125084. private _expensiveBlur;
  125085. /**
  125086. * If bilateral blur should be used
  125087. */
  125088. expensiveBlur: boolean;
  125089. /**
  125090. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125091. */
  125092. radius: number;
  125093. /**
  125094. * The base color of the SSAO post-process
  125095. * The final result is "base + ssao" between [0, 1]
  125096. */
  125097. base: number;
  125098. /**
  125099. * Support test.
  125100. */
  125101. static readonly IsSupported: boolean;
  125102. private _scene;
  125103. private _depthTexture;
  125104. private _normalTexture;
  125105. private _randomTexture;
  125106. private _originalColorPostProcess;
  125107. private _ssaoPostProcess;
  125108. private _blurHPostProcess;
  125109. private _blurVPostProcess;
  125110. private _ssaoCombinePostProcess;
  125111. private _firstUpdate;
  125112. /**
  125113. * Gets active scene
  125114. */
  125115. readonly scene: Scene;
  125116. /**
  125117. * @constructor
  125118. * @param name The rendering pipeline name
  125119. * @param scene The scene linked to this pipeline
  125120. * @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 }
  125121. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125122. */
  125123. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125124. /**
  125125. * Get the class name
  125126. * @returns "SSAO2RenderingPipeline"
  125127. */
  125128. getClassName(): string;
  125129. /**
  125130. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125131. */
  125132. dispose(disableGeometryBufferRenderer?: boolean): void;
  125133. private _createBlurPostProcess;
  125134. /** @hidden */
  125135. _rebuild(): void;
  125136. private _bits;
  125137. private _radicalInverse_VdC;
  125138. private _hammersley;
  125139. private _hemisphereSample_uniform;
  125140. private _generateHemisphere;
  125141. private _createSSAOPostProcess;
  125142. private _createSSAOCombinePostProcess;
  125143. private _createRandomTexture;
  125144. /**
  125145. * Serialize the rendering pipeline (Used when exporting)
  125146. * @returns the serialized object
  125147. */
  125148. serialize(): any;
  125149. /**
  125150. * Parse the serialized pipeline
  125151. * @param source Source pipeline.
  125152. * @param scene The scene to load the pipeline to.
  125153. * @param rootUrl The URL of the serialized pipeline.
  125154. * @returns An instantiated pipeline from the serialized object.
  125155. */
  125156. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125157. }
  125158. }
  125159. declare module BABYLON {
  125160. /** @hidden */
  125161. export var ssaoPixelShader: {
  125162. name: string;
  125163. shader: string;
  125164. };
  125165. }
  125166. declare module BABYLON {
  125167. /**
  125168. * Render pipeline to produce ssao effect
  125169. */
  125170. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125171. /**
  125172. * @ignore
  125173. * The PassPostProcess id in the pipeline that contains the original scene color
  125174. */
  125175. SSAOOriginalSceneColorEffect: string;
  125176. /**
  125177. * @ignore
  125178. * The SSAO PostProcess id in the pipeline
  125179. */
  125180. SSAORenderEffect: string;
  125181. /**
  125182. * @ignore
  125183. * The horizontal blur PostProcess id in the pipeline
  125184. */
  125185. SSAOBlurHRenderEffect: string;
  125186. /**
  125187. * @ignore
  125188. * The vertical blur PostProcess id in the pipeline
  125189. */
  125190. SSAOBlurVRenderEffect: string;
  125191. /**
  125192. * @ignore
  125193. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125194. */
  125195. SSAOCombineRenderEffect: string;
  125196. /**
  125197. * The output strength of the SSAO post-process. Default value is 1.0.
  125198. */
  125199. totalStrength: number;
  125200. /**
  125201. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125202. */
  125203. radius: number;
  125204. /**
  125205. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125206. * Must not be equal to fallOff and superior to fallOff.
  125207. * Default value is 0.0075
  125208. */
  125209. area: number;
  125210. /**
  125211. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125212. * Must not be equal to area and inferior to area.
  125213. * Default value is 0.000001
  125214. */
  125215. fallOff: number;
  125216. /**
  125217. * The base color of the SSAO post-process
  125218. * The final result is "base + ssao" between [0, 1]
  125219. */
  125220. base: number;
  125221. private _scene;
  125222. private _depthTexture;
  125223. private _randomTexture;
  125224. private _originalColorPostProcess;
  125225. private _ssaoPostProcess;
  125226. private _blurHPostProcess;
  125227. private _blurVPostProcess;
  125228. private _ssaoCombinePostProcess;
  125229. private _firstUpdate;
  125230. /**
  125231. * Gets active scene
  125232. */
  125233. readonly scene: Scene;
  125234. /**
  125235. * @constructor
  125236. * @param name - The rendering pipeline name
  125237. * @param scene - The scene linked to this pipeline
  125238. * @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 }
  125239. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125240. */
  125241. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125242. /**
  125243. * Get the class name
  125244. * @returns "SSAORenderingPipeline"
  125245. */
  125246. getClassName(): string;
  125247. /**
  125248. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125249. */
  125250. dispose(disableDepthRender?: boolean): void;
  125251. private _createBlurPostProcess;
  125252. /** @hidden */
  125253. _rebuild(): void;
  125254. private _createSSAOPostProcess;
  125255. private _createSSAOCombinePostProcess;
  125256. private _createRandomTexture;
  125257. }
  125258. }
  125259. declare module BABYLON {
  125260. /** @hidden */
  125261. export var standardPixelShader: {
  125262. name: string;
  125263. shader: string;
  125264. };
  125265. }
  125266. declare module BABYLON {
  125267. /**
  125268. * Standard rendering pipeline
  125269. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125270. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125271. */
  125272. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125273. /**
  125274. * Public members
  125275. */
  125276. /**
  125277. * Post-process which contains the original scene color before the pipeline applies all the effects
  125278. */
  125279. originalPostProcess: Nullable<PostProcess>;
  125280. /**
  125281. * Post-process used to down scale an image x4
  125282. */
  125283. downSampleX4PostProcess: Nullable<PostProcess>;
  125284. /**
  125285. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125286. */
  125287. brightPassPostProcess: Nullable<PostProcess>;
  125288. /**
  125289. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125290. */
  125291. blurHPostProcesses: PostProcess[];
  125292. /**
  125293. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125294. */
  125295. blurVPostProcesses: PostProcess[];
  125296. /**
  125297. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125298. */
  125299. textureAdderPostProcess: Nullable<PostProcess>;
  125300. /**
  125301. * Post-process used to create volumetric lighting effect
  125302. */
  125303. volumetricLightPostProcess: Nullable<PostProcess>;
  125304. /**
  125305. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125306. */
  125307. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125308. /**
  125309. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125310. */
  125311. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125312. /**
  125313. * Post-process used to merge the volumetric light effect and the real scene color
  125314. */
  125315. volumetricLightMergePostProces: Nullable<PostProcess>;
  125316. /**
  125317. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125318. */
  125319. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125320. /**
  125321. * Base post-process used to calculate the average luminance of the final image for HDR
  125322. */
  125323. luminancePostProcess: Nullable<PostProcess>;
  125324. /**
  125325. * Post-processes used to create down sample post-processes in order to get
  125326. * the average luminance of the final image for HDR
  125327. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125328. */
  125329. luminanceDownSamplePostProcesses: PostProcess[];
  125330. /**
  125331. * Post-process used to create a HDR effect (light adaptation)
  125332. */
  125333. hdrPostProcess: Nullable<PostProcess>;
  125334. /**
  125335. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125336. */
  125337. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125338. /**
  125339. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125340. */
  125341. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125342. /**
  125343. * Post-process used to merge the final HDR post-process and the real scene color
  125344. */
  125345. hdrFinalPostProcess: Nullable<PostProcess>;
  125346. /**
  125347. * Post-process used to create a lens flare effect
  125348. */
  125349. lensFlarePostProcess: Nullable<PostProcess>;
  125350. /**
  125351. * Post-process that merges the result of the lens flare post-process and the real scene color
  125352. */
  125353. lensFlareComposePostProcess: Nullable<PostProcess>;
  125354. /**
  125355. * Post-process used to create a motion blur effect
  125356. */
  125357. motionBlurPostProcess: Nullable<PostProcess>;
  125358. /**
  125359. * Post-process used to create a depth of field effect
  125360. */
  125361. depthOfFieldPostProcess: Nullable<PostProcess>;
  125362. /**
  125363. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125364. */
  125365. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125366. /**
  125367. * Represents the brightness threshold in order to configure the illuminated surfaces
  125368. */
  125369. brightThreshold: number;
  125370. /**
  125371. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125372. */
  125373. blurWidth: number;
  125374. /**
  125375. * Sets if the blur for highlighted surfaces must be only horizontal
  125376. */
  125377. horizontalBlur: boolean;
  125378. /**
  125379. * Gets the overall exposure used by the pipeline
  125380. */
  125381. /**
  125382. * Sets the overall exposure used by the pipeline
  125383. */
  125384. exposure: number;
  125385. /**
  125386. * Texture used typically to simulate "dirty" on camera lens
  125387. */
  125388. lensTexture: Nullable<Texture>;
  125389. /**
  125390. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125391. */
  125392. volumetricLightCoefficient: number;
  125393. /**
  125394. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125395. */
  125396. volumetricLightPower: number;
  125397. /**
  125398. * Used the set the blur intensity to smooth the volumetric lights
  125399. */
  125400. volumetricLightBlurScale: number;
  125401. /**
  125402. * Light (spot or directional) used to generate the volumetric lights rays
  125403. * The source light must have a shadow generate so the pipeline can get its
  125404. * depth map
  125405. */
  125406. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125407. /**
  125408. * For eye adaptation, represents the minimum luminance the eye can see
  125409. */
  125410. hdrMinimumLuminance: number;
  125411. /**
  125412. * For eye adaptation, represents the decrease luminance speed
  125413. */
  125414. hdrDecreaseRate: number;
  125415. /**
  125416. * For eye adaptation, represents the increase luminance speed
  125417. */
  125418. hdrIncreaseRate: number;
  125419. /**
  125420. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125421. */
  125422. /**
  125423. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125424. */
  125425. hdrAutoExposure: boolean;
  125426. /**
  125427. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125428. */
  125429. lensColorTexture: Nullable<Texture>;
  125430. /**
  125431. * The overall strengh for the lens flare effect
  125432. */
  125433. lensFlareStrength: number;
  125434. /**
  125435. * Dispersion coefficient for lens flare ghosts
  125436. */
  125437. lensFlareGhostDispersal: number;
  125438. /**
  125439. * Main lens flare halo width
  125440. */
  125441. lensFlareHaloWidth: number;
  125442. /**
  125443. * Based on the lens distortion effect, defines how much the lens flare result
  125444. * is distorted
  125445. */
  125446. lensFlareDistortionStrength: number;
  125447. /**
  125448. * Configures the blur intensity used for for lens flare (halo)
  125449. */
  125450. lensFlareBlurWidth: number;
  125451. /**
  125452. * Lens star texture must be used to simulate rays on the flares and is available
  125453. * in the documentation
  125454. */
  125455. lensStarTexture: Nullable<Texture>;
  125456. /**
  125457. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125458. * flare effect by taking account of the dirt texture
  125459. */
  125460. lensFlareDirtTexture: Nullable<Texture>;
  125461. /**
  125462. * Represents the focal length for the depth of field effect
  125463. */
  125464. depthOfFieldDistance: number;
  125465. /**
  125466. * Represents the blur intensity for the blurred part of the depth of field effect
  125467. */
  125468. depthOfFieldBlurWidth: number;
  125469. /**
  125470. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125471. */
  125472. /**
  125473. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125474. */
  125475. motionStrength: number;
  125476. /**
  125477. * Gets wether or not the motion blur post-process is object based or screen based.
  125478. */
  125479. /**
  125480. * Sets wether or not the motion blur post-process should be object based or screen based
  125481. */
  125482. objectBasedMotionBlur: boolean;
  125483. /**
  125484. * List of animations for the pipeline (IAnimatable implementation)
  125485. */
  125486. animations: Animation[];
  125487. /**
  125488. * Private members
  125489. */
  125490. private _scene;
  125491. private _currentDepthOfFieldSource;
  125492. private _basePostProcess;
  125493. private _fixedExposure;
  125494. private _currentExposure;
  125495. private _hdrAutoExposure;
  125496. private _hdrCurrentLuminance;
  125497. private _motionStrength;
  125498. private _isObjectBasedMotionBlur;
  125499. private _floatTextureType;
  125500. private _camerasToBeAttached;
  125501. private _ratio;
  125502. private _bloomEnabled;
  125503. private _depthOfFieldEnabled;
  125504. private _vlsEnabled;
  125505. private _lensFlareEnabled;
  125506. private _hdrEnabled;
  125507. private _motionBlurEnabled;
  125508. private _fxaaEnabled;
  125509. private _motionBlurSamples;
  125510. private _volumetricLightStepsCount;
  125511. private _samples;
  125512. /**
  125513. * @ignore
  125514. * Specifies if the bloom pipeline is enabled
  125515. */
  125516. BloomEnabled: boolean;
  125517. /**
  125518. * @ignore
  125519. * Specifies if the depth of field pipeline is enabed
  125520. */
  125521. DepthOfFieldEnabled: boolean;
  125522. /**
  125523. * @ignore
  125524. * Specifies if the lens flare pipeline is enabed
  125525. */
  125526. LensFlareEnabled: boolean;
  125527. /**
  125528. * @ignore
  125529. * Specifies if the HDR pipeline is enabled
  125530. */
  125531. HDREnabled: boolean;
  125532. /**
  125533. * @ignore
  125534. * Specifies if the volumetric lights scattering effect is enabled
  125535. */
  125536. VLSEnabled: boolean;
  125537. /**
  125538. * @ignore
  125539. * Specifies if the motion blur effect is enabled
  125540. */
  125541. MotionBlurEnabled: boolean;
  125542. /**
  125543. * Specifies if anti-aliasing is enabled
  125544. */
  125545. fxaaEnabled: boolean;
  125546. /**
  125547. * Specifies the number of steps used to calculate the volumetric lights
  125548. * Typically in interval [50, 200]
  125549. */
  125550. volumetricLightStepsCount: number;
  125551. /**
  125552. * Specifies the number of samples used for the motion blur effect
  125553. * Typically in interval [16, 64]
  125554. */
  125555. motionBlurSamples: number;
  125556. /**
  125557. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125558. */
  125559. samples: number;
  125560. /**
  125561. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125562. * @constructor
  125563. * @param name The rendering pipeline name
  125564. * @param scene The scene linked to this pipeline
  125565. * @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)
  125566. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125567. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125568. */
  125569. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125570. private _buildPipeline;
  125571. private _createDownSampleX4PostProcess;
  125572. private _createBrightPassPostProcess;
  125573. private _createBlurPostProcesses;
  125574. private _createTextureAdderPostProcess;
  125575. private _createVolumetricLightPostProcess;
  125576. private _createLuminancePostProcesses;
  125577. private _createHdrPostProcess;
  125578. private _createLensFlarePostProcess;
  125579. private _createDepthOfFieldPostProcess;
  125580. private _createMotionBlurPostProcess;
  125581. private _getDepthTexture;
  125582. private _disposePostProcesses;
  125583. /**
  125584. * Dispose of the pipeline and stop all post processes
  125585. */
  125586. dispose(): void;
  125587. /**
  125588. * Serialize the rendering pipeline (Used when exporting)
  125589. * @returns the serialized object
  125590. */
  125591. serialize(): any;
  125592. /**
  125593. * Parse the serialized pipeline
  125594. * @param source Source pipeline.
  125595. * @param scene The scene to load the pipeline to.
  125596. * @param rootUrl The URL of the serialized pipeline.
  125597. * @returns An instantiated pipeline from the serialized object.
  125598. */
  125599. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125600. /**
  125601. * Luminance steps
  125602. */
  125603. static LuminanceSteps: number;
  125604. }
  125605. }
  125606. declare module BABYLON {
  125607. /** @hidden */
  125608. export var tonemapPixelShader: {
  125609. name: string;
  125610. shader: string;
  125611. };
  125612. }
  125613. declare module BABYLON {
  125614. /** Defines operator used for tonemapping */
  125615. export enum TonemappingOperator {
  125616. /** Hable */
  125617. Hable = 0,
  125618. /** Reinhard */
  125619. Reinhard = 1,
  125620. /** HejiDawson */
  125621. HejiDawson = 2,
  125622. /** Photographic */
  125623. Photographic = 3
  125624. }
  125625. /**
  125626. * Defines a post process to apply tone mapping
  125627. */
  125628. export class TonemapPostProcess extends PostProcess {
  125629. private _operator;
  125630. /** Defines the required exposure adjustement */
  125631. exposureAdjustment: number;
  125632. /**
  125633. * Creates a new TonemapPostProcess
  125634. * @param name defines the name of the postprocess
  125635. * @param _operator defines the operator to use
  125636. * @param exposureAdjustment defines the required exposure adjustement
  125637. * @param camera defines the camera to use (can be null)
  125638. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125639. * @param engine defines the hosting engine (can be ignore if camera is set)
  125640. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125641. */
  125642. constructor(name: string, _operator: TonemappingOperator,
  125643. /** Defines the required exposure adjustement */
  125644. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  125645. }
  125646. }
  125647. declare module BABYLON {
  125648. /** @hidden */
  125649. export var depthVertexShader: {
  125650. name: string;
  125651. shader: string;
  125652. };
  125653. }
  125654. declare module BABYLON {
  125655. /** @hidden */
  125656. export var volumetricLightScatteringPixelShader: {
  125657. name: string;
  125658. shader: string;
  125659. };
  125660. }
  125661. declare module BABYLON {
  125662. /** @hidden */
  125663. export var volumetricLightScatteringPassVertexShader: {
  125664. name: string;
  125665. shader: string;
  125666. };
  125667. }
  125668. declare module BABYLON {
  125669. /** @hidden */
  125670. export var volumetricLightScatteringPassPixelShader: {
  125671. name: string;
  125672. shader: string;
  125673. };
  125674. }
  125675. declare module BABYLON {
  125676. /**
  125677. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  125678. */
  125679. export class VolumetricLightScatteringPostProcess extends PostProcess {
  125680. private _volumetricLightScatteringPass;
  125681. private _volumetricLightScatteringRTT;
  125682. private _viewPort;
  125683. private _screenCoordinates;
  125684. private _cachedDefines;
  125685. /**
  125686. * If not undefined, the mesh position is computed from the attached node position
  125687. */
  125688. attachedNode: {
  125689. position: Vector3;
  125690. };
  125691. /**
  125692. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  125693. */
  125694. customMeshPosition: Vector3;
  125695. /**
  125696. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  125697. */
  125698. useCustomMeshPosition: boolean;
  125699. /**
  125700. * If the post-process should inverse the light scattering direction
  125701. */
  125702. invert: boolean;
  125703. /**
  125704. * The internal mesh used by the post-process
  125705. */
  125706. mesh: Mesh;
  125707. /**
  125708. * @hidden
  125709. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  125710. */
  125711. useDiffuseColor: boolean;
  125712. /**
  125713. * Array containing the excluded meshes not rendered in the internal pass
  125714. */
  125715. excludedMeshes: AbstractMesh[];
  125716. /**
  125717. * Controls the overall intensity of the post-process
  125718. */
  125719. exposure: number;
  125720. /**
  125721. * Dissipates each sample's contribution in range [0, 1]
  125722. */
  125723. decay: number;
  125724. /**
  125725. * Controls the overall intensity of each sample
  125726. */
  125727. weight: number;
  125728. /**
  125729. * Controls the density of each sample
  125730. */
  125731. density: number;
  125732. /**
  125733. * @constructor
  125734. * @param name The post-process name
  125735. * @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)
  125736. * @param camera The camera that the post-process will be attached to
  125737. * @param mesh The mesh used to create the light scattering
  125738. * @param samples The post-process quality, default 100
  125739. * @param samplingModeThe post-process filtering mode
  125740. * @param engine The babylon engine
  125741. * @param reusable If the post-process is reusable
  125742. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  125743. */
  125744. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  125745. /**
  125746. * Returns the string "VolumetricLightScatteringPostProcess"
  125747. * @returns "VolumetricLightScatteringPostProcess"
  125748. */
  125749. getClassName(): string;
  125750. private _isReady;
  125751. /**
  125752. * Sets the new light position for light scattering effect
  125753. * @param position The new custom light position
  125754. */
  125755. setCustomMeshPosition(position: Vector3): void;
  125756. /**
  125757. * Returns the light position for light scattering effect
  125758. * @return Vector3 The custom light position
  125759. */
  125760. getCustomMeshPosition(): Vector3;
  125761. /**
  125762. * Disposes the internal assets and detaches the post-process from the camera
  125763. */
  125764. dispose(camera: Camera): void;
  125765. /**
  125766. * Returns the render target texture used by the post-process
  125767. * @return the render target texture used by the post-process
  125768. */
  125769. getPass(): RenderTargetTexture;
  125770. private _meshExcluded;
  125771. private _createPass;
  125772. private _updateMeshScreenCoordinates;
  125773. /**
  125774. * Creates a default mesh for the Volumeric Light Scattering post-process
  125775. * @param name The mesh name
  125776. * @param scene The scene where to create the mesh
  125777. * @return the default mesh
  125778. */
  125779. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  125780. }
  125781. }
  125782. declare module BABYLON {
  125783. interface Scene {
  125784. /** @hidden (Backing field) */
  125785. _boundingBoxRenderer: BoundingBoxRenderer;
  125786. /** @hidden (Backing field) */
  125787. _forceShowBoundingBoxes: boolean;
  125788. /**
  125789. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  125790. */
  125791. forceShowBoundingBoxes: boolean;
  125792. /**
  125793. * Gets the bounding box renderer associated with the scene
  125794. * @returns a BoundingBoxRenderer
  125795. */
  125796. getBoundingBoxRenderer(): BoundingBoxRenderer;
  125797. }
  125798. interface AbstractMesh {
  125799. /** @hidden (Backing field) */
  125800. _showBoundingBox: boolean;
  125801. /**
  125802. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  125803. */
  125804. showBoundingBox: boolean;
  125805. }
  125806. /**
  125807. * Component responsible of rendering the bounding box of the meshes in a scene.
  125808. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  125809. */
  125810. export class BoundingBoxRenderer implements ISceneComponent {
  125811. /**
  125812. * The component name helpfull to identify the component in the list of scene components.
  125813. */
  125814. readonly name: string;
  125815. /**
  125816. * The scene the component belongs to.
  125817. */
  125818. scene: Scene;
  125819. /**
  125820. * Color of the bounding box lines placed in front of an object
  125821. */
  125822. frontColor: Color3;
  125823. /**
  125824. * Color of the bounding box lines placed behind an object
  125825. */
  125826. backColor: Color3;
  125827. /**
  125828. * Defines if the renderer should show the back lines or not
  125829. */
  125830. showBackLines: boolean;
  125831. /**
  125832. * @hidden
  125833. */
  125834. renderList: SmartArray<BoundingBox>;
  125835. private _colorShader;
  125836. private _vertexBuffers;
  125837. private _indexBuffer;
  125838. private _fillIndexBuffer;
  125839. private _fillIndexData;
  125840. /**
  125841. * Instantiates a new bounding box renderer in a scene.
  125842. * @param scene the scene the renderer renders in
  125843. */
  125844. constructor(scene: Scene);
  125845. /**
  125846. * Registers the component in a given scene
  125847. */
  125848. register(): void;
  125849. private _evaluateSubMesh;
  125850. private _activeMesh;
  125851. private _prepareRessources;
  125852. private _createIndexBuffer;
  125853. /**
  125854. * Rebuilds the elements related to this component in case of
  125855. * context lost for instance.
  125856. */
  125857. rebuild(): void;
  125858. /**
  125859. * @hidden
  125860. */
  125861. reset(): void;
  125862. /**
  125863. * Render the bounding boxes of a specific rendering group
  125864. * @param renderingGroupId defines the rendering group to render
  125865. */
  125866. render(renderingGroupId: number): void;
  125867. /**
  125868. * In case of occlusion queries, we can render the occlusion bounding box through this method
  125869. * @param mesh Define the mesh to render the occlusion bounding box for
  125870. */
  125871. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  125872. /**
  125873. * Dispose and release the resources attached to this renderer.
  125874. */
  125875. dispose(): void;
  125876. }
  125877. }
  125878. declare module BABYLON {
  125879. /** @hidden */
  125880. export var depthPixelShader: {
  125881. name: string;
  125882. shader: string;
  125883. };
  125884. }
  125885. declare module BABYLON {
  125886. /**
  125887. * This represents a depth renderer in Babylon.
  125888. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  125889. */
  125890. export class DepthRenderer {
  125891. private _scene;
  125892. private _depthMap;
  125893. private _effect;
  125894. private readonly _storeNonLinearDepth;
  125895. private readonly _clearColor;
  125896. /** Get if the depth renderer is using packed depth or not */
  125897. readonly isPacked: boolean;
  125898. private _cachedDefines;
  125899. private _camera;
  125900. /**
  125901. * Specifiess that the depth renderer will only be used within
  125902. * the camera it is created for.
  125903. * This can help forcing its rendering during the camera processing.
  125904. */
  125905. useOnlyInActiveCamera: boolean;
  125906. /** @hidden */
  125907. static _SceneComponentInitialization: (scene: Scene) => void;
  125908. /**
  125909. * Instantiates a depth renderer
  125910. * @param scene The scene the renderer belongs to
  125911. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  125912. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  125913. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  125914. */
  125915. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  125916. /**
  125917. * Creates the depth rendering effect and checks if the effect is ready.
  125918. * @param subMesh The submesh to be used to render the depth map of
  125919. * @param useInstances If multiple world instances should be used
  125920. * @returns if the depth renderer is ready to render the depth map
  125921. */
  125922. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125923. /**
  125924. * Gets the texture which the depth map will be written to.
  125925. * @returns The depth map texture
  125926. */
  125927. getDepthMap(): RenderTargetTexture;
  125928. /**
  125929. * Disposes of the depth renderer.
  125930. */
  125931. dispose(): void;
  125932. }
  125933. }
  125934. declare module BABYLON {
  125935. interface Scene {
  125936. /** @hidden (Backing field) */
  125937. _depthRenderer: {
  125938. [id: string]: DepthRenderer;
  125939. };
  125940. /**
  125941. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  125942. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  125943. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  125944. * @returns the created depth renderer
  125945. */
  125946. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  125947. /**
  125948. * Disables a depth renderer for a given camera
  125949. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  125950. */
  125951. disableDepthRenderer(camera?: Nullable<Camera>): void;
  125952. }
  125953. /**
  125954. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  125955. * in several rendering techniques.
  125956. */
  125957. export class DepthRendererSceneComponent implements ISceneComponent {
  125958. /**
  125959. * The component name helpfull to identify the component in the list of scene components.
  125960. */
  125961. readonly name: string;
  125962. /**
  125963. * The scene the component belongs to.
  125964. */
  125965. scene: Scene;
  125966. /**
  125967. * Creates a new instance of the component for the given scene
  125968. * @param scene Defines the scene to register the component in
  125969. */
  125970. constructor(scene: Scene);
  125971. /**
  125972. * Registers the component in a given scene
  125973. */
  125974. register(): void;
  125975. /**
  125976. * Rebuilds the elements related to this component in case of
  125977. * context lost for instance.
  125978. */
  125979. rebuild(): void;
  125980. /**
  125981. * Disposes the component and the associated ressources
  125982. */
  125983. dispose(): void;
  125984. private _gatherRenderTargets;
  125985. private _gatherActiveCameraRenderTargets;
  125986. }
  125987. }
  125988. declare module BABYLON {
  125989. /** @hidden */
  125990. export var outlinePixelShader: {
  125991. name: string;
  125992. shader: string;
  125993. };
  125994. }
  125995. declare module BABYLON {
  125996. /** @hidden */
  125997. export var outlineVertexShader: {
  125998. name: string;
  125999. shader: string;
  126000. };
  126001. }
  126002. declare module BABYLON {
  126003. interface Scene {
  126004. /** @hidden */
  126005. _outlineRenderer: OutlineRenderer;
  126006. /**
  126007. * Gets the outline renderer associated with the scene
  126008. * @returns a OutlineRenderer
  126009. */
  126010. getOutlineRenderer(): OutlineRenderer;
  126011. }
  126012. interface AbstractMesh {
  126013. /** @hidden (Backing field) */
  126014. _renderOutline: boolean;
  126015. /**
  126016. * Gets or sets a boolean indicating if the outline must be rendered as well
  126017. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126018. */
  126019. renderOutline: boolean;
  126020. /** @hidden (Backing field) */
  126021. _renderOverlay: boolean;
  126022. /**
  126023. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126024. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126025. */
  126026. renderOverlay: boolean;
  126027. }
  126028. /**
  126029. * This class is responsible to draw bothe outline/overlay of meshes.
  126030. * It should not be used directly but through the available method on mesh.
  126031. */
  126032. export class OutlineRenderer implements ISceneComponent {
  126033. /**
  126034. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126035. */
  126036. private static _StencilReference;
  126037. /**
  126038. * The name of the component. Each component must have a unique name.
  126039. */
  126040. name: string;
  126041. /**
  126042. * The scene the component belongs to.
  126043. */
  126044. scene: Scene;
  126045. /**
  126046. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126047. */
  126048. zOffset: number;
  126049. private _engine;
  126050. private _effect;
  126051. private _cachedDefines;
  126052. private _savedDepthWrite;
  126053. /**
  126054. * Instantiates a new outline renderer. (There could be only one per scene).
  126055. * @param scene Defines the scene it belongs to
  126056. */
  126057. constructor(scene: Scene);
  126058. /**
  126059. * Register the component to one instance of a scene.
  126060. */
  126061. register(): void;
  126062. /**
  126063. * Rebuilds the elements related to this component in case of
  126064. * context lost for instance.
  126065. */
  126066. rebuild(): void;
  126067. /**
  126068. * Disposes the component and the associated ressources.
  126069. */
  126070. dispose(): void;
  126071. /**
  126072. * Renders the outline in the canvas.
  126073. * @param subMesh Defines the sumesh to render
  126074. * @param batch Defines the batch of meshes in case of instances
  126075. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126076. */
  126077. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126078. /**
  126079. * Returns whether or not the outline renderer is ready for a given submesh.
  126080. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126081. * @param subMesh Defines the submesh to check readyness for
  126082. * @param useInstances Defines wheter wee are trying to render instances or not
  126083. * @returns true if ready otherwise false
  126084. */
  126085. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126086. private _beforeRenderingMesh;
  126087. private _afterRenderingMesh;
  126088. }
  126089. }
  126090. declare module BABYLON {
  126091. /**
  126092. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126093. * @see http://doc.babylonjs.com/babylon101/sprites
  126094. */
  126095. export class SpritePackedManager extends SpriteManager {
  126096. /** defines the packed manager's name */
  126097. name: string;
  126098. /**
  126099. * Creates a new sprite manager from a packed sprite sheet
  126100. * @param name defines the manager's name
  126101. * @param imgUrl defines the sprite sheet url
  126102. * @param capacity defines the maximum allowed number of sprites
  126103. * @param scene defines the hosting scene
  126104. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126105. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126106. * @param samplingMode defines the smapling mode to use with spritesheet
  126107. * @param fromPacked set to true; do not alter
  126108. */
  126109. constructor(
  126110. /** defines the packed manager's name */
  126111. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126112. }
  126113. }
  126114. declare module BABYLON {
  126115. /**
  126116. * Defines the list of states available for a task inside a AssetsManager
  126117. */
  126118. export enum AssetTaskState {
  126119. /**
  126120. * Initialization
  126121. */
  126122. INIT = 0,
  126123. /**
  126124. * Running
  126125. */
  126126. RUNNING = 1,
  126127. /**
  126128. * Done
  126129. */
  126130. DONE = 2,
  126131. /**
  126132. * Error
  126133. */
  126134. ERROR = 3
  126135. }
  126136. /**
  126137. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126138. */
  126139. export abstract class AbstractAssetTask {
  126140. /**
  126141. * Task name
  126142. */ name: string;
  126143. /**
  126144. * Callback called when the task is successful
  126145. */
  126146. onSuccess: (task: any) => void;
  126147. /**
  126148. * Callback called when the task is not successful
  126149. */
  126150. onError: (task: any, message?: string, exception?: any) => void;
  126151. /**
  126152. * Creates a new AssetsManager
  126153. * @param name defines the name of the task
  126154. */
  126155. constructor(
  126156. /**
  126157. * Task name
  126158. */ name: string);
  126159. private _isCompleted;
  126160. private _taskState;
  126161. private _errorObject;
  126162. /**
  126163. * Get if the task is completed
  126164. */
  126165. readonly isCompleted: boolean;
  126166. /**
  126167. * Gets the current state of the task
  126168. */
  126169. readonly taskState: AssetTaskState;
  126170. /**
  126171. * Gets the current error object (if task is in error)
  126172. */
  126173. readonly errorObject: {
  126174. message?: string;
  126175. exception?: any;
  126176. };
  126177. /**
  126178. * Internal only
  126179. * @hidden
  126180. */
  126181. _setErrorObject(message?: string, exception?: any): void;
  126182. /**
  126183. * Execute the current task
  126184. * @param scene defines the scene where you want your assets to be loaded
  126185. * @param onSuccess is a callback called when the task is successfully executed
  126186. * @param onError is a callback called if an error occurs
  126187. */
  126188. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126189. /**
  126190. * Execute the current task
  126191. * @param scene defines the scene where you want your assets to be loaded
  126192. * @param onSuccess is a callback called when the task is successfully executed
  126193. * @param onError is a callback called if an error occurs
  126194. */
  126195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126196. /**
  126197. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126198. * This can be used with failed tasks that have the reason for failure fixed.
  126199. */
  126200. reset(): void;
  126201. private onErrorCallback;
  126202. private onDoneCallback;
  126203. }
  126204. /**
  126205. * Define the interface used by progress events raised during assets loading
  126206. */
  126207. export interface IAssetsProgressEvent {
  126208. /**
  126209. * Defines the number of remaining tasks to process
  126210. */
  126211. remainingCount: number;
  126212. /**
  126213. * Defines the total number of tasks
  126214. */
  126215. totalCount: number;
  126216. /**
  126217. * Defines the task that was just processed
  126218. */
  126219. task: AbstractAssetTask;
  126220. }
  126221. /**
  126222. * Class used to share progress information about assets loading
  126223. */
  126224. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126225. /**
  126226. * Defines the number of remaining tasks to process
  126227. */
  126228. remainingCount: number;
  126229. /**
  126230. * Defines the total number of tasks
  126231. */
  126232. totalCount: number;
  126233. /**
  126234. * Defines the task that was just processed
  126235. */
  126236. task: AbstractAssetTask;
  126237. /**
  126238. * Creates a AssetsProgressEvent
  126239. * @param remainingCount defines the number of remaining tasks to process
  126240. * @param totalCount defines the total number of tasks
  126241. * @param task defines the task that was just processed
  126242. */
  126243. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126244. }
  126245. /**
  126246. * Define a task used by AssetsManager to load meshes
  126247. */
  126248. export class MeshAssetTask extends AbstractAssetTask {
  126249. /**
  126250. * Defines the name of the task
  126251. */
  126252. name: string;
  126253. /**
  126254. * Defines the list of mesh's names you want to load
  126255. */
  126256. meshesNames: any;
  126257. /**
  126258. * Defines the root url to use as a base to load your meshes and associated resources
  126259. */
  126260. rootUrl: string;
  126261. /**
  126262. * Defines the filename of the scene to load from
  126263. */
  126264. sceneFilename: string;
  126265. /**
  126266. * Gets the list of loaded meshes
  126267. */
  126268. loadedMeshes: Array<AbstractMesh>;
  126269. /**
  126270. * Gets the list of loaded particle systems
  126271. */
  126272. loadedParticleSystems: Array<IParticleSystem>;
  126273. /**
  126274. * Gets the list of loaded skeletons
  126275. */
  126276. loadedSkeletons: Array<Skeleton>;
  126277. /**
  126278. * Gets the list of loaded animation groups
  126279. */
  126280. loadedAnimationGroups: Array<AnimationGroup>;
  126281. /**
  126282. * Callback called when the task is successful
  126283. */
  126284. onSuccess: (task: MeshAssetTask) => void;
  126285. /**
  126286. * Callback called when the task is successful
  126287. */
  126288. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126289. /**
  126290. * Creates a new MeshAssetTask
  126291. * @param name defines the name of the task
  126292. * @param meshesNames defines the list of mesh's names you want to load
  126293. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126294. * @param sceneFilename defines the filename of the scene to load from
  126295. */
  126296. constructor(
  126297. /**
  126298. * Defines the name of the task
  126299. */
  126300. name: string,
  126301. /**
  126302. * Defines the list of mesh's names you want to load
  126303. */
  126304. meshesNames: any,
  126305. /**
  126306. * Defines the root url to use as a base to load your meshes and associated resources
  126307. */
  126308. rootUrl: string,
  126309. /**
  126310. * Defines the filename of the scene to load from
  126311. */
  126312. sceneFilename: string);
  126313. /**
  126314. * Execute the current task
  126315. * @param scene defines the scene where you want your assets to be loaded
  126316. * @param onSuccess is a callback called when the task is successfully executed
  126317. * @param onError is a callback called if an error occurs
  126318. */
  126319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126320. }
  126321. /**
  126322. * Define a task used by AssetsManager to load text content
  126323. */
  126324. export class TextFileAssetTask extends AbstractAssetTask {
  126325. /**
  126326. * Defines the name of the task
  126327. */
  126328. name: string;
  126329. /**
  126330. * Defines the location of the file to load
  126331. */
  126332. url: string;
  126333. /**
  126334. * Gets the loaded text string
  126335. */
  126336. text: string;
  126337. /**
  126338. * Callback called when the task is successful
  126339. */
  126340. onSuccess: (task: TextFileAssetTask) => void;
  126341. /**
  126342. * Callback called when the task is successful
  126343. */
  126344. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126345. /**
  126346. * Creates a new TextFileAssetTask object
  126347. * @param name defines the name of the task
  126348. * @param url defines the location of the file to load
  126349. */
  126350. constructor(
  126351. /**
  126352. * Defines the name of the task
  126353. */
  126354. name: string,
  126355. /**
  126356. * Defines the location of the file to load
  126357. */
  126358. url: string);
  126359. /**
  126360. * Execute the current task
  126361. * @param scene defines the scene where you want your assets to be loaded
  126362. * @param onSuccess is a callback called when the task is successfully executed
  126363. * @param onError is a callback called if an error occurs
  126364. */
  126365. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126366. }
  126367. /**
  126368. * Define a task used by AssetsManager to load binary data
  126369. */
  126370. export class BinaryFileAssetTask extends AbstractAssetTask {
  126371. /**
  126372. * Defines the name of the task
  126373. */
  126374. name: string;
  126375. /**
  126376. * Defines the location of the file to load
  126377. */
  126378. url: string;
  126379. /**
  126380. * Gets the lodaded data (as an array buffer)
  126381. */
  126382. data: ArrayBuffer;
  126383. /**
  126384. * Callback called when the task is successful
  126385. */
  126386. onSuccess: (task: BinaryFileAssetTask) => void;
  126387. /**
  126388. * Callback called when the task is successful
  126389. */
  126390. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126391. /**
  126392. * Creates a new BinaryFileAssetTask object
  126393. * @param name defines the name of the new task
  126394. * @param url defines the location of the file to load
  126395. */
  126396. constructor(
  126397. /**
  126398. * Defines the name of the task
  126399. */
  126400. name: string,
  126401. /**
  126402. * Defines the location of the file to load
  126403. */
  126404. url: string);
  126405. /**
  126406. * Execute the current task
  126407. * @param scene defines the scene where you want your assets to be loaded
  126408. * @param onSuccess is a callback called when the task is successfully executed
  126409. * @param onError is a callback called if an error occurs
  126410. */
  126411. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126412. }
  126413. /**
  126414. * Define a task used by AssetsManager to load images
  126415. */
  126416. export class ImageAssetTask extends AbstractAssetTask {
  126417. /**
  126418. * Defines the name of the task
  126419. */
  126420. name: string;
  126421. /**
  126422. * Defines the location of the image to load
  126423. */
  126424. url: string;
  126425. /**
  126426. * Gets the loaded images
  126427. */
  126428. image: HTMLImageElement;
  126429. /**
  126430. * Callback called when the task is successful
  126431. */
  126432. onSuccess: (task: ImageAssetTask) => void;
  126433. /**
  126434. * Callback called when the task is successful
  126435. */
  126436. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126437. /**
  126438. * Creates a new ImageAssetTask
  126439. * @param name defines the name of the task
  126440. * @param url defines the location of the image to load
  126441. */
  126442. constructor(
  126443. /**
  126444. * Defines the name of the task
  126445. */
  126446. name: string,
  126447. /**
  126448. * Defines the location of the image to load
  126449. */
  126450. url: string);
  126451. /**
  126452. * Execute the current task
  126453. * @param scene defines the scene where you want your assets to be loaded
  126454. * @param onSuccess is a callback called when the task is successfully executed
  126455. * @param onError is a callback called if an error occurs
  126456. */
  126457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126458. }
  126459. /**
  126460. * Defines the interface used by texture loading tasks
  126461. */
  126462. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126463. /**
  126464. * Gets the loaded texture
  126465. */
  126466. texture: TEX;
  126467. }
  126468. /**
  126469. * Define a task used by AssetsManager to load 2D textures
  126470. */
  126471. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126472. /**
  126473. * Defines the name of the task
  126474. */
  126475. name: string;
  126476. /**
  126477. * Defines the location of the file to load
  126478. */
  126479. url: string;
  126480. /**
  126481. * Defines if mipmap should not be generated (default is false)
  126482. */
  126483. noMipmap?: boolean | undefined;
  126484. /**
  126485. * Defines if texture must be inverted on Y axis (default is false)
  126486. */
  126487. invertY?: boolean | undefined;
  126488. /**
  126489. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126490. */
  126491. samplingMode: number;
  126492. /**
  126493. * Gets the loaded texture
  126494. */
  126495. texture: Texture;
  126496. /**
  126497. * Callback called when the task is successful
  126498. */
  126499. onSuccess: (task: TextureAssetTask) => void;
  126500. /**
  126501. * Callback called when the task is successful
  126502. */
  126503. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126504. /**
  126505. * Creates a new TextureAssetTask object
  126506. * @param name defines the name of the task
  126507. * @param url defines the location of the file to load
  126508. * @param noMipmap defines if mipmap should not be generated (default is false)
  126509. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126510. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126511. */
  126512. constructor(
  126513. /**
  126514. * Defines the name of the task
  126515. */
  126516. name: string,
  126517. /**
  126518. * Defines the location of the file to load
  126519. */
  126520. url: string,
  126521. /**
  126522. * Defines if mipmap should not be generated (default is false)
  126523. */
  126524. noMipmap?: boolean | undefined,
  126525. /**
  126526. * Defines if texture must be inverted on Y axis (default is false)
  126527. */
  126528. invertY?: boolean | undefined,
  126529. /**
  126530. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126531. */
  126532. samplingMode?: number);
  126533. /**
  126534. * Execute the current task
  126535. * @param scene defines the scene where you want your assets to be loaded
  126536. * @param onSuccess is a callback called when the task is successfully executed
  126537. * @param onError is a callback called if an error occurs
  126538. */
  126539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126540. }
  126541. /**
  126542. * Define a task used by AssetsManager to load cube textures
  126543. */
  126544. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126545. /**
  126546. * Defines the name of the task
  126547. */
  126548. name: string;
  126549. /**
  126550. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126551. */
  126552. url: string;
  126553. /**
  126554. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126555. */
  126556. extensions?: string[] | undefined;
  126557. /**
  126558. * Defines if mipmaps should not be generated (default is false)
  126559. */
  126560. noMipmap?: boolean | undefined;
  126561. /**
  126562. * Defines the explicit list of files (undefined by default)
  126563. */
  126564. files?: string[] | undefined;
  126565. /**
  126566. * Gets the loaded texture
  126567. */
  126568. texture: CubeTexture;
  126569. /**
  126570. * Callback called when the task is successful
  126571. */
  126572. onSuccess: (task: CubeTextureAssetTask) => void;
  126573. /**
  126574. * Callback called when the task is successful
  126575. */
  126576. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126577. /**
  126578. * Creates a new CubeTextureAssetTask
  126579. * @param name defines the name of the task
  126580. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126581. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126582. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126583. * @param files defines the explicit list of files (undefined by default)
  126584. */
  126585. constructor(
  126586. /**
  126587. * Defines the name of the task
  126588. */
  126589. name: string,
  126590. /**
  126591. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126592. */
  126593. url: string,
  126594. /**
  126595. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126596. */
  126597. extensions?: string[] | undefined,
  126598. /**
  126599. * Defines if mipmaps should not be generated (default is false)
  126600. */
  126601. noMipmap?: boolean | undefined,
  126602. /**
  126603. * Defines the explicit list of files (undefined by default)
  126604. */
  126605. files?: string[] | undefined);
  126606. /**
  126607. * Execute the current task
  126608. * @param scene defines the scene where you want your assets to be loaded
  126609. * @param onSuccess is a callback called when the task is successfully executed
  126610. * @param onError is a callback called if an error occurs
  126611. */
  126612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126613. }
  126614. /**
  126615. * Define a task used by AssetsManager to load HDR cube textures
  126616. */
  126617. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126618. /**
  126619. * Defines the name of the task
  126620. */
  126621. name: string;
  126622. /**
  126623. * Defines the location of the file to load
  126624. */
  126625. url: string;
  126626. /**
  126627. * Defines the desired size (the more it increases the longer the generation will be)
  126628. */
  126629. size: number;
  126630. /**
  126631. * Defines if mipmaps should not be generated (default is false)
  126632. */
  126633. noMipmap: boolean;
  126634. /**
  126635. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126636. */
  126637. generateHarmonics: boolean;
  126638. /**
  126639. * 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)
  126640. */
  126641. gammaSpace: boolean;
  126642. /**
  126643. * Internal Use Only
  126644. */
  126645. reserved: boolean;
  126646. /**
  126647. * Gets the loaded texture
  126648. */
  126649. texture: HDRCubeTexture;
  126650. /**
  126651. * Callback called when the task is successful
  126652. */
  126653. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  126654. /**
  126655. * Callback called when the task is successful
  126656. */
  126657. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  126658. /**
  126659. * Creates a new HDRCubeTextureAssetTask object
  126660. * @param name defines the name of the task
  126661. * @param url defines the location of the file to load
  126662. * @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.
  126663. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126664. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126665. * @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)
  126666. * @param reserved Internal use only
  126667. */
  126668. constructor(
  126669. /**
  126670. * Defines the name of the task
  126671. */
  126672. name: string,
  126673. /**
  126674. * Defines the location of the file to load
  126675. */
  126676. url: string,
  126677. /**
  126678. * Defines the desired size (the more it increases the longer the generation will be)
  126679. */
  126680. size: number,
  126681. /**
  126682. * Defines if mipmaps should not be generated (default is false)
  126683. */
  126684. noMipmap?: boolean,
  126685. /**
  126686. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126687. */
  126688. generateHarmonics?: boolean,
  126689. /**
  126690. * 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)
  126691. */
  126692. gammaSpace?: boolean,
  126693. /**
  126694. * Internal Use Only
  126695. */
  126696. reserved?: boolean);
  126697. /**
  126698. * Execute the current task
  126699. * @param scene defines the scene where you want your assets to be loaded
  126700. * @param onSuccess is a callback called when the task is successfully executed
  126701. * @param onError is a callback called if an error occurs
  126702. */
  126703. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126704. }
  126705. /**
  126706. * Define a task used by AssetsManager to load Equirectangular cube textures
  126707. */
  126708. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  126709. /**
  126710. * Defines the name of the task
  126711. */
  126712. name: string;
  126713. /**
  126714. * Defines the location of the file to load
  126715. */
  126716. url: string;
  126717. /**
  126718. * Defines the desired size (the more it increases the longer the generation will be)
  126719. */
  126720. size: number;
  126721. /**
  126722. * Defines if mipmaps should not be generated (default is false)
  126723. */
  126724. noMipmap: boolean;
  126725. /**
  126726. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  126727. * but the standard material would require them in Gamma space) (default is true)
  126728. */
  126729. gammaSpace: boolean;
  126730. /**
  126731. * Gets the loaded texture
  126732. */
  126733. texture: EquiRectangularCubeTexture;
  126734. /**
  126735. * Callback called when the task is successful
  126736. */
  126737. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  126738. /**
  126739. * Callback called when the task is successful
  126740. */
  126741. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  126742. /**
  126743. * Creates a new EquiRectangularCubeTextureAssetTask object
  126744. * @param name defines the name of the task
  126745. * @param url defines the location of the file to load
  126746. * @param size defines the desired size (the more it increases the longer the generation will be)
  126747. * If the size is omitted this implies you are using a preprocessed cubemap.
  126748. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126749. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  126750. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  126751. * (default is true)
  126752. */
  126753. constructor(
  126754. /**
  126755. * Defines the name of the task
  126756. */
  126757. name: string,
  126758. /**
  126759. * Defines the location of the file to load
  126760. */
  126761. url: string,
  126762. /**
  126763. * Defines the desired size (the more it increases the longer the generation will be)
  126764. */
  126765. size: number,
  126766. /**
  126767. * Defines if mipmaps should not be generated (default is false)
  126768. */
  126769. noMipmap?: boolean,
  126770. /**
  126771. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  126772. * but the standard material would require them in Gamma space) (default is true)
  126773. */
  126774. gammaSpace?: boolean);
  126775. /**
  126776. * Execute the current task
  126777. * @param scene defines the scene where you want your assets to be loaded
  126778. * @param onSuccess is a callback called when the task is successfully executed
  126779. * @param onError is a callback called if an error occurs
  126780. */
  126781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126782. }
  126783. /**
  126784. * This class can be used to easily import assets into a scene
  126785. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  126786. */
  126787. export class AssetsManager {
  126788. private _scene;
  126789. private _isLoading;
  126790. protected _tasks: AbstractAssetTask[];
  126791. protected _waitingTasksCount: number;
  126792. protected _totalTasksCount: number;
  126793. /**
  126794. * Callback called when all tasks are processed
  126795. */
  126796. onFinish: (tasks: AbstractAssetTask[]) => void;
  126797. /**
  126798. * Callback called when a task is successful
  126799. */
  126800. onTaskSuccess: (task: AbstractAssetTask) => void;
  126801. /**
  126802. * Callback called when a task had an error
  126803. */
  126804. onTaskError: (task: AbstractAssetTask) => void;
  126805. /**
  126806. * Callback called when a task is done (whatever the result is)
  126807. */
  126808. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  126809. /**
  126810. * Observable called when all tasks are processed
  126811. */
  126812. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  126813. /**
  126814. * Observable called when a task had an error
  126815. */
  126816. onTaskErrorObservable: Observable<AbstractAssetTask>;
  126817. /**
  126818. * Observable called when all tasks were executed
  126819. */
  126820. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  126821. /**
  126822. * Observable called when a task is done (whatever the result is)
  126823. */
  126824. onProgressObservable: Observable<IAssetsProgressEvent>;
  126825. /**
  126826. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  126827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  126828. */
  126829. useDefaultLoadingScreen: boolean;
  126830. /**
  126831. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  126832. * when all assets have been downloaded.
  126833. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  126834. */
  126835. autoHideLoadingUI: boolean;
  126836. /**
  126837. * Creates a new AssetsManager
  126838. * @param scene defines the scene to work on
  126839. */
  126840. constructor(scene: Scene);
  126841. /**
  126842. * Add a MeshAssetTask to the list of active tasks
  126843. * @param taskName defines the name of the new task
  126844. * @param meshesNames defines the name of meshes to load
  126845. * @param rootUrl defines the root url to use to locate files
  126846. * @param sceneFilename defines the filename of the scene file
  126847. * @returns a new MeshAssetTask object
  126848. */
  126849. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  126850. /**
  126851. * Add a TextFileAssetTask to the list of active tasks
  126852. * @param taskName defines the name of the new task
  126853. * @param url defines the url of the file to load
  126854. * @returns a new TextFileAssetTask object
  126855. */
  126856. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  126857. /**
  126858. * Add a BinaryFileAssetTask to the list of active tasks
  126859. * @param taskName defines the name of the new task
  126860. * @param url defines the url of the file to load
  126861. * @returns a new BinaryFileAssetTask object
  126862. */
  126863. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  126864. /**
  126865. * Add a ImageAssetTask to the list of active tasks
  126866. * @param taskName defines the name of the new task
  126867. * @param url defines the url of the file to load
  126868. * @returns a new ImageAssetTask object
  126869. */
  126870. addImageTask(taskName: string, url: string): ImageAssetTask;
  126871. /**
  126872. * Add a TextureAssetTask to the list of active tasks
  126873. * @param taskName defines the name of the new task
  126874. * @param url defines the url of the file to load
  126875. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126876. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  126877. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  126878. * @returns a new TextureAssetTask object
  126879. */
  126880. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  126881. /**
  126882. * Add a CubeTextureAssetTask to the list of active tasks
  126883. * @param taskName defines the name of the new task
  126884. * @param url defines the url of the file to load
  126885. * @param extensions defines the extension to use to load the cube map (can be null)
  126886. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126887. * @param files defines the list of files to load (can be null)
  126888. * @returns a new CubeTextureAssetTask object
  126889. */
  126890. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  126891. /**
  126892. *
  126893. * Add a HDRCubeTextureAssetTask to the list of active tasks
  126894. * @param taskName defines the name of the new task
  126895. * @param url defines the url of the file to load
  126896. * @param size defines the size you want for the cubemap (can be null)
  126897. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126898. * @param generateHarmonics defines if you want to automatically generate (true by default)
  126899. * @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)
  126900. * @param reserved Internal use only
  126901. * @returns a new HDRCubeTextureAssetTask object
  126902. */
  126903. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  126904. /**
  126905. *
  126906. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  126907. * @param taskName defines the name of the new task
  126908. * @param url defines the url of the file to load
  126909. * @param size defines the size you want for the cubemap (can be null)
  126910. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  126911. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  126912. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  126913. * @returns a new EquiRectangularCubeTextureAssetTask object
  126914. */
  126915. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  126916. /**
  126917. * Remove a task from the assets manager.
  126918. * @param task the task to remove
  126919. */
  126920. removeTask(task: AbstractAssetTask): void;
  126921. private _decreaseWaitingTasksCount;
  126922. private _runTask;
  126923. /**
  126924. * Reset the AssetsManager and remove all tasks
  126925. * @return the current instance of the AssetsManager
  126926. */
  126927. reset(): AssetsManager;
  126928. /**
  126929. * Start the loading process
  126930. * @return the current instance of the AssetsManager
  126931. */
  126932. load(): AssetsManager;
  126933. /**
  126934. * Start the loading process as an async operation
  126935. * @return a promise returning the list of failed tasks
  126936. */
  126937. loadAsync(): Promise<void>;
  126938. }
  126939. }
  126940. declare module BABYLON {
  126941. /**
  126942. * Wrapper class for promise with external resolve and reject.
  126943. */
  126944. export class Deferred<T> {
  126945. /**
  126946. * The promise associated with this deferred object.
  126947. */
  126948. readonly promise: Promise<T>;
  126949. private _resolve;
  126950. private _reject;
  126951. /**
  126952. * The resolve method of the promise associated with this deferred object.
  126953. */
  126954. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  126955. /**
  126956. * The reject method of the promise associated with this deferred object.
  126957. */
  126958. readonly reject: (reason?: any) => void;
  126959. /**
  126960. * Constructor for this deferred object.
  126961. */
  126962. constructor();
  126963. }
  126964. }
  126965. declare module BABYLON {
  126966. /**
  126967. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  126968. */
  126969. export class MeshExploder {
  126970. private _centerMesh;
  126971. private _meshes;
  126972. private _meshesOrigins;
  126973. private _toCenterVectors;
  126974. private _scaledDirection;
  126975. private _newPosition;
  126976. private _centerPosition;
  126977. /**
  126978. * Explodes meshes from a center mesh.
  126979. * @param meshes The meshes to explode.
  126980. * @param centerMesh The mesh to be center of explosion.
  126981. */
  126982. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  126983. private _setCenterMesh;
  126984. /**
  126985. * Get class name
  126986. * @returns "MeshExploder"
  126987. */
  126988. getClassName(): string;
  126989. /**
  126990. * "Exploded meshes"
  126991. * @returns Array of meshes with the centerMesh at index 0.
  126992. */
  126993. getMeshes(): Array<Mesh>;
  126994. /**
  126995. * Explodes meshes giving a specific direction
  126996. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  126997. */
  126998. explode(direction?: number): void;
  126999. }
  127000. }
  127001. declare module BABYLON {
  127002. /**
  127003. * Class used to help managing file picking and drag'n'drop
  127004. */
  127005. export class FilesInput {
  127006. /**
  127007. * List of files ready to be loaded
  127008. */
  127009. static readonly FilesToLoad: {
  127010. [key: string]: File;
  127011. };
  127012. /**
  127013. * Callback called when a file is processed
  127014. */
  127015. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127016. private _engine;
  127017. private _currentScene;
  127018. private _sceneLoadedCallback;
  127019. private _progressCallback;
  127020. private _additionalRenderLoopLogicCallback;
  127021. private _textureLoadingCallback;
  127022. private _startingProcessingFilesCallback;
  127023. private _onReloadCallback;
  127024. private _errorCallback;
  127025. private _elementToMonitor;
  127026. private _sceneFileToLoad;
  127027. private _filesToLoad;
  127028. /**
  127029. * Creates a new FilesInput
  127030. * @param engine defines the rendering engine
  127031. * @param scene defines the hosting scene
  127032. * @param sceneLoadedCallback callback called when scene is loaded
  127033. * @param progressCallback callback called to track progress
  127034. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127035. * @param textureLoadingCallback callback called when a texture is loading
  127036. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127037. * @param onReloadCallback callback called when a reload is requested
  127038. * @param errorCallback callback call if an error occurs
  127039. */
  127040. 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);
  127041. private _dragEnterHandler;
  127042. private _dragOverHandler;
  127043. private _dropHandler;
  127044. /**
  127045. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127046. * @param elementToMonitor defines the DOM element to track
  127047. */
  127048. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127049. /**
  127050. * Release all associated resources
  127051. */
  127052. dispose(): void;
  127053. private renderFunction;
  127054. private drag;
  127055. private drop;
  127056. private _traverseFolder;
  127057. private _processFiles;
  127058. /**
  127059. * Load files from a drop event
  127060. * @param event defines the drop event to use as source
  127061. */
  127062. loadFiles(event: any): void;
  127063. private _processReload;
  127064. /**
  127065. * Reload the current scene from the loaded files
  127066. */
  127067. reload(): void;
  127068. }
  127069. }
  127070. declare module BABYLON {
  127071. /**
  127072. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127074. */
  127075. export class SceneOptimization {
  127076. /**
  127077. * Defines the priority of this optimization (0 by default which means first in the list)
  127078. */
  127079. priority: number;
  127080. /**
  127081. * Gets a string describing the action executed by the current optimization
  127082. * @returns description string
  127083. */
  127084. getDescription(): string;
  127085. /**
  127086. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127087. * @param scene defines the current scene where to apply this optimization
  127088. * @param optimizer defines the current optimizer
  127089. * @returns true if everything that can be done was applied
  127090. */
  127091. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127092. /**
  127093. * Creates the SceneOptimization object
  127094. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127095. * @param desc defines the description associated with the optimization
  127096. */
  127097. constructor(
  127098. /**
  127099. * Defines the priority of this optimization (0 by default which means first in the list)
  127100. */
  127101. priority?: number);
  127102. }
  127103. /**
  127104. * Defines an optimization used to reduce the size of render target textures
  127105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127106. */
  127107. export class TextureOptimization extends SceneOptimization {
  127108. /**
  127109. * Defines the priority of this optimization (0 by default which means first in the list)
  127110. */
  127111. priority: number;
  127112. /**
  127113. * 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
  127114. */
  127115. maximumSize: number;
  127116. /**
  127117. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127118. */
  127119. step: number;
  127120. /**
  127121. * Gets a string describing the action executed by the current optimization
  127122. * @returns description string
  127123. */
  127124. getDescription(): string;
  127125. /**
  127126. * Creates the TextureOptimization object
  127127. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127128. * @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
  127129. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127130. */
  127131. constructor(
  127132. /**
  127133. * Defines the priority of this optimization (0 by default which means first in the list)
  127134. */
  127135. priority?: number,
  127136. /**
  127137. * 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
  127138. */
  127139. maximumSize?: number,
  127140. /**
  127141. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127142. */
  127143. step?: number);
  127144. /**
  127145. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127146. * @param scene defines the current scene where to apply this optimization
  127147. * @param optimizer defines the current optimizer
  127148. * @returns true if everything that can be done was applied
  127149. */
  127150. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127151. }
  127152. /**
  127153. * Defines an optimization used to increase or decrease the rendering resolution
  127154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127155. */
  127156. export class HardwareScalingOptimization extends SceneOptimization {
  127157. /**
  127158. * Defines the priority of this optimization (0 by default which means first in the list)
  127159. */
  127160. priority: number;
  127161. /**
  127162. * Defines the maximum scale to use (2 by default)
  127163. */
  127164. maximumScale: number;
  127165. /**
  127166. * Defines the step to use between two passes (0.5 by default)
  127167. */
  127168. step: number;
  127169. private _currentScale;
  127170. private _directionOffset;
  127171. /**
  127172. * Gets a string describing the action executed by the current optimization
  127173. * @return description string
  127174. */
  127175. getDescription(): string;
  127176. /**
  127177. * Creates the HardwareScalingOptimization object
  127178. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127179. * @param maximumScale defines the maximum scale to use (2 by default)
  127180. * @param step defines the step to use between two passes (0.5 by default)
  127181. */
  127182. constructor(
  127183. /**
  127184. * Defines the priority of this optimization (0 by default which means first in the list)
  127185. */
  127186. priority?: number,
  127187. /**
  127188. * Defines the maximum scale to use (2 by default)
  127189. */
  127190. maximumScale?: number,
  127191. /**
  127192. * Defines the step to use between two passes (0.5 by default)
  127193. */
  127194. step?: number);
  127195. /**
  127196. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127197. * @param scene defines the current scene where to apply this optimization
  127198. * @param optimizer defines the current optimizer
  127199. * @returns true if everything that can be done was applied
  127200. */
  127201. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127202. }
  127203. /**
  127204. * Defines an optimization used to remove shadows
  127205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127206. */
  127207. export class ShadowsOptimization extends SceneOptimization {
  127208. /**
  127209. * Gets a string describing the action executed by the current optimization
  127210. * @return description string
  127211. */
  127212. getDescription(): string;
  127213. /**
  127214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127215. * @param scene defines the current scene where to apply this optimization
  127216. * @param optimizer defines the current optimizer
  127217. * @returns true if everything that can be done was applied
  127218. */
  127219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127220. }
  127221. /**
  127222. * Defines an optimization used to turn post-processes off
  127223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127224. */
  127225. export class PostProcessesOptimization extends SceneOptimization {
  127226. /**
  127227. * Gets a string describing the action executed by the current optimization
  127228. * @return description string
  127229. */
  127230. getDescription(): string;
  127231. /**
  127232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127233. * @param scene defines the current scene where to apply this optimization
  127234. * @param optimizer defines the current optimizer
  127235. * @returns true if everything that can be done was applied
  127236. */
  127237. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127238. }
  127239. /**
  127240. * Defines an optimization used to turn lens flares off
  127241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127242. */
  127243. export class LensFlaresOptimization extends SceneOptimization {
  127244. /**
  127245. * Gets a string describing the action executed by the current optimization
  127246. * @return description string
  127247. */
  127248. getDescription(): string;
  127249. /**
  127250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127251. * @param scene defines the current scene where to apply this optimization
  127252. * @param optimizer defines the current optimizer
  127253. * @returns true if everything that can be done was applied
  127254. */
  127255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127256. }
  127257. /**
  127258. * Defines an optimization based on user defined callback.
  127259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127260. */
  127261. export class CustomOptimization extends SceneOptimization {
  127262. /**
  127263. * Callback called to apply the custom optimization.
  127264. */
  127265. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127266. /**
  127267. * Callback called to get custom description
  127268. */
  127269. onGetDescription: () => string;
  127270. /**
  127271. * Gets a string describing the action executed by the current optimization
  127272. * @returns description string
  127273. */
  127274. getDescription(): string;
  127275. /**
  127276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127277. * @param scene defines the current scene where to apply this optimization
  127278. * @param optimizer defines the current optimizer
  127279. * @returns true if everything that can be done was applied
  127280. */
  127281. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127282. }
  127283. /**
  127284. * Defines an optimization used to turn particles off
  127285. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127286. */
  127287. export class ParticlesOptimization extends SceneOptimization {
  127288. /**
  127289. * Gets a string describing the action executed by the current optimization
  127290. * @return description string
  127291. */
  127292. getDescription(): string;
  127293. /**
  127294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127295. * @param scene defines the current scene where to apply this optimization
  127296. * @param optimizer defines the current optimizer
  127297. * @returns true if everything that can be done was applied
  127298. */
  127299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127300. }
  127301. /**
  127302. * Defines an optimization used to turn render targets off
  127303. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127304. */
  127305. export class RenderTargetsOptimization extends SceneOptimization {
  127306. /**
  127307. * Gets a string describing the action executed by the current optimization
  127308. * @return description string
  127309. */
  127310. getDescription(): string;
  127311. /**
  127312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127313. * @param scene defines the current scene where to apply this optimization
  127314. * @param optimizer defines the current optimizer
  127315. * @returns true if everything that can be done was applied
  127316. */
  127317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127318. }
  127319. /**
  127320. * Defines an optimization used to merge meshes with compatible materials
  127321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127322. */
  127323. export class MergeMeshesOptimization extends SceneOptimization {
  127324. private static _UpdateSelectionTree;
  127325. /**
  127326. * Gets or sets a boolean which defines if optimization octree has to be updated
  127327. */
  127328. /**
  127329. * Gets or sets a boolean which defines if optimization octree has to be updated
  127330. */
  127331. static UpdateSelectionTree: boolean;
  127332. /**
  127333. * Gets a string describing the action executed by the current optimization
  127334. * @return description string
  127335. */
  127336. getDescription(): string;
  127337. private _canBeMerged;
  127338. /**
  127339. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127340. * @param scene defines the current scene where to apply this optimization
  127341. * @param optimizer defines the current optimizer
  127342. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127343. * @returns true if everything that can be done was applied
  127344. */
  127345. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127346. }
  127347. /**
  127348. * Defines a list of options used by SceneOptimizer
  127349. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127350. */
  127351. export class SceneOptimizerOptions {
  127352. /**
  127353. * Defines the target frame rate to reach (60 by default)
  127354. */
  127355. targetFrameRate: number;
  127356. /**
  127357. * Defines the interval between two checkes (2000ms by default)
  127358. */
  127359. trackerDuration: number;
  127360. /**
  127361. * Gets the list of optimizations to apply
  127362. */
  127363. optimizations: SceneOptimization[];
  127364. /**
  127365. * Creates a new list of options used by SceneOptimizer
  127366. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127367. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127368. */
  127369. constructor(
  127370. /**
  127371. * Defines the target frame rate to reach (60 by default)
  127372. */
  127373. targetFrameRate?: number,
  127374. /**
  127375. * Defines the interval between two checkes (2000ms by default)
  127376. */
  127377. trackerDuration?: number);
  127378. /**
  127379. * Add a new optimization
  127380. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127381. * @returns the current SceneOptimizerOptions
  127382. */
  127383. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127384. /**
  127385. * Add a new custom optimization
  127386. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127387. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127388. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127389. * @returns the current SceneOptimizerOptions
  127390. */
  127391. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127392. /**
  127393. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127394. * @param targetFrameRate defines the target frame rate (60 by default)
  127395. * @returns a SceneOptimizerOptions object
  127396. */
  127397. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127398. /**
  127399. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127400. * @param targetFrameRate defines the target frame rate (60 by default)
  127401. * @returns a SceneOptimizerOptions object
  127402. */
  127403. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127404. /**
  127405. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127406. * @param targetFrameRate defines the target frame rate (60 by default)
  127407. * @returns a SceneOptimizerOptions object
  127408. */
  127409. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127410. }
  127411. /**
  127412. * Class used to run optimizations in order to reach a target frame rate
  127413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127414. */
  127415. export class SceneOptimizer implements IDisposable {
  127416. private _isRunning;
  127417. private _options;
  127418. private _scene;
  127419. private _currentPriorityLevel;
  127420. private _targetFrameRate;
  127421. private _trackerDuration;
  127422. private _currentFrameRate;
  127423. private _sceneDisposeObserver;
  127424. private _improvementMode;
  127425. /**
  127426. * Defines an observable called when the optimizer reaches the target frame rate
  127427. */
  127428. onSuccessObservable: Observable<SceneOptimizer>;
  127429. /**
  127430. * Defines an observable called when the optimizer enables an optimization
  127431. */
  127432. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127433. /**
  127434. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127435. */
  127436. onFailureObservable: Observable<SceneOptimizer>;
  127437. /**
  127438. * Gets a boolean indicating if the optimizer is in improvement mode
  127439. */
  127440. readonly isInImprovementMode: boolean;
  127441. /**
  127442. * Gets the current priority level (0 at start)
  127443. */
  127444. readonly currentPriorityLevel: number;
  127445. /**
  127446. * Gets the current frame rate checked by the SceneOptimizer
  127447. */
  127448. readonly currentFrameRate: number;
  127449. /**
  127450. * Gets or sets the current target frame rate (60 by default)
  127451. */
  127452. /**
  127453. * Gets or sets the current target frame rate (60 by default)
  127454. */
  127455. targetFrameRate: number;
  127456. /**
  127457. * Gets or sets the current interval between two checks (every 2000ms by default)
  127458. */
  127459. /**
  127460. * Gets or sets the current interval between two checks (every 2000ms by default)
  127461. */
  127462. trackerDuration: number;
  127463. /**
  127464. * Gets the list of active optimizations
  127465. */
  127466. readonly optimizations: SceneOptimization[];
  127467. /**
  127468. * Creates a new SceneOptimizer
  127469. * @param scene defines the scene to work on
  127470. * @param options defines the options to use with the SceneOptimizer
  127471. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127472. * @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)
  127473. */
  127474. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127475. /**
  127476. * Stops the current optimizer
  127477. */
  127478. stop(): void;
  127479. /**
  127480. * Reset the optimizer to initial step (current priority level = 0)
  127481. */
  127482. reset(): void;
  127483. /**
  127484. * Start the optimizer. By default it will try to reach a specific framerate
  127485. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127486. */
  127487. start(): void;
  127488. private _checkCurrentState;
  127489. /**
  127490. * Release all resources
  127491. */
  127492. dispose(): void;
  127493. /**
  127494. * Helper function to create a SceneOptimizer with one single line of code
  127495. * @param scene defines the scene to work on
  127496. * @param options defines the options to use with the SceneOptimizer
  127497. * @param onSuccess defines a callback to call on success
  127498. * @param onFailure defines a callback to call on failure
  127499. * @returns the new SceneOptimizer object
  127500. */
  127501. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127502. }
  127503. }
  127504. declare module BABYLON {
  127505. /**
  127506. * Class used to serialize a scene into a string
  127507. */
  127508. export class SceneSerializer {
  127509. /**
  127510. * Clear cache used by a previous serialization
  127511. */
  127512. static ClearCache(): void;
  127513. /**
  127514. * Serialize a scene into a JSON compatible object
  127515. * @param scene defines the scene to serialize
  127516. * @returns a JSON compatible object
  127517. */
  127518. static Serialize(scene: Scene): any;
  127519. /**
  127520. * Serialize a mesh into a JSON compatible object
  127521. * @param toSerialize defines the mesh to serialize
  127522. * @param withParents defines if parents must be serialized as well
  127523. * @param withChildren defines if children must be serialized as well
  127524. * @returns a JSON compatible object
  127525. */
  127526. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127527. }
  127528. }
  127529. declare module BABYLON {
  127530. /**
  127531. * Class used to host texture specific utilities
  127532. */
  127533. export class TextureTools {
  127534. /**
  127535. * Uses the GPU to create a copy texture rescaled at a given size
  127536. * @param texture Texture to copy from
  127537. * @param width defines the desired width
  127538. * @param height defines the desired height
  127539. * @param useBilinearMode defines if bilinear mode has to be used
  127540. * @return the generated texture
  127541. */
  127542. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127543. }
  127544. }
  127545. declare module BABYLON {
  127546. /**
  127547. * This represents the different options available for the video capture.
  127548. */
  127549. export interface VideoRecorderOptions {
  127550. /** Defines the mime type of the video. */
  127551. mimeType: string;
  127552. /** Defines the FPS the video should be recorded at. */
  127553. fps: number;
  127554. /** Defines the chunk size for the recording data. */
  127555. recordChunckSize: number;
  127556. /** The audio tracks to attach to the recording. */
  127557. audioTracks?: MediaStreamTrack[];
  127558. }
  127559. /**
  127560. * This can help with recording videos from BabylonJS.
  127561. * This is based on the available WebRTC functionalities of the browser.
  127562. *
  127563. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127564. */
  127565. export class VideoRecorder {
  127566. private static readonly _defaultOptions;
  127567. /**
  127568. * Returns whether or not the VideoRecorder is available in your browser.
  127569. * @param engine Defines the Babylon Engine.
  127570. * @returns true if supported otherwise false.
  127571. */
  127572. static IsSupported(engine: Engine): boolean;
  127573. private readonly _options;
  127574. private _canvas;
  127575. private _mediaRecorder;
  127576. private _recordedChunks;
  127577. private _fileName;
  127578. private _resolve;
  127579. private _reject;
  127580. /**
  127581. * True when a recording is already in progress.
  127582. */
  127583. readonly isRecording: boolean;
  127584. /**
  127585. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127586. * @param engine Defines the BabylonJS Engine you wish to record.
  127587. * @param options Defines options that can be used to customize the capture.
  127588. */
  127589. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127590. /**
  127591. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127592. */
  127593. stopRecording(): void;
  127594. /**
  127595. * Starts recording the canvas for a max duration specified in parameters.
  127596. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127597. * If null no automatic download will start and you can rely on the promise to get the data back.
  127598. * @param maxDuration Defines the maximum recording time in seconds.
  127599. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127600. * @return A promise callback at the end of the recording with the video data in Blob.
  127601. */
  127602. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127603. /**
  127604. * Releases internal resources used during the recording.
  127605. */
  127606. dispose(): void;
  127607. private _handleDataAvailable;
  127608. private _handleError;
  127609. private _handleStop;
  127610. }
  127611. }
  127612. declare module BABYLON {
  127613. /**
  127614. * Class containing a set of static utilities functions for screenshots
  127615. */
  127616. export class ScreenshotTools {
  127617. /**
  127618. * Captures a screenshot of the current rendering
  127619. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127620. * @param engine defines the rendering engine
  127621. * @param camera defines the source camera
  127622. * @param size This parameter can be set to a single number or to an object with the
  127623. * following (optional) properties: precision, width, height. If a single number is passed,
  127624. * it will be used for both width and height. If an object is passed, the screenshot size
  127625. * will be derived from the parameters. The precision property is a multiplier allowing
  127626. * rendering at a higher or lower resolution
  127627. * @param successCallback defines the callback receives a single parameter which contains the
  127628. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127629. * src parameter of an <img> to display it
  127630. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127631. * Check your browser for supported MIME types
  127632. */
  127633. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127634. /**
  127635. * Captures a screenshot of the current rendering
  127636. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127637. * @param engine defines the rendering engine
  127638. * @param camera defines the source camera
  127639. * @param size This parameter can be set to a single number or to an object with the
  127640. * following (optional) properties: precision, width, height. If a single number is passed,
  127641. * it will be used for both width and height. If an object is passed, the screenshot size
  127642. * will be derived from the parameters. The precision property is a multiplier allowing
  127643. * rendering at a higher or lower resolution
  127644. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127645. * Check your browser for supported MIME types
  127646. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127647. * to the src parameter of an <img> to display it
  127648. */
  127649. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  127650. /**
  127651. * Generates an image screenshot from the specified camera.
  127652. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127653. * @param engine The engine to use for rendering
  127654. * @param camera The camera to use for rendering
  127655. * @param size This parameter can be set to a single number or to an object with the
  127656. * following (optional) properties: precision, width, height. If a single number is passed,
  127657. * it will be used for both width and height. If an object is passed, the screenshot size
  127658. * will be derived from the parameters. The precision property is a multiplier allowing
  127659. * rendering at a higher or lower resolution
  127660. * @param successCallback The callback receives a single parameter which contains the
  127661. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127662. * src parameter of an <img> to display it
  127663. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127664. * Check your browser for supported MIME types
  127665. * @param samples Texture samples (default: 1)
  127666. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127667. * @param fileName A name for for the downloaded file.
  127668. */
  127669. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  127670. /**
  127671. * Generates an image screenshot from the specified camera.
  127672. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127673. * @param engine The engine to use for rendering
  127674. * @param camera The camera to use for rendering
  127675. * @param size This parameter can be set to a single number or to an object with the
  127676. * following (optional) properties: precision, width, height. If a single number is passed,
  127677. * it will be used for both width and height. If an object is passed, the screenshot size
  127678. * will be derived from the parameters. The precision property is a multiplier allowing
  127679. * rendering at a higher or lower resolution
  127680. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127681. * Check your browser for supported MIME types
  127682. * @param samples Texture samples (default: 1)
  127683. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  127684. * @param fileName A name for for the downloaded file.
  127685. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127686. * to the src parameter of an <img> to display it
  127687. */
  127688. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  127689. /**
  127690. * Gets height and width for screenshot size
  127691. * @private
  127692. */
  127693. private static _getScreenshotSize;
  127694. }
  127695. }
  127696. declare module BABYLON {
  127697. /**
  127698. * A cursor which tracks a point on a path
  127699. */
  127700. export class PathCursor {
  127701. private path;
  127702. /**
  127703. * Stores path cursor callbacks for when an onchange event is triggered
  127704. */
  127705. private _onchange;
  127706. /**
  127707. * The value of the path cursor
  127708. */
  127709. value: number;
  127710. /**
  127711. * The animation array of the path cursor
  127712. */
  127713. animations: Animation[];
  127714. /**
  127715. * Initializes the path cursor
  127716. * @param path The path to track
  127717. */
  127718. constructor(path: Path2);
  127719. /**
  127720. * Gets the cursor point on the path
  127721. * @returns A point on the path cursor at the cursor location
  127722. */
  127723. getPoint(): Vector3;
  127724. /**
  127725. * Moves the cursor ahead by the step amount
  127726. * @param step The amount to move the cursor forward
  127727. * @returns This path cursor
  127728. */
  127729. moveAhead(step?: number): PathCursor;
  127730. /**
  127731. * Moves the cursor behind by the step amount
  127732. * @param step The amount to move the cursor back
  127733. * @returns This path cursor
  127734. */
  127735. moveBack(step?: number): PathCursor;
  127736. /**
  127737. * Moves the cursor by the step amount
  127738. * If the step amount is greater than one, an exception is thrown
  127739. * @param step The amount to move the cursor
  127740. * @returns This path cursor
  127741. */
  127742. move(step: number): PathCursor;
  127743. /**
  127744. * Ensures that the value is limited between zero and one
  127745. * @returns This path cursor
  127746. */
  127747. private ensureLimits;
  127748. /**
  127749. * Runs onchange callbacks on change (used by the animation engine)
  127750. * @returns This path cursor
  127751. */
  127752. private raiseOnChange;
  127753. /**
  127754. * Executes a function on change
  127755. * @param f A path cursor onchange callback
  127756. * @returns This path cursor
  127757. */
  127758. onchange(f: (cursor: PathCursor) => void): PathCursor;
  127759. }
  127760. }
  127761. declare module BABYLON {
  127762. /** @hidden */
  127763. export var blurPixelShader: {
  127764. name: string;
  127765. shader: string;
  127766. };
  127767. }
  127768. declare module BABYLON {
  127769. /** @hidden */
  127770. export var pointCloudVertexDeclaration: {
  127771. name: string;
  127772. shader: string;
  127773. };
  127774. }
  127775. // Mixins
  127776. interface Window {
  127777. mozIndexedDB: IDBFactory;
  127778. webkitIndexedDB: IDBFactory;
  127779. msIndexedDB: IDBFactory;
  127780. webkitURL: typeof URL;
  127781. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  127782. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  127783. WebGLRenderingContext: WebGLRenderingContext;
  127784. MSGesture: MSGesture;
  127785. CANNON: any;
  127786. AudioContext: AudioContext;
  127787. webkitAudioContext: AudioContext;
  127788. PointerEvent: any;
  127789. Math: Math;
  127790. Uint8Array: Uint8ArrayConstructor;
  127791. Float32Array: Float32ArrayConstructor;
  127792. mozURL: typeof URL;
  127793. msURL: typeof URL;
  127794. VRFrameData: any; // WebVR, from specs 1.1
  127795. DracoDecoderModule: any;
  127796. setImmediate(handler: (...args: any[]) => void): number;
  127797. }
  127798. interface HTMLCanvasElement {
  127799. requestPointerLock(): void;
  127800. msRequestPointerLock?(): void;
  127801. mozRequestPointerLock?(): void;
  127802. webkitRequestPointerLock?(): void;
  127803. /** Track wether a record is in progress */
  127804. isRecording: boolean;
  127805. /** Capture Stream method defined by some browsers */
  127806. captureStream(fps?: number): MediaStream;
  127807. }
  127808. interface CanvasRenderingContext2D {
  127809. msImageSmoothingEnabled: boolean;
  127810. }
  127811. interface MouseEvent {
  127812. mozMovementX: number;
  127813. mozMovementY: number;
  127814. webkitMovementX: number;
  127815. webkitMovementY: number;
  127816. msMovementX: number;
  127817. msMovementY: number;
  127818. }
  127819. interface Navigator {
  127820. mozGetVRDevices: (any: any) => any;
  127821. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127822. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127823. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  127824. webkitGetGamepads(): Gamepad[];
  127825. msGetGamepads(): Gamepad[];
  127826. webkitGamepads(): Gamepad[];
  127827. }
  127828. interface HTMLVideoElement {
  127829. mozSrcObject: any;
  127830. }
  127831. interface Math {
  127832. fround(x: number): number;
  127833. imul(a: number, b: number): number;
  127834. }
  127835. interface WebGLRenderingContext {
  127836. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  127837. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  127838. vertexAttribDivisor(index: number, divisor: number): void;
  127839. createVertexArray(): any;
  127840. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  127841. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  127842. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  127843. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  127844. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  127845. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  127846. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  127847. // Queries
  127848. createQuery(): WebGLQuery;
  127849. deleteQuery(query: WebGLQuery): void;
  127850. beginQuery(target: number, query: WebGLQuery): void;
  127851. endQuery(target: number): void;
  127852. getQueryParameter(query: WebGLQuery, pname: number): any;
  127853. getQuery(target: number, pname: number): any;
  127854. MAX_SAMPLES: number;
  127855. RGBA8: number;
  127856. READ_FRAMEBUFFER: number;
  127857. DRAW_FRAMEBUFFER: number;
  127858. UNIFORM_BUFFER: number;
  127859. HALF_FLOAT_OES: number;
  127860. RGBA16F: number;
  127861. RGBA32F: number;
  127862. R32F: number;
  127863. RG32F: number;
  127864. RGB32F: number;
  127865. R16F: number;
  127866. RG16F: number;
  127867. RGB16F: number;
  127868. RED: number;
  127869. RG: number;
  127870. R8: number;
  127871. RG8: number;
  127872. UNSIGNED_INT_24_8: number;
  127873. DEPTH24_STENCIL8: number;
  127874. /* Multiple Render Targets */
  127875. drawBuffers(buffers: number[]): void;
  127876. readBuffer(src: number): void;
  127877. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  127878. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  127879. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  127880. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  127881. // Occlusion Query
  127882. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  127883. ANY_SAMPLES_PASSED: number;
  127884. QUERY_RESULT_AVAILABLE: number;
  127885. QUERY_RESULT: number;
  127886. }
  127887. interface WebGLProgram {
  127888. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  127889. }
  127890. interface EXT_disjoint_timer_query {
  127891. QUERY_COUNTER_BITS_EXT: number;
  127892. TIME_ELAPSED_EXT: number;
  127893. TIMESTAMP_EXT: number;
  127894. GPU_DISJOINT_EXT: number;
  127895. QUERY_RESULT_EXT: number;
  127896. QUERY_RESULT_AVAILABLE_EXT: number;
  127897. queryCounterEXT(query: WebGLQuery, target: number): void;
  127898. createQueryEXT(): WebGLQuery;
  127899. beginQueryEXT(target: number, query: WebGLQuery): void;
  127900. endQueryEXT(target: number): void;
  127901. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  127902. deleteQueryEXT(query: WebGLQuery): void;
  127903. }
  127904. interface WebGLUniformLocation {
  127905. _currentState: any;
  127906. }
  127907. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  127908. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  127909. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  127910. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  127911. interface WebGLRenderingContext {
  127912. readonly RASTERIZER_DISCARD: number;
  127913. readonly DEPTH_COMPONENT24: number;
  127914. readonly TEXTURE_3D: number;
  127915. readonly TEXTURE_2D_ARRAY: number;
  127916. readonly TEXTURE_COMPARE_FUNC: number;
  127917. readonly TEXTURE_COMPARE_MODE: number;
  127918. readonly COMPARE_REF_TO_TEXTURE: number;
  127919. readonly TEXTURE_WRAP_R: number;
  127920. readonly HALF_FLOAT: number;
  127921. readonly RGB8: number;
  127922. readonly RED_INTEGER: number;
  127923. readonly RG_INTEGER: number;
  127924. readonly RGB_INTEGER: number;
  127925. readonly RGBA_INTEGER: number;
  127926. readonly R8_SNORM: number;
  127927. readonly RG8_SNORM: number;
  127928. readonly RGB8_SNORM: number;
  127929. readonly RGBA8_SNORM: number;
  127930. readonly R8I: number;
  127931. readonly RG8I: number;
  127932. readonly RGB8I: number;
  127933. readonly RGBA8I: number;
  127934. readonly R8UI: number;
  127935. readonly RG8UI: number;
  127936. readonly RGB8UI: number;
  127937. readonly RGBA8UI: number;
  127938. readonly R16I: number;
  127939. readonly RG16I: number;
  127940. readonly RGB16I: number;
  127941. readonly RGBA16I: number;
  127942. readonly R16UI: number;
  127943. readonly RG16UI: number;
  127944. readonly RGB16UI: number;
  127945. readonly RGBA16UI: number;
  127946. readonly R32I: number;
  127947. readonly RG32I: number;
  127948. readonly RGB32I: number;
  127949. readonly RGBA32I: number;
  127950. readonly R32UI: number;
  127951. readonly RG32UI: number;
  127952. readonly RGB32UI: number;
  127953. readonly RGBA32UI: number;
  127954. readonly RGB10_A2UI: number;
  127955. readonly R11F_G11F_B10F: number;
  127956. readonly RGB9_E5: number;
  127957. readonly RGB10_A2: number;
  127958. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  127959. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  127960. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  127961. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  127962. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  127963. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  127964. 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;
  127965. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  127966. readonly TRANSFORM_FEEDBACK: number;
  127967. readonly INTERLEAVED_ATTRIBS: number;
  127968. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  127969. createTransformFeedback(): WebGLTransformFeedback;
  127970. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  127971. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  127972. beginTransformFeedback(primitiveMode: number): void;
  127973. endTransformFeedback(): void;
  127974. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  127975. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127976. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127977. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  127978. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  127979. }
  127980. interface ImageBitmap {
  127981. readonly width: number;
  127982. readonly height: number;
  127983. close(): void;
  127984. }
  127985. interface WebGLQuery extends WebGLObject {
  127986. }
  127987. declare var WebGLQuery: {
  127988. prototype: WebGLQuery;
  127989. new(): WebGLQuery;
  127990. };
  127991. interface WebGLSampler extends WebGLObject {
  127992. }
  127993. declare var WebGLSampler: {
  127994. prototype: WebGLSampler;
  127995. new(): WebGLSampler;
  127996. };
  127997. interface WebGLSync extends WebGLObject {
  127998. }
  127999. declare var WebGLSync: {
  128000. prototype: WebGLSync;
  128001. new(): WebGLSync;
  128002. };
  128003. interface WebGLTransformFeedback extends WebGLObject {
  128004. }
  128005. declare var WebGLTransformFeedback: {
  128006. prototype: WebGLTransformFeedback;
  128007. new(): WebGLTransformFeedback;
  128008. };
  128009. interface WebGLVertexArrayObject extends WebGLObject {
  128010. }
  128011. declare var WebGLVertexArrayObject: {
  128012. prototype: WebGLVertexArrayObject;
  128013. new(): WebGLVertexArrayObject;
  128014. };
  128015. // Type definitions for WebVR API
  128016. // Project: https://w3c.github.io/webvr/
  128017. // Definitions by: six a <https://github.com/lostfictions>
  128018. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128019. interface VRDisplay extends EventTarget {
  128020. /**
  128021. * Dictionary of capabilities describing the VRDisplay.
  128022. */
  128023. readonly capabilities: VRDisplayCapabilities;
  128024. /**
  128025. * z-depth defining the far plane of the eye view frustum
  128026. * enables mapping of values in the render target depth
  128027. * attachment to scene coordinates. Initially set to 10000.0.
  128028. */
  128029. depthFar: number;
  128030. /**
  128031. * z-depth defining the near plane of the eye view frustum
  128032. * enables mapping of values in the render target depth
  128033. * attachment to scene coordinates. Initially set to 0.01.
  128034. */
  128035. depthNear: number;
  128036. /**
  128037. * An identifier for this distinct VRDisplay. Used as an
  128038. * association point in the Gamepad API.
  128039. */
  128040. readonly displayId: number;
  128041. /**
  128042. * A display name, a user-readable name identifying it.
  128043. */
  128044. readonly displayName: string;
  128045. readonly isConnected: boolean;
  128046. readonly isPresenting: boolean;
  128047. /**
  128048. * If this VRDisplay supports room-scale experiences, the optional
  128049. * stage attribute contains details on the room-scale parameters.
  128050. */
  128051. readonly stageParameters: VRStageParameters | null;
  128052. /**
  128053. * Passing the value returned by `requestAnimationFrame` to
  128054. * `cancelAnimationFrame` will unregister the callback.
  128055. * @param handle Define the hanle of the request to cancel
  128056. */
  128057. cancelAnimationFrame(handle: number): void;
  128058. /**
  128059. * Stops presenting to the VRDisplay.
  128060. * @returns a promise to know when it stopped
  128061. */
  128062. exitPresent(): Promise<void>;
  128063. /**
  128064. * Return the current VREyeParameters for the given eye.
  128065. * @param whichEye Define the eye we want the parameter for
  128066. * @returns the eye parameters
  128067. */
  128068. getEyeParameters(whichEye: string): VREyeParameters;
  128069. /**
  128070. * Populates the passed VRFrameData with the information required to render
  128071. * the current frame.
  128072. * @param frameData Define the data structure to populate
  128073. * @returns true if ok otherwise false
  128074. */
  128075. getFrameData(frameData: VRFrameData): boolean;
  128076. /**
  128077. * Get the layers currently being presented.
  128078. * @returns the list of VR layers
  128079. */
  128080. getLayers(): VRLayer[];
  128081. /**
  128082. * Return a VRPose containing the future predicted pose of the VRDisplay
  128083. * when the current frame will be presented. The value returned will not
  128084. * change until JavaScript has returned control to the browser.
  128085. *
  128086. * The VRPose will contain the position, orientation, velocity,
  128087. * and acceleration of each of these properties.
  128088. * @returns the pose object
  128089. */
  128090. getPose(): VRPose;
  128091. /**
  128092. * Return the current instantaneous pose of the VRDisplay, with no
  128093. * prediction applied.
  128094. * @returns the current instantaneous pose
  128095. */
  128096. getImmediatePose(): VRPose;
  128097. /**
  128098. * The callback passed to `requestAnimationFrame` will be called
  128099. * any time a new frame should be rendered. When the VRDisplay is
  128100. * presenting the callback will be called at the native refresh
  128101. * rate of the HMD. When not presenting this function acts
  128102. * identically to how window.requestAnimationFrame acts. Content should
  128103. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128104. * asynchronously from other displays and at differing refresh rates.
  128105. * @param callback Define the eaction to run next frame
  128106. * @returns the request handle it
  128107. */
  128108. requestAnimationFrame(callback: FrameRequestCallback): number;
  128109. /**
  128110. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128111. * Repeat calls while already presenting will update the VRLayers being displayed.
  128112. * @param layers Define the list of layer to present
  128113. * @returns a promise to know when the request has been fulfilled
  128114. */
  128115. requestPresent(layers: VRLayer[]): Promise<void>;
  128116. /**
  128117. * Reset the pose for this display, treating its current position and
  128118. * orientation as the "origin/zero" values. VRPose.position,
  128119. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128120. * updated when calling resetPose(). This should be called in only
  128121. * sitting-space experiences.
  128122. */
  128123. resetPose(): void;
  128124. /**
  128125. * The VRLayer provided to the VRDisplay will be captured and presented
  128126. * in the HMD. Calling this function has the same effect on the source
  128127. * canvas as any other operation that uses its source image, and canvases
  128128. * created without preserveDrawingBuffer set to true will be cleared.
  128129. * @param pose Define the pose to submit
  128130. */
  128131. submitFrame(pose?: VRPose): void;
  128132. }
  128133. declare var VRDisplay: {
  128134. prototype: VRDisplay;
  128135. new(): VRDisplay;
  128136. };
  128137. interface VRLayer {
  128138. leftBounds?: number[] | Float32Array | null;
  128139. rightBounds?: number[] | Float32Array | null;
  128140. source?: HTMLCanvasElement | null;
  128141. }
  128142. interface VRDisplayCapabilities {
  128143. readonly canPresent: boolean;
  128144. readonly hasExternalDisplay: boolean;
  128145. readonly hasOrientation: boolean;
  128146. readonly hasPosition: boolean;
  128147. readonly maxLayers: number;
  128148. }
  128149. interface VREyeParameters {
  128150. /** @deprecated */
  128151. readonly fieldOfView: VRFieldOfView;
  128152. readonly offset: Float32Array;
  128153. readonly renderHeight: number;
  128154. readonly renderWidth: number;
  128155. }
  128156. interface VRFieldOfView {
  128157. readonly downDegrees: number;
  128158. readonly leftDegrees: number;
  128159. readonly rightDegrees: number;
  128160. readonly upDegrees: number;
  128161. }
  128162. interface VRFrameData {
  128163. readonly leftProjectionMatrix: Float32Array;
  128164. readonly leftViewMatrix: Float32Array;
  128165. readonly pose: VRPose;
  128166. readonly rightProjectionMatrix: Float32Array;
  128167. readonly rightViewMatrix: Float32Array;
  128168. readonly timestamp: number;
  128169. }
  128170. interface VRPose {
  128171. readonly angularAcceleration: Float32Array | null;
  128172. readonly angularVelocity: Float32Array | null;
  128173. readonly linearAcceleration: Float32Array | null;
  128174. readonly linearVelocity: Float32Array | null;
  128175. readonly orientation: Float32Array | null;
  128176. readonly position: Float32Array | null;
  128177. readonly timestamp: number;
  128178. }
  128179. interface VRStageParameters {
  128180. sittingToStandingTransform?: Float32Array;
  128181. sizeX?: number;
  128182. sizeY?: number;
  128183. }
  128184. interface Navigator {
  128185. getVRDisplays(): Promise<VRDisplay[]>;
  128186. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128187. }
  128188. interface Window {
  128189. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128190. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128191. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128192. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128193. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128194. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128195. }
  128196. interface Gamepad {
  128197. readonly displayId: number;
  128198. }
  128199. type XRSessionMode =
  128200. | "inline"
  128201. | "immersive-vr"
  128202. | "immersive-ar";
  128203. type XRReferenceSpaceType =
  128204. | "viewer"
  128205. | "local"
  128206. | "local-floor"
  128207. | "bounded-floor"
  128208. | "unbounded";
  128209. type XREnvironmentBlendMode =
  128210. | "opaque"
  128211. | "additive"
  128212. | "alpha-blend";
  128213. type XRVisibilityState =
  128214. | "visible"
  128215. | "visible-blurred"
  128216. | "hidden";
  128217. type XRHandedness =
  128218. | "none"
  128219. | "left"
  128220. | "right";
  128221. type XRTargetRayMode =
  128222. | "gaze"
  128223. | "tracked-pointer"
  128224. | "screen";
  128225. type XREye =
  128226. | "none"
  128227. | "left"
  128228. | "right";
  128229. interface XRSpace extends EventTarget {
  128230. }
  128231. interface XRRenderState {
  128232. depthNear?: number;
  128233. depthFar?: number;
  128234. inlineVerticalFieldOfView?: number;
  128235. baseLayer?: XRWebGLLayer;
  128236. }
  128237. interface XRInputSource {
  128238. handedness: XRHandedness;
  128239. targetRayMode: XRTargetRayMode;
  128240. targetRaySpace: XRSpace;
  128241. gripSpace: XRSpace | undefined;
  128242. gamepad: Gamepad | undefined;
  128243. profiles: Array<string>;
  128244. }
  128245. interface XRSession {
  128246. addEventListener: Function;
  128247. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128248. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128249. requestAnimationFrame: Function;
  128250. end(): Promise<void>;
  128251. renderState: XRRenderState;
  128252. inputSources: Array<XRInputSource>;
  128253. }
  128254. interface XRReferenceSpace extends XRSpace {
  128255. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128256. onreset: any;
  128257. }
  128258. interface XRFrame {
  128259. session: XRSession;
  128260. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128261. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128262. }
  128263. interface XRViewerPose extends XRPose {
  128264. views: Array<XRView>;
  128265. }
  128266. interface XRPose {
  128267. transform: XRRigidTransform;
  128268. emulatedPosition: boolean;
  128269. }
  128270. declare var XRWebGLLayer: {
  128271. prototype: XRWebGLLayer;
  128272. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128273. };
  128274. interface XRWebGLLayer {
  128275. framebuffer: WebGLFramebuffer;
  128276. framebufferWidth: number;
  128277. framebufferHeight: number;
  128278. getViewport: Function;
  128279. }
  128280. interface XRRigidTransform {
  128281. position: DOMPointReadOnly;
  128282. orientation: DOMPointReadOnly;
  128283. matrix: Float32Array;
  128284. inverse: XRRigidTransform;
  128285. }
  128286. interface XRView {
  128287. eye: XREye;
  128288. projectionMatrix: Float32Array;
  128289. transform: XRRigidTransform;
  128290. }
  128291. interface XRInputSourceChangeEvent {
  128292. session: XRSession;
  128293. removed: Array<XRInputSource>;
  128294. added: Array<XRInputSource>;
  128295. }